dependency-injection
Advanced tools
Comparing version 2.3.2 to 2.3.3
@@ -1,2 +0,1 @@ | ||
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
@@ -3,0 +2,0 @@ var Defaults, isWindow; |
@@ -1,2 +0,1 @@ | ||
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
@@ -47,7 +46,10 @@ var DI, Defaults, Helpers, Service, | ||
DI.prototype.addService = function(name, service, args) { | ||
var arg, i, originalService, _i, _len; | ||
DI.prototype.addService = function(name, service, args, factory) { | ||
var arg, factoryArguments, i, instantiate, match, originalService, _i, _len; | ||
if (args == null) { | ||
args = []; | ||
} | ||
if (factory == null) { | ||
factory = false; | ||
} | ||
if (__indexOf.call(this.reserved, name) >= 0 && typeof this.services[name] !== 'undefined') { | ||
@@ -57,2 +59,7 @@ throw new Error("DI: name '" + name + "' is reserved by DI."); | ||
originalService = service; | ||
instantiate = this.instantiate; | ||
factoryArguments = []; | ||
if (factory) { | ||
instantiate = false; | ||
} | ||
if (typeof service === 'string') { | ||
@@ -62,2 +69,6 @@ if (service.match(/^(factory\:)?[@$]/)) { | ||
} else { | ||
if (match = service.match(/^(.+)\((.*)\)$/)) { | ||
service = match[1]; | ||
factoryArguments = match[2]; | ||
} | ||
service = this.resolveModulePath(service); | ||
@@ -74,4 +85,3 @@ if (service === null) { | ||
} | ||
this.services[name] = new Service(this, name, service, args); | ||
this.services[name].setInstantiate(this.instantiate); | ||
this.services[name] = (new Service(this, name, service, args)).setInstantiate(instantiate).setFactory(factory, factoryArguments); | ||
return this.services[name]; | ||
@@ -94,4 +104,24 @@ }; | ||
DI.prototype.tryCallStringArguments = function(args) { | ||
var a, i, match, _i, _len; | ||
if (typeof args !== 'string') { | ||
return args; | ||
} | ||
args = args.split(','); | ||
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) { | ||
a = args[i]; | ||
a = a.trim(); | ||
if ((match = a.match(/'(.*)'/)) || (match = a.match(/"(.*)"/))) { | ||
args[i] = match[1]; | ||
} else if (this.config !== null && (match = a.match(/^%([a-zA-Z.-_]+)%$/))) { | ||
args[i] = this.getParameter(match[1]); | ||
} else { | ||
args[i] = this.tryCallArgument(a); | ||
} | ||
} | ||
return args; | ||
}; | ||
DI.prototype.tryCallArgument = function(arg) { | ||
var a, after, args, factory, i, match, original, pos, service, sub, type, _i, _len; | ||
var after, args, factory, match, original, pos, service, sub, type; | ||
if (typeof arg !== 'string') { | ||
@@ -134,14 +164,3 @@ return arg; | ||
sub = match[1]; | ||
args = match[2].split(','); | ||
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) { | ||
a = args[i]; | ||
a = a.trim(); | ||
if ((match = a.match(/'(.*)'/)) || (match = a.match(/"(.*)"/))) { | ||
args[i] = match[1]; | ||
} else if (this.config !== null && (match = a.match(/^%([a-zA-Z.-_]+)%$/))) { | ||
args[i] = this.getParameter(match[1]); | ||
} else { | ||
args[i] = this.tryCallArgument(a); | ||
} | ||
} | ||
args = this.tryCallStringArguments(match[2]); | ||
} | ||
@@ -148,0 +167,0 @@ if (typeof service[sub] === 'undefined') { |
@@ -1,2 +0,1 @@ | ||
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
@@ -38,2 +37,3 @@ var Configuration, DI, DIFactory, Helpers, callsite, isWindow, path; | ||
service: null, | ||
factory: null, | ||
"arguments": [], | ||
@@ -75,3 +75,3 @@ instantiate: null, | ||
DIFactory.prototype.create = function() { | ||
var configuration, defaultDefaults, defaultService, defaultSetup, di, expose, method, name, run, s, service, _i, _len, _ref, _ref1; | ||
var configuration, defaultDefaults, defaultService, defaultSetup, di, expose, method, name, run, s, service, serviceName, _i, _len, _ref, _ref1; | ||
defaultService = this.defaultService; | ||
@@ -122,4 +122,5 @@ this.config.addSection('services').loadConfiguration = function() { | ||
if (configuration.services.hasOwnProperty(name) && (name !== '__proto__')) { | ||
serviceName = service.service || service.factory; | ||
if (service.instantiate === null) { | ||
if (service.service.match(/^(factory\:)?[@$]/)) { | ||
if (serviceName.match(/^(factory\:)?[@$]/) || service.factory !== null) { | ||
service.instantiate = false; | ||
@@ -130,5 +131,3 @@ } else { | ||
} | ||
s = di.addService(name, service.service, service["arguments"]); | ||
s.setInstantiate(service.instantiate); | ||
s.setAutowired(service.autowired); | ||
s = di.addService(name, serviceName, service["arguments"], service.factory !== null).setAutowired(service.autowired).setInstantiate(service.instantiate); | ||
_ref1 = service.setup; | ||
@@ -135,0 +134,0 @@ for (method in _ref1) { |
@@ -1,2 +0,1 @@ | ||
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
@@ -3,0 +2,0 @@ var Helpers; |
@@ -1,2 +0,1 @@ | ||
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
@@ -20,2 +19,6 @@ var Helpers, Service; | ||
Service.prototype.factory = false; | ||
Service.prototype.factoryArguments = []; | ||
Service.prototype.setup = null; | ||
@@ -52,2 +55,5 @@ | ||
} | ||
if (this.factory) { | ||
service = service.apply(service, Helpers.autowireArguments(service, this.di.tryCallStringArguments(this.factoryArguments), this.di)); | ||
} | ||
try { | ||
@@ -88,2 +94,8 @@ service = this.di.createInstance(service, this["arguments"], this.instantiate); | ||
Service.prototype.setFactory = function(factory, factoryArguments) { | ||
this.factory = factory; | ||
this.factoryArguments = factoryArguments; | ||
return this; | ||
}; | ||
Service.prototype.setAutowired = function(autowired) { | ||
@@ -90,0 +102,0 @@ this.autowired = autowired; |
{ | ||
"name": "dependency-injection", | ||
"description": "Dependency injection with configuration and autowire for node js and browser", | ||
"version": "2.3.2", | ||
"description": "[ABANDONED] Dependency injection with configuration and autowire for node js and browser", | ||
"version": "2.3.3", | ||
"author": { | ||
"name": "David Kudera", | ||
"email": "sakren@gmail.com" | ||
"email": "kudera.d@gmail.com" | ||
}, | ||
@@ -17,3 +17,3 @@ "keywords": [ | ||
"type": "git", | ||
"url": "git@github.com:sakren/node-dependency-injection.git" | ||
"url": "git@github.com:Carrooi/Node-DependencyInjection.git" | ||
}, | ||
@@ -32,12 +32,15 @@ "license": "MIT", | ||
"mocha": "~1.18.0", | ||
"mocha-phantomjs": "~3.3.1", | ||
"phantomjs": "~1.9.2-6" | ||
"gulp": "~3.8.6", | ||
"gulp-coffee": "~2.1.1" | ||
}, | ||
"scripts": { | ||
"test": "npm run test-node && npm run test-browser", | ||
"build-and-test": "npm run test-build && npm run test", | ||
"test-build": "coffee -co ./test/data ./test/data; coffee -co ./test/node/lib ./test/node/src; cd ./test/browser; simq build;", | ||
"test-node": "mocha ./test/node/index.js --reporter spec", | ||
"test-browser": "mocha-phantomjs ./test/browser/index.html" | ||
"test": "mocha ./test/index.js --reporter spec", | ||
"compile": "gulp compile", | ||
"compile-source": "gulp compile-source", | ||
"compile-test": "gulp compile-test", | ||
"compile-test-source": "gulp compile-test-source", | ||
"compile-test-data": "gulp compile-test-data" | ||
} | ||
} | ||
} | ||
@@ -1,4 +0,4 @@ | ||
[![NPM version](https://badge.fury.io/js/dependency-injection.png)](http://badge.fury.io/js/dependency-injection) | ||
[![Dependency Status](https://gemnasium.com/sakren/node-dependency-injection.png)](https://gemnasium.com/sakren/node-dependency-injection) | ||
[![Build Status](https://travis-ci.org/sakren/node-dependency-injection.png?branch=master)](https://travis-ci.org/sakren/node-dependency-injection) | ||
[![NPM version](https://img.shields.io/npm/v/dependency-injection.svg?style=flat-square)](http://badge.fury.io/js/dependency-injection) | ||
[![Dependency Status](https://img.shields.io/gemnasium/Carrooi/Node-DependencyInjection.svg?style=flat-square)](https://gemnasium.com/Carrooi/Node-DependencyInjection) | ||
[![Build Status](https://img.shields.io/travis/Carrooi/Node-DependencyInjection.svg?style=flat-square)](https://travis-ci.org/Carrooi/Node-DependencyInjection) | ||
@@ -20,2 +20,10 @@ # Dependency injection | ||
## Help | ||
Unfortunately I don't have any more time to maintain this repository :-( | ||
Don't you want to save me and this project by taking over it? | ||
![sad cat](https://raw.githubusercontent.com/sakren/sakren.github.io/master/images/sad-kitten.jpg) | ||
## Installation | ||
@@ -437,3 +445,3 @@ | ||
console.log(di.parameters); // whole object of expanded parameters | ||
console.log(di.getParameter('database.user'); // root | ||
console.log(di.getParameter('database.user')); // root | ||
``` | ||
@@ -524,2 +532,6 @@ | ||
* 2.3.3 | ||
+ Move under Carrooi organization | ||
+ Abandon package | ||
* 2.3.1 - 2.3.2 | ||
@@ -651,2 +663,2 @@ + Fixed bug with passing list of parameters in method calls [https://github.com/sakren/node-dependency-injection/issues/7](#7) | ||
* 1.0.0 | ||
+ Initial version | ||
+ Initial version |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
56
661
2
103477
1482
2