Comparing version 1.12.1 to 1.12.3
@@ -12,4 +12,2 @@ /** | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _bottlejs = require('bottlejs'); | ||
@@ -27,11 +25,7 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* Deep dependency injection module | ||
*/ | ||
let DI = exports.DI = function () { | ||
function DI() { | ||
_classCallCheck(this, DI); | ||
class DI { | ||
constructor() { | ||
this._bottle = new _bottlejs2.default(); | ||
@@ -48,110 +42,84 @@ this._localBackend = false; | ||
*/ | ||
register(serviceName, serviceClass, dependencies) { | ||
var args = [serviceName, serviceClass]; | ||
_createClass(DI, [{ | ||
key: 'register', | ||
value: function register(serviceName, serviceClass, dependencies) { | ||
var args = [serviceName, serviceClass]; | ||
if (dependencies) { | ||
args = args.concat(dependencies); | ||
} | ||
this._bottle.service.apply(this._bottle, args); | ||
if (dependencies) { | ||
args = args.concat(dependencies); | ||
} | ||
/** | ||
* Defines a factory method to create a service | ||
* | ||
* @param {String} serviceName | ||
* @param {Object} factoryClass | ||
*/ | ||
this._bottle.service.apply(this._bottle, args); | ||
} | ||
}, { | ||
key: 'factory', | ||
value: function factory(serviceName, factoryClass) { | ||
this._bottle.factory(serviceName, factoryClass); | ||
} | ||
/** | ||
* Defines a factory method to create a service | ||
* | ||
* @param {String} serviceName | ||
* @param {Object} factoryClass | ||
*/ | ||
factory(serviceName, factoryClass) { | ||
this._bottle.factory(serviceName, factoryClass); | ||
} | ||
/** | ||
* Adds a parameter into container | ||
* | ||
* @param {String} name | ||
* @param {*} value | ||
*/ | ||
/** | ||
* Adds a parameter into container | ||
* | ||
* @param {String} name | ||
* @param {*} value | ||
*/ | ||
addParameter(name, value) { | ||
this._bottle.value(name, value); | ||
} | ||
}, { | ||
key: 'addParameter', | ||
value: function addParameter(name, value) { | ||
this._bottle.value(name, value); | ||
/** | ||
* Adds an instantiated service into container | ||
* | ||
* @param {String} name | ||
* @param {Object} value | ||
*/ | ||
addService(name, value) { | ||
if (!(value instanceof Object)) { | ||
throw new _deepCore2.default.Exception.InvalidArgumentException(value, 'Object'); | ||
} | ||
/** | ||
* Adds an instantiated service into container | ||
* | ||
* @param {String} name | ||
* @param {Object} value | ||
*/ | ||
this._bottle.value(name, value); | ||
} | ||
}, { | ||
key: 'addService', | ||
value: function addService(name, value) { | ||
if (!(value instanceof Object)) { | ||
throw new _deepCore2.default.Exception.InvalidArgumentException(value, 'Object'); | ||
} | ||
this._bottle.value(name, value); | ||
/** | ||
* Returns a service / parameter from container | ||
* @param {String} key | ||
* @returns {Object} | ||
*/ | ||
get(key) { | ||
if (typeof this._bottle.container[key] === 'undefined') { | ||
throw new _MissingServiceException.MissingServiceException(`Unregistered service or parameter "${key}"`); | ||
} | ||
/** | ||
* Returns a service / parameter from container | ||
* @param {String} key | ||
* @returns {Object} | ||
*/ | ||
return this._bottle.container[key]; | ||
} | ||
}, { | ||
key: 'get', | ||
value: function get(key) { | ||
if (typeof this._bottle.container[key] === 'undefined') { | ||
throw new _MissingServiceException.MissingServiceException(`Unregistered service or parameter "${key}"`); | ||
} | ||
/** | ||
* Checks if service / parameter exists in container | ||
* @param {String} key | ||
* @returns {Boolean} | ||
*/ | ||
has(key) { | ||
return this._bottle.container.hasOwnProperty(key); | ||
} | ||
return this._bottle.container[key]; | ||
} | ||
/** | ||
* @param {Boolean} localBackend | ||
*/ | ||
set localBackend(localBackend) { | ||
this._localBackend = localBackend; | ||
} | ||
/** | ||
* Checks if service / parameter exists in container | ||
* @param {String} key | ||
* @returns {Boolean} | ||
*/ | ||
/** | ||
* @returns {Boolean} | ||
*/ | ||
get localBackend() { | ||
return this._localBackend; | ||
} | ||
}, { | ||
key: 'has', | ||
value: function has(key) { | ||
return this._bottle.container.hasOwnProperty(key); | ||
} | ||
/** | ||
* @param {Boolean} localBackend | ||
*/ | ||
}, { | ||
key: 'cleanup', | ||
value: function cleanup() {} | ||
}, { | ||
key: 'localBackend', | ||
set: function set(localBackend) { | ||
this._localBackend = localBackend; | ||
} | ||
/** | ||
* @returns {Boolean} | ||
*/ | ||
, | ||
get: function get() { | ||
return this._localBackend; | ||
} | ||
}]); | ||
return DI; | ||
}(); | ||
cleanup() {} | ||
} | ||
exports.DI = DI; |
@@ -18,30 +18,13 @@ /** | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
/** | ||
* Thrown when any exception occurs | ||
*/ | ||
let Exception = exports.Exception = function (_Core$Exception$Excep) { | ||
_inherits(Exception, _Core$Exception$Excep); | ||
class Exception extends _deepCore2.default.Exception.Exception { | ||
/** | ||
* @param {Array} args | ||
*/ | ||
function Exception() { | ||
var _ref; | ||
_classCallCheck(this, Exception); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _possibleConstructorReturn(this, (_ref = Exception.__proto__ || Object.getPrototypeOf(Exception)).call.apply(_ref, [this].concat(args))); | ||
constructor(...args) { | ||
super(...args); | ||
} | ||
return Exception; | ||
}(_deepCore2.default.Exception.Exception); | ||
} | ||
exports.Exception = Exception; |
@@ -12,26 +12,15 @@ /** | ||
var _Exception2 = require('./Exception'); | ||
var _Exception = require('./Exception'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
/** | ||
* Thrown when requested service is missing | ||
*/ | ||
let MissingServiceException = exports.MissingServiceException = function (_Exception) { | ||
_inherits(MissingServiceException, _Exception); | ||
class MissingServiceException extends _Exception.Exception { | ||
/** | ||
* @param {String} serviceName | ||
*/ | ||
function MissingServiceException(serviceName) { | ||
_classCallCheck(this, MissingServiceException); | ||
return _possibleConstructorReturn(this, (MissingServiceException.__proto__ || Object.getPrototypeOf(MissingServiceException)).call(this, `Missing service ${serviceName} in deep-kernel`)); | ||
constructor(serviceName) { | ||
super(`Missing service ${serviceName} in deep-kernel`); | ||
} | ||
return MissingServiceException; | ||
}(_Exception2.Exception); | ||
} | ||
exports.MissingServiceException = MissingServiceException; |
{ | ||
"name": "deep-di", | ||
"version": "1.12.1", | ||
"version": "1.12.3", | ||
"description": "DEEP Dependency Injection Library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12192
148