Comparing version 0.4.0 to 0.4.5
/* ======================================================================== | ||
* infect.js v0.4.0 | ||
* infect.js v0.4.5 | ||
* Dependency injection for any web project | ||
@@ -16,2 +16,4 @@ * | ||
(function (root, factory) { | ||
'use strict'; | ||
if (typeof define === 'function' && define.amd) { | ||
@@ -28,2 +30,4 @@ // AMD. Register as an anonymous module. | ||
}(this, function () { | ||
'use strict'; | ||
var strains = {}, | ||
@@ -125,7 +129,13 @@ op = '$', | ||
function func(fnc, scope) { | ||
var i, key, args, argCount, Infected; | ||
var i, key, args, argCount, Infected, $infect; | ||
if (type(fnc) === 'Array') { | ||
$infect = fnc; | ||
fnc = $infect.pop(); | ||
fnc.$infect = $infect; | ||
} | ||
if (type(fnc) === 'Function') { | ||
scope = scope || {}; | ||
// pull the function's parameters as a string | ||
@@ -198,3 +208,3 @@ args = /\(([^)]+)/.exec(fnc.toString()); | ||
_args = _args.concat(args); | ||
// execute the injected function | ||
@@ -201,0 +211,0 @@ return fnc.apply(_scope, _args); |
@@ -1,2 +0,2 @@ | ||
// infect.js v0.4.0 (2014-01-15) // | ||
!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.infect=b()}(this,function(){function a(a){return/ (.*)]/.exec(Object.prototype.toString.call(a))[1]}function b(b){var c,d=[].slice.call(arguments,1),e="";for(c=0;c<d.length;c++)e+=e.length>0?", "+a(d[c]):a(d[c]);throw i+"Invalid call to infect."+b+"("+e+")"}function c(c,d){"String"===a(c)&&"Undefined"!==a(d)&&d instanceof Object?(c=0===c.indexOf(h)?c.substr(h.length):c,g[c]=d):b("set",c,d)}function d(c){return"String"===a(c)?(c=0===c.indexOf(h)?c.substr(h.length):c,g[c]||void 0):(b("get",c),void 0)}function e(c,e){var f,g;if("Object"===a(c)&&e instanceof Array){for(g=e.length;g--;)f=e[g],f=0===f.indexOf(h)?f.substr(h.length):f,c[h+f]=d(f);return c}b("obj",c,e)}function f(c,e){var f,g,j,k,l;if("Function"===a(c)){for(e=e||{},j=/\(([^)]+)/.exec(c.toString()),j=null!==j?j[1]:"",j&&(j=j.split(/\s*,\s*/)),f=k=j.length;f--;){if(g=j[f],0!==g.indexOf(h)){j=j.slice(f+1);break}j[f]=d(g)||g}return l=function(){j=l.$infect&&l.$infect.length>0&&!j.length?l.$infect:j;var b=[].slice.call(arguments),g=b.length+j.length,h=e;for(this instanceof l&&(h=this);k>g;g++)b.push(void 0);for(f=j.length;f--;)"String"===a(j[f])&&(j[f]=d(j[f]));if(g>k)throw i+"Too many parameters! I expected "+(k-j.length)+" (or less) but got "+b.length;return b=b.concat(j),c.apply(h,b)},l.prototype=c.prototype,l.prototype.constructor=l,l.$infect=c.$infect,l}b("func",c,e)}var g={},h="$",i=" == infect.js => ";return{set:c,get:d,obj:e,func:f,funk:f}}); | ||
// infect.js v0.4.5 (2014-06-16) // | ||
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.infect=b()}(this,function(){"use strict";function a(a){return/ (.*)]/.exec(Object.prototype.toString.call(a))[1]}function b(b){var c,d=[].slice.call(arguments,1),e="";for(c=0;c<d.length;c++)e+=e.length>0?", "+a(d[c]):a(d[c]);throw i+"Invalid call to infect."+b+"("+e+")"}function c(c,d){"String"===a(c)&&"Undefined"!==a(d)&&d instanceof Object?(c=0===c.indexOf(h)?c.substr(h.length):c,g[c]=d):b("set",c,d)}function d(c){return"String"===a(c)?(c=0===c.indexOf(h)?c.substr(h.length):c,g[c]||void 0):(b("get",c),void 0)}function e(c,e){var f,g;if("Object"===a(c)&&e instanceof Array){for(g=e.length;g--;)f=e[g],f=0===f.indexOf(h)?f.substr(h.length):f,c[h+f]=d(f);return c}b("obj",c,e)}function f(c,e){var f,g,j,k,l,m;if("Array"===a(c)&&(m=c,c=m.pop(),c.$infect=m),"Function"===a(c)){for(e=e||{},j=/\(([^)]+)/.exec(c.toString()),j=null!==j?j[1]:"",j&&(j=j.split(/\s*,\s*/)),f=k=j.length;f--;){if(g=j[f],0!==g.indexOf(h)){j=j.slice(f+1);break}j[f]=d(g)||g}return l=function(){j=l.$infect&&l.$infect.length>0&&!j.length?l.$infect:j;var b=[].slice.call(arguments),g=b.length+j.length,h=e;for(this instanceof l&&(h=this);k>g;g++)b.push(void 0);for(f=j.length;f--;)"String"===a(j[f])&&(j[f]=d(j[f]));if(g>k)throw i+"Too many parameters! I expected "+(k-j.length)+" (or less) but got "+b.length;return b=b.concat(j),c.apply(h,b)},l.prototype=c.prototype,l.prototype.constructor=l,l.$infect=c.$infect,l}b("func",c,e)}var g={},h="$",i=" == infect.js => ";return{set:c,get:d,obj:e,func:f,funk:f}}); |
{ | ||
"name": "infect", | ||
"version": "0.4.0", | ||
"version": "0.4.5", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Infect.js is a simple way to add the magic of dependency injection to any web project, regardless of the framework on which you choose to write your application. It's infectiously simple!", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
19091
6
203
1