New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

iniettore

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iniettore - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

coverage/PhantomJS 1.9.7 (Mac OS X)/lcov-report/index.html

157

dist/iniettore.js

@@ -8,3 +8,3 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.iniettore=e()}}(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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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(_dereq_,module,exports){

var PROVIDER = _dereq_('./options').PROVIDER;
var createResolvers = _dereq_('./resolvers');
var resolvers = _dereq_('./resolvers');
var VALUE = _dereq_('./options');

@@ -22,4 +22,4 @@ var log = _dereq_('./log');

function Container(mappings) {
this.$Container_resolvers = createResolvers()
function Container(conf, mappings) {
this.$Container_resolvers = resolvers
this.$Container_mappings = mappings || {}

@@ -29,5 +29,9 @@ this.$Container_resolving = {}

this.bind(CONTAINER_ALIAS, this)
.as(VALUE)
.done()
this.bind(CONTAINER_ALIAS, this).as(VALUE).done()
if (typeof conf === 'function') {
conf(this)
if (this.$Container_pending.length) {
this.$Container_done()
}
}
}

@@ -102,16 +106,8 @@

Container.prototype.createChild=function() {
return new Container(Object.create(this.$Container_mappings))
Container.prototype.createChild=function(conf) {
return new Container(conf, Object.create(this.$Container_mappings))
};
Container.prototype.createBlueprint=function(alias, blueprint) {
this.bind(alias, function() {
var child = this.createChild()
blueprint(child)
return child
}.bind(this))
.as(PROVIDER)
.done()
this.bind(alias, function() {return this.createChild(blueprint);}.bind(this)).as(PROVIDER).done()
};

@@ -175,4 +171,4 @@

function create() {
return new Container()
function create(conf) {
return new Container(conf)
} module.exports.create = create;

@@ -258,34 +254,31 @@

var mod$5 = _dereq_('./utils');
var leftCurryTwice = mod$5.leftCurryTwice;
var identity = mod$5.identity;
var compose = mod$5.compose;
var mod$4 = _dereq_('./utils');
var leftCurryTwice = mod$4.leftCurryTwice;
var identity = mod$4.identity;
var compose = mod$4.compose;
var resolveDeps = mod$5.resolveDeps;
var invoke = mod$5.invoke;
var resolveDeps = mod$4.resolveDeps;
var invoke = mod$4.invoke;
var instanciate = mod$5.instanciate;
var singletonify = mod$5.singletonify;
var instanciate = mod$4.instanciate;
var singletonify = mod$4.singletonify;
var generateType = _dereq_('./generateType');
var mod$6 = _dereq_('./options');
var VALUE = mod$6.VALUE;
var PROVIDER = mod$6.PROVIDER;
var CONSTRUCTOR = mod$6.CONSTRUCTOR;
var SINGLETON = mod$6.SINGLETON;
var mod$5 = _dereq_('./options');
var VALUE = mod$5.VALUE;
var PROVIDER = mod$5.PROVIDER;
var CONSTRUCTOR = mod$5.CONSTRUCTOR;
var SINGLETON = mod$5.SINGLETON;
module.exports = function createResolvers() {
var resolvers = {}
var resolvers = {}
resolvers[ generateType([VALUE]) ] = compose(leftCurryTwice, resolveDeps)(identity)
resolvers[ generateType([CONSTRUCTOR]) ] = compose(leftCurryTwice, resolveDeps)(instanciate)
resolvers[ generateType([CONSTRUCTOR, SINGLETON]) ] = compose(leftCurryTwice, singletonify)(instanciate)
resolvers[ generateType([PROVIDER]) ] = compose(leftCurryTwice, resolveDeps)(invoke)
resolvers[ generateType([SINGLETON, PROVIDER]) ] = compose(leftCurryTwice, singletonify)(invoke)
resolvers[ generateType([VALUE]) ] = compose(leftCurryTwice, resolveDeps)(identity)
resolvers[ generateType([CONSTRUCTOR]) ] = compose(leftCurryTwice, resolveDeps)(instanciate)
resolvers[ generateType([CONSTRUCTOR, SINGLETON]) ] = singletonify(instanciate)
resolvers[ generateType([PROVIDER]) ] = compose(leftCurryTwice, resolveDeps)(invoke)
resolvers[ generateType([SINGLETON, PROVIDER]) ] = singletonify(invoke)
return resolvers
}
module.exports = resolvers

@@ -306,40 +299,43 @@ },{"./generateType":2,"./options":7,"./utils":11}],9:[function(_dereq_,module,exports){

module.exports = function singletonify(fn) {
module.exports = function singletonify(create) {
var handlers = {}
var count = 0
var instance
return function (value, resolveDeps, releaseDeps) {
function dispose() {
if (typeof instance.dispose === 'function') {
instance.dispose()
var handlers = {}
var count = 0
var instance
function dispose() {
if (typeof instance.dispose === 'function') {
instance.dispose()
}
instance = undefined
count = 0
}
instance = undefined
count = 0
}
handlers[ACQUIRE] = function (value, resolveDeps, releaseDeps, args) {
if (typeof instance === 'undefined') {
instance = fn.call(this, value, resolveDeps(), args)
handlers[ACQUIRE] = function (value, args) {
if (typeof instance === 'undefined') {
instance = create.call(this, value, resolveDeps(), args)
}
count++
return instance
}
count++
return instance
}
handlers[RELEASE] = function (value, resolveDeps, releaseDeps) {
count--
if (count <= 0) {
handlers[RELEASE] = function (value) {
count--
if (count <= 0) {
releaseDeps()
dispose()
}
}
handlers[DISPOSE] = function (value) {
releaseDeps()
dispose()
}
}
handlers[DISPOSE] = function (value, resolveDeps, releaseDeps) {
releaseDeps()
dispose()
return function (signal, args) {
return handlers[signal].call(this, value, args)
}
}
return function (value, resolveDeps, releaseDeps, signal, args) {
return handlers[signal].call(this, value, resolveDeps, releaseDeps, args)
}
}

@@ -363,15 +359,2 @@

// not used
function memoize(fn) {
var value
return function () {var args=Array.prototype.slice.call(arguments,0);
if (typeof value === 'undefined') {
value = fn.apply(this, args)
}
return value
}
} module.exports.memoize = memoize;
function compose() {var funcs=Array.prototype.slice.call(arguments,0);

@@ -399,12 +382,2 @@ return function () {var args=Array.prototype.slice.call(arguments,0);

// not used
function merge(first ) {var sources=Array.prototype.slice.call(arguments,1);
return sources.reduce(function (out, source) {
for (var k in source) {
out[k] = source[k]
}
return out
}, first)
} module.exports.merge = merge;
module.exports.instanciate = instanciate;module.exports.singletonify = singletonify;

@@ -411,0 +384,0 @@

@@ -1,1 +0,1 @@

!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.iniettore=n()}}(function(){return function n(t,e,r){function i(s,a){if(!e[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=e[s]={exports:{}};t[s][0].call(c.exports,function(n){var e=t[s][1][n];return i(e?e:n)},c,c.exports,n,t,e,r)}return e[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(n,t){"use strict";function e(n){this.$Container_resolvers=p(),this.$Container_mappings=n||{},this.$Container_resolving={},this.$Container_pending=[],this.bind(g,this).as(f).done()}var r=n("./generateType"),i=n("./invariant"),o=n("./signals"),s=o.ACQUIRE,a=o.RELEASE,u=o.DISPOSE,c=n("./options").PROVIDER,p=n("./resolvers"),f=n("./options"),l=n("./log"),d=0,f=1,h=2,y=3,g="$container";e.prototype.bind=function(n,t){return this.$Container_pending=[n,t],{as:function(){var n=Array.prototype.slice.call(arguments,0);return this.$Container_pending[h]=r(n),{bind:function(){var n=Array.prototype.slice.call(arguments,0);return this.$Container_done(),this.bind.apply(this,n)}.bind(this),inject:function(){var n=Array.prototype.slice.call(arguments,0);return this.$Container_pending[y]=n,{bind:function(){var n=Array.prototype.slice.call(arguments,0);return this.$Container_done(),this.bind.apply(this,n)}.bind(this),done:function(){return this.$Container_done()}.bind(this)}}.bind(this),done:function(){return this.$Container_done()}.bind(this)}}.bind(this),done:function(){return this.$Container_done()}.bind(this)}},e.prototype.get=function(n){var t,e=Array.prototype.slice.call(arguments,1);i(!this.$Container_resolving[n],"Circular dependency detected while resolving `%s`.",n),l("Resolving "+n),this.$Container_resolving[n]=!0;try{t=this.$Container_mappings[n](s,e)}catch(r){throw r.message="Failed while resolving '"+n+"' due to "+r.message,r}return this.$Container_resolving[n]=!1,l.done(),t},e.prototype.release=function(n){try{this.$Container_mappings[n](a)}catch(t){throw t.message="Failed while disposing '"+n+"' due to "+t.message,t}},e.prototype.createChild=function(){return new e(Object.create(this.$Container_mappings))},e.prototype.createBlueprint=function(n,t){this.bind(n,function(){var n=this.createChild();return t(n),n}.bind(this)).as(c).done()},e.prototype.dispose=function(){var n,t=this.$Container_mappings;for(n in t)if(t.hasOwnProperty(n))try{t[n](u)}catch(e){throw e.message="Failed while disposing '"+n+"' due to "+e.message,e}},e.prototype.$Container_done=function(){var n=this.$Container_pending,t=n[y]?n[y]:[],e=this.$Container_resolvers[n[h]](n[f],this.$Container_resolve.bind(this,t),this.$Container_release.bind(this,t));return this.$Container_mappings[n[d]]=e,this.$Container_pending=[],this},e.prototype.$Container_release=function(n){return n.forEach(function(n){this.release(n)}.bind(this))},e.prototype.$Container_resolve=function(n){return n.map(function(n){return this.get(n)}.bind(this))},t.exports=e},{"./generateType":2,"./invariant":5,"./log":6,"./options":7,"./resolvers":8,"./signals":9}],2:[function(n,t){"use strict";t.exports=function(n){return n.reduce(function(n,t){return n|t},0)}},{}],3:[function(n,t){"use strict";function e(){return new r}var r=n("./Container");t.exports.create=e},{"./Container":1}],4:[function(n,t){"use strict";t.exports=function(n,t,e){var r,i;return r=function(){},r.prototype=n.prototype,i=new r,n.apply(i,t.concat(e)),i}},{}],5:[function(n,t){"use strict";var e=function(n){if(!n)throw new Error("Minified exception occured; use the non-minified dev environment for the full error message and additional helpful warnings.")};t.exports=e},{}],6:[function(n,t){"use strict";function e(n){o++,i=n,r=Array(2*o).join(" ")}var r,i,o=0;e.done=function(){o--},t.exports=e},{}],7:[function(n,t){"use strict";t.exports=["VALUE","PROVIDER","CONSTRUCTOR","SINGLETON"].reduce(function(n,t,e){return n[t]=Math.pow(2,e),n},{})},{}],8:[function(n,t){"use strict";var e=n("./utils"),r=e.leftCurryTwice,i=e.identity,o=e.compose,s=e.resolveDeps,a=e.invoke,u=e.instanciate,c=e.singletonify,p=n("./generateType"),f=n("./options"),l=f.VALUE,d=f.PROVIDER,h=f.CONSTRUCTOR,y=f.SINGLETON;t.exports=function(){var n={};return n[p([l])]=o(r,s)(i),n[p([h])]=o(r,s)(u),n[p([h,y])]=o(r,c)(u),n[p([d])]=o(r,s)(a),n[p([y,d])]=o(r,c)(a),n}},{"./generateType":2,"./options":7,"./utils":11}],9:[function(n,t){"use strict";t.exports={ACQUIRE:"ACQUIRE",RELEASE:"RELEASE",DISPOSE:"DISPOSE"}},{}],10:[function(n,t){"use strict";var e=n("./signals"),r=e.ACQUIRE,i=e.RELEASE,o=e.DISPOSE;t.exports=function(n){function t(){"function"==typeof e.dispose&&e.dispose(),e=void 0,a=0}var e,s={},a=0;return s[r]=function(t,r,i,o){return"undefined"==typeof e&&(e=n.call(this,t,r(),o)),a++,e},s[i]=function(n,e,r){a--,0>=a&&(r(),t())},s[o]=function(n,e,r){r(),t()},function(n,t,e,r,i){return s[r].call(this,n,t,e,i)}}},{"./signals":9}],11:[function(n,t){"use strict";function e(n){return n}function r(n){return function(){var t=Array.prototype.slice.call(arguments,0);return function(){var e=Array.prototype.slice.call(arguments,0);return n.apply(null,t.concat(e))}}}function i(n){var t;return function(){var e=Array.prototype.slice.call(arguments,0);return"undefined"==typeof t&&(t=n.apply(this,e)),t}}function o(){var n=Array.prototype.slice.call(arguments,0);return function(){var t,e=Array.prototype.slice.call(arguments,0);for(t=n.length-1;t>=0;t--)e=[n[t].apply(this,e)];return e[0]}}function s(n){return function(t,e,r,i,o){return n.call(this,t,e(),o)}}function a(n,t,e){return n.apply(null,t.concat(e))}function u(n){var t=Array.prototype.slice.call(arguments,1);return t.reduce(function(n,t){for(var e in t)n[e]=t[e];return n},n)}var c=n("./instanciate"),p=n("./singletonify");t.exports.identity=e,t.exports.leftCurryTwice=r,t.exports.memoize=i,t.exports.compose=o,t.exports.resolveDeps=s,t.exports.invoke=a,t.exports.merge=u,t.exports.instanciate=c,t.exports.singletonify=p},{"./instanciate":4,"./singletonify":10}]},{},[3])(3)});
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.iniettore=n()}}(function(){return function n(t,e,i){function r(s,a){if(!e[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=e[s]={exports:{}};t[s][0].call(c.exports,function(n){var e=t[s][1][n];return r(e?e:n)},c,c.exports,n,t,e,i)}return e[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)r(i[s]);return r}({1:[function(n,t){"use strict";function e(n,t){this.$Container_resolvers=p,this.$Container_mappings=t||{},this.$Container_resolving={},this.$Container_pending=[],this.bind(g,this).as(f).done(),"function"==typeof n&&(n(this),this.$Container_pending.length&&this.$Container_done())}var i=n("./generateType"),r=n("./invariant"),o=n("./signals"),s=o.ACQUIRE,a=o.RELEASE,u=o.DISPOSE,c=n("./options").PROVIDER,p=n("./resolvers"),f=n("./options"),l=n("./log"),d=0,f=1,h=2,y=3,g="$container";e.prototype.bind=function(n,t){return this.$Container_pending=[n,t],{as:function(){var n=Array.prototype.slice.call(arguments,0);return this.$Container_pending[h]=i(n),{bind:function(){var n=Array.prototype.slice.call(arguments,0);return this.$Container_done(),this.bind.apply(this,n)}.bind(this),inject:function(){var n=Array.prototype.slice.call(arguments,0);return this.$Container_pending[y]=n,{bind:function(){var n=Array.prototype.slice.call(arguments,0);return this.$Container_done(),this.bind.apply(this,n)}.bind(this),done:function(){return this.$Container_done()}.bind(this)}}.bind(this),done:function(){return this.$Container_done()}.bind(this)}}.bind(this),done:function(){return this.$Container_done()}.bind(this)}},e.prototype.get=function(n){var t,e=Array.prototype.slice.call(arguments,1);r(!this.$Container_resolving[n],"Circular dependency detected while resolving `%s`.",n),l("Resolving "+n),this.$Container_resolving[n]=!0;try{t=this.$Container_mappings[n](s,e)}catch(i){throw i.message="Failed while resolving '"+n+"' due to "+i.message,i}return this.$Container_resolving[n]=!1,l.done(),t},e.prototype.release=function(n){try{this.$Container_mappings[n](a)}catch(t){throw t.message="Failed while disposing '"+n+"' due to "+t.message,t}},e.prototype.createChild=function(n){return new e(n,Object.create(this.$Container_mappings))},e.prototype.createBlueprint=function(n,t){this.bind(n,function(){return this.createChild(t)}.bind(this)).as(c).done()},e.prototype.dispose=function(){var n,t=this.$Container_mappings;for(n in t)if(t.hasOwnProperty(n))try{t[n](u)}catch(e){throw e.message="Failed while disposing '"+n+"' due to "+e.message,e}},e.prototype.$Container_done=function(){var n=this.$Container_pending,t=n[y]?n[y]:[],e=this.$Container_resolvers[n[h]](n[f],this.$Container_resolve.bind(this,t),this.$Container_release.bind(this,t));return this.$Container_mappings[n[d]]=e,this.$Container_pending=[],this},e.prototype.$Container_release=function(n){return n.forEach(function(n){this.release(n)}.bind(this))},e.prototype.$Container_resolve=function(n){return n.map(function(n){return this.get(n)}.bind(this))},t.exports=e},{"./generateType":2,"./invariant":5,"./log":6,"./options":7,"./resolvers":8,"./signals":9}],2:[function(n,t){"use strict";t.exports=function(n){return n.reduce(function(n,t){return n|t},0)}},{}],3:[function(n,t){"use strict";function e(n){return new i(n)}var i=n("./Container");t.exports.create=e},{"./Container":1}],4:[function(n,t){"use strict";t.exports=function(n,t,e){var i,r;return i=function(){},i.prototype=n.prototype,r=new i,n.apply(r,t.concat(e)),r}},{}],5:[function(n,t){"use strict";var e=function(n){if(!n)throw new Error("Minified exception occured; use the non-minified dev environment for the full error message and additional helpful warnings.")};t.exports=e},{}],6:[function(n,t){"use strict";function e(n){o++,r=n,i=Array(2*o).join(" ")}var i,r,o=0;e.done=function(){o--},t.exports=e},{}],7:[function(n,t){"use strict";t.exports=["VALUE","PROVIDER","CONSTRUCTOR","SINGLETON"].reduce(function(n,t,e){return n[t]=Math.pow(2,e),n},{})},{}],8:[function(n,t){"use strict";var e=n("./utils"),i=e.leftCurryTwice,r=e.identity,o=e.compose,s=e.resolveDeps,a=e.invoke,u=e.instanciate,c=e.singletonify,p=n("./generateType"),f=n("./options"),l=f.VALUE,d=f.PROVIDER,h=f.CONSTRUCTOR,y=f.SINGLETON,g={};g[p([l])]=o(i,s)(r),g[p([h])]=o(i,s)(u),g[p([h,y])]=c(u),g[p([d])]=o(i,s)(a),g[p([y,d])]=c(a),t.exports=g},{"./generateType":2,"./options":7,"./utils":11}],9:[function(n,t){"use strict";t.exports={ACQUIRE:"ACQUIRE",RELEASE:"RELEASE",DISPOSE:"DISPOSE"}},{}],10:[function(n,t){"use strict";var e=n("./signals"),i=e.ACQUIRE,r=e.RELEASE,o=e.DISPOSE;t.exports=function(n){return function(t,e,s){function a(){"function"==typeof u.dispose&&u.dispose(),u=void 0,p=0}var u,c={},p=0;return c[i]=function(t,i){return"undefined"==typeof u&&(u=n.call(this,t,e(),i)),p++,u},c[r]=function(){p--,0>=p&&(s(),a())},c[o]=function(){s(),a()},function(n,e){return c[n].call(this,t,e)}}}},{"./signals":9}],11:[function(n,t){"use strict";function e(n){return n}function i(n){return function(){var t=Array.prototype.slice.call(arguments,0);return function(){var e=Array.prototype.slice.call(arguments,0);return n.apply(null,t.concat(e))}}}function r(){var n=Array.prototype.slice.call(arguments,0);return function(){var t,e=Array.prototype.slice.call(arguments,0);for(t=n.length-1;t>=0;t--)e=[n[t].apply(this,e)];return e[0]}}function o(n){return function(t,e,i,r,o){return n.call(this,t,e(),o)}}function s(n,t,e){return n.apply(null,t.concat(e))}var a=n("./instanciate"),u=n("./singletonify");t.exports.identity=e,t.exports.leftCurryTwice=i,t.exports.compose=r,t.exports.resolveDeps=o,t.exports.invoke=s,t.exports.instanciate=a,t.exports.singletonify=u},{"./instanciate":4,"./singletonify":10}]},{},[3])(3)});
var gulp = require('gulp')
var coveralls = require('gulp-coveralls')
var requireDir = require('require-dir')

@@ -12,2 +13,7 @@ var runSequence = require('run-sequence')

gulp.task('send-coverage-report', function (done) {
gulp.src('./coverage/**/lcov.info')
.pipe(coveralls())
})
gulp.task('test', function (done) {

@@ -21,2 +27,10 @@ runSequence(

gulp.task('test-ci', function (done) {
runSequence(
'test',
'send-coverage-report',
done
)
})
gulp.task('default', function (done) {

@@ -23,0 +37,0 @@ runSequence(

@@ -17,4 +17,8 @@ module.exports = function(config) {

reporters: ['spec'],
reporters: ['spec', 'coverage'],
coverageReporter: {
type: 'lcov'
},
// web server port

@@ -21,0 +25,0 @@ port: 9876,

@@ -7,3 +7,3 @@ 'use strict'

var PROVIDER = require('./options').PROVIDER;
var createResolvers = require('./resolvers');
var resolvers = require('./resolvers');
var VALUE = require('./options');

@@ -21,4 +21,4 @@ var log = require('./log');

function Container(mappings) {
this.$Container_resolvers = createResolvers()
function Container(conf, mappings) {
this.$Container_resolvers = resolvers
this.$Container_mappings = mappings || {}

@@ -28,5 +28,9 @@ this.$Container_resolving = {}

this.bind(CONTAINER_ALIAS, this)
.as(VALUE)
.done()
this.bind(CONTAINER_ALIAS, this).as(VALUE).done()
if (typeof conf === 'function') {
conf(this)
if (this.$Container_pending.length) {
this.$Container_done()
}
}
}

@@ -101,16 +105,8 @@

Container.prototype.createChild=function() {
return new Container(Object.create(this.$Container_mappings))
Container.prototype.createChild=function(conf) {
return new Container(conf, Object.create(this.$Container_mappings))
};
Container.prototype.createBlueprint=function(alias, blueprint) {
this.bind(alias, function() {
var child = this.createChild()
blueprint(child)
return child
}.bind(this))
.as(PROVIDER)
.done()
this.bind(alias, function() {return this.createChild(blueprint);}.bind(this)).as(PROVIDER).done()
};

@@ -117,0 +113,0 @@

@@ -5,4 +5,4 @@ 'use strict'

function create() {
return new Container()
function create(conf) {
return new Container(conf)
} module.exports.create = create;

@@ -23,13 +23,10 @@ 'use strict'

module.exports = function createResolvers() {
var resolvers = {}
var resolvers = {}
resolvers[ generateType([VALUE]) ] = compose(leftCurryTwice, resolveDeps)(identity)
resolvers[ generateType([CONSTRUCTOR]) ] = compose(leftCurryTwice, resolveDeps)(instanciate)
resolvers[ generateType([CONSTRUCTOR, SINGLETON]) ] = compose(leftCurryTwice, singletonify)(instanciate)
resolvers[ generateType([PROVIDER]) ] = compose(leftCurryTwice, resolveDeps)(invoke)
resolvers[ generateType([SINGLETON, PROVIDER]) ] = compose(leftCurryTwice, singletonify)(invoke)
resolvers[ generateType([VALUE]) ] = compose(leftCurryTwice, resolveDeps)(identity)
resolvers[ generateType([CONSTRUCTOR]) ] = compose(leftCurryTwice, resolveDeps)(instanciate)
resolvers[ generateType([CONSTRUCTOR, SINGLETON]) ] = singletonify(instanciate)
resolvers[ generateType([PROVIDER]) ] = compose(leftCurryTwice, resolveDeps)(invoke)
resolvers[ generateType([SINGLETON, PROVIDER]) ] = singletonify(invoke)
return resolvers
}
module.exports = resolvers
'use strict'
var mod$4 = require('./signals');var ACQUIRE = mod$4.ACQUIRE;var RELEASE = mod$4.RELEASE;var DISPOSE = mod$4.DISPOSE;
var mod$6 = require('./signals');var ACQUIRE = mod$6.ACQUIRE;var RELEASE = mod$6.RELEASE;var DISPOSE = mod$6.DISPOSE;
module.exports = function singletonify(fn) {
module.exports = function singletonify(create) {
var handlers = {}
var count = 0
var instance
return function (value, resolveDeps, releaseDeps) {
function dispose() {
if (typeof instance.dispose === 'function') {
instance.dispose()
var handlers = {}
var count = 0
var instance
function dispose() {
if (typeof instance.dispose === 'function') {
instance.dispose()
}
instance = undefined
count = 0
}
instance = undefined
count = 0
}
handlers[ACQUIRE] = function (value, resolveDeps, releaseDeps, args) {
if (typeof instance === 'undefined') {
instance = fn.call(this, value, resolveDeps(), args)
handlers[ACQUIRE] = function (value, args) {
if (typeof instance === 'undefined') {
instance = create.call(this, value, resolveDeps(), args)
}
count++
return instance
}
count++
return instance
}
handlers[RELEASE] = function (value, resolveDeps, releaseDeps) {
count--
if (count <= 0) {
handlers[RELEASE] = function (value) {
count--
if (count <= 0) {
releaseDeps()
dispose()
}
}
handlers[DISPOSE] = function (value) {
releaseDeps()
dispose()
}
}
handlers[DISPOSE] = function (value, resolveDeps, releaseDeps) {
releaseDeps()
dispose()
return function (signal, args) {
return handlers[signal].call(this, value, args)
}
}
return function (value, resolveDeps, releaseDeps, signal, args) {
return handlers[signal].call(this, value, resolveDeps, releaseDeps, args)
}
}

@@ -16,15 +16,2 @@ 'use strict'

// not used
function memoize(fn) {
var value
return function () {var args=Array.prototype.slice.call(arguments,0);
if (typeof value === 'undefined') {
value = fn.apply(this, args)
}
return value
}
} module.exports.memoize = memoize;
function compose() {var funcs=Array.prototype.slice.call(arguments,0);

@@ -52,12 +39,2 @@ return function () {var args=Array.prototype.slice.call(arguments,0);

// not used
function merge(first ) {var sources=Array.prototype.slice.call(arguments,1);
return sources.reduce(function (out, source) {
for (var k in source) {
out[k] = source[k]
}
return out
}, first)
} module.exports.merge = merge;
module.exports.instanciate = instanciate;module.exports.singletonify = singletonify;
{
"name": "iniettore",
"version": "0.0.3",
"version": "0.0.4",
"description": "A light and simple IoC container",
"main": "lib/iniettore.js",
"scripts": {
"test": "node_modules/.bin/gulp test",
"test": "node_modules/.bin/gulp test-ci",
"build": "node_modules/.bin/gulp default",

@@ -17,3 +17,3 @@ "prepublish": "node_modules/.bin/gulp build"

],
"engines": {
"engines": {
"node": ">=0.10.25"

@@ -72,4 +72,6 @@ },

"jstransform": "~5.0.0",
"gulp-size": "~0.4.0"
"gulp-size": "~0.4.0",
"browserify-istanbul": "~0.1.0",
"gulp-coveralls": "~0.1.2"
}
}

@@ -6,2 +6,4 @@

[![GitHub version](https://badge.fury.io/gh/cesarenaldi%2Finiettore.svg)](http://badge.fury.io/gh/cesarenaldi%2Finiettore)
[![NPM dependencies](https://david-dm.org/cesarenaldi/iniettore.svg)](https://david-dm.org/cesarenaldi/iniettore)
[![Coverage Status](https://img.shields.io/coveralls/cesarenaldi/iniettore.svg)](https://coveralls.io/r/cesarenaldi/iniettore?branch=master)

@@ -21,7 +23,7 @@ ## TODO

- [ ] Improve fluid API
- [ ] remove done call
- [ ] remove done call, should I segregate the contribution phase into a revealing construction pattern?
- [ ] test case when singletons do NOT implement a dispose method
- [ ] cleanup
- [ ] remove memoize if not used
- [ ] remove merge if not used
- [x] cleanup
- [x] remove memoize if not used
- [x] remove merge if not used

@@ -28,0 +30,0 @@ - [ ] DOCS

var gulp = require('gulp')
var debug = require('gulp-debug')
var karma = require('gulp-karma')
var istanbul = require('browserify-istanbul')
var browserify = require('browserify')
var watchify = require('watchify')
var glob = require('glob')
var watch = require('gulp-watch')
var jstransformify = require('jstransformify')
var source = require('vinyl-source-stream')
var streamify = require('gulp-streamify')
var foreach = require('gulp-foreach')

@@ -19,5 +15,15 @@ var visitors = require('./utils/visitors').visitors

.transform({
visitors: visitors
visitors: visitors,
minify: true
}, jstransformify)
.bundle({ debug: true, minify: true })
.transform(istanbul({
ignore: ['**/node_modules/**', '**/test/**'],
defaultIgnore: true
}))
.bundle({
debug: true,
insertGlobals: false,
detectGlobals: true,
noBuiltins: true
})
.pipe(source(file.path))

@@ -28,3 +34,3 @@ }))

configFile: 'karma.conf.js'
}))
}))
})

@@ -25,2 +25,3 @@ 'use strict'

container.createBlueprint('foo', function (container) {
container

@@ -27,0 +28,0 @@ .bind('baz', blueprintProviderStub)

@@ -98,2 +98,44 @@ 'use strict'

})
describe('with some other singleton constructors shared dependencies', function () {
describe('when requesting the corresponding alias', function () {
it('should create singletons from the respective constructors', function () {
var commonInstance
class Common {
constructor() {
commonInstance = this
}
}
class Bar {
constructor(common) {
expect(common).to.be.instanceof(Common)
}
}
class Foo {
constructor(common, bar) {
expect(common).to.be.instanceof(Common)
expect(bar).to.be.instanceof(Bar)
}
}
container
.bind('common', Common)
.as(SINGLETON, CONSTRUCTOR)
.bind('bar', Bar)
.as(SINGLETON, CONSTRUCTOR)
.inject('common')
.bind('foo', Foo)
.as(SINGLETON, CONSTRUCTOR)
.inject('common', 'bar')
.done()
expect(container.get('foo')).to.be.instanceof(Foo)
})
})
})
})

@@ -100,0 +142,0 @@

@@ -12,7 +12,7 @@ 'use strict'

before(function () {
container = iniettore.create()
container
.bind('bar', DUMMY_VALUE)
.as(VALUE)
.done()
container = iniettore.create(function (container) {
container
.bind('bar', DUMMY_VALUE)
.as(VALUE)
})
})

@@ -19,0 +19,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc