| @@ -1,20 +1,28 | |||||
| 1 | HISTORY |
|
1 | HISTORY | |
| 2 | ======= |
|
2 | ======= | |
| 3 |
|
3 | |||
|
|
4 | 1.2.16 | |||
|
|
5 | ------ | |||
|
|
6 | ||||
|
|
7 | Minor fixes and improvements | |||
|
|
8 | ||||
|
|
9 | - added `isCancellable` type predicate function to `safe` module | |||
|
|
10 | - `isString, isNumber, isInteger, isPrimitive` are now type predicates | |||
|
|
11 | ||||
| 4 | 1.2.0 |
|
12 | 1.2.0 | |
| 5 | ----- |
|
13 | ----- | |
| 6 |
|
14 | |||
| 7 | Major rafactoring, moving to support both browser (rjs) and server (cjs) environments. |
|
15 | Major rafactoring, moving to support both browser (rjs) and server (cjs) environments. | |
| 8 |
|
16 | |||
| 9 | - dependency injection container ported to typescript |
|
17 | - dependency injection container ported to typescript | |
| 10 | - sources are split to several sets to provide the ability for the conditional build of the project. |
|
18 | - sources are split to several sets to provide the ability for the conditional build of the project. | |
| 11 |
|
19 | |||
| 12 | 1.0.1 |
|
20 | 1.0.1 | |
| 13 | ----- |
|
21 | ----- | |
| 14 |
|
22 | |||
| 15 | First release, intorduces the following features |
|
23 | First release, intorduces the following features | |
| 16 |
|
24 | |||
| 17 | - `di` - dependency injection container |
|
25 | - `di` - dependency injection container | |
| 18 | - `log` - log4 style logging system |
|
26 | - `log` - log4 style logging system | |
| 19 | - `text` - simple and fast text templating and formatting |
|
27 | - `text` - simple and fast text templating and formatting | |
| 20 | - `Uuid` - uuid generation traits No newline at end of file |
|
28 | - `Uuid` - uuid generation traits | |
| @@ -1,471 +1,471 | |||||
| 1 | { |
|
1 | { | |
| 2 | "name": "@implab/core", |
|
2 | "name": "@implab/core", | |
| 3 | "version": "0.0.1-dev", |
|
3 | "version": "0.0.1-dev", | |
| 4 | "lockfileVersion": 1, |
|
4 | "lockfileVersion": 1, | |
| 5 | "requires": true, |
|
5 | "requires": true, | |
| 6 | "dependencies": { |
|
6 | "dependencies": { | |
| 7 | "@types/node": { |
|
7 | "@types/node": { | |
| 8 | "version": "10.12.18", |
|
8 | "version": "10.12.18", | |
| 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", |
|
9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", | |
| 10 | "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==", |
|
10 | "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==", | |
| 11 | "dev": true |
|
11 | "dev": true | |
| 12 | }, |
|
12 | }, | |
| 13 | "@types/requirejs": { |
|
13 | "@types/requirejs": { | |
| 14 | "version": "2.1.31", |
|
14 | "version": "2.1.31", | |
| 15 | "resolved": "https://registry.npmjs.org/@types/requirejs/-/requirejs-2.1.31.tgz", |
|
15 | "resolved": "https://registry.npmjs.org/@types/requirejs/-/requirejs-2.1.31.tgz", | |
| 16 | "integrity": "sha512-b2soeyuU76rMbcRJ4e0hEl0tbMhFwZeTC0VZnfuWlfGlk6BwWNsev6kFu/twKABPX29wkX84wU2o+cEJoXsiTw==", |
|
16 | "integrity": "sha512-b2soeyuU76rMbcRJ4e0hEl0tbMhFwZeTC0VZnfuWlfGlk6BwWNsev6kFu/twKABPX29wkX84wU2o+cEJoXsiTw==", | |
| 17 | "dev": true |
|
17 | "dev": true | |
| 18 | }, |
|
18 | }, | |
| 19 | "@types/tape": { |
|
19 | "@types/tape": { | |
| 20 | "version": "4.2.33", |
|
20 | "version": "4.2.33", | |
| 21 | "resolved": "https://registry.npmjs.org/@types/tape/-/tape-4.2.33.tgz", |
|
21 | "resolved": "https://registry.npmjs.org/@types/tape/-/tape-4.2.33.tgz", | |
| 22 | "integrity": "sha512-ltfyuY5BIkYlGuQfwqzTDT8f0q8Z5DGppvUnWGs39oqDmMd6/UWhNpX3ZMh/VYvfxs3rFGHMrLC/eGRdLiDGuw==", |
|
22 | "integrity": "sha512-ltfyuY5BIkYlGuQfwqzTDT8f0q8Z5DGppvUnWGs39oqDmMd6/UWhNpX3ZMh/VYvfxs3rFGHMrLC/eGRdLiDGuw==", | |
| 23 | "dev": true, |
|
23 | "dev": true, | |
| 24 | "requires": { |
|
24 | "requires": { | |
| 25 | "@types/node": "*" |
|
25 | "@types/node": "*" | |
| 26 | } |
|
26 | } | |
| 27 | }, |
|
27 | }, | |
| 28 | "balanced-match": { |
|
28 | "balanced-match": { | |
| 29 | "version": "1.0.0", |
|
29 | "version": "1.0.0", | |
| 30 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", |
|
30 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", | |
| 31 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", |
|
31 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", | |
| 32 | "dev": true |
|
32 | "dev": true | |
| 33 | }, |
|
33 | }, | |
| 34 | "brace-expansion": { |
|
34 | "brace-expansion": { | |
| 35 | "version": "1.1.11", |
|
35 | "version": "1.1.11", | |
| 36 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", |
|
36 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", | |
| 37 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", |
|
37 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", | |
| 38 | "dev": true, |
|
38 | "dev": true, | |
| 39 | "requires": { |
|
39 | "requires": { | |
| 40 | "balanced-match": "^1.0.0", |
|
40 | "balanced-match": "^1.0.0", | |
| 41 | "concat-map": "0.0.1" |
|
41 | "concat-map": "0.0.1" | |
| 42 | } |
|
42 | } | |
| 43 | }, |
|
43 | }, | |
| 44 | "concat-map": { |
|
44 | "concat-map": { | |
| 45 | "version": "0.0.1", |
|
45 | "version": "0.0.1", | |
| 46 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", |
|
46 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", | |
| 47 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", |
|
47 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", | |
| 48 | "dev": true |
|
48 | "dev": true | |
| 49 | }, |
|
49 | }, | |
| 50 | "core-util-is": { |
|
50 | "core-util-is": { | |
| 51 | "version": "1.0.2", |
|
51 | "version": "1.0.2", | |
| 52 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", |
|
52 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", | |
| 53 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", |
|
53 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", | |
| 54 | "dev": true |
|
54 | "dev": true | |
| 55 | }, |
|
55 | }, | |
| 56 | "deep-equal": { |
|
56 | "deep-equal": { | |
| 57 | "version": "0.1.2", |
|
57 | "version": "0.1.2", | |
| 58 | "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.1.2.tgz", |
|
58 | "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.1.2.tgz", | |
| 59 | "integrity": "sha1-skbCuApXCkfBG+HZvRBw7IeLh84=", |
|
59 | "integrity": "sha1-skbCuApXCkfBG+HZvRBw7IeLh84=", | |
| 60 | "dev": true |
|
60 | "dev": true | |
| 61 | }, |
|
61 | }, | |
| 62 | "define-properties": { |
|
62 | "define-properties": { | |
| 63 | "version": "1.1.3", |
|
63 | "version": "1.1.3", | |
| 64 | "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", |
|
64 | "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", | |
| 65 | "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", |
|
65 | "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", | |
| 66 | "dev": true, |
|
66 | "dev": true, | |
| 67 | "requires": { |
|
67 | "requires": { | |
| 68 | "object-keys": "^1.0.12" |
|
68 | "object-keys": "^1.0.12" | |
| 69 | }, |
|
69 | }, | |
| 70 | "dependencies": { |
|
70 | "dependencies": { | |
| 71 | "object-keys": { |
|
71 | "object-keys": { | |
| 72 | "version": "1.0.12", |
|
72 | "version": "1.0.12", | |
| 73 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", |
|
73 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", | |
| 74 | "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", |
|
74 | "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", | |
| 75 | "dev": true |
|
75 | "dev": true | |
| 76 | } |
|
76 | } | |
| 77 | } |
|
77 | } | |
| 78 | }, |
|
78 | }, | |
| 79 | "defined": { |
|
79 | "defined": { | |
| 80 | "version": "0.0.0", |
|
80 | "version": "0.0.0", | |
| 81 | "resolved": "https://registry.npmjs.org/defined/-/defined-0.0.0.tgz", |
|
81 | "resolved": "https://registry.npmjs.org/defined/-/defined-0.0.0.tgz", | |
| 82 | "integrity": "sha1-817qfXBekzuvE7LwOz+D2SFAOz4=", |
|
82 | "integrity": "sha1-817qfXBekzuvE7LwOz+D2SFAOz4=", | |
| 83 | "dev": true |
|
83 | "dev": true | |
| 84 | }, |
|
84 | }, | |
| 85 | "dojo": { |
|
85 | "dojo": { | |
| 86 | "version": "1.14.2", |
|
86 | "version": "1.14.2", | |
| 87 | "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.14.2.tgz", |
|
87 | "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.14.2.tgz", | |
| 88 | "integrity": "sha512-TI+Ytgfh/VfmHWERp45Jte6NFMdoJTPsvUP/uzJUvAXET8FP2h442LePWWJ/q/xZ4V0V8OtdJhx8It/GB+Zbxg==", |
|
88 | "integrity": "sha512-TI+Ytgfh/VfmHWERp45Jte6NFMdoJTPsvUP/uzJUvAXET8FP2h442LePWWJ/q/xZ4V0V8OtdJhx8It/GB+Zbxg==", | |
| 89 | "dev": true |
|
89 | "dev": true | |
| 90 | }, |
|
90 | }, | |
| 91 | "duplexer": { |
|
91 | "duplexer": { | |
| 92 | "version": "0.1.1", |
|
92 | "version": "0.1.1", | |
| 93 | "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", |
|
93 | "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", | |
| 94 | "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", |
|
94 | "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", | |
| 95 | "dev": true |
|
95 | "dev": true | |
| 96 | }, |
|
96 | }, | |
| 97 | "es-abstract": { |
|
97 | "es-abstract": { | |
| 98 | "version": "1.13.0", |
|
98 | "version": "1.13.0", | |
| 99 | "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", |
|
99 | "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", | |
| 100 | "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", |
|
100 | "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", | |
| 101 | "dev": true, |
|
101 | "dev": true, | |
| 102 | "requires": { |
|
102 | "requires": { | |
| 103 | "es-to-primitive": "^1.2.0", |
|
103 | "es-to-primitive": "^1.2.0", | |
| 104 | "function-bind": "^1.1.1", |
|
104 | "function-bind": "^1.1.1", | |
| 105 | "has": "^1.0.3", |
|
105 | "has": "^1.0.3", | |
| 106 | "is-callable": "^1.1.4", |
|
106 | "is-callable": "^1.1.4", | |
| 107 | "is-regex": "^1.0.4", |
|
107 | "is-regex": "^1.0.4", | |
| 108 | "object-keys": "^1.0.12" |
|
108 | "object-keys": "^1.0.12" | |
| 109 | }, |
|
109 | }, | |
| 110 | "dependencies": { |
|
110 | "dependencies": { | |
| 111 | "object-keys": { |
|
111 | "object-keys": { | |
| 112 | "version": "1.0.12", |
|
112 | "version": "1.0.12", | |
| 113 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", |
|
113 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", | |
| 114 | "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", |
|
114 | "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", | |
| 115 | "dev": true |
|
115 | "dev": true | |
| 116 | } |
|
116 | } | |
| 117 | } |
|
117 | } | |
| 118 | }, |
|
118 | }, | |
| 119 | "es-to-primitive": { |
|
119 | "es-to-primitive": { | |
| 120 | "version": "1.2.0", |
|
120 | "version": "1.2.0", | |
| 121 | "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", |
|
121 | "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", | |
| 122 | "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", |
|
122 | "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", | |
| 123 | "dev": true, |
|
123 | "dev": true, | |
| 124 | "requires": { |
|
124 | "requires": { | |
| 125 | "is-callable": "^1.1.4", |
|
125 | "is-callable": "^1.1.4", | |
| 126 | "is-date-object": "^1.0.1", |
|
126 | "is-date-object": "^1.0.1", | |
| 127 | "is-symbol": "^1.0.2" |
|
127 | "is-symbol": "^1.0.2" | |
| 128 | } |
|
128 | } | |
| 129 | }, |
|
129 | }, | |
| 130 | "faucet": { |
|
130 | "faucet": { | |
| 131 | "version": "0.0.1", |
|
131 | "version": "0.0.1", | |
| 132 | "resolved": "https://registry.npmjs.org/faucet/-/faucet-0.0.1.tgz", |
|
132 | "resolved": "https://registry.npmjs.org/faucet/-/faucet-0.0.1.tgz", | |
| 133 | "integrity": "sha1-WX3PHSGJosBiMhtZHo8VHtIDnZw=", |
|
133 | "integrity": "sha1-WX3PHSGJosBiMhtZHo8VHtIDnZw=", | |
| 134 | "dev": true, |
|
134 | "dev": true, | |
| 135 | "requires": { |
|
135 | "requires": { | |
| 136 | "defined": "0.0.0", |
|
136 | "defined": "0.0.0", | |
| 137 | "duplexer": "~0.1.1", |
|
137 | "duplexer": "~0.1.1", | |
| 138 | "minimist": "0.0.5", |
|
138 | "minimist": "0.0.5", | |
| 139 | "sprintf": "~0.1.3", |
|
139 | "sprintf": "~0.1.3", | |
| 140 | "tap-parser": "~0.4.0", |
|
140 | "tap-parser": "~0.4.0", | |
| 141 | "tape": "~2.3.2", |
|
141 | "tape": "~2.3.2", | |
| 142 | "through2": "~0.2.3" |
|
142 | "through2": "~0.2.3" | |
| 143 | }, |
|
143 | }, | |
| 144 | "dependencies": { |
|
144 | "dependencies": { | |
| 145 | "tape": { |
|
145 | "tape": { | |
| 146 | "version": "2.3.3", |
|
146 | "version": "2.3.3", | |
| 147 | "resolved": "http://registry.npmjs.org/tape/-/tape-2.3.3.tgz", |
|
147 | "resolved": "https://registry.npmjs.org/tape/-/tape-2.3.3.tgz", | |
| 148 | "integrity": "sha1-Lnzgox3wn41oUWZKcYQuDKUFevc=", |
|
148 | "integrity": "sha1-Lnzgox3wn41oUWZKcYQuDKUFevc=", | |
| 149 | "dev": true, |
|
149 | "dev": true, | |
| 150 | "requires": { |
|
150 | "requires": { | |
| 151 | "deep-equal": "~0.1.0", |
|
151 | "deep-equal": "~0.1.0", | |
| 152 | "defined": "~0.0.0", |
|
152 | "defined": "~0.0.0", | |
| 153 | "inherits": "~2.0.1", |
|
153 | "inherits": "~2.0.1", | |
| 154 | "jsonify": "~0.0.0", |
|
154 | "jsonify": "~0.0.0", | |
| 155 | "resumer": "~0.0.0", |
|
155 | "resumer": "~0.0.0", | |
| 156 | "through": "~2.3.4" |
|
156 | "through": "~2.3.4" | |
| 157 | } |
|
157 | } | |
| 158 | } |
|
158 | } | |
| 159 | } |
|
159 | } | |
| 160 | }, |
|
160 | }, | |
| 161 | "for-each": { |
|
161 | "for-each": { | |
| 162 | "version": "0.3.3", |
|
162 | "version": "0.3.3", | |
| 163 | "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", |
|
163 | "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", | |
| 164 | "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", |
|
164 | "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", | |
| 165 | "dev": true, |
|
165 | "dev": true, | |
| 166 | "requires": { |
|
166 | "requires": { | |
| 167 | "is-callable": "^1.1.3" |
|
167 | "is-callable": "^1.1.3" | |
| 168 | } |
|
168 | } | |
| 169 | }, |
|
169 | }, | |
| 170 | "fs.realpath": { |
|
170 | "fs.realpath": { | |
| 171 | "version": "1.0.0", |
|
171 | "version": "1.0.0", | |
| 172 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", |
|
172 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", | |
| 173 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", |
|
173 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", | |
| 174 | "dev": true |
|
174 | "dev": true | |
| 175 | }, |
|
175 | }, | |
| 176 | "function-bind": { |
|
176 | "function-bind": { | |
| 177 | "version": "1.1.1", |
|
177 | "version": "1.1.1", | |
| 178 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", |
|
178 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", | |
| 179 | "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", |
|
179 | "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", | |
| 180 | "dev": true |
|
180 | "dev": true | |
| 181 | }, |
|
181 | }, | |
| 182 | "glob": { |
|
182 | "glob": { | |
| 183 | "version": "7.1.3", |
|
183 | "version": "7.1.3", | |
| 184 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", |
|
184 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", | |
| 185 | "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", |
|
185 | "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", | |
| 186 | "dev": true, |
|
186 | "dev": true, | |
| 187 | "requires": { |
|
187 | "requires": { | |
| 188 | "fs.realpath": "^1.0.0", |
|
188 | "fs.realpath": "^1.0.0", | |
| 189 | "inflight": "^1.0.4", |
|
189 | "inflight": "^1.0.4", | |
| 190 | "inherits": "2", |
|
190 | "inherits": "2", | |
| 191 | "minimatch": "^3.0.4", |
|
191 | "minimatch": "^3.0.4", | |
| 192 | "once": "^1.3.0", |
|
192 | "once": "^1.3.0", | |
| 193 | "path-is-absolute": "^1.0.0" |
|
193 | "path-is-absolute": "^1.0.0" | |
| 194 | } |
|
194 | } | |
| 195 | }, |
|
195 | }, | |
| 196 | "has": { |
|
196 | "has": { | |
| 197 | "version": "1.0.3", |
|
197 | "version": "1.0.3", | |
| 198 | "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", |
|
198 | "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", | |
| 199 | "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", |
|
199 | "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", | |
| 200 | "dev": true, |
|
200 | "dev": true, | |
| 201 | "requires": { |
|
201 | "requires": { | |
| 202 | "function-bind": "^1.1.1" |
|
202 | "function-bind": "^1.1.1" | |
| 203 | } |
|
203 | } | |
| 204 | }, |
|
204 | }, | |
| 205 | "has-symbols": { |
|
205 | "has-symbols": { | |
| 206 | "version": "1.0.0", |
|
206 | "version": "1.0.0", | |
| 207 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", |
|
207 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", | |
| 208 | "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", |
|
208 | "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", | |
| 209 | "dev": true |
|
209 | "dev": true | |
| 210 | }, |
|
210 | }, | |
| 211 | "inflight": { |
|
211 | "inflight": { | |
| 212 | "version": "1.0.6", |
|
212 | "version": "1.0.6", | |
| 213 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", |
|
213 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", | |
| 214 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", |
|
214 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", | |
| 215 | "dev": true, |
|
215 | "dev": true, | |
| 216 | "requires": { |
|
216 | "requires": { | |
| 217 | "once": "^1.3.0", |
|
217 | "once": "^1.3.0", | |
| 218 | "wrappy": "1" |
|
218 | "wrappy": "1" | |
| 219 | } |
|
219 | } | |
| 220 | }, |
|
220 | }, | |
| 221 | "inherits": { |
|
221 | "inherits": { | |
| 222 | "version": "2.0.3", |
|
222 | "version": "2.0.3", | |
| 223 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", |
|
223 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", | |
| 224 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", |
|
224 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", | |
| 225 | "dev": true |
|
225 | "dev": true | |
| 226 | }, |
|
226 | }, | |
| 227 | "is-callable": { |
|
227 | "is-callable": { | |
| 228 | "version": "1.1.4", |
|
228 | "version": "1.1.4", | |
| 229 | "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", |
|
229 | "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", | |
| 230 | "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", |
|
230 | "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", | |
| 231 | "dev": true |
|
231 | "dev": true | |
| 232 | }, |
|
232 | }, | |
| 233 | "is-date-object": { |
|
233 | "is-date-object": { | |
| 234 | "version": "1.0.1", |
|
234 | "version": "1.0.1", | |
| 235 | "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", |
|
235 | "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", | |
| 236 | "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", |
|
236 | "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", | |
| 237 | "dev": true |
|
237 | "dev": true | |
| 238 | }, |
|
238 | }, | |
| 239 | "is-regex": { |
|
239 | "is-regex": { | |
| 240 | "version": "1.0.4", |
|
240 | "version": "1.0.4", | |
| 241 | "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", |
|
241 | "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", | |
| 242 | "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", |
|
242 | "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", | |
| 243 | "dev": true, |
|
243 | "dev": true, | |
| 244 | "requires": { |
|
244 | "requires": { | |
| 245 | "has": "^1.0.1" |
|
245 | "has": "^1.0.1" | |
| 246 | } |
|
246 | } | |
| 247 | }, |
|
247 | }, | |
| 248 | "is-symbol": { |
|
248 | "is-symbol": { | |
| 249 | "version": "1.0.2", |
|
249 | "version": "1.0.2", | |
| 250 | "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", |
|
250 | "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", | |
| 251 | "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", |
|
251 | "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", | |
| 252 | "dev": true, |
|
252 | "dev": true, | |
| 253 | "requires": { |
|
253 | "requires": { | |
| 254 | "has-symbols": "^1.0.0" |
|
254 | "has-symbols": "^1.0.0" | |
| 255 | } |
|
255 | } | |
| 256 | }, |
|
256 | }, | |
| 257 | "isarray": { |
|
257 | "isarray": { | |
| 258 | "version": "0.0.1", |
|
258 | "version": "0.0.1", | |
| 259 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", |
|
259 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", | |
| 260 | "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", |
|
260 | "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", | |
| 261 | "dev": true |
|
261 | "dev": true | |
| 262 | }, |
|
262 | }, | |
| 263 | "jsonify": { |
|
263 | "jsonify": { | |
| 264 | "version": "0.0.0", |
|
264 | "version": "0.0.0", | |
| 265 | "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", |
|
265 | "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", | |
| 266 | "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", |
|
266 | "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", | |
| 267 | "dev": true |
|
267 | "dev": true | |
| 268 | }, |
|
268 | }, | |
| 269 | "minimatch": { |
|
269 | "minimatch": { | |
| 270 | "version": "3.0.4", |
|
270 | "version": "3.0.4", | |
| 271 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", |
|
271 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", | |
| 272 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", |
|
272 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", | |
| 273 | "dev": true, |
|
273 | "dev": true, | |
| 274 | "requires": { |
|
274 | "requires": { | |
| 275 | "brace-expansion": "^1.1.7" |
|
275 | "brace-expansion": "^1.1.7" | |
| 276 | } |
|
276 | } | |
| 277 | }, |
|
277 | }, | |
| 278 | "minimist": { |
|
278 | "minimist": { | |
| 279 | "version": "0.0.5", |
|
279 | "version": "0.0.5", | |
| 280 | "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz", |
|
280 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz", | |
| 281 | "integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY=", |
|
281 | "integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY=", | |
| 282 | "dev": true |
|
282 | "dev": true | |
| 283 | }, |
|
283 | }, | |
| 284 | "object-inspect": { |
|
284 | "object-inspect": { | |
| 285 | "version": "1.6.0", |
|
285 | "version": "1.6.0", | |
| 286 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", |
|
286 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", | |
| 287 | "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", |
|
287 | "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", | |
| 288 | "dev": true |
|
288 | "dev": true | |
| 289 | }, |
|
289 | }, | |
| 290 | "object-keys": { |
|
290 | "object-keys": { | |
| 291 | "version": "0.4.0", |
|
291 | "version": "0.4.0", | |
| 292 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", |
|
292 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", | |
| 293 | "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", |
|
293 | "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", | |
| 294 | "dev": true |
|
294 | "dev": true | |
| 295 | }, |
|
295 | }, | |
| 296 | "once": { |
|
296 | "once": { | |
| 297 | "version": "1.4.0", |
|
297 | "version": "1.4.0", | |
| 298 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", |
|
298 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", | |
| 299 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", |
|
299 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", | |
| 300 | "dev": true, |
|
300 | "dev": true, | |
| 301 | "requires": { |
|
301 | "requires": { | |
| 302 | "wrappy": "1" |
|
302 | "wrappy": "1" | |
| 303 | } |
|
303 | } | |
| 304 | }, |
|
304 | }, | |
| 305 | "path-is-absolute": { |
|
305 | "path-is-absolute": { | |
| 306 | "version": "1.0.1", |
|
306 | "version": "1.0.1", | |
| 307 | "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", |
|
307 | "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", | |
| 308 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", |
|
308 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", | |
| 309 | "dev": true |
|
309 | "dev": true | |
| 310 | }, |
|
310 | }, | |
| 311 | "path-parse": { |
|
311 | "path-parse": { | |
| 312 | "version": "1.0.6", |
|
312 | "version": "1.0.6", | |
| 313 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", |
|
313 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", | |
| 314 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", |
|
314 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", | |
| 315 | "dev": true |
|
315 | "dev": true | |
| 316 | }, |
|
316 | }, | |
| 317 | "readable-stream": { |
|
317 | "readable-stream": { | |
| 318 | "version": "1.1.14", |
|
318 | "version": "1.1.14", | |
| 319 | "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", |
|
319 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", | |
| 320 | "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", |
|
320 | "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", | |
| 321 | "dev": true, |
|
321 | "dev": true, | |
| 322 | "requires": { |
|
322 | "requires": { | |
| 323 | "core-util-is": "~1.0.0", |
|
323 | "core-util-is": "~1.0.0", | |
| 324 | "inherits": "~2.0.1", |
|
324 | "inherits": "~2.0.1", | |
| 325 | "isarray": "0.0.1", |
|
325 | "isarray": "0.0.1", | |
| 326 | "string_decoder": "~0.10.x" |
|
326 | "string_decoder": "~0.10.x" | |
| 327 | } |
|
327 | } | |
| 328 | }, |
|
328 | }, | |
| 329 | "requirejs": { |
|
329 | "requirejs": { | |
| 330 | "version": "2.3.6", |
|
330 | "version": "2.3.6", | |
| 331 | "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", |
|
331 | "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", | |
| 332 | "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", |
|
332 | "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", | |
| 333 | "dev": true |
|
333 | "dev": true | |
| 334 | }, |
|
334 | }, | |
| 335 | "resolve": { |
|
335 | "resolve": { | |
| 336 | "version": "1.7.1", |
|
336 | "version": "1.7.1", | |
| 337 | "resolved": "http://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", |
|
337 | "resolved": "http://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", | |
| 338 | "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", |
|
338 | "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", | |
| 339 | "dev": true, |
|
339 | "dev": true, | |
| 340 | "requires": { |
|
340 | "requires": { | |
| 341 | "path-parse": "^1.0.5" |
|
341 | "path-parse": "^1.0.5" | |
| 342 | } |
|
342 | } | |
| 343 | }, |
|
343 | }, | |
| 344 | "resumer": { |
|
344 | "resumer": { | |
| 345 | "version": "0.0.0", |
|
345 | "version": "0.0.0", | |
| 346 | "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", |
|
346 | "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", | |
| 347 | "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", |
|
347 | "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", | |
| 348 | "dev": true, |
|
348 | "dev": true, | |
| 349 | "requires": { |
|
349 | "requires": { | |
| 350 | "through": "~2.3.4" |
|
350 | "through": "~2.3.4" | |
| 351 | } |
|
351 | } | |
| 352 | }, |
|
352 | }, | |
| 353 | "sprintf": { |
|
353 | "sprintf": { | |
| 354 | "version": "0.1.5", |
|
354 | "version": "0.1.5", | |
| 355 | "resolved": "https://registry.npmjs.org/sprintf/-/sprintf-0.1.5.tgz", |
|
355 | "resolved": "https://registry.npmjs.org/sprintf/-/sprintf-0.1.5.tgz", | |
| 356 | "integrity": "sha1-j4PjmpMXwaUCy324BQ5Rxnn27c8=", |
|
356 | "integrity": "sha1-j4PjmpMXwaUCy324BQ5Rxnn27c8=", | |
| 357 | "dev": true |
|
357 | "dev": true | |
| 358 | }, |
|
358 | }, | |
| 359 | "string.prototype.trim": { |
|
359 | "string.prototype.trim": { | |
| 360 | "version": "1.1.2", |
|
360 | "version": "1.1.2", | |
| 361 | "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", |
|
361 | "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", | |
| 362 | "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", |
|
362 | "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", | |
| 363 | "dev": true, |
|
363 | "dev": true, | |
| 364 | "requires": { |
|
364 | "requires": { | |
| 365 | "define-properties": "^1.1.2", |
|
365 | "define-properties": "^1.1.2", | |
| 366 | "es-abstract": "^1.5.0", |
|
366 | "es-abstract": "^1.5.0", | |
| 367 | "function-bind": "^1.0.2" |
|
367 | "function-bind": "^1.0.2" | |
| 368 | } |
|
368 | } | |
| 369 | }, |
|
369 | }, | |
| 370 | "string_decoder": { |
|
370 | "string_decoder": { | |
| 371 | "version": "0.10.31", |
|
371 | "version": "0.10.31", | |
| 372 | "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", |
|
372 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", | |
| 373 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", |
|
373 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", | |
| 374 | "dev": true |
|
374 | "dev": true | |
| 375 | }, |
|
375 | }, | |
| 376 | "tap-parser": { |
|
376 | "tap-parser": { | |
| 377 | "version": "0.4.3", |
|
377 | "version": "0.4.3", | |
| 378 | "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-0.4.3.tgz", |
|
378 | "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-0.4.3.tgz", | |
| 379 | "integrity": "sha1-pOrhkMENdsehEZIf84u+TVjwnuo=", |
|
379 | "integrity": "sha1-pOrhkMENdsehEZIf84u+TVjwnuo=", | |
| 380 | "dev": true, |
|
380 | "dev": true, | |
| 381 | "requires": { |
|
381 | "requires": { | |
| 382 | "inherits": "~2.0.1", |
|
382 | "inherits": "~2.0.1", | |
| 383 | "readable-stream": "~1.1.11" |
|
383 | "readable-stream": "~1.1.11" | |
| 384 | } |
|
384 | } | |
| 385 | }, |
|
385 | }, | |
| 386 | "tape": { |
|
386 | "tape": { | |
| 387 | "version": "4.9.2", |
|
387 | "version": "4.9.2", | |
| 388 | "resolved": "https://registry.npmjs.org/tape/-/tape-4.9.2.tgz", |
|
388 | "resolved": "https://registry.npmjs.org/tape/-/tape-4.9.2.tgz", | |
| 389 | "integrity": "sha512-lPXKRKILZ1kZaUy5ynWKs8ATGSUO7HAFHCFnBam6FaGSqPdOwMWbxXHq4EXFLE8WRTleo/YOMXkaUTRmTB1Fiw==", |
|
389 | "integrity": "sha512-lPXKRKILZ1kZaUy5ynWKs8ATGSUO7HAFHCFnBam6FaGSqPdOwMWbxXHq4EXFLE8WRTleo/YOMXkaUTRmTB1Fiw==", | |
| 390 | "dev": true, |
|
390 | "dev": true, | |
| 391 | "requires": { |
|
391 | "requires": { | |
| 392 | "deep-equal": "~1.0.1", |
|
392 | "deep-equal": "~1.0.1", | |
| 393 | "defined": "~1.0.0", |
|
393 | "defined": "~1.0.0", | |
| 394 | "for-each": "~0.3.3", |
|
394 | "for-each": "~0.3.3", | |
| 395 | "function-bind": "~1.1.1", |
|
395 | "function-bind": "~1.1.1", | |
| 396 | "glob": "~7.1.2", |
|
396 | "glob": "~7.1.2", | |
| 397 | "has": "~1.0.3", |
|
397 | "has": "~1.0.3", | |
| 398 | "inherits": "~2.0.3", |
|
398 | "inherits": "~2.0.3", | |
| 399 | "minimist": "~1.2.0", |
|
399 | "minimist": "~1.2.0", | |
| 400 | "object-inspect": "~1.6.0", |
|
400 | "object-inspect": "~1.6.0", | |
| 401 | "resolve": "~1.7.1", |
|
401 | "resolve": "~1.7.1", | |
| 402 | "resumer": "~0.0.0", |
|
402 | "resumer": "~0.0.0", | |
| 403 | "string.prototype.trim": "~1.1.2", |
|
403 | "string.prototype.trim": "~1.1.2", | |
| 404 | "through": "~2.3.8" |
|
404 | "through": "~2.3.8" | |
| 405 | }, |
|
405 | }, | |
| 406 | "dependencies": { |
|
406 | "dependencies": { | |
| 407 | "deep-equal": { |
|
407 | "deep-equal": { | |
| 408 | "version": "1.0.1", |
|
408 | "version": "1.0.1", | |
| 409 | "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", |
|
409 | "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", | |
| 410 | "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", |
|
410 | "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", | |
| 411 | "dev": true |
|
411 | "dev": true | |
| 412 | }, |
|
412 | }, | |
| 413 | "defined": { |
|
413 | "defined": { | |
| 414 | "version": "1.0.0", |
|
414 | "version": "1.0.0", | |
| 415 | "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", |
|
415 | "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", | |
| 416 | "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", |
|
416 | "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", | |
| 417 | "dev": true |
|
417 | "dev": true | |
| 418 | }, |
|
418 | }, | |
| 419 | "minimist": { |
|
419 | "minimist": { | |
| 420 | "version": "1.2.0", |
|
420 | "version": "1.2.0", | |
| 421 | "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", |
|
421 | "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", | |
| 422 | "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", |
|
422 | "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", | |
| 423 | "dev": true |
|
423 | "dev": true | |
| 424 | } |
|
424 | } | |
| 425 | } |
|
425 | } | |
| 426 | }, |
|
426 | }, | |
| 427 | "through": { |
|
427 | "through": { | |
| 428 | "version": "2.3.8", |
|
428 | "version": "2.3.8", | |
| 429 | "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", |
|
429 | "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", | |
| 430 | "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", |
|
430 | "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", | |
| 431 | "dev": true |
|
431 | "dev": true | |
| 432 | }, |
|
432 | }, | |
| 433 | "through2": { |
|
433 | "through2": { | |
| 434 | "version": "0.2.3", |
|
434 | "version": "0.2.3", | |
| 435 | "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz", |
|
435 | "resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz", | |
| 436 | "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", |
|
436 | "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", | |
| 437 | "dev": true, |
|
437 | "dev": true, | |
| 438 | "requires": { |
|
438 | "requires": { | |
| 439 | "readable-stream": "~1.1.9", |
|
439 | "readable-stream": "~1.1.9", | |
| 440 | "xtend": "~2.1.1" |
|
440 | "xtend": "~2.1.1" | |
| 441 | } |
|
441 | } | |
| 442 | }, |
|
442 | }, | |
| 443 | "tslib": { |
|
443 | "tslib": { | |
| 444 | "version": "1.9.3", |
|
444 | "version": "1.9.3", | |
| 445 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", |
|
445 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", | |
| 446 | "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", |
|
446 | "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", | |
| 447 | "dev": true |
|
447 | "dev": true | |
| 448 | }, |
|
448 | }, | |
| 449 | "typescript": { |
|
449 | "typescript": { | |
| 450 | "version": "3.2.2", |
|
450 | "version": "3.2.2", | |
| 451 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz", |
|
451 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz", | |
| 452 | "integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==", |
|
452 | "integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==", | |
| 453 | "dev": true |
|
453 | "dev": true | |
| 454 | }, |
|
454 | }, | |
| 455 | "wrappy": { |
|
455 | "wrappy": { | |
| 456 | "version": "1.0.2", |
|
456 | "version": "1.0.2", | |
| 457 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", |
|
457 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", | |
| 458 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", |
|
458 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", | |
| 459 | "dev": true |
|
459 | "dev": true | |
| 460 | }, |
|
460 | }, | |
| 461 | "xtend": { |
|
461 | "xtend": { | |
| 462 | "version": "2.1.2", |
|
462 | "version": "2.1.2", | |
| 463 | "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", |
|
463 | "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", | |
| 464 | "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", |
|
464 | "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", | |
| 465 | "dev": true, |
|
465 | "dev": true, | |
| 466 | "requires": { |
|
466 | "requires": { | |
| 467 | "object-keys": "~0.4.0" |
|
467 | "object-keys": "~0.4.0" | |
| 468 | } |
|
468 | } | |
| 469 | } |
|
469 | } | |
| 470 | } |
|
470 | } | |
| 471 | } |
|
471 | } | |
| @@ -1,74 +1,41 | |||||
| 1 | import { Uuid } from "../Uuid"; |
|
1 | import { Uuid } from "../Uuid"; | |
| 2 | import { argumentNotEmptyString, getGlobal, isNullOrEmptyString } from "../safe"; |
|
2 | import { argumentNotEmptyString, getGlobal, isNullOrEmptyString } from "../safe"; | |
| 3 |
import { TraceSource |
|
3 | import { TraceSource } from "../log/TraceSource"; | |
| 4 | import m = require("module"); |
|
4 | import m = require("module"); | |
| 5 |
|
5 | |||
| 6 | const sandboxId = Uuid(); |
|
6 | const sandboxId = Uuid(); | |
| 7 | define(sandboxId, ["require"], r => r); |
|
7 | define(sandboxId, ["require"], r => r); | |
| 8 |
|
8 | |||
| 9 | // tslint:disable-next-line:no-var-requires |
|
9 | // tslint:disable-next-line:no-var-requires | |
| 10 | const globalRequire = getGlobal().require as Require; |
|
10 | const globalRequire = getGlobal().require as Require; | |
| 11 |
|
11 | |||
| 12 | const trace = TraceSource.get(m.id); |
|
12 | const trace = TraceSource.get(m.id); | |
| 13 |
|
13 | |||
| 14 | export async function createContextRequire(moduleName: string): Promise<Require> { |
|
|||
| 15 | argumentNotEmptyString(moduleName, "moduleName"); |
|
|||
| 16 |
|
||||
| 17 | const parts = moduleName.split("/"); |
|
|||
| 18 | if (parts[0] === ".") |
|
|||
| 19 | throw new Error("An absolute module path is required"); |
|
|||
| 20 |
|
||||
| 21 | if (parts.length > 1) |
|
|||
| 22 | parts.splice(-1, 1, Uuid()); |
|
|||
| 23 | else |
|
|||
| 24 | parts.push(Uuid()); |
|
|||
| 25 |
|
||||
| 26 | const shim = parts.join("/"); |
|
|||
| 27 |
|
||||
| 28 | trace.debug(`define shim ${shim}`); |
|
|||
| 29 |
|
||||
| 30 | return new Promise<Require>(cb => { |
|
|||
| 31 | define(shim, ["require"], r => { |
|
|||
| 32 | trace.debug("shim resolved"); |
|
|||
| 33 | return r; |
|
|||
| 34 | }); |
|
|||
| 35 | require([shim], cb); |
|
|||
| 36 | }); |
|
|||
| 37 | } |
|
|||
| 38 |
|
||||
| 39 | class ModuleResolver { |
|
14 | class ModuleResolver { | |
| 40 | _base: string; |
|
15 | _base: string; | |
| 41 | _require: Require; |
|
16 | _require: Require; | |
| 42 |
|
17 | |||
| 43 | constructor(req: Require, base?: string) { |
|
18 | constructor(req: Require, base?: string) { | |
| 44 | this._base = base; |
|
19 | this._base = base; | |
| 45 |
this._require = req |
|
20 | this._require = req; | |
| 46 | } |
|
21 | } | |
| 47 |
|
22 | |||
| 48 | resolve(moduleName: string) { |
|
23 | resolve(moduleName: string) { | |
| 49 | argumentNotEmptyString(moduleName, "moduleName"); |
|
24 | argumentNotEmptyString(moduleName, "moduleName"); | |
| 50 | const resolvedName = moduleName[0] === "." && this._base ? [this._base, moduleName].join("/") : moduleName; |
|
25 | const resolvedName = moduleName[0] === "." && this._base ? [this._base, moduleName].join("/") : moduleName; | |
| 51 | trace.debug(`${moduleName} -> ${resolvedName}`); |
|
26 | trace.debug(`${moduleName} -> ${resolvedName}`); | |
| 52 |
|
27 | |||
| 53 | const req = this._require; |
|
28 | const req = this._require; | |
| 54 |
|
29 | |||
| 55 | return new Promise<any>((cb, eb) => { |
|
30 | return new Promise<any>((cb, eb) => { | |
| 56 | req([resolvedName], cb, eb); |
|
31 | req([resolvedName], cb, eb); | |
| 57 | }); |
|
32 | }); | |
| 58 | } |
|
33 | } | |
| 59 | } |
|
34 | } | |
| 60 |
|
35 | |||
| 61 |
export |
|
36 | export function makeResolver(moduleName: string, contextRequire: Require) { | |
| 62 | trace.debug( |
|
37 | const base = moduleName && moduleName.split("/").slice(0, -1).join("/"); | |
| 63 | "makeResolver moduleName={0}, contextRequire={1}", |
|
|||
| 64 | moduleName || "<nil>", |
|
|||
| 65 | contextRequire ? typeof (contextRequire) : "<nil>" |
|
|||
| 66 | ); |
|
|||
| 67 |
|
38 | |||
| 68 | const nestedRequire = isNullOrEmptyString(moduleName) ? null : await createContextRequire(moduleName); |
|
39 | const resolver = new ModuleResolver(contextRequire, base); | |
| 69 |
|
||||
| 70 | // const base = moduleName && moduleName.split("/").slice(0, -1).join("/"); |
|
|||
| 71 |
|
||||
| 72 | const resolver = new ModuleResolver(nestedRequire, null); |
|
|||
| 73 | return (id: string) => resolver.resolve(id); |
|
40 | return (id: string) => resolver.resolve(id); | |
| 74 | } |
|
41 | } | |
| @@ -1,348 +1,348 | |||||
| 1 | import { |
|
1 | import { | |
| 2 | ServiceRegistration, |
|
2 | ServiceRegistration, | |
| 3 | TypeRegistration, |
|
3 | TypeRegistration, | |
| 4 | FactoryRegistration, |
|
4 | FactoryRegistration, | |
| 5 | ServiceMap, |
|
5 | ServiceMap, | |
| 6 | isDescriptor, |
|
6 | isDescriptor, | |
| 7 | isDependencyRegistration, |
|
7 | isDependencyRegistration, | |
| 8 | DependencyRegistration, |
|
8 | DependencyRegistration, | |
| 9 | ValueRegistration, |
|
9 | ValueRegistration, | |
| 10 | ActivationType, |
|
10 | ActivationType, | |
| 11 | isValueRegistration, |
|
11 | isValueRegistration, | |
| 12 | isTypeRegistration, |
|
12 | isTypeRegistration, | |
| 13 | isFactoryRegistration |
|
13 | isFactoryRegistration | |
| 14 | } from "./interfaces"; |
|
14 | } from "./interfaces"; | |
| 15 |
|
15 | |||
| 16 | import { argumentNotEmptyString, isPrimitive, isPromise, delegate, argumentOfType, argumentNotNull, get } from "../safe"; |
|
16 | import { argumentNotEmptyString, isPrimitive, isPromise, delegate, argumentOfType, argumentNotNull, get } from "../safe"; | |
| 17 | import { AggregateDescriptor } from "./AggregateDescriptor"; |
|
17 | import { AggregateDescriptor } from "./AggregateDescriptor"; | |
| 18 | import { ValueDescriptor } from "./ValueDescriptor"; |
|
18 | import { ValueDescriptor } from "./ValueDescriptor"; | |
| 19 | import { Container } from "./Container"; |
|
19 | import { Container } from "./Container"; | |
| 20 | import { ReferenceDescriptor } from "./ReferenceDescriptor"; |
|
20 | import { ReferenceDescriptor } from "./ReferenceDescriptor"; | |
| 21 | import { TypeServiceDescriptor } from "./TypeServiceDescriptor"; |
|
21 | import { TypeServiceDescriptor } from "./TypeServiceDescriptor"; | |
| 22 | import { FactoryServiceDescriptor } from "./FactoryServiceDescriptor"; |
|
22 | import { FactoryServiceDescriptor } from "./FactoryServiceDescriptor"; | |
| 23 | import { TraceSource } from "../log/TraceSource"; |
|
23 | import { TraceSource } from "../log/TraceSource"; | |
| 24 | import { ConfigError } from "./ConfigError"; |
|
24 | import { ConfigError } from "./ConfigError"; | |
| 25 | import { Cancellation } from "../Cancellation"; |
|
25 | import { Cancellation } from "../Cancellation"; | |
| 26 | import { makeResolver } from "./ResolverHelper"; |
|
26 | import { makeResolver } from "./ResolverHelper"; | |
| 27 | import { ICancellation } from "../interfaces"; |
|
27 | import { ICancellation } from "../interfaces"; | |
| 28 |
|
28 | |||
| 29 | const trace = TraceSource.get("@implab/core/di/Configuration"); |
|
29 | const trace = TraceSource.get("@implab/core/di/Configuration"); | |
| 30 |
|
30 | |||
| 31 | async function mapAll(data: object | any[], map?: (v, k) => any): Promise<any> { |
|
31 | async function mapAll(data: object | any[], map?: (v, k) => any): Promise<any> { | |
| 32 | if (data instanceof Array) { |
|
32 | if (data instanceof Array) { | |
| 33 | return Promise.all(map ? data.map(map) : data); |
|
33 | return Promise.all(map ? data.map(map) : data); | |
| 34 | } else { |
|
34 | } else { | |
| 35 | const keys = Object.keys(data); |
|
35 | const keys = Object.keys(data); | |
| 36 |
|
36 | |||
| 37 | const o: any = {}; |
|
37 | const o: any = {}; | |
| 38 |
|
38 | |||
| 39 | await Promise.all(keys.map(async k => { |
|
39 | await Promise.all(keys.map(async k => { | |
| 40 | const v = map ? map(data[k], k) : data[k]; |
|
40 | const v = map ? map(data[k], k) : data[k]; | |
| 41 | o[k] = isPromise(v) ? await v : v; |
|
41 | o[k] = isPromise(v) ? await v : v; | |
| 42 | })); |
|
42 | })); | |
| 43 |
|
43 | |||
| 44 | return o; |
|
44 | return o; | |
| 45 | } |
|
45 | } | |
| 46 | } |
|
46 | } | |
| 47 |
|
47 | |||
| 48 | export type ModuleResolver = (moduleName: string, ct?: ICancellation) => any; |
|
48 | export type ModuleResolver = (moduleName: string, ct?: ICancellation) => any; | |
| 49 |
|
49 | |||
| 50 | type _key = string | number; |
|
50 | type _key = string | number; | |
| 51 |
|
51 | |||
| 52 | export class Configuration { |
|
52 | export class Configuration { | |
| 53 |
|
53 | |||
| 54 | _hasInnerDescriptors = false; |
|
54 | _hasInnerDescriptors = false; | |
| 55 |
|
55 | |||
| 56 | _container: Container; |
|
56 | _container: Container; | |
| 57 |
|
57 | |||
| 58 | _path: Array<_key>; |
|
58 | _path: Array<_key>; | |
| 59 |
|
59 | |||
| 60 | _configName: string; |
|
60 | _configName: string; | |
| 61 |
|
61 | |||
| 62 | _require: ModuleResolver; |
|
62 | _require: ModuleResolver; | |
| 63 |
|
63 | |||
| 64 | constructor(container: Container) { |
|
64 | constructor(container: Container) { | |
| 65 | argumentNotNull(container, container); |
|
65 | argumentNotNull(container, container); | |
| 66 | this._container = container; |
|
66 | this._container = container; | |
| 67 | this._path = []; |
|
67 | this._path = []; | |
| 68 | } |
|
68 | } | |
| 69 |
|
69 | |||
| 70 | async loadConfiguration(moduleName: string, contextRequire?: any, ct = Cancellation.none) { |
|
70 | async loadConfiguration(moduleName: string, contextRequire?: any, ct = Cancellation.none) { | |
| 71 | argumentNotEmptyString(moduleName, "moduleName"); |
|
71 | argumentNotEmptyString(moduleName, "moduleName"); | |
| 72 |
|
72 | |||
| 73 | trace.log( |
|
73 | trace.log( | |
| 74 | "loadConfiguration moduleName={0}, contextRequire={1}", |
|
74 | "loadConfiguration moduleName={0}, contextRequire={1}", | |
| 75 | moduleName, |
|
75 | moduleName, | |
| 76 | contextRequire ? typeof (contextRequire) : "<nil>" |
|
76 | contextRequire ? typeof (contextRequire) : "<nil>" | |
| 77 | ); |
|
77 | ); | |
| 78 |
|
78 | |||
| 79 | this._configName = moduleName; |
|
79 | this._configName = moduleName; | |
| 80 |
|
80 | |||
| 81 | const r = await makeResolver(null, contextRequire); |
|
81 | const r = await makeResolver(null, contextRequire); | |
| 82 |
|
82 | |||
| 83 | const config = await r(moduleName, ct); |
|
83 | const config = await r(moduleName, ct); | |
| 84 |
|
84 | |||
| 85 | await this._applyConfiguration( |
|
85 | await this._applyConfiguration( | |
| 86 | config, |
|
86 | config, | |
| 87 | await makeResolver(moduleName, contextRequire), |
|
87 | await makeResolver(moduleName, contextRequire), | |
| 88 | ct |
|
88 | ct | |
| 89 | ); |
|
89 | ); | |
| 90 | } |
|
90 | } | |
| 91 |
|
91 | |||
| 92 | async applyConfiguration(data: object, contextRequire?: any, ct = Cancellation.none) { |
|
92 | async applyConfiguration(data: object, contextRequire?: any, ct = Cancellation.none) { | |
| 93 | argumentNotNull(data, "data"); |
|
93 | argumentNotNull(data, "data"); | |
| 94 |
|
94 | |||
| 95 | await this._applyConfiguration(data, await makeResolver(void (0), contextRequire), ct); |
|
95 | await this._applyConfiguration(data, await makeResolver(void (0), contextRequire), ct); | |
| 96 | } |
|
96 | } | |
| 97 |
|
97 | |||
| 98 | async _applyConfiguration(data: object, resolver?: ModuleResolver, ct = Cancellation.none) { |
|
98 | async _applyConfiguration(data: object, resolver?: ModuleResolver, ct = Cancellation.none) { | |
| 99 | trace.log("applyConfiguration"); |
|
99 | trace.log("applyConfiguration"); | |
| 100 |
|
100 | |||
| 101 | this._configName = "$"; |
|
101 | this._configName = "$"; | |
| 102 |
|
102 | |||
| 103 | if (resolver) |
|
103 | if (resolver) | |
| 104 | this._require = resolver; |
|
104 | this._require = resolver; | |
| 105 |
|
105 | |||
| 106 | let services: ServiceMap; |
|
106 | let services: ServiceMap; | |
| 107 |
|
107 | |||
| 108 | try { |
|
108 | try { | |
| 109 | services = await this._visitRegistrations(data, "$"); |
|
109 | services = await this._visitRegistrations(data, "$"); | |
| 110 | } catch (e) { |
|
110 | } catch (e) { | |
| 111 | throw this._makeError(e); |
|
111 | throw this._makeError(e); | |
| 112 | } |
|
112 | } | |
| 113 |
|
113 | |||
| 114 | this._container.register(services); |
|
114 | this._container.register(services); | |
| 115 | } |
|
115 | } | |
| 116 |
|
116 | |||
| 117 | _makeError(inner) { |
|
117 | _makeError(inner) { | |
| 118 | const e = new ConfigError("Failed to load configuration", inner); |
|
118 | const e = new ConfigError("Failed to load configuration", inner); | |
| 119 | e.configName = this._configName; |
|
119 | e.configName = this._configName; | |
| 120 | e.path = this._makePath(); |
|
120 | e.path = this._makePath(); | |
| 121 | return e; |
|
121 | return e; | |
| 122 | } |
|
122 | } | |
| 123 |
|
123 | |||
| 124 | _makePath() { |
|
124 | _makePath() { | |
| 125 | return this._path |
|
125 | return this._path | |
| 126 | .reduce( |
|
126 | .reduce( | |
| 127 | (prev, cur) => typeof cur === "number" ? |
|
127 | (prev, cur) => typeof cur === "number" ? | |
| 128 | `${prev}[${cur}]` : |
|
128 | `${prev}[${cur}]` : | |
| 129 | `${prev}.${cur}` |
|
129 | `${prev}.${cur}` | |
| 130 | ) |
|
130 | ) | |
| 131 | .toString(); |
|
131 | .toString(); | |
| 132 | } |
|
132 | } | |
| 133 |
|
133 | |||
| 134 | async _resolveType(moduleName: string, localName: string) { |
|
134 | async _resolveType(moduleName: string, localName: string) { | |
| 135 | trace.log("resolveType moduleName={0}, localName={1}", moduleName, localName); |
|
135 | trace.log("resolveType moduleName={0}, localName={1}", moduleName, localName); | |
| 136 | try { |
|
136 | try { | |
| 137 | const m = await this._loadModule(moduleName); |
|
137 | const m = await this._loadModule(moduleName); | |
| 138 | return localName ? get(localName, m) : m; |
|
138 | return localName ? get(localName, m) : m; | |
| 139 | } catch (e) { |
|
139 | } catch (e) { | |
| 140 | trace.error("Failed to resolve type moduleName={0}, localName={1}", moduleName, localName); |
|
140 | trace.error("Failed to resolve type moduleName={0}, localName={1}", moduleName, localName); | |
| 141 | throw e; |
|
141 | throw e; | |
| 142 | } |
|
142 | } | |
| 143 | } |
|
143 | } | |
| 144 |
|
144 | |||
| 145 | _loadModule(moduleName: string) { |
|
145 | _loadModule(moduleName: string) { | |
| 146 | trace.debug("loadModule {0}", moduleName); |
|
146 | trace.debug("loadModule {0}", moduleName); | |
| 147 |
|
147 | |||
| 148 | return this._require(moduleName); |
|
148 | return this._require(moduleName); | |
| 149 | } |
|
149 | } | |
| 150 |
|
150 | |||
| 151 | async _visitRegistrations(data, name: _key) { |
|
151 | async _visitRegistrations(data, name: _key) { | |
| 152 | this._enter(name); |
|
152 | this._enter(name); | |
| 153 |
|
153 | |||
| 154 | if (data.constructor && |
|
154 | if (data.constructor && | |
| 155 | data.constructor.prototype !== Object.prototype) |
|
155 | data.constructor.prototype !== Object.prototype) | |
| 156 | throw new Error("Configuration must be a simple object"); |
|
156 | throw new Error("Configuration must be a simple object"); | |
| 157 |
|
157 | |||
| 158 | const o: ServiceMap = {}; |
|
158 | const o: ServiceMap = {}; | |
| 159 | const keys = Object.keys(data); |
|
159 | const keys = Object.keys(data); | |
| 160 |
|
160 | |||
| 161 | const services = await mapAll(data, async (v, k) => { |
|
161 | const services = await mapAll(data, async (v, k) => { | |
| 162 | const d = await this._visit(v, k); |
|
162 | const d = await this._visit(v, k); | |
| 163 | return isDescriptor(d) ? d : new AggregateDescriptor(d); |
|
163 | return isDescriptor(d) ? d : new AggregateDescriptor(d); | |
| 164 | }) as ServiceMap; |
|
164 | }) as ServiceMap; | |
| 165 |
|
165 | |||
| 166 | this._leave(); |
|
166 | this._leave(); | |
| 167 |
|
167 | |||
| 168 | return services; |
|
168 | return services; | |
| 169 | } |
|
169 | } | |
| 170 |
|
170 | |||
| 171 | _enter(name: _key) { |
|
171 | _enter(name: _key) { | |
| 172 | this._path.push(name); |
|
172 | this._path.push(name); | |
| 173 | trace.debug(">{0}", name); |
|
173 | trace.debug(">{0}", name); | |
| 174 | } |
|
174 | } | |
| 175 |
|
175 | |||
| 176 | _leave() { |
|
176 | _leave() { | |
| 177 | const name = this._path.pop(); |
|
177 | const name = this._path.pop(); | |
| 178 | trace.debug("<{0}", name); |
|
178 | trace.debug("<{0}", name); | |
| 179 | } |
|
179 | } | |
| 180 |
|
180 | |||
| 181 |
_visit(data, name: string) |
|
181 | async _visit(data, name: string) { | |
| 182 | if (isPrimitive(data) || isDescriptor(data)) |
|
182 | if (isPrimitive(data) || isDescriptor(data)) | |
| 183 | return data; |
|
183 | return data; | |
| 184 |
|
184 | |||
| 185 | if (isDependencyRegistration(data)) { |
|
185 | if (isDependencyRegistration(data)) { | |
| 186 | return this._visitDependencyRegistration(data, name); |
|
186 | return this._visitDependencyRegistration(data, name); | |
| 187 | } else if (isValueRegistration(data)) { |
|
187 | } else if (isValueRegistration(data)) { | |
| 188 | return this._visitValueRegistration(data, name); |
|
188 | return this._visitValueRegistration(data, name); | |
| 189 | } else if (isTypeRegistration(data)) { |
|
189 | } else if (isTypeRegistration(data)) { | |
| 190 | return this._visitTypeRegistration(data, name); |
|
190 | return this._visitTypeRegistration(data, name); | |
| 191 | } else if (isFactoryRegistration(data)) { |
|
191 | } else if (isFactoryRegistration(data)) { | |
| 192 | return this._visitFactoryRegistration(data, name); |
|
192 | return this._visitFactoryRegistration(data, name); | |
| 193 | } else if (data instanceof Array) { |
|
193 | } else if (data instanceof Array) { | |
| 194 | return this._visitArray(data, name); |
|
194 | return this._visitArray(data, name); | |
| 195 | } |
|
195 | } | |
| 196 |
|
196 | |||
| 197 | return this._visitObject(data, name); |
|
197 | return this._visitObject(data, name); | |
| 198 | } |
|
198 | } | |
| 199 |
|
199 | |||
| 200 | async _visitObject(data: object, name: _key) { |
|
200 | async _visitObject(data: object, name: _key) { | |
| 201 | if (data.constructor && |
|
201 | if (data.constructor && | |
| 202 | data.constructor.prototype !== Object.prototype) |
|
202 | data.constructor.prototype !== Object.prototype) | |
| 203 | return new ValueDescriptor(data); |
|
203 | return new ValueDescriptor(data); | |
| 204 |
|
204 | |||
| 205 | this._enter(name); |
|
205 | this._enter(name); | |
| 206 |
|
206 | |||
| 207 | const v = await mapAll(data, delegate(this, "_visit")); |
|
207 | const v = await mapAll(data, delegate(this, "_visit")); | |
| 208 |
|
208 | |||
| 209 | // TODO: handle inline descriptors properly |
|
209 | // TODO: handle inline descriptors properly | |
| 210 | // const ex = { |
|
210 | // const ex = { | |
| 211 | // activate(ctx) { |
|
211 | // activate(ctx) { | |
| 212 | // const value = ctx.activate(this.prop, "prop"); |
|
212 | // const value = ctx.activate(this.prop, "prop"); | |
| 213 | // // some code |
|
213 | // // some code | |
| 214 | // }, |
|
214 | // }, | |
| 215 | // // will be turned to ReferenceDescriptor |
|
215 | // // will be turned to ReferenceDescriptor | |
| 216 | // prop: { $dependency: "depName" } |
|
216 | // prop: { $dependency: "depName" } | |
| 217 | // }; |
|
217 | // }; | |
| 218 |
|
218 | |||
| 219 | this._leave(); |
|
219 | this._leave(); | |
| 220 | return v; |
|
220 | return v; | |
| 221 | } |
|
221 | } | |
| 222 |
|
222 | |||
| 223 | async _visitArray(data: any[], name: _key) { |
|
223 | async _visitArray(data: any[], name: _key) { | |
| 224 | if (data.constructor && |
|
224 | if (data.constructor && | |
| 225 | data.constructor.prototype !== Array.prototype) |
|
225 | data.constructor.prototype !== Array.prototype) | |
| 226 | return new ValueDescriptor(data); |
|
226 | return new ValueDescriptor(data); | |
| 227 |
|
227 | |||
| 228 | this._enter(name); |
|
228 | this._enter(name); | |
| 229 |
|
229 | |||
| 230 | const v = await mapAll(data, delegate(this, "_visit")); |
|
230 | const v = await mapAll(data, delegate(this, "_visit")); | |
| 231 | this._leave(); |
|
231 | this._leave(); | |
| 232 |
|
232 | |||
| 233 | return v; |
|
233 | return v; | |
| 234 | } |
|
234 | } | |
| 235 |
|
235 | |||
| 236 | _makeServiceParams(data: ServiceRegistration) { |
|
236 | _makeServiceParams(data: ServiceRegistration) { | |
| 237 | const opts: any = { |
|
237 | const opts: any = { | |
| 238 | owner: this._container |
|
238 | owner: this._container | |
| 239 | }; |
|
239 | }; | |
| 240 | if (data.services) |
|
240 | if (data.services) | |
| 241 | opts.services = this._visitRegistrations(data.services, "services"); |
|
241 | opts.services = this._visitRegistrations(data.services, "services"); | |
| 242 |
|
242 | |||
| 243 | if (data.inject) { |
|
243 | if (data.inject) { | |
| 244 | this._enter("inject"); |
|
244 | this._enter("inject"); | |
| 245 | opts.inject = mapAll( |
|
245 | opts.inject = mapAll( | |
| 246 | data.inject instanceof Array ? |
|
246 | data.inject instanceof Array ? | |
| 247 | data.inject : |
|
247 | data.inject : | |
| 248 | [data.inject], |
|
248 | [data.inject], | |
| 249 | delegate(this, "_visitObject") |
|
249 | delegate(this, "_visitObject") | |
| 250 | ); |
|
250 | ); | |
| 251 | this._leave(); |
|
251 | this._leave(); | |
| 252 | } |
|
252 | } | |
| 253 |
|
253 | |||
| 254 | if ("params" in data) |
|
254 | if ("params" in data) | |
| 255 | opts.params = data.params instanceof Array ? |
|
255 | opts.params = data.params instanceof Array ? | |
| 256 | this._visitArray(data.params, "params") : |
|
256 | this._visitArray(data.params, "params") : | |
| 257 | this._visit(data.params, "params"); |
|
257 | this._visit(data.params, "params"); | |
| 258 |
|
258 | |||
| 259 | if (data.activation) { |
|
259 | if (data.activation) { | |
| 260 | if (typeof (data.activation) === "string") { |
|
260 | if (typeof (data.activation) === "string") { | |
| 261 | switch (data.activation.toLowerCase()) { |
|
261 | switch (data.activation.toLowerCase()) { | |
| 262 | case "singleton": |
|
262 | case "singleton": | |
| 263 | opts.activation = ActivationType.Singleton; |
|
263 | opts.activation = ActivationType.Singleton; | |
| 264 | break; |
|
264 | break; | |
| 265 | case "container": |
|
265 | case "container": | |
| 266 | opts.activation = ActivationType.Container; |
|
266 | opts.activation = ActivationType.Container; | |
| 267 | break; |
|
267 | break; | |
| 268 | case "hierarchy": |
|
268 | case "hierarchy": | |
| 269 | opts.activation = ActivationType.Hierarchy; |
|
269 | opts.activation = ActivationType.Hierarchy; | |
| 270 | break; |
|
270 | break; | |
| 271 | case "context": |
|
271 | case "context": | |
| 272 | opts.activation = ActivationType.Context; |
|
272 | opts.activation = ActivationType.Context; | |
| 273 | break; |
|
273 | break; | |
| 274 | case "call": |
|
274 | case "call": | |
| 275 | opts.activation = ActivationType.Call; |
|
275 | opts.activation = ActivationType.Call; | |
| 276 | break; |
|
276 | break; | |
| 277 | default: |
|
277 | default: | |
| 278 | throw new Error("Unknown activation type: " + |
|
278 | throw new Error("Unknown activation type: " + | |
| 279 | data.activation); |
|
279 | data.activation); | |
| 280 | } |
|
280 | } | |
| 281 | } else { |
|
281 | } else { | |
| 282 | opts.activation = Number(data.activation); |
|
282 | opts.activation = Number(data.activation); | |
| 283 | } |
|
283 | } | |
| 284 | } |
|
284 | } | |
| 285 |
|
285 | |||
| 286 | if (data.cleanup) |
|
286 | if (data.cleanup) | |
| 287 | opts.cleanup = data.cleanup; |
|
287 | opts.cleanup = data.cleanup; | |
| 288 |
|
288 | |||
| 289 | return opts; |
|
289 | return opts; | |
| 290 | } |
|
290 | } | |
| 291 |
|
291 | |||
| 292 | async _visitValueRegistration(data: ValueRegistration, name: _key) { |
|
292 | async _visitValueRegistration(data: ValueRegistration, name: _key) { | |
| 293 | this._enter(name); |
|
293 | this._enter(name); | |
| 294 | const d = data.parse ? new AggregateDescriptor(data.$value) : new ValueDescriptor(data.$value); |
|
294 | const d = data.parse ? new AggregateDescriptor(data.$value) : new ValueDescriptor(data.$value); | |
| 295 | this._leave(); |
|
295 | this._leave(); | |
| 296 | return d; |
|
296 | return d; | |
| 297 | } |
|
297 | } | |
| 298 |
|
298 | |||
| 299 | async _visitDependencyRegistration(data: DependencyRegistration, name: _key) { |
|
299 | async _visitDependencyRegistration(data: DependencyRegistration, name: _key) { | |
| 300 | argumentNotEmptyString(data && data.$dependency, "data.$dependency"); |
|
300 | argumentNotEmptyString(data && data.$dependency, "data.$dependency"); | |
| 301 | this._enter(name); |
|
301 | this._enter(name); | |
| 302 | const d = new ReferenceDescriptor({ |
|
302 | const d = new ReferenceDescriptor({ | |
| 303 | name: data.$dependency, |
|
303 | name: data.$dependency, | |
| 304 | lazy: data.lazy, |
|
304 | lazy: data.lazy, | |
| 305 | optional: data.optional, |
|
305 | optional: data.optional, | |
| 306 | default: data.default, |
|
306 | default: data.default, | |
| 307 | services: data.services && await this._visitRegistrations(data.services, "services") |
|
307 | services: data.services && await this._visitRegistrations(data.services, "services") | |
| 308 | }); |
|
308 | }); | |
| 309 | this._leave(); |
|
309 | this._leave(); | |
| 310 | return d; |
|
310 | return d; | |
| 311 | } |
|
311 | } | |
| 312 |
|
312 | |||
| 313 | async _visitTypeRegistration(data: TypeRegistration, name: _key) { |
|
313 | async _visitTypeRegistration(data: TypeRegistration, name: _key) { | |
| 314 | argumentNotNull(data.$type, "data.$type"); |
|
314 | argumentNotNull(data.$type, "data.$type"); | |
| 315 | this._enter(name); |
|
315 | this._enter(name); | |
| 316 |
|
316 | |||
| 317 | const opts = this._makeServiceParams(data); |
|
317 | const opts = this._makeServiceParams(data); | |
| 318 | if (data.$type instanceof Function) { |
|
318 | if (data.$type instanceof Function) { | |
| 319 | opts.type = data.$type; |
|
319 | opts.type = data.$type; | |
| 320 | } else { |
|
320 | } else { | |
| 321 | const [moduleName, typeName] = data.$type.split(":", 2); |
|
321 | const [moduleName, typeName] = data.$type.split(":", 2); | |
| 322 | opts.type = this._resolveType(moduleName, typeName); |
|
322 | opts.type = this._resolveType(moduleName, typeName); | |
| 323 | } |
|
323 | } | |
| 324 |
|
324 | |||
| 325 | const d = new TypeServiceDescriptor( |
|
325 | const d = new TypeServiceDescriptor( | |
| 326 | await mapAll(opts) |
|
326 | await mapAll(opts) | |
| 327 | ); |
|
327 | ); | |
| 328 |
|
328 | |||
| 329 | this._leave(); |
|
329 | this._leave(); | |
| 330 |
|
330 | |||
| 331 | return d; |
|
331 | return d; | |
| 332 | } |
|
332 | } | |
| 333 |
|
333 | |||
| 334 | async _visitFactoryRegistration(data: FactoryRegistration, name: _key) { |
|
334 | async _visitFactoryRegistration(data: FactoryRegistration, name: _key) { | |
| 335 | argumentOfType(data.$factory, Function, "data.$factory"); |
|
335 | argumentOfType(data.$factory, Function, "data.$factory"); | |
| 336 | this._enter(name); |
|
336 | this._enter(name); | |
| 337 |
|
337 | |||
| 338 | const opts = this._makeServiceParams(data); |
|
338 | const opts = this._makeServiceParams(data); | |
| 339 | opts.factory = data.$factory; |
|
339 | opts.factory = data.$factory; | |
| 340 |
|
340 | |||
| 341 | const d = new FactoryServiceDescriptor( |
|
341 | const d = new FactoryServiceDescriptor( | |
| 342 | await mapAll(opts) |
|
342 | await mapAll(opts) | |
| 343 | ); |
|
343 | ); | |
| 344 |
|
344 | |||
| 345 | this._leave(); |
|
345 | this._leave(); | |
| 346 | return d; |
|
346 | return d; | |
| 347 | } |
|
347 | } | |
| 348 | } |
|
348 | } | |
| @@ -1,354 +1,360 | |||||
|
|
1 | import { ICancellable } from "./interfaces"; | |||
|
|
2 | ||||
| 1 | let _nextOid = 0; |
|
3 | let _nextOid = 0; | |
| 2 | const _oid = typeof Symbol === "function" ? |
|
4 | const _oid = typeof Symbol === "function" ? | |
| 3 | Symbol("__implab__oid__") : |
|
5 | Symbol("__implab__oid__") : | |
| 4 | "__implab__oid__"; |
|
6 | "__implab__oid__"; | |
| 5 |
|
7 | |||
| 6 | declare const window: any; |
|
8 | declare const window: any; | |
| 7 | declare const global: any; |
|
9 | declare const global: any; | |
| 8 |
|
10 | |||
| 9 | export function oid(instance: object): string { |
|
11 | export function oid(instance: object): string { | |
| 10 | if (isNull(instance)) |
|
12 | if (isNull(instance)) | |
| 11 | return null; |
|
13 | return null; | |
| 12 |
|
14 | |||
| 13 | if (_oid in instance) |
|
15 | if (_oid in instance) | |
| 14 | return instance[_oid]; |
|
16 | return instance[_oid]; | |
| 15 | else |
|
17 | else | |
| 16 | return (instance[_oid] = "oid_" + (++_nextOid)); |
|
18 | return (instance[_oid] = "oid_" + (++_nextOid)); | |
| 17 | } |
|
19 | } | |
| 18 |
|
20 | |||
| 19 | export function argumentNotNull(arg, name) { |
|
21 | export function argumentNotNull(arg, name) { | |
| 20 | if (arg === null || arg === undefined) |
|
22 | if (arg === null || arg === undefined) | |
| 21 | throw new Error("The argument " + name + " can't be null or undefined"); |
|
23 | throw new Error("The argument " + name + " can't be null or undefined"); | |
| 22 | } |
|
24 | } | |
| 23 |
|
25 | |||
| 24 | export function argumentNotEmptyString(arg, name) { |
|
26 | export function argumentNotEmptyString(arg, name) { | |
| 25 | if (typeof (arg) !== "string" || !arg.length) |
|
27 | if (typeof (arg) !== "string" || !arg.length) | |
| 26 | throw new Error("The argument '" + name + "' must be a not empty string"); |
|
28 | throw new Error("The argument '" + name + "' must be a not empty string"); | |
| 27 | } |
|
29 | } | |
| 28 |
|
30 | |||
| 29 | export function argumentNotEmptyArray(arg, name) { |
|
31 | export function argumentNotEmptyArray(arg, name) { | |
| 30 | if (!(arg instanceof Array) || !arg.length) |
|
32 | if (!(arg instanceof Array) || !arg.length) | |
| 31 | throw new Error("The argument '" + name + "' must be a not empty array"); |
|
33 | throw new Error("The argument '" + name + "' must be a not empty array"); | |
| 32 | } |
|
34 | } | |
| 33 |
|
35 | |||
| 34 | export function argumentOfType(arg, type, name) { |
|
36 | export function argumentOfType(arg, type, name) { | |
| 35 | if (!(arg instanceof type)) |
|
37 | if (!(arg instanceof type)) | |
| 36 | throw new Error("The argument '" + name + "' type doesn't match"); |
|
38 | throw new Error("The argument '" + name + "' type doesn't match"); | |
| 37 | } |
|
39 | } | |
| 38 |
|
40 | |||
| 39 | export function isNull(arg) { |
|
41 | export function isNull(arg) { | |
| 40 | return (arg === null || arg === undefined); |
|
42 | return (arg === null || arg === undefined); | |
| 41 | } |
|
43 | } | |
| 42 |
|
44 | |||
| 43 | export function isPrimitive(arg) { |
|
45 | export function isPrimitive(arg): arg is string | number | boolean | undefined | null { | |
| 44 | return (arg === null || arg === undefined || typeof (arg) === "string" || |
|
46 | return (arg === null || arg === undefined || typeof (arg) === "string" || | |
| 45 | typeof (arg) === "number" || typeof (arg) === "boolean"); |
|
47 | typeof (arg) === "number" || typeof (arg) === "boolean"); | |
| 46 | } |
|
48 | } | |
| 47 |
|
49 | |||
| 48 | export function isInteger(arg) { |
|
50 | export function isInteger(arg): arg is number { | |
| 49 | return parseInt(arg, 10) === arg; |
|
51 | return parseInt(arg, 10) === arg; | |
| 50 | } |
|
52 | } | |
| 51 |
|
53 | |||
| 52 | export function isNumber(arg) { |
|
54 | export function isNumber(arg): arg is number { | |
| 53 | return parseFloat(arg) === arg; |
|
55 | return parseFloat(arg) === arg; | |
| 54 | } |
|
56 | } | |
| 55 |
|
57 | |||
| 56 | export function isString(val) { |
|
58 | export function isString(val): val is string { | |
| 57 | return typeof (val) === "string" || val instanceof String; |
|
59 | return typeof (val) === "string" || val instanceof String; | |
| 58 | } |
|
60 | } | |
| 59 |
|
61 | |||
| 60 | export function isPromise(val): val is PromiseLike<any> { |
|
62 | export function isPromise(val): val is PromiseLike<any> { | |
| 61 | return val && typeof val.then === "function"; |
|
63 | return val && typeof val.then === "function"; | |
| 62 | } |
|
64 | } | |
| 63 |
|
65 | |||
|
|
66 | export function isCancellable(val): val is ICancellable { | |||
|
|
67 | return val && typeof val.cancel === "function"; | |||
|
|
68 | } | |||
|
|
69 | ||||
| 64 | export function isNullOrEmptyString(str) { |
|
70 | export function isNullOrEmptyString(str) { | |
| 65 | if (str === null || str === undefined || |
|
71 | if (str === null || str === undefined || | |
| 66 | ((typeof (str) === "string" || str instanceof String) && str.length === 0)) |
|
72 | ((typeof (str) === "string" || str instanceof String) && str.length === 0)) | |
| 67 | return true; |
|
73 | return true; | |
| 68 | } |
|
74 | } | |
| 69 |
|
75 | |||
| 70 | export function isNotEmptyArray(arg): arg is Array<any> { |
|
76 | export function isNotEmptyArray(arg): arg is Array<any> { | |
| 71 | return (arg instanceof Array && arg.length > 0); |
|
77 | return (arg instanceof Array && arg.length > 0); | |
| 72 | } |
|
78 | } | |
| 73 |
|
79 | |||
| 74 | function _isStrictMode() { |
|
80 | function _isStrictMode() { | |
| 75 | return !this; |
|
81 | return !this; | |
| 76 | } |
|
82 | } | |
| 77 |
|
83 | |||
| 78 | function _getNonStrictGlobal() { |
|
84 | function _getNonStrictGlobal() { | |
| 79 | return this; |
|
85 | return this; | |
| 80 | } |
|
86 | } | |
| 81 |
|
87 | |||
| 82 | export function getGlobal() { |
|
88 | export function getGlobal() { | |
| 83 | // in es3 we can't use indirect call to eval, since it will |
|
89 | // in es3 we can't use indirect call to eval, since it will | |
| 84 | // be executed in the current call context. |
|
90 | // be executed in the current call context. | |
| 85 | if (!_isStrictMode()) { |
|
91 | if (!_isStrictMode()) { | |
| 86 | return _getNonStrictGlobal(); |
|
92 | return _getNonStrictGlobal(); | |
| 87 | } else { |
|
93 | } else { | |
| 88 | // tslint:disable-next-line:no-eval |
|
94 | // tslint:disable-next-line:no-eval | |
| 89 | return eval.call(null, "this"); |
|
95 | return eval.call(null, "this"); | |
| 90 | } |
|
96 | } | |
| 91 | } |
|
97 | } | |
| 92 |
|
98 | |||
| 93 | export function get(member: string, context?: object) { |
|
99 | export function get(member: string, context?: object) { | |
| 94 | argumentNotEmptyString(member, "member"); |
|
100 | argumentNotEmptyString(member, "member"); | |
| 95 | let that = context || getGlobal(); |
|
101 | let that = context || getGlobal(); | |
| 96 | const parts = member.split("."); |
|
102 | const parts = member.split("."); | |
| 97 | for (const m of parts) { |
|
103 | for (const m of parts) { | |
| 98 | if (!m) |
|
104 | if (!m) | |
| 99 | continue; |
|
105 | continue; | |
| 100 | if (isNull(that = that[m])) |
|
106 | if (isNull(that = that[m])) | |
| 101 | break; |
|
107 | break; | |
| 102 | } |
|
108 | } | |
| 103 | return that; |
|
109 | return that; | |
| 104 | } |
|
110 | } | |
| 105 |
|
111 | |||
| 106 | /** |
|
112 | /** | |
| 107 | * ΠΡΠΏΠΎΠ»Π½ΡΠ΅Ρ ΠΌΠ΅ΡΠΎΠ΄ Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° ΠΌΠ°ΡΡΠΈΠ²Π°, ΠΎΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΡΡΡ, ΠΊΠΎΠ³Π΄Π° |
|
113 | * ΠΡΠΏΠΎΠ»Π½ΡΠ΅Ρ ΠΌΠ΅ΡΠΎΠ΄ Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° ΠΌΠ°ΡΡΠΈΠ²Π°, ΠΎΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΡΡΡ, ΠΊΠΎΠ³Π΄Π° | |
| 108 | * Π»ΠΈΠ±ΠΎ Π΄ΠΎΡΡΠΈΠ³Π½ΡΡ ΠΊΠΎΠ½Π΅Ρ ΠΌΠ°ΡΡΠΈΠ²Π°, Π»ΠΈΠ±ΠΎ ΡΡΠ½ΠΊΡΠΈΡ <c>cb</c> Π²Π΅ΡΠ½ΡΠ»Π° |
|
114 | * Π»ΠΈΠ±ΠΎ Π΄ΠΎΡΡΠΈΠ³Π½ΡΡ ΠΊΠΎΠ½Π΅Ρ ΠΌΠ°ΡΡΠΈΠ²Π°, Π»ΠΈΠ±ΠΎ ΡΡΠ½ΠΊΡΠΈΡ <c>cb</c> Π²Π΅ΡΠ½ΡΠ»Π° | |
| 109 | * Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅. |
|
115 | * Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅. | |
| 110 | * |
|
116 | * | |
| 111 | * @param {Array | Object} obj ΠΌΠ°ΡΡΠΈΠ² ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² Π΄Π»Ρ ΠΏΡΠΎΡΠΌΠΎΡΡΠ° |
|
117 | * @param {Array | Object} obj ΠΌΠ°ΡΡΠΈΠ² ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² Π΄Π»Ρ ΠΏΡΠΎΡΠΌΠΎΡΡΠ° | |
| 112 | * @param {Function} cb ΡΡΠ½ΠΊΡΠΈΡ, Π²ΡΠ·ΡΠ²Π°Π΅ΠΌΠ°Ρ Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° |
|
118 | * @param {Function} cb ΡΡΠ½ΠΊΡΠΈΡ, Π²ΡΠ·ΡΠ²Π°Π΅ΠΌΠ°Ρ Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° | |
| 113 | * @param {Object} thisArg Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅, ΠΊΠΎΡΠΎΡΠΎΠ΅ Π±ΡΠ΄Π΅Ρ ΠΏΠ΅ΡΠ΅Π΄Π°Π½ΠΎ Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ |
|
119 | * @param {Object} thisArg Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅, ΠΊΠΎΡΠΎΡΠΎΠ΅ Π±ΡΠ΄Π΅Ρ ΠΏΠ΅ΡΠ΅Π΄Π°Π½ΠΎ Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ | |
| 114 | * <c>this</c> Π² <c>cb</c>. |
|
120 | * <c>this</c> Π² <c>cb</c>. | |
| 115 | * @returns Π Π΅Π·ΡΠ»ΡΡΠ°Ρ Π²ΡΠ·ΠΎΠ²Π° ΡΡΠ½ΠΊΡΠΈΠΈ <c>cb</c>, Π»ΠΈΠ±ΠΎ <c>undefined</c> |
|
121 | * @returns Π Π΅Π·ΡΠ»ΡΡΠ°Ρ Π²ΡΠ·ΠΎΠ²Π° ΡΡΠ½ΠΊΡΠΈΠΈ <c>cb</c>, Π»ΠΈΠ±ΠΎ <c>undefined</c> | |
| 116 | * Π΅ΡΠ»ΠΈ Π΄ΠΎΡΡΠΈΠ³Π½ΡΡ ΠΊΠΎΠ½Π΅Ρ ΠΌΠ°ΡΡΠΈΠ²Π°. |
|
122 | * Π΅ΡΠ»ΠΈ Π΄ΠΎΡΡΠΈΠ³Π½ΡΡ ΠΊΠΎΠ½Π΅Ρ ΠΌΠ°ΡΡΠΈΠ²Π°. | |
| 117 | */ |
|
123 | */ | |
| 118 | export function each(obj, cb, thisArg?) { |
|
124 | export function each(obj, cb, thisArg?) { | |
| 119 | argumentNotNull(cb, "cb"); |
|
125 | argumentNotNull(cb, "cb"); | |
| 120 | if (obj instanceof Array) { |
|
126 | if (obj instanceof Array) { | |
| 121 | for (let i = 0; i < obj.length; i++) { |
|
127 | for (let i = 0; i < obj.length; i++) { | |
| 122 | const x = cb.call(thisArg, obj[i], i); |
|
128 | const x = cb.call(thisArg, obj[i], i); | |
| 123 | if (x !== undefined) |
|
129 | if (x !== undefined) | |
| 124 | return x; |
|
130 | return x; | |
| 125 | } |
|
131 | } | |
| 126 | } else { |
|
132 | } else { | |
| 127 | const keys = Object.keys(obj); |
|
133 | const keys = Object.keys(obj); | |
| 128 | for (const k of keys) { |
|
134 | for (const k of keys) { | |
| 129 | const x = cb.call(thisArg, obj[k], k); |
|
135 | const x = cb.call(thisArg, obj[k], k); | |
| 130 | if (x !== undefined) |
|
136 | if (x !== undefined) | |
| 131 | return x; |
|
137 | return x; | |
| 132 | } |
|
138 | } | |
| 133 | } |
|
139 | } | |
| 134 | } |
|
140 | } | |
| 135 |
|
141 | |||
| 136 | /** Copies property values from a source object to the destination and returns |
|
142 | /** Copies property values from a source object to the destination and returns | |
| 137 | * the destination onject. |
|
143 | * the destination onject. | |
| 138 | * |
|
144 | * | |
| 139 | * @param dest The destination object into which properties from the source |
|
145 | * @param dest The destination object into which properties from the source | |
| 140 | * object will be copied. |
|
146 | * object will be copied. | |
| 141 | * @param source The source of values which will be copied to the destination |
|
147 | * @param source The source of values which will be copied to the destination | |
| 142 | * object. |
|
148 | * object. | |
| 143 | * @param template An optional parameter specifies which properties should be |
|
149 | * @param template An optional parameter specifies which properties should be | |
| 144 | * copied from the source and how to map them to the destination. If the |
|
150 | * copied from the source and how to map them to the destination. If the | |
| 145 | * template is an array it contains the list of property names to copy from the |
|
151 | * template is an array it contains the list of property names to copy from the | |
| 146 | * source to the destination. In case of object the templates contains the map |
|
152 | * source to the destination. In case of object the templates contains the map | |
| 147 | * where keys are property names in the source and the values are property |
|
153 | * where keys are property names in the source and the values are property | |
| 148 | * names in the destination object. If the template isn't specified then the |
|
154 | * names in the destination object. If the template isn't specified then the | |
| 149 | * own properties of the source are entirely copied to the destination. |
|
155 | * own properties of the source are entirely copied to the destination. | |
| 150 | * |
|
156 | * | |
| 151 | */ |
|
157 | */ | |
| 152 | export function mixin<T, S>(dest: T, source: S, template?: string[] | object): T & S { |
|
158 | export function mixin<T, S>(dest: T, source: S, template?: string[] | object): T & S { | |
| 153 | argumentNotNull(dest, "to"); |
|
159 | argumentNotNull(dest, "to"); | |
| 154 | const _res = dest as T & S; |
|
160 | const _res = dest as T & S; | |
| 155 |
|
161 | |||
| 156 | if (isPrimitive(source)) |
|
162 | if (isPrimitive(source)) | |
| 157 | return _res; |
|
163 | return _res; | |
| 158 |
|
164 | |||
| 159 | if (template instanceof Array) { |
|
165 | if (template instanceof Array) { | |
| 160 | for (const p of template) { |
|
166 | for (const p of template) { | |
| 161 | if (p in source) |
|
167 | if (p in source) | |
| 162 | _res[p] = source[p]; |
|
168 | _res[p] = source[p]; | |
| 163 | } |
|
169 | } | |
| 164 | } else if (template) { |
|
170 | } else if (template) { | |
| 165 | const keys = Object.keys(source); |
|
171 | const keys = Object.keys(source); | |
| 166 | for (const p of keys) { |
|
172 | for (const p of keys) { | |
| 167 | if (p in template) |
|
173 | if (p in template) | |
| 168 | _res[template[p]] = source[p]; |
|
174 | _res[template[p]] = source[p]; | |
| 169 | } |
|
175 | } | |
| 170 | } else { |
|
176 | } else { | |
| 171 | const keys = Object.keys(source); |
|
177 | const keys = Object.keys(source); | |
| 172 | for (const p of keys) |
|
178 | for (const p of keys) | |
| 173 | _res[p] = source[p]; |
|
179 | _res[p] = source[p]; | |
| 174 | } |
|
180 | } | |
| 175 |
|
181 | |||
| 176 | return _res; |
|
182 | return _res; | |
| 177 | } |
|
183 | } | |
| 178 |
|
184 | |||
| 179 | /** Wraps the specified function to emulate an asynchronous execution. |
|
185 | /** Wraps the specified function to emulate an asynchronous execution. | |
| 180 | * @param{Object} thisArg [Optional] Object which will be passed as 'this' to the function. |
|
186 | * @param{Object} thisArg [Optional] Object which will be passed as 'this' to the function. | |
| 181 | * @param{Function|String} fn [Required] Function wich will be wrapped. |
|
187 | * @param{Function|String} fn [Required] Function wich will be wrapped. | |
| 182 | */ |
|
188 | */ | |
| 183 | export function async(_fn: (...args: any[]) => any, thisArg): (...args: any[]) => PromiseLike<any> { |
|
189 | export function async(_fn: (...args: any[]) => any, thisArg): (...args: any[]) => PromiseLike<any> { | |
| 184 | let fn = _fn; |
|
190 | let fn = _fn; | |
| 185 |
|
191 | |||
| 186 | if (arguments.length === 2 && !(fn instanceof Function)) |
|
192 | if (arguments.length === 2 && !(fn instanceof Function)) | |
| 187 | fn = thisArg[fn]; |
|
193 | fn = thisArg[fn]; | |
| 188 |
|
194 | |||
| 189 | if (fn == null) |
|
195 | if (fn == null) | |
| 190 | throw new Error("The function must be specified"); |
|
196 | throw new Error("The function must be specified"); | |
| 191 |
|
197 | |||
| 192 | function wrapresult(x, e?): PromiseLike<any> { |
|
198 | function wrapresult(x, e?): PromiseLike<any> { | |
| 193 | if (e) { |
|
199 | if (e) { | |
| 194 | return { |
|
200 | return { | |
| 195 | then(cb, eb) { |
|
201 | then(cb, eb) { | |
| 196 | try { |
|
202 | try { | |
| 197 | return eb ? wrapresult(eb(e)) : this; |
|
203 | return eb ? wrapresult(eb(e)) : this; | |
| 198 | } catch (e2) { |
|
204 | } catch (e2) { | |
| 199 | return wrapresult(null, e2); |
|
205 | return wrapresult(null, e2); | |
| 200 | } |
|
206 | } | |
| 201 | } |
|
207 | } | |
| 202 | }; |
|
208 | }; | |
| 203 | } else { |
|
209 | } else { | |
| 204 | if (x && x.then) |
|
210 | if (x && x.then) | |
| 205 | return x; |
|
211 | return x; | |
| 206 | return { |
|
212 | return { | |
| 207 | then(cb) { |
|
213 | then(cb) { | |
| 208 | try { |
|
214 | try { | |
| 209 | return cb ? wrapresult(cb(x)) : this; |
|
215 | return cb ? wrapresult(cb(x)) : this; | |
| 210 | } catch (e2) { |
|
216 | } catch (e2) { | |
| 211 | return wrapresult(e2); |
|
217 | return wrapresult(e2); | |
| 212 | } |
|
218 | } | |
| 213 | } |
|
219 | } | |
| 214 | }; |
|
220 | }; | |
| 215 | } |
|
221 | } | |
| 216 | } |
|
222 | } | |
| 217 |
|
223 | |||
| 218 | return (...args) => { |
|
224 | return (...args) => { | |
| 219 | try { |
|
225 | try { | |
| 220 | return wrapresult(fn.apply(thisArg, args)); |
|
226 | return wrapresult(fn.apply(thisArg, args)); | |
| 221 | } catch (e) { |
|
227 | } catch (e) { | |
| 222 | return wrapresult(null, e); |
|
228 | return wrapresult(null, e); | |
| 223 | } |
|
229 | } | |
| 224 | }; |
|
230 | }; | |
| 225 | } |
|
231 | } | |
| 226 |
|
232 | |||
| 227 | type _AnyFn = (...args) => any; |
|
233 | type _AnyFn = (...args) => any; | |
| 228 |
|
234 | |||
| 229 | export function delegate<T, K extends keyof T>(target: T, _method: (K | _AnyFn)) { |
|
235 | export function delegate<T, K extends keyof T>(target: T, _method: (K | _AnyFn)) { | |
| 230 | let method; |
|
236 | let method; | |
| 231 |
|
237 | |||
| 232 | if (!(_method instanceof Function)) { |
|
238 | if (!(_method instanceof Function)) { | |
| 233 | argumentNotNull(target, "target"); |
|
239 | argumentNotNull(target, "target"); | |
| 234 | method = target[_method]; |
|
240 | method = target[_method]; | |
| 235 | if (!(method instanceof Function)) |
|
241 | if (!(method instanceof Function)) | |
| 236 | throw new Error("'method' argument must be a Function or a method name"); |
|
242 | throw new Error("'method' argument must be a Function or a method name"); | |
| 237 | } else { |
|
243 | } else { | |
| 238 | method = _method; |
|
244 | method = _method; | |
| 239 | } |
|
245 | } | |
| 240 |
|
246 | |||
| 241 | return (...args) => { |
|
247 | return (...args) => { | |
| 242 | return method.apply(target, args); |
|
248 | return method.apply(target, args); | |
| 243 | }; |
|
249 | }; | |
| 244 | } |
|
250 | } | |
| 245 |
|
251 | |||
| 246 | /** |
|
252 | /** | |
| 247 | * ΠΠ»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° ΠΌΠ°ΡΡΠΈΠ²Π° Π²ΡΠ·ΡΠ²Π°Π΅Ρ ΡΠΊΠ°Π·Π°Π½Π½ΡΡ ΡΡΠ½ΠΊΡΠΈΡ ΠΈ ΡΠΎΡ ΡΠ°Π½ΡΠ΅Ρ |
|
253 | * ΠΠ»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° ΠΌΠ°ΡΡΠΈΠ²Π° Π²ΡΠ·ΡΠ²Π°Π΅Ρ ΡΠΊΠ°Π·Π°Π½Π½ΡΡ ΡΡΠ½ΠΊΡΠΈΡ ΠΈ ΡΠΎΡ ΡΠ°Π½ΡΠ΅Ρ | |
| 248 | * Π²ΠΎΠ·Π²ΡΠ°ΡΠ΅Π½Π½ΠΎΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ Π² ΠΌΠ°ΡΡΠΈΠ²Π΅ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ². |
|
254 | * Π²ΠΎΠ·Π²ΡΠ°ΡΠ΅Π½Π½ΠΎΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ Π² ΠΌΠ°ΡΡΠΈΠ²Π΅ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠ². | |
| 249 | * |
|
255 | * | |
| 250 | * @remarks cb ΠΌΠΎΠΆΠ΅Ρ Π²ΡΠΏΠΎΠ»Π½ΡΡΡΡΡ Π°ΡΠΈΠ½Ρ ΡΠΎΠ½Π½ΠΎ, ΠΏΡΠΈ ΡΡΠΎΠΌ ΠΎΠ΄Π½ΠΎΠ²ΡΠ΅ΠΌΠ΅Π½Π½ΠΎ Π±ΡΠ΄Π΅Ρ |
|
256 | * @remarks cb ΠΌΠΎΠΆΠ΅Ρ Π²ΡΠΏΠΎΠ»Π½ΡΡΡΡΡ Π°ΡΠΈΠ½Ρ ΡΠΎΠ½Π½ΠΎ, ΠΏΡΠΈ ΡΡΠΎΠΌ ΠΎΠ΄Π½ΠΎΠ²ΡΠ΅ΠΌΠ΅Π½Π½ΠΎ Π±ΡΠ΄Π΅Ρ | |
| 251 | * ΡΠΎΠ»ΡΠΊΠΎ ΠΎΠ΄Π½Π° ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ. |
|
257 | * ΡΠΎΠ»ΡΠΊΠΎ ΠΎΠ΄Π½Π° ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ. | |
| 252 | * |
|
258 | * | |
| 253 | * @async |
|
259 | * @async | |
| 254 | */ |
|
260 | */ | |
| 255 | export function pmap(items, cb) { |
|
261 | export function pmap(items, cb) { | |
| 256 | argumentNotNull(cb, "cb"); |
|
262 | argumentNotNull(cb, "cb"); | |
| 257 |
|
263 | |||
| 258 | if (isPromise(items)) |
|
264 | if (isPromise(items)) | |
| 259 | return items.then(data => pmap(data, cb)); |
|
265 | return items.then(data => pmap(data, cb)); | |
| 260 |
|
266 | |||
| 261 | if (isNull(items) || !items.length) |
|
267 | if (isNull(items) || !items.length) | |
| 262 | return items; |
|
268 | return items; | |
| 263 |
|
269 | |||
| 264 | let i = 0; |
|
270 | let i = 0; | |
| 265 | const result = []; |
|
271 | const result = []; | |
| 266 |
|
272 | |||
| 267 | function next() { |
|
273 | function next() { | |
| 268 | let r; |
|
274 | let r; | |
| 269 | let ri; |
|
275 | let ri; | |
| 270 |
|
276 | |||
| 271 | function chain(x) { |
|
277 | function chain(x) { | |
| 272 | result[ri] = x; |
|
278 | result[ri] = x; | |
| 273 | return next(); |
|
279 | return next(); | |
| 274 | } |
|
280 | } | |
| 275 |
|
281 | |||
| 276 | while (i < items.length) { |
|
282 | while (i < items.length) { | |
| 277 | r = cb(items[i], i); |
|
283 | r = cb(items[i], i); | |
| 278 | ri = i; |
|
284 | ri = i; | |
| 279 | i++; |
|
285 | i++; | |
| 280 | if (isPromise(r)) { |
|
286 | if (isPromise(r)) { | |
| 281 | return r.then(chain); |
|
287 | return r.then(chain); | |
| 282 | } else { |
|
288 | } else { | |
| 283 | result[ri] = r; |
|
289 | result[ri] = r; | |
| 284 | } |
|
290 | } | |
| 285 | } |
|
291 | } | |
| 286 | return result; |
|
292 | return result; | |
| 287 | } |
|
293 | } | |
| 288 |
|
294 | |||
| 289 | return next(); |
|
295 | return next(); | |
| 290 | } |
|
296 | } | |
| 291 |
|
297 | |||
| 292 | export function pfor(items, cb) { |
|
298 | export function pfor(items, cb) { | |
| 293 | argumentNotNull(cb, "cb"); |
|
299 | argumentNotNull(cb, "cb"); | |
| 294 |
|
300 | |||
| 295 | if (isPromise(items)) |
|
301 | if (isPromise(items)) | |
| 296 | return items.then(data => { |
|
302 | return items.then(data => { | |
| 297 | return pmap(data, cb); |
|
303 | return pmap(data, cb); | |
| 298 | }); |
|
304 | }); | |
| 299 |
|
305 | |||
| 300 | if (isNull(items) || !items.length) |
|
306 | if (isNull(items) || !items.length) | |
| 301 | return items; |
|
307 | return items; | |
| 302 |
|
308 | |||
| 303 | let i = 0; |
|
309 | let i = 0; | |
| 304 |
|
310 | |||
| 305 | function next() { |
|
311 | function next() { | |
| 306 | while (i < items.length) { |
|
312 | while (i < items.length) { | |
| 307 | const r = cb(items[i], i); |
|
313 | const r = cb(items[i], i); | |
| 308 | i++; |
|
314 | i++; | |
| 309 | if (isPromise(r)) |
|
315 | if (isPromise(r)) | |
| 310 | return r.then(next); |
|
316 | return r.then(next); | |
| 311 | } |
|
317 | } | |
| 312 | } |
|
318 | } | |
| 313 |
|
319 | |||
| 314 | return next(); |
|
320 | return next(); | |
| 315 | } |
|
321 | } | |
| 316 |
|
322 | |||
| 317 | /** |
|
323 | /** | |
| 318 | * ΠΡΠ±ΠΈΡΠ°Π΅Ρ ΠΏΠ΅ΡΠ²ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΠΈΠ· ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΠ΅Π»ΡΠ½ΠΎΡΡΠΈ, ΠΈΠ»ΠΈ ΠΎΠ±Π΅ΡΠ°Π½ΠΈΡ, Π΅ΡΠ»ΠΈ Π² |
|
324 | * ΠΡΠ±ΠΈΡΠ°Π΅Ρ ΠΏΠ΅ΡΠ²ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΠΈΠ· ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΠ΅Π»ΡΠ½ΠΎΡΡΠΈ, ΠΈΠ»ΠΈ ΠΎΠ±Π΅ΡΠ°Π½ΠΈΡ, Π΅ΡΠ»ΠΈ Π² | |
| 319 | * ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠ° ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ ΠΎΠ±Π΅ΡΠ°Π½ΠΈΠ΅, ΠΎΠ½ΠΎ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π²Π΅ΡΠ½ΡΡΡ ΠΌΠ°ΡΡΠΈΠ². |
|
325 | * ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠ° ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ ΠΎΠ±Π΅ΡΠ°Π½ΠΈΠ΅, ΠΎΠ½ΠΎ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π²Π΅ΡΠ½ΡΡΡ ΠΌΠ°ΡΡΠΈΠ². | |
| 320 | * |
|
326 | * | |
| 321 | * @param {Function} cb ΠΎΠ±ΡΠ°Π±ΠΎΡΡΠΈΠΊ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠ°, Π΅ΠΌΡ Π±ΡΠ΄Π΅Ρ ΠΏΠ΅ΡΠ΅Π΄Π°Π½ ΠΏΠ΅ΡΠ²ΡΠΉ |
|
327 | * @param {Function} cb ΠΎΠ±ΡΠ°Π±ΠΎΡΡΠΈΠΊ ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠ°, Π΅ΠΌΡ Π±ΡΠ΄Π΅Ρ ΠΏΠ΅ΡΠ΅Π΄Π°Π½ ΠΏΠ΅ΡΠ²ΡΠΉ | |
| 322 | * ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΠ΅Π»ΡΠ½ΠΎΡΡΠΈ Π² ΡΠ»ΡΡΠ°Π΅ ΡΡΠΏΠ΅Ρ Π° |
|
328 | * ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΠ΅Π»ΡΠ½ΠΎΡΡΠΈ Π² ΡΠ»ΡΡΠ°Π΅ ΡΡΠΏΠ΅Ρ Π° | |
| 323 | * @param {Function} err ΠΎΠ±ΡΠ°Π±ΠΎΡΡΠΈΠΊ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΡ, Π΅ΡΠ»ΠΈ ΠΌΠ°ΡΡΠΈΠ² ΠΏΡΡΡΠΎΠΉ, Π»ΠΈΠ±ΠΎ |
|
329 | * @param {Function} err ΠΎΠ±ΡΠ°Π±ΠΎΡΡΠΈΠΊ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΡ, Π΅ΡΠ»ΠΈ ΠΌΠ°ΡΡΠΈΠ² ΠΏΡΡΡΠΎΠΉ, Π»ΠΈΠ±ΠΎ | |
| 324 | * Π½Π΅ ΠΌΠ°ΡΡΠΈΠ² |
|
330 | * Π½Π΅ ΠΌΠ°ΡΡΠΈΠ² | |
| 325 | * |
|
331 | * | |
| 326 | * @remarks ΠΡΠ»ΠΈ Π½Π΅ ΡΠΊΠ°Π·Π°Π½Ρ Π½ΠΈ cb Π½ΠΈ err, ΡΠΎΠ³Π΄Π° ΡΡΠ½ΠΊΡΠΈΡ Π²Π΅ΡΠ½Π΅Ρ Π»ΠΈΠ±ΠΎ |
|
332 | * @remarks ΠΡΠ»ΠΈ Π½Π΅ ΡΠΊΠ°Π·Π°Π½Ρ Π½ΠΈ cb Π½ΠΈ err, ΡΠΎΠ³Π΄Π° ΡΡΠ½ΠΊΡΠΈΡ Π²Π΅ΡΠ½Π΅Ρ Π»ΠΈΠ±ΠΎ | |
| 327 | * ΠΎΠ±Π΅ΡΠ°Π½ΠΈΠ΅, Π»ΠΈΠ±ΠΎ ΠΏΠ΅ΡΠ²ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ. |
|
333 | * ΠΎΠ±Π΅ΡΠ°Π½ΠΈΠ΅, Π»ΠΈΠ±ΠΎ ΠΏΠ΅ΡΠ²ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ. | |
| 328 | * @async |
|
334 | * @async | |
| 329 | */ |
|
335 | */ | |
| 330 | export function first(sequence, cb: (x) => any, err: (x) => any) { |
|
336 | export function first(sequence, cb: (x) => any, err: (x) => any) { | |
| 331 | if (sequence) { |
|
337 | if (sequence) { | |
| 332 | if (isPromise(sequence)) { |
|
338 | if (isPromise(sequence)) { | |
| 333 | return sequence.then(res => first(res, cb, err)); |
|
339 | return sequence.then(res => first(res, cb, err)); | |
| 334 | } else if (sequence && "length" in sequence) { |
|
340 | } else if (sequence && "length" in sequence) { | |
| 335 | if (sequence.length === 0) { |
|
341 | if (sequence.length === 0) { | |
| 336 | if (err) |
|
342 | if (err) | |
| 337 | return err(new Error("The sequence is empty")); |
|
343 | return err(new Error("The sequence is empty")); | |
| 338 | else |
|
344 | else | |
| 339 | throw new Error("The sequence is empty"); |
|
345 | throw new Error("The sequence is empty"); | |
| 340 | } |
|
346 | } | |
| 341 | return cb ? cb(sequence[0]) : sequence[0]; |
|
347 | return cb ? cb(sequence[0]) : sequence[0]; | |
| 342 | } |
|
348 | } | |
| 343 | } |
|
349 | } | |
| 344 |
|
350 | |||
| 345 | if (err) |
|
351 | if (err) | |
| 346 | return err(new Error("The sequence is required")); |
|
352 | return err(new Error("The sequence is required")); | |
| 347 | else |
|
353 | else | |
| 348 | throw new Error("The sequence is required"); |
|
354 | throw new Error("The sequence is required"); | |
| 349 | } |
|
355 | } | |
| 350 |
|
356 | |||
| 351 | export function destroy(d) { |
|
357 | export function destroy(d) { | |
| 352 | if (d && "destroy" in d) |
|
358 | if (d && "destroy" in d) | |
| 353 | d.destroy(); |
|
359 | d.destroy(); | |
| 354 | } |
|
360 | } | |
General Comments 0
You need to be logged in to leave comments.
Login now
