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

sack

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sack - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

28

lib/Container.js

@@ -49,3 +49,3 @@ var getArgs = require('typedef').getArguments;

*/
Container.prototype.singleton = function(name, T)
Container.prototype.shared = function(name, T)
{

@@ -71,5 +71,11 @@ return this.register(name, T, true);

{
var deps;
var _this = this;
// Use parameter names of the function to bring in more deps
if (name instanceof Function)
return this.makeFromConstructor(name);
if (name instanceof Function) {
var T = name;
deps = _(getArgs(T)).map(function(d) { return _this.make(d); });
return callNew(T, deps);
}

@@ -87,8 +93,6 @@ // Nop if we are passing in something weird

// Resolve all string deps into make deps
var _this = this;
var instance;
if (!info.shared || !info.instance) {
var deps = info.deps.map(function(d) { return _this.make(d); });
deps = _(info.deps).map(function(d) { return _this.make(d); });
instance = callNew(info.type, deps);

@@ -116,14 +120,2 @@

/**
* Create an object by resolving deps for a class not in the container (but
* whose deps are)
* @param {Function} T Constructor function.
*/
Container.prototype.makeFromConstructor = function(T)
{
var _this = this;
var deps = getArgs(T).map(function(d) { return _this.make(d); });
return callNew(T, deps);
};
/**
* Resolve the name of a dep

@@ -130,0 +122,0 @@ * @param {String} name The dep name.

{
"name": "sack",
"version": "0.1.0",
"version": "1.0.0",
"description": "Inversion-of-control container for all your dependency injection needs.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -81,3 +81,3 @@ var test = require('tape');

r.register('a', A);
r.makeFromConstructor(T);
r.make(T);

@@ -91,3 +91,3 @@ });

function T() { t.ok(true, 'T ctor fired'); }
r.singleton('t', T);
r.shared('t', T);

@@ -111,3 +111,3 @@ t.strictEqual(r.make('t'), r.make('t'), 'Same instance created');

r.register('a', A);
r.singleton('t', T);
r.shared('t', T);

@@ -114,0 +114,0 @@ r.make('t');

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