AgentiaSystems/agentia-asset-manager

View on GitHub
lib/helpers/check-if.js

Summary

Maintainability
A
1 hr
Test Coverage
'use strict';

var checkMustBeString = require('./check-must-be-string');

function checkIf(id, check) {
  checkMustBeString(id, 'id');
  if (this.isRegistered(id)) {
    switch (check) {
      case 'instance': {
        return this.__assets[id].isInstance;
      }
      case 'module': {
        return this.__assets[id].isModule;
      }
      case 'function': {
        return this.__assets[id].isFunction;
      }
      case 'injectable': {
        return this.__assets[id].isInjectable;
      }
      case 'resolved': {
        return this.__assets[id].isResolved;
      }
    }
  }
  return false;
}

module.exports = checkIf;