Socket
Socket
Sign inDemoInstall

di

Package Overview
Dependencies
1
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-pre-6 to 2.0.0-pre-7

28

dist/amd/annotations.js

@@ -6,5 +6,7 @@ define(['./util'], function($__0) {

$__0 = {'default': $__0};
var isFunction = ($__0).isFunction;
var isFunction = $traceurRuntime.assertObject($__0).isFunction;
var SuperConstructor = function SuperConstructor() {};
($traceurRuntime.createClass)(SuperConstructor, {}, {});
var TransientScope = function TransientScope() {};
($traceurRuntime.createClass)(TransientScope, {}, {});
var InjectAnnotation = function InjectAnnotation() {

@@ -36,2 +38,11 @@ for (var tokens = [],

($traceurRuntime.createClass)(ProvidePromiseAnnotation, {}, {}, ProvideAnnotation);
var InjectLazyAnnotation = function InjectLazyAnnotation() {
for (var tokens = [],
$__8 = 0; $__8 < arguments.length; $__8++)
tokens[$__8] = arguments[$__8];
this.tokens = tokens;
this.isPromise = false;
this.isLazy = true;
};
($traceurRuntime.createClass)(InjectLazyAnnotation, {}, {}, InjectAnnotation);
var Inject = InjectAnnotation;

@@ -41,2 +52,3 @@ var InjectPromise = InjectPromiseAnnotation;

var ProvidePromise = ProvidePromiseAnnotation;
var InjectLazy = InjectLazyAnnotation;
function annotate(fn, annotation) {

@@ -66,3 +78,4 @@ fn.annotations = fn.annotations || [];

injectTokens: [],
injectPromises: []
injectPromises: [],
injectLazily: []
};

@@ -93,5 +106,7 @@ if (fn.annotations && fn.annotations.length) {

collectedAnnotations.injectPromises[idx] = false;
collectedAnnotations.injectLazily[idx] = false;
} else if (paramAnnotation instanceof InjectAnnotation) {
collectedAnnotations.injectTokens[idx] = paramAnnotation.tokens[0];
collectedAnnotations.injectPromises[idx] = paramAnnotation.isPromise;
collectedAnnotations.injectLazily[idx] = paramAnnotation.isLazy;
}

@@ -112,2 +127,5 @@ }

},
get TransientScope() {
return TransientScope;
},
get Inject() {

@@ -125,2 +143,8 @@ return Inject;

},
get InjectLazy() {
return InjectLazy;
},
get InjectLazyAnnotation() {
return InjectLazyAnnotation;
},
get Provide() {

@@ -127,0 +151,0 @@ return Provide;

@@ -10,7 +10,9 @@ define(['./annotations', './util', './profiler'], function($__0,$__1,$__2) {

$__2 = {'default': $__2};
var $__7 = $__0,
var $__7 = $traceurRuntime.assertObject($__0),
SuperConstructor = $__7.SuperConstructor,
readAnnotations = $__7.readAnnotations,
hasAnnotation = $__7.hasAnnotation;
var $__7 = $__1,
hasAnnotation = $__7.hasAnnotation,
ProvideAnnotation = $__7.ProvideAnnotation,
TransientScope = $__7.TransientScope;
var $__7 = $traceurRuntime.assertObject($__1),
isUpperCase = $__7.isUpperCase,

@@ -21,3 +23,3 @@ isClass = $__7.isClass,

toString = $__7.toString;
var getUniqueId = ($__2).getUniqueId;
var getUniqueId = $traceurRuntime.assertObject($__2).getUniqueId;
var EmptyFunction = Object.getPrototypeOf(Function);

@@ -40,2 +42,3 @@ function constructResolvingMessage(resolving) {

this.paramsPromises = annotations.injectPromises;
this.paramsLazily = annotations.injectLazily;
};

@@ -101,2 +104,3 @@ ($traceurRuntime.createClass)(Provider, {}, {});

var wantPromise = arguments[2] !== (void 0) ? arguments[2] : false;
var wantLazy = arguments[3] !== (void 0) ? arguments[3] : false;
var $__3 = this;

@@ -106,2 +110,3 @@ var defaultProvider;

var instance;
var injector = this;
function instantiate(args, context, provider, resolving, token) {

@@ -131,2 +136,22 @@ var returnedValue;

}
if (wantLazy) {
return function() {
var lazyInjector = injector;
if (arguments.length) {
var locals = [];
var args = arguments;
for (var i = 0; i < args.length; i += 2) {
locals.push((function(ii) {
var fn = function() {
return args[ii + 1];
};
fn.annotations = [new ProvideAnnotation(args[ii])];
return fn;
})(i));
}
lazyInjector = injector.createChild(locals);
}
return lazyInjector.get(token, resolving, wantPromise, false);
};
}
if (this.cache.has(token)) {

@@ -167,3 +192,2 @@ instance = this.cache.get(token);

}
var injector = this;
var delayingInstantiation = wantPromise && provider.params.some((function(token, i) {

@@ -191,5 +215,5 @@ return !provider.paramsPromises[i];

if (delayingInstantiation) {
return $__3.get(token, resolving, true);
return $__3.get(token, resolving, true, provider.paramsLazily[idx]);
}
return $__3.get(token, resolving, provider.paramsPromises[idx]);
return $__3.get(token, resolving, provider.paramsPromises[idx], provider.paramsLazily[idx]);
}));

@@ -206,3 +230,5 @@ if (delayingInstantiation) {

instance = instantiate(args, context, provider, resolving, token);
this.cache.set(token, instance);
if (!hasAnnotation(provider.provider, TransientScope)) {
this.cache.set(token, instance);
}
if (!wantPromise && provider.isPromise) {

@@ -209,0 +235,0 @@ resolvingMsg = constructResolvingMessage(resolving);

6

dist/amd/testing.js

@@ -10,8 +10,8 @@ define(['./injector', './annotations', './util'], function($__0,$__1,$__2) {

$__2 = {'default': $__2};
var Injector = ($__0).Injector;
var $__6 = $__1,
var Injector = $traceurRuntime.assertObject($__0).Injector;
var $__6 = $traceurRuntime.assertObject($__1),
Inject = $__6.Inject,
annotate = $__6.annotate,
readAnnotations = $__6.readAnnotations;
var $__6 = $__2,
var $__6 = $traceurRuntime.assertObject($__2),
isUpperCase = $__6.isUpperCase,

@@ -18,0 +18,0 @@ isClass = $__6.isClass;

"use strict";
var __moduleName = "annotations";
var isFunction = require('./util').isFunction;
var isFunction = $traceurRuntime.assertObject(require('./util')).isFunction;
var SuperConstructor = function SuperConstructor() {};
($traceurRuntime.createClass)(SuperConstructor, {}, {});
var TransientScope = function TransientScope() {};
($traceurRuntime.createClass)(TransientScope, {}, {});
var InjectAnnotation = function InjectAnnotation() {

@@ -32,2 +34,11 @@ for (var tokens = [],

($traceurRuntime.createClass)(ProvidePromiseAnnotation, {}, {}, ProvideAnnotation);
var InjectLazyAnnotation = function InjectLazyAnnotation() {
for (var tokens = [],
$__7 = 0; $__7 < arguments.length; $__7++)
tokens[$__7] = arguments[$__7];
this.tokens = tokens;
this.isPromise = false;
this.isLazy = true;
};
($traceurRuntime.createClass)(InjectLazyAnnotation, {}, {}, InjectAnnotation);
var Inject = InjectAnnotation;

@@ -37,2 +48,3 @@ var InjectPromise = InjectPromiseAnnotation;

var ProvidePromise = ProvidePromiseAnnotation;
var InjectLazy = InjectLazyAnnotation;
function annotate(fn, annotation) {

@@ -62,3 +74,4 @@ fn.annotations = fn.annotations || [];

injectTokens: [],
injectPromises: []
injectPromises: [],
injectLazily: []
};

@@ -89,5 +102,7 @@ if (fn.annotations && fn.annotations.length) {

collectedAnnotations.injectPromises[idx] = false;
collectedAnnotations.injectLazily[idx] = false;
} else if (paramAnnotation instanceof InjectAnnotation) {
collectedAnnotations.injectTokens[idx] = paramAnnotation.tokens[0];
collectedAnnotations.injectPromises[idx] = paramAnnotation.isPromise;
collectedAnnotations.injectLazily[idx] = paramAnnotation.isLazy;
}

@@ -108,2 +123,5 @@ }

},
get TransientScope() {
return TransientScope;
},
get Inject() {

@@ -121,2 +139,8 @@ return Inject;

},
get InjectLazy() {
return InjectLazy;
},
get InjectLazyAnnotation() {
return InjectLazyAnnotation;
},
get Provide() {

@@ -123,0 +147,0 @@ return Provide;

"use strict";
var __moduleName = "injector";
var $__4 = require('./annotations'),
var $__4 = $traceurRuntime.assertObject(require('./annotations')),
SuperConstructor = $__4.SuperConstructor,
readAnnotations = $__4.readAnnotations,
hasAnnotation = $__4.hasAnnotation;
var $__4 = require('./util'),
hasAnnotation = $__4.hasAnnotation,
ProvideAnnotation = $__4.ProvideAnnotation,
TransientScope = $__4.TransientScope;
var $__4 = $traceurRuntime.assertObject(require('./util')),
isUpperCase = $__4.isUpperCase,

@@ -13,3 +15,3 @@ isClass = $__4.isClass,

toString = $__4.toString;
var getUniqueId = require('./profiler').getUniqueId;
var getUniqueId = $traceurRuntime.assertObject(require('./profiler')).getUniqueId;
var EmptyFunction = Object.getPrototypeOf(Function);

@@ -32,2 +34,3 @@ function constructResolvingMessage(resolving) {

this.paramsPromises = annotations.injectPromises;
this.paramsLazily = annotations.injectLazily;
};

@@ -93,2 +96,3 @@ ($traceurRuntime.createClass)(Provider, {}, {});

var wantPromise = arguments[2] !== (void 0) ? arguments[2] : false;
var wantLazy = arguments[3] !== (void 0) ? arguments[3] : false;
var $__0 = this;

@@ -98,2 +102,3 @@ var defaultProvider;

var instance;
var injector = this;
function instantiate(args, context, provider, resolving, token) {

@@ -123,2 +128,22 @@ var returnedValue;

}
if (wantLazy) {
return function() {
var lazyInjector = injector;
if (arguments.length) {
var locals = [];
var args = arguments;
for (var i = 0; i < args.length; i += 2) {
locals.push((function(ii) {
var fn = function() {
return args[ii + 1];
};
fn.annotations = [new ProvideAnnotation(args[ii])];
return fn;
})(i));
}
lazyInjector = injector.createChild(locals);
}
return lazyInjector.get(token, resolving, wantPromise, false);
};
}
if (this.cache.has(token)) {

@@ -159,3 +184,2 @@ instance = this.cache.get(token);

}
var injector = this;
var delayingInstantiation = wantPromise && provider.params.some((function(token, i) {

@@ -183,5 +207,5 @@ return !provider.paramsPromises[i];

if (delayingInstantiation) {
return $__0.get(token, resolving, true);
return $__0.get(token, resolving, true, provider.paramsLazily[idx]);
}
return $__0.get(token, resolving, provider.paramsPromises[idx]);
return $__0.get(token, resolving, provider.paramsPromises[idx], provider.paramsLazily[idx]);
}));

@@ -198,3 +222,5 @@ if (delayingInstantiation) {

instance = instantiate(args, context, provider, resolving, token);
this.cache.set(token, instance);
if (!hasAnnotation(provider.provider, TransientScope)) {
this.cache.set(token, instance);
}
if (!wantPromise && provider.isPromise) {

@@ -201,0 +227,0 @@ resolvingMsg = constructResolvingMessage(resolving);

"use strict";
var __moduleName = "testing";
var Injector = require('./injector').Injector;
var $__3 = require('./annotations'),
var Injector = $traceurRuntime.assertObject(require('./injector')).Injector;
var $__3 = $traceurRuntime.assertObject(require('./annotations')),
Inject = $__3.Inject,
annotate = $__3.annotate,
readAnnotations = $__3.readAnnotations;
var $__3 = require('./util'),
var $__3 = $traceurRuntime.assertObject(require('./util')),
isUpperCase = $__3.isUpperCase,

@@ -10,0 +10,0 @@ isClass = $__3.isClass;

{
"name": "di",
"version": "2.0.0-pre-6",
"version": "2.0.0-pre-7",
"description": "A DI framework.",

@@ -15,9 +15,21 @@ "main": "node/index.js",

"dependencies": {
"traceur": "~0.0.30",
"traceur": "vojtajina/traceur-compiler#add-es6-pure-transformer-dist",
"es6-shim": "~0.9.2"
},
"devDependencies": {
"pipe": "angular/pipe",
"gulp-connect": "~0.3.0",
"rtts-assert": "angular/assert",
"gulp": "^3.5.6",
"gulp-connect": "~1.0.5",
"gulp-traceur": "vojtajina/gulp-traceur#traceur-as-peer",
"gulp-git": "vojtajina/gulp-git#hacked",
"karma": "^0.12.1",
"karma-script-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3",
"karma-phantomjs-launcher": "~0.1.2",
"karma-sauce-launcher": "~0.2.4",
"karma-jasmine": "^0.2.2",
"karma-requirejs": "^0.2.1",
"karma-traceur-preprocessor": "vojtajina/karma-traceur-preprocessor#traceur-as-peer",
"pipe": "angular/pipe#remove-transitive-deps",
"requirejs": "2.1.10",

@@ -24,0 +36,0 @@ "through2": "~0.4.1"

@@ -5,2 +5,4 @@ import {isFunction} from './util';

class TransientScope {}
class InjectAnnotation {

@@ -34,2 +36,10 @@ constructor(...tokens) {

class InjectLazyAnnotation extends InjectAnnotation {
constructor(...tokens) {
this.tokens = tokens;
this.isPromise = false;
this.isLazy = true;
}
}
// aliases

@@ -40,2 +50,3 @@ var Inject = InjectAnnotation;

var ProvidePromise = ProvidePromiseAnnotation;
var InjectLazy = InjectLazyAnnotation;

@@ -77,3 +88,6 @@ // Helpers for when annotations are not enabled in Traceur.

// Is given dependency required as a promise?
injectPromises: []
injectPromises: [],
// List of booleans.
// Is given dependency required lazily?
injectLazily: []
};

@@ -86,2 +100,3 @@

// TODO(vojta): set injectPromises
// TODO(vojta): set injectLazily
}

@@ -104,5 +119,7 @@

collectedAnnotations.injectPromises[idx] = false;
collectedAnnotations.injectLazily[idx] = false;
} else if (paramAnnotation instanceof InjectAnnotation) {
collectedAnnotations.injectTokens[idx] = paramAnnotation.tokens[0];
collectedAnnotations.injectPromises[idx] = paramAnnotation.isPromise;
collectedAnnotations.injectLazily[idx] = paramAnnotation.isLazy;
}

@@ -120,2 +137,3 @@ }

SuperConstructor,
TransientScope,
Inject,

@@ -125,2 +143,4 @@ InjectAnnotation,

InjectPromiseAnnotation,
InjectLazy,
InjectLazyAnnotation,
Provide,

@@ -127,0 +147,0 @@ ProvideAnnotation,

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

import {SuperConstructor, readAnnotations, hasAnnotation} from './annotations';
import {SuperConstructor, readAnnotations, hasAnnotation, ProvideAnnotation, TransientScope} from './annotations';
import {isUpperCase, isClass, isFunction, isObject, toString} from './util';

@@ -33,2 +33,3 @@ import {getUniqueId} from './profiler';

this.paramsPromises = annotations.injectPromises;
this.paramsLazily = annotations.injectLazily;
}

@@ -104,6 +105,7 @@ }

get(token, resolving = [], wantPromise = false) {
get(token, resolving = [], wantPromise = false, wantLazy = false) {
var defaultProvider;
var resolvingMsg = '';
var instance;
var injector = this;

@@ -142,2 +144,28 @@ function instantiate(args, context, provider, resolving, token) {

// TODO(vojta): optimize - no child injector for locals?
if (wantLazy) {
return function() {
var lazyInjector = injector;
if (arguments.length) {
var locals = [];
var args = arguments;
for (var i = 0; i < args.length; i += 2) {
locals.push((function(ii) {
var fn = function() {
return args[ii + 1];
};
fn.annotations = [new ProvideAnnotation(args[ii])]
return fn;
})(i));
}
lazyInjector = injector.createChild(locals);
}
return lazyInjector.get(token, resolving, wantPromise, false);
};
}
// Check if there is a cached instance already.

@@ -199,3 +227,2 @@ if (this.cache.has(token)) {

// -> error, but let it go inside to throw where exactly is the async provider
var injector = this;
var delayingInstantiation = wantPromise && provider.params.some((token, i) => !provider.paramsPromises[i]);

@@ -230,6 +257,6 @@

if (delayingInstantiation) {
return this.get(token, resolving, true);
return this.get(token, resolving, true, provider.paramsLazily[idx]);
}
return this.get(token, resolving, provider.paramsPromises[idx]);
return this.get(token, resolving, provider.paramsPromises[idx], provider.paramsLazily[idx]);
});

@@ -261,3 +288,5 @@

this.cache.set(token, instance);
if (!hasAnnotation(provider.provider, TransientScope)) {
this.cache.set(token, instance);
}

@@ -264,0 +293,0 @@ if (!wantPromise && provider.isPromise) {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc