blister
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -84,2 +84,16 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Blister = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
/** | ||
* Returns the dependencies with the given ids as an object. | ||
* @param {...string} ids Dependency ids to return as keys | ||
* @return {Object} | ||
*/ | ||
pick: function() { | ||
var ids = [].slice.call(arguments); | ||
var self = this; | ||
return ids.reduce(function(deps, id) { | ||
deps[id] = self.get(id); | ||
return deps; | ||
}, {}); | ||
}, | ||
/** | ||
* Registers the given value with the specified id | ||
@@ -86,0 +100,0 @@ * @param {string} id |
@@ -1,2 +0,2 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Blister=e()}}(function(){return function e(t,n,r){function o(s,u){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!u&&c)return c(s,!0);if(i)return i(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var d=n[s]={exports:{}};t[s][0].call(d.exports,function(e){var n=t[s][1][e];return o(n?n:e)},d,d.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t){"use strict";function n(e){if("string"!=typeof e)throw new TypeError("The dependency id must be a string: "+e)}function r(){this._deps=Object.create(null)}var o=e("./wrappers"),i=e("./errors"),s=i.IllegalExtensionError,u=i.UnregisteredDependencyError,c=i.UnregisteredExtendedDependencyError,f="value",d="singleton",p="factory";r.IllegalExtensionError=s,r.UnregisteredDependencyError=u,r.UnregisteredExtendedDependencyError=c,r.prototype={constructor:r,has:function(e){return n(e),e in this._deps},keys:function(){return Object.keys(this._deps)},get:function(e){if(n(e),!this.has(e))throw new u("Cannot get unregistered dependency "+e);return this._deps[e].call(this)},value:function(e,t){return this._set(e,t,f,!1)},factory:function(e,t){return this._set(e,t,p,!1)},service:function(e,t){return this._set(e,t,d,!1)},extend:function(e,t){return this._set(e,t,void 0,!0)},_set:function(e,t,r,i){n(e);var s=i?this._deps[e]:void 0;if(i){if(!s)throw new c;r=s.type,r===f&&(r=d)}if("function"!=typeof t&&(i||r!==f))throw new TypeError("The argument must be a function: "+t);return this._deps[e]=o.create(r,t,this,s),this},register:function(e){return"function"==typeof e?e(this):e.register(this),this}},t.exports=r},{"./errors":2,"./wrappers":3}],2:[function(e,t){"use strict";function n(){}function r(e){this.name="IllegalExtensionError",this.message=e||"Values cannot be extended. Redefine them instead"}function o(e){this.name="UnregisteredDependencyError",this.message=e||"Cannot get an unregistered dependency"}function i(e){this.name="UnregisteredExtendedDependencyError",this.message=e||"Cannot extend a dependency not previously set"}n.prototype=Error.prototype,r.prototype=new n,r.constructor=r,o.prototype=new n,o.constructor=o,i.prototype=new n,i.constructor=i,t.exports={IllegalExtensionError:r,UnregisteredDependencyError:o,UnregisteredExtendedDependencyError:i}},{}],3:[function(e,t){"use strict";var n={value:function(e){return function(){return e}},factory:function(e,t,n){return function(){return n?e.call(this,n(),this):e.call(this,this)}},singleton:function(e,t,n){var r,o=!1;return function(){return o||(r=n?e.call(t,n(),t):e.call(t,t),o=!0,e=null),r}},create:function(e,t,n,r){var o=this[e](t,n,r);return o.type=e,o}};t.exports=n},{}]},{},[1])(1)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Blister=e()}}(function(){return function e(t,n,r){function o(s,u){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!u&&c)return c(s,!0);if(i)return i(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var d=n[s]={exports:{}};t[s][0].call(d.exports,function(e){var n=t[s][1][e];return o(n?n:e)},d,d.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t){"use strict";function n(e){if("string"!=typeof e)throw new TypeError("The dependency id must be a string: "+e)}function r(){this._deps=Object.create(null)}var o=e("./wrappers"),i=e("./errors"),s=i.IllegalExtensionError,u=i.UnregisteredDependencyError,c=i.UnregisteredExtendedDependencyError,f="value",d="singleton",p="factory";r.IllegalExtensionError=s,r.UnregisteredDependencyError=u,r.UnregisteredExtendedDependencyError=c,r.prototype={constructor:r,has:function(e){return n(e),e in this._deps},keys:function(){return Object.keys(this._deps)},get:function(e){if(n(e),!this.has(e))throw new u("Cannot get unregistered dependency "+e);return this._deps[e].call(this)},pick:function(){var e=[].slice.call(arguments),t=this;return e.reduce(function(e,n){return e[n]=t.get(n),e},{})},value:function(e,t){return this._set(e,t,f,!1)},factory:function(e,t){return this._set(e,t,p,!1)},service:function(e,t){return this._set(e,t,d,!1)},extend:function(e,t){return this._set(e,t,void 0,!0)},_set:function(e,t,r,i){n(e);var s=i?this._deps[e]:void 0;if(i){if(!s)throw new c;r=s.type,r===f&&(r=d)}if("function"!=typeof t&&(i||r!==f))throw new TypeError("The argument must be a function: "+t);return this._deps[e]=o.create(r,t,this,s),this},register:function(e){return"function"==typeof e?e(this):e.register(this),this}},t.exports=r},{"./errors":2,"./wrappers":3}],2:[function(e,t){"use strict";function n(){}function r(e){this.name="IllegalExtensionError",this.message=e||"Values cannot be extended. Redefine them instead"}function o(e){this.name="UnregisteredDependencyError",this.message=e||"Cannot get an unregistered dependency"}function i(e){this.name="UnregisteredExtendedDependencyError",this.message=e||"Cannot extend a dependency not previously set"}n.prototype=Error.prototype,r.prototype=new n,r.constructor=r,o.prototype=new n,o.constructor=o,i.prototype=new n,i.constructor=i,t.exports={IllegalExtensionError:r,UnregisteredDependencyError:o,UnregisteredExtendedDependencyError:i}},{}],3:[function(e,t){"use strict";var n={value:function(e){return function(){return e}},factory:function(e,t,n){return function(){return n?e.call(this,n(),this):e.call(this,this)}},singleton:function(e,t,n){var r,o=!1;return function(){return o||(r=n?e.call(t,n(),t):e.call(t,t),o=!0,e=null),r}},create:function(e,t,n,r){var o=this[e](t,n,r);return o.type=e,o}};t.exports=n},{}]},{},[1])(1)}); | ||
//# sourceMappingURL=blister.min.js.map |
{ | ||
"name": "blister", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Rubén Norte <rubennorte@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Minimalist dependency injection container for JavaScript", |
@@ -1,2 +0,2 @@ | ||
# Blister | ||
# Blister [![npm](https://img.shields.io/npm/l/blister.svg)](https://www.npmjs.org/package/blister) [![npm](https://img.shields.io/npm/v/blister.svg)](https://www.npmjs.org/package/blister) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contribute) | ||
@@ -47,7 +47,9 @@ Minimalist dependency injection container for JavaScript. | ||
container.value('name', 'Robert'); | ||
container.value('surname', 'Baratheon'); | ||
container.get('name'); //> 'Robert' | ||
container.has('name'); //> true | ||
container.pick('name', 'surname'); //> { name: 'Robert', surname: 'Baratheon' } | ||
container.keys(); //> ['name'] | ||
container.keys(); //> ['name', 'surname'] | ||
``` | ||
@@ -177,1 +179,26 @@ | ||
5. Submit a pull request :D | ||
## License | ||
Copyright (c) 2015-2016 Rubén Norte <rubennorte@gmail.com> | ||
MIT License | ||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@@ -83,2 +83,16 @@ 'use strict'; | ||
/** | ||
* Returns the dependencies with the given ids as an object. | ||
* @param {...string} ids Dependency ids to return as keys | ||
* @return {Object} | ||
*/ | ||
pick: function() { | ||
var ids = [].slice.call(arguments); | ||
var self = this; | ||
return ids.reduce(function(deps, id) { | ||
deps[id] = self.get(id); | ||
return deps; | ||
}, {}); | ||
}, | ||
/** | ||
* Registers the given value with the specified id | ||
@@ -85,0 +99,0 @@ * @param {string} id |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
63456
10
669
203