Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
20
node_modules/di/LICENSE
generated
vendored
Normal file
20
node_modules/di/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
The MIT License
|
||||
|
||||
Copyright (C) 2013 Vojta Jína.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
node_modules/di/README.md
generated
vendored
Normal file
22
node_modules/di/README.md
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Dependency Injection for Node.js
|
||||
|
||||
Heavily influenced by [AngularJS] and its implementation of dependency injection.
|
||||
Inspired by [Guice] and [Pico Container].
|
||||
|
||||
[AngularJS]: http://angularjs.org/
|
||||
[Pico Container]: http://picocontainer.codehaus.org/
|
||||
[Guice]: http://code.google.com/p/google-guice/
|
||||
|
||||
<!--
|
||||
Differences compare to Angular:
|
||||
- service -> type
|
||||
- no config/runtime phase
|
||||
- no providers (configuration happens by registering config)
|
||||
- no $provide
|
||||
- no global module register
|
||||
- no array annotations (but annotate helper)
|
||||
- no decorators
|
||||
- no child injectors (yet)
|
||||
- comment annotation (TBD)
|
||||
- node module injection (TBD)
|
||||
-->
|
37
node_modules/di/lib/annotation.js
generated
vendored
Normal file
37
node_modules/di/lib/annotation.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
var annotate = function() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var fn = args.pop();
|
||||
|
||||
fn.$inject = args;
|
||||
|
||||
return fn;
|
||||
};
|
||||
|
||||
|
||||
// Current limitations:
|
||||
// - can't put into "function arg" comments
|
||||
// function /* (no parenthesis like this) */ (){}
|
||||
// function abc( /* xx (no parenthesis like this) */ a, b) {}
|
||||
//
|
||||
// Just put the comment before function or inside:
|
||||
// /* (((this is fine))) */ function(a, b) {}
|
||||
// function abc(a) { /* (((this is fine))) */}
|
||||
|
||||
var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
|
||||
var FN_ARG = /\/\*([^\*]*)\*\//m;
|
||||
|
||||
var parse = function(fn) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new Error('Can not annotate "' + fn + '". Expected a function!');
|
||||
}
|
||||
|
||||
var match = fn.toString().match(FN_ARGS);
|
||||
return match[1] && match[1].split(',').map(function(arg) {
|
||||
match = arg.match(FN_ARG);
|
||||
return match ? match[1].trim() : arg.trim();
|
||||
}) || [];
|
||||
};
|
||||
|
||||
|
||||
exports.annotate = annotate;
|
||||
exports.parse = parse;
|
5
node_modules/di/lib/index.js
generated
vendored
Normal file
5
node_modules/di/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
annotate: require('./annotation').annotate,
|
||||
Module: require('./module'),
|
||||
Injector: require('./injector')
|
||||
};
|
131
node_modules/di/lib/injector.js
generated
vendored
Normal file
131
node_modules/di/lib/injector.js
generated
vendored
Normal file
|
@ -0,0 +1,131 @@
|
|||
var Module = require('./module');
|
||||
var autoAnnotate = require('./annotation').parse;
|
||||
|
||||
|
||||
var Injector = function(modules, parent) {
|
||||
parent = parent || {
|
||||
get: function(name) {
|
||||
currentlyResolving.push(name);
|
||||
throw error('No provider for "' + name + '"!');
|
||||
}
|
||||
};
|
||||
|
||||
var currentlyResolving = [];
|
||||
var providers = this._providers = Object.create(parent._providers || null);
|
||||
var instances = this._instances = Object.create(null);
|
||||
|
||||
instances.injector = this;
|
||||
|
||||
var error = function(msg) {
|
||||
var stack = currentlyResolving.join(' -> ');
|
||||
currentlyResolving.length = 0;
|
||||
return new Error(stack ? msg + ' (Resolving: ' + stack + ')' : msg);
|
||||
};
|
||||
|
||||
var get = function(name) {
|
||||
if (!providers[name] && name.indexOf('.') !== -1) {
|
||||
var parts = name.split('.');
|
||||
var pivot = get(parts.shift());
|
||||
|
||||
while(parts.length) {
|
||||
pivot = pivot[parts.shift()];
|
||||
}
|
||||
|
||||
return pivot;
|
||||
}
|
||||
|
||||
if (Object.hasOwnProperty.call(instances, name)) {
|
||||
return instances[name];
|
||||
}
|
||||
|
||||
if (Object.hasOwnProperty.call(providers, name)) {
|
||||
if (currentlyResolving.indexOf(name) !== -1) {
|
||||
currentlyResolving.push(name);
|
||||
throw error('Can not resolve circular dependency!');
|
||||
}
|
||||
|
||||
currentlyResolving.push(name);
|
||||
instances[name] = providers[name][0](providers[name][1]);
|
||||
currentlyResolving.pop();
|
||||
|
||||
return instances[name];
|
||||
}
|
||||
|
||||
return parent.get(name);
|
||||
};
|
||||
|
||||
var instantiate = function(Type) {
|
||||
var instance = Object.create(Type.prototype);
|
||||
var returned = invoke(Type, instance);
|
||||
|
||||
return typeof returned === 'object' ? returned : instance;
|
||||
};
|
||||
|
||||
var invoke = function(fn, context) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw error('Can not invoke "' + fn + '". Expected a function!');
|
||||
}
|
||||
|
||||
var inject = fn.$inject && fn.$inject || autoAnnotate(fn);
|
||||
var dependencies = inject.map(function(dep) {
|
||||
return get(dep);
|
||||
});
|
||||
|
||||
// TODO(vojta): optimize without apply
|
||||
return fn.apply(context, dependencies);
|
||||
};
|
||||
|
||||
var createChild = function(modules, providersFromParent) {
|
||||
if (providersFromParent && providersFromParent.length) {
|
||||
var fromParentModule = Object.create(null);
|
||||
|
||||
providersFromParent.forEach(function(name) {
|
||||
if (!providers[name]) {
|
||||
throw new Error('No provider for "' + name + '". Can not use provider from the parent!');
|
||||
}
|
||||
|
||||
fromParentModule[name] = [providers[name][2], providers[name][1]];
|
||||
});
|
||||
|
||||
modules.unshift(fromParentModule);
|
||||
}
|
||||
|
||||
return new Injector(modules, this);
|
||||
};
|
||||
|
||||
var factoryMap = {
|
||||
factory: invoke,
|
||||
type: instantiate,
|
||||
value: function(value) {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
modules.forEach(function(module) {
|
||||
// TODO(vojta): handle wrong inputs (modules)
|
||||
if (module instanceof Module) {
|
||||
module.forEach(function(provider) {
|
||||
var name = provider[0];
|
||||
var type = provider[1];
|
||||
var value = provider[2];
|
||||
|
||||
providers[name] = [factoryMap[type], value, type];
|
||||
});
|
||||
} else if (typeof module === 'object') {
|
||||
Object.keys(module).forEach(function(name) {
|
||||
var type = module[name][0];
|
||||
var value = module[name][1];
|
||||
|
||||
providers[name] = [factoryMap[type], value, type];
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// public API
|
||||
this.get = get;
|
||||
this.invoke = invoke;
|
||||
this.instantiate = instantiate;
|
||||
this.createChild = createChild;
|
||||
};
|
||||
|
||||
module.exports = Injector;
|
24
node_modules/di/lib/module.js
generated
vendored
Normal file
24
node_modules/di/lib/module.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
var Module = function() {
|
||||
var providers = [];
|
||||
|
||||
this.factory = function(name, factory) {
|
||||
providers.push([name, 'factory', factory]);
|
||||
return this;
|
||||
};
|
||||
|
||||
this.value = function(name, value) {
|
||||
providers.push([name, 'value', value]);
|
||||
return this;
|
||||
};
|
||||
|
||||
this.type = function(name, type) {
|
||||
providers.push([name, 'type', type]);
|
||||
return this;
|
||||
};
|
||||
|
||||
this.forEach = function(iterator) {
|
||||
providers.forEach(iterator);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = Module;
|
29
node_modules/di/package.json
generated
vendored
Normal file
29
node_modules/di/package.json
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "di",
|
||||
"version": "0.0.1",
|
||||
"description": "Dependency Injection for Node.js. Heavily inspired by AngularJS.",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"test": "mocha --compilers coffee:coffee-script test/*"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/vojtajina/node-di.git"
|
||||
},
|
||||
"keywords": [
|
||||
"di",
|
||||
"dependency",
|
||||
"injection",
|
||||
"injector"
|
||||
],
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.0rc5",
|
||||
"grunt-simple-mocha": "~0.3.2",
|
||||
"grunt-contrib-jshint": "~0.1.1rc5",
|
||||
"mocha": "1.8.1",
|
||||
"chai": "1.4.2",
|
||||
"coffee-script": "1.4.0"
|
||||
},
|
||||
"author": "Vojta Jina <vojta.jina@gmail.com>",
|
||||
"license": "MIT"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue