1 | 'use strict'
|
2 |
|
3 | var instanciate = require('./instanciate');
|
4 | var singletonify = require('./singletonify');
|
5 | var 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 |
|
7 | var EAGER_SINGLETON_PROVIDER = generateMask([EAGER, SINGLETON, PROVIDER])
|
8 | var EAGER_SINGLETON_CONSTRUCTOR = generateMask([EAGER, SINGLETON, CONSTRUCTOR])
|
9 |
|
10 | function identity(value) { return value } module.exports.identity = identity;
|
11 |
|
12 | function 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 |
|
20 | function 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 |
|
32 | function resolveDeps(fn) {
|
33 | return function (value, resolve, release, signal) {
|
34 | return fn.call(this, value, resolve())
|
35 | }
|
36 | } module.exports.resolveDeps = resolveDeps;
|
37 |
|
38 | function invoke(fn, deps) {
|
39 | return fn.apply(null, deps)
|
40 | } module.exports.invoke = invoke;
|
41 |
|
42 | function 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 |
|
48 | function generateMask(flags) {
|
49 | return flags.reduce(function(prev, curr) {return prev | curr;}, 0)
|
50 | } module.exports.generateMask = generateMask;
|
51 |
|
52 | function isEagerSingleton(type) {
|
53 | return [EAGER_SINGLETON_PROVIDER, EAGER_SINGLETON_CONSTRUCTOR].indexOf(type) > -1
|
54 | } module.exports.isEagerSingleton = isEagerSingleton;
|
55 |
|
56 | function noop() {} module.exports.noop = noop;
|
57 |
|
58 | module.exports.instanciate = instanciate;module.exports.singletonify = singletonify; |
\ | No newline at end of file |