UNPKG

2.02 kBJavaScriptView Raw
1'use strict'
2
3var instanciate = require('./instanciate');
4var singletonify = require('./singletonify');
5var mod$16 = require('./options');var EAGER = mod$16.EAGER;var SINGLETON = mod$16.SINGLETON;var PROVIDER = mod$16.PROVIDER;var CONSTRUCTOR = mod$16.CONSTRUCTOR;
6
7var EAGER_SINGLETON_PROVIDER = generateMask([EAGER, SINGLETON, PROVIDER])
8var EAGER_SINGLETON_CONSTRUCTOR = generateMask([EAGER, SINGLETON, CONSTRUCTOR])
9
10function identity(value) { return value } module.exports.identity = identity;
11
12function leftCurryTwice(fn) {
13 return function firstCurry() {var firstArgs=Array.prototype.slice.call(arguments,0);
14 return function secondCurry() {var secondArgs=Array.prototype.slice.call(arguments,0);
15 return fn.apply(null, firstArgs.concat(secondArgs))
16 }
17 }
18} module.exports.leftCurryTwice = leftCurryTwice;
19
20function compose() {var funcs=Array.prototype.slice.call(arguments,0);
21 return function () {var args=Array.prototype.slice.call(arguments,0);
22
23 var i
24
25 for (i = funcs.length - 1; i >= 0; i--) {
26 args = [funcs[i].apply(this, args)]
27 }
28 return args[0]
29 }
30} module.exports.compose = compose;
31
32function resolveDeps(fn) {
33 return function (value, resolve, release, signal) {
34 return fn.call(this, value, resolve())
35 }
36} module.exports.resolveDeps = resolveDeps;
37
38function invoke(fn, deps) {
39 return fn.apply(null, deps)
40} module.exports.invoke = invoke;
41
42function partial(func, boundArgs) {
43 return function () {var args=Array.prototype.slice.call(arguments,0);
44 return func.apply(this, boundArgs.concat(args))
45 }
46} module.exports.partial = partial;
47
48function generateMask(flags) {
49 return flags.reduce(function(prev, curr) {return prev | curr;}, 0)
50} module.exports.generateMask = generateMask;
51
52function isEagerSingleton(type) {
53 return [EAGER_SINGLETON_PROVIDER, EAGER_SINGLETON_CONSTRUCTOR].indexOf(type) > -1
54} module.exports.isEagerSingleton = isEagerSingleton;
55
56function noop() {} module.exports.noop = noop;
57
58module.exports.instanciate = instanciate;module.exports.singletonify = singletonify;
\No newline at end of file