Leon4gr45 commited on
Commit
93877d6
·
verified ·
1 Parent(s): 5832e08

Upload folder using huggingface_hub (part 5)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/binary-extensions/binary-extensions.json.d.ts +3 -0
  2. node_modules/binary-extensions/index.d.ts +14 -0
  3. node_modules/binary-extensions/index.js +1 -0
  4. node_modules/binary-extensions/license +10 -0
  5. node_modules/binary-extensions/package.json +40 -0
  6. node_modules/binary-extensions/readme.md +25 -0
  7. node_modules/bindings/LICENSE.md +22 -0
  8. node_modules/bindings/README.md +98 -0
  9. node_modules/bindings/bindings.js +221 -0
  10. node_modules/bindings/package.json +28 -0
  11. node_modules/birpc/LICENSE +21 -0
  12. node_modules/birpc/README.md +163 -0
  13. node_modules/birpc/package.json +57 -0
  14. node_modules/bl/.travis.yml +17 -0
  15. node_modules/bl/BufferList.js +396 -0
  16. node_modules/bl/LICENSE.md +13 -0
  17. node_modules/bl/README.md +247 -0
  18. node_modules/bl/bl.js +84 -0
  19. node_modules/bl/package.json +37 -0
  20. node_modules/bl/test/convert.js +21 -0
  21. node_modules/bl/test/indexOf.js +492 -0
  22. node_modules/bl/test/isBufferList.js +32 -0
  23. node_modules/bl/test/test.js +869 -0
  24. node_modules/bluebird/LICENSE +21 -0
  25. node_modules/bluebird/README.md +57 -0
  26. node_modules/bluebird/changelog.md +1 -0
  27. node_modules/bluebird/js/browser/bluebird.core.js +0 -0
  28. node_modules/bluebird/js/browser/bluebird.core.min.js +31 -0
  29. node_modules/bluebird/js/browser/bluebird.js +0 -0
  30. node_modules/bluebird/js/browser/bluebird.min.js +31 -0
  31. node_modules/bluebird/js/release/any.js +21 -0
  32. node_modules/bluebird/js/release/assert.js +55 -0
  33. node_modules/bluebird/js/release/async.js +120 -0
  34. node_modules/bluebird/js/release/bind.js +67 -0
  35. node_modules/bluebird/js/release/bluebird.js +11 -0
  36. node_modules/bluebird/js/release/call_get.js +123 -0
  37. node_modules/bluebird/js/release/cancel.js +129 -0
  38. node_modules/bluebird/js/release/catch_filter.js +42 -0
  39. node_modules/bluebird/js/release/context.js +69 -0
  40. node_modules/bluebird/js/release/debuggability.js +1009 -0
  41. node_modules/bluebird/js/release/direct_resolve.js +46 -0
  42. node_modules/bluebird/js/release/each.js +30 -0
  43. node_modules/bluebird/js/release/errors.js +116 -0
  44. node_modules/bluebird/js/release/es5.js +80 -0
  45. node_modules/bluebird/js/release/filter.js +12 -0
  46. node_modules/bluebird/js/release/finally.js +146 -0
  47. node_modules/bluebird/js/release/generators.js +223 -0
  48. node_modules/bluebird/js/release/join.js +165 -0
  49. node_modules/bluebird/js/release/map.js +175 -0
  50. node_modules/bluebird/js/release/method.js +55 -0
node_modules/binary-extensions/binary-extensions.json.d.ts ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ declare const binaryExtensionsJson: readonly string[];
2
+
3
+ export = binaryExtensionsJson;
node_modules/binary-extensions/index.d.ts ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ List of binary file extensions.
3
+
4
+ @example
5
+ ```
6
+ import binaryExtensions = require('binary-extensions');
7
+
8
+ console.log(binaryExtensions);
9
+ //=> ['3ds', '3g2', …]
10
+ ```
11
+ */
12
+ declare const binaryExtensions: readonly string[];
13
+
14
+ export = binaryExtensions;
node_modules/binary-extensions/index.js ADDED
@@ -0,0 +1 @@
 
 
1
+ module.exports = require('./binary-extensions.json');
node_modules/binary-extensions/license ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+ Copyright (c) Paul Miller (https://paulmillr.com)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/binary-extensions/package.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "binary-extensions",
3
+ "version": "2.3.0",
4
+ "description": "List of binary file extensions",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/binary-extensions",
7
+ "funding": "https://github.com/sponsors/sindresorhus",
8
+ "author": {
9
+ "name": "Sindre Sorhus",
10
+ "email": "sindresorhus@gmail.com",
11
+ "url": "https://sindresorhus.com"
12
+ },
13
+ "sideEffects": false,
14
+ "engines": {
15
+ "node": ">=8"
16
+ },
17
+ "scripts": {
18
+ "test": "xo && ava && tsd"
19
+ },
20
+ "files": [
21
+ "index.js",
22
+ "index.d.ts",
23
+ "binary-extensions.json",
24
+ "binary-extensions.json.d.ts"
25
+ ],
26
+ "keywords": [
27
+ "binary",
28
+ "extensions",
29
+ "extension",
30
+ "file",
31
+ "json",
32
+ "list",
33
+ "array"
34
+ ],
35
+ "devDependencies": {
36
+ "ava": "^1.4.1",
37
+ "tsd": "^0.7.2",
38
+ "xo": "^0.24.0"
39
+ }
40
+ }
node_modules/binary-extensions/readme.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # binary-extensions
2
+
3
+ > List of binary file extensions
4
+
5
+ The list is just a [JSON file](binary-extensions.json) and can be used anywhere.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install binary-extensions
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ const binaryExtensions = require('binary-extensions');
17
+
18
+ console.log(binaryExtensions);
19
+ //=> ['3ds', '3g2', …]
20
+ ```
21
+
22
+ ## Related
23
+
24
+ - [is-binary-path](https://github.com/sindresorhus/is-binary-path) - Check if a filepath is a binary file
25
+ - [text-extensions](https://github.com/sindresorhus/text-extensions) - List of text file extensions
node_modules/bindings/LICENSE.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2012 Nathan Rajlich &lt;nathan@tootallnate.net&gt;
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/bindings/README.md ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ node-bindings
2
+ =============
3
+ ### Helper module for loading your native module's `.node` file
4
+
5
+ This is a helper module for authors of Node.js native addon modules.
6
+ It is basically the "swiss army knife" of `require()`ing your native module's
7
+ `.node` file.
8
+
9
+ Throughout the course of Node's native addon history, addons have ended up being
10
+ compiled in a variety of different places, depending on which build tool and which
11
+ version of node was used. To make matters worse, now the `gyp` build tool can
12
+ produce either a __Release__ or __Debug__ build, each being built into different
13
+ locations.
14
+
15
+ This module checks _all_ the possible locations that a native addon would be built
16
+ at, and returns the first one that loads successfully.
17
+
18
+
19
+ Installation
20
+ ------------
21
+
22
+ Install with `npm`:
23
+
24
+ ``` bash
25
+ $ npm install --save bindings
26
+ ```
27
+
28
+ Or add it to the `"dependencies"` section of your `package.json` file.
29
+
30
+
31
+ Example
32
+ -------
33
+
34
+ `require()`ing the proper bindings file for the current node version, platform
35
+ and architecture is as simple as:
36
+
37
+ ``` js
38
+ var bindings = require('bindings')('binding.node')
39
+
40
+ // Use your bindings defined in your C files
41
+ bindings.your_c_function()
42
+ ```
43
+
44
+
45
+ Nice Error Output
46
+ -----------------
47
+
48
+ When the `.node` file could not be loaded, `node-bindings` throws an Error with
49
+ a nice error message telling you exactly what was tried. You can also check the
50
+ `err.tries` Array property.
51
+
52
+ ```
53
+ Error: Could not load the bindings file. Tried:
54
+ → /Users/nrajlich/ref/build/binding.node
55
+ → /Users/nrajlich/ref/build/Debug/binding.node
56
+ → /Users/nrajlich/ref/build/Release/binding.node
57
+ → /Users/nrajlich/ref/out/Debug/binding.node
58
+ → /Users/nrajlich/ref/Debug/binding.node
59
+ → /Users/nrajlich/ref/out/Release/binding.node
60
+ → /Users/nrajlich/ref/Release/binding.node
61
+ → /Users/nrajlich/ref/build/default/binding.node
62
+ → /Users/nrajlich/ref/compiled/0.8.2/darwin/x64/binding.node
63
+ at bindings (/Users/nrajlich/ref/node_modules/bindings/bindings.js:84:13)
64
+ at Object.<anonymous> (/Users/nrajlich/ref/lib/ref.js:5:47)
65
+ at Module._compile (module.js:449:26)
66
+ at Object.Module._extensions..js (module.js:467:10)
67
+ at Module.load (module.js:356:32)
68
+ at Function.Module._load (module.js:312:12)
69
+ ...
70
+ ```
71
+
72
+ The searching for the `.node` file will originate from the first directory in which has a `package.json` file is found.
73
+
74
+ License
75
+ -------
76
+
77
+ (The MIT License)
78
+
79
+ Copyright (c) 2012 Nathan Rajlich &lt;nathan@tootallnate.net&gt;
80
+
81
+ Permission is hereby granted, free of charge, to any person obtaining
82
+ a copy of this software and associated documentation files (the
83
+ 'Software'), to deal in the Software without restriction, including
84
+ without limitation the rights to use, copy, modify, merge, publish,
85
+ distribute, sublicense, and/or sell copies of the Software, and to
86
+ permit persons to whom the Software is furnished to do so, subject to
87
+ the following conditions:
88
+
89
+ The above copyright notice and this permission notice shall be
90
+ included in all copies or substantial portions of the Software.
91
+
92
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
93
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
94
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
95
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
96
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
97
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
98
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/bindings/bindings.js ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Module dependencies.
3
+ */
4
+
5
+ var fs = require('fs'),
6
+ path = require('path'),
7
+ fileURLToPath = require('file-uri-to-path'),
8
+ join = path.join,
9
+ dirname = path.dirname,
10
+ exists =
11
+ (fs.accessSync &&
12
+ function(path) {
13
+ try {
14
+ fs.accessSync(path);
15
+ } catch (e) {
16
+ return false;
17
+ }
18
+ return true;
19
+ }) ||
20
+ fs.existsSync ||
21
+ path.existsSync,
22
+ defaults = {
23
+ arrow: process.env.NODE_BINDINGS_ARROW || ' → ',
24
+ compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled',
25
+ platform: process.platform,
26
+ arch: process.arch,
27
+ nodePreGyp:
28
+ 'node-v' +
29
+ process.versions.modules +
30
+ '-' +
31
+ process.platform +
32
+ '-' +
33
+ process.arch,
34
+ version: process.versions.node,
35
+ bindings: 'bindings.node',
36
+ try: [
37
+ // node-gyp's linked version in the "build" dir
38
+ ['module_root', 'build', 'bindings'],
39
+ // node-waf and gyp_addon (a.k.a node-gyp)
40
+ ['module_root', 'build', 'Debug', 'bindings'],
41
+ ['module_root', 'build', 'Release', 'bindings'],
42
+ // Debug files, for development (legacy behavior, remove for node v0.9)
43
+ ['module_root', 'out', 'Debug', 'bindings'],
44
+ ['module_root', 'Debug', 'bindings'],
45
+ // Release files, but manually compiled (legacy behavior, remove for node v0.9)
46
+ ['module_root', 'out', 'Release', 'bindings'],
47
+ ['module_root', 'Release', 'bindings'],
48
+ // Legacy from node-waf, node <= 0.4.x
49
+ ['module_root', 'build', 'default', 'bindings'],
50
+ // Production "Release" buildtype binary (meh...)
51
+ ['module_root', 'compiled', 'version', 'platform', 'arch', 'bindings'],
52
+ // node-qbs builds
53
+ ['module_root', 'addon-build', 'release', 'install-root', 'bindings'],
54
+ ['module_root', 'addon-build', 'debug', 'install-root', 'bindings'],
55
+ ['module_root', 'addon-build', 'default', 'install-root', 'bindings'],
56
+ // node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
57
+ ['module_root', 'lib', 'binding', 'nodePreGyp', 'bindings']
58
+ ]
59
+ };
60
+
61
+ /**
62
+ * The main `bindings()` function loads the compiled bindings for a given module.
63
+ * It uses V8's Error API to determine the parent filename that this function is
64
+ * being invoked from, which is then used to find the root directory.
65
+ */
66
+
67
+ function bindings(opts) {
68
+ // Argument surgery
69
+ if (typeof opts == 'string') {
70
+ opts = { bindings: opts };
71
+ } else if (!opts) {
72
+ opts = {};
73
+ }
74
+
75
+ // maps `defaults` onto `opts` object
76
+ Object.keys(defaults).map(function(i) {
77
+ if (!(i in opts)) opts[i] = defaults[i];
78
+ });
79
+
80
+ // Get the module root
81
+ if (!opts.module_root) {
82
+ opts.module_root = exports.getRoot(exports.getFileName());
83
+ }
84
+
85
+ // Ensure the given bindings name ends with .node
86
+ if (path.extname(opts.bindings) != '.node') {
87
+ opts.bindings += '.node';
88
+ }
89
+
90
+ // https://github.com/webpack/webpack/issues/4175#issuecomment-342931035
91
+ var requireFunc =
92
+ typeof __webpack_require__ === 'function'
93
+ ? __non_webpack_require__
94
+ : require;
95
+
96
+ var tries = [],
97
+ i = 0,
98
+ l = opts.try.length,
99
+ n,
100
+ b,
101
+ err;
102
+
103
+ for (; i < l; i++) {
104
+ n = join.apply(
105
+ null,
106
+ opts.try[i].map(function(p) {
107
+ return opts[p] || p;
108
+ })
109
+ );
110
+ tries.push(n);
111
+ try {
112
+ b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
113
+ if (!opts.path) {
114
+ b.path = n;
115
+ }
116
+ return b;
117
+ } catch (e) {
118
+ if (e.code !== 'MODULE_NOT_FOUND' &&
119
+ e.code !== 'QUALIFIED_PATH_RESOLUTION_FAILED' &&
120
+ !/not find/i.test(e.message)) {
121
+ throw e;
122
+ }
123
+ }
124
+ }
125
+
126
+ err = new Error(
127
+ 'Could not locate the bindings file. Tried:\n' +
128
+ tries
129
+ .map(function(a) {
130
+ return opts.arrow + a;
131
+ })
132
+ .join('\n')
133
+ );
134
+ err.tries = tries;
135
+ throw err;
136
+ }
137
+ module.exports = exports = bindings;
138
+
139
+ /**
140
+ * Gets the filename of the JavaScript file that invokes this function.
141
+ * Used to help find the root directory of a module.
142
+ * Optionally accepts an filename argument to skip when searching for the invoking filename
143
+ */
144
+
145
+ exports.getFileName = function getFileName(calling_file) {
146
+ var origPST = Error.prepareStackTrace,
147
+ origSTL = Error.stackTraceLimit,
148
+ dummy = {},
149
+ fileName;
150
+
151
+ Error.stackTraceLimit = 10;
152
+
153
+ Error.prepareStackTrace = function(e, st) {
154
+ for (var i = 0, l = st.length; i < l; i++) {
155
+ fileName = st[i].getFileName();
156
+ if (fileName !== __filename) {
157
+ if (calling_file) {
158
+ if (fileName !== calling_file) {
159
+ return;
160
+ }
161
+ } else {
162
+ return;
163
+ }
164
+ }
165
+ }
166
+ };
167
+
168
+ // run the 'prepareStackTrace' function above
169
+ Error.captureStackTrace(dummy);
170
+ dummy.stack;
171
+
172
+ // cleanup
173
+ Error.prepareStackTrace = origPST;
174
+ Error.stackTraceLimit = origSTL;
175
+
176
+ // handle filename that starts with "file://"
177
+ var fileSchema = 'file://';
178
+ if (fileName.indexOf(fileSchema) === 0) {
179
+ fileName = fileURLToPath(fileName);
180
+ }
181
+
182
+ return fileName;
183
+ };
184
+
185
+ /**
186
+ * Gets the root directory of a module, given an arbitrary filename
187
+ * somewhere in the module tree. The "root directory" is the directory
188
+ * containing the `package.json` file.
189
+ *
190
+ * In: /home/nate/node-native-module/lib/index.js
191
+ * Out: /home/nate/node-native-module
192
+ */
193
+
194
+ exports.getRoot = function getRoot(file) {
195
+ var dir = dirname(file),
196
+ prev;
197
+ while (true) {
198
+ if (dir === '.') {
199
+ // Avoids an infinite loop in rare cases, like the REPL
200
+ dir = process.cwd();
201
+ }
202
+ if (
203
+ exists(join(dir, 'package.json')) ||
204
+ exists(join(dir, 'node_modules'))
205
+ ) {
206
+ // Found the 'package.json' file or 'node_modules' dir; we're done
207
+ return dir;
208
+ }
209
+ if (prev === dir) {
210
+ // Got to the top
211
+ throw new Error(
212
+ 'Could not find module root given file: "' +
213
+ file +
214
+ '". Do you have a `package.json` file? '
215
+ );
216
+ }
217
+ // Try the parent dir next
218
+ prev = dir;
219
+ dir = join(dir, '..');
220
+ }
221
+ };
node_modules/bindings/package.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "bindings",
3
+ "description": "Helper module for loading your native module's .node file",
4
+ "keywords": [
5
+ "native",
6
+ "addon",
7
+ "bindings",
8
+ "gyp",
9
+ "waf",
10
+ "c",
11
+ "c++"
12
+ ],
13
+ "version": "1.5.0",
14
+ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git://github.com/TooTallNate/node-bindings.git"
18
+ },
19
+ "main": "./bindings.js",
20
+ "bugs": {
21
+ "url": "https://github.com/TooTallNate/node-bindings/issues"
22
+ },
23
+ "homepage": "https://github.com/TooTallNate/node-bindings",
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "file-uri-to-path": "1.0.0"
27
+ }
28
+ }
node_modules/birpc/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/birpc/README.md ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # birpc
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/birpc?color=a1b858&label=)](https://www.npmjs.com/package/birpc)
4
+
5
+ Message-based two-way remote procedure call. Useful for WebSockets and Workers communication.
6
+
7
+ ## Features
8
+
9
+ - Intuitive - call remote functions just like locals, with Promise to get the response
10
+ - TypeScript - safe function calls for arguments and returns
11
+ - Protocol agonostic - WebSocket, MessageChannel, any protocols with messages communication would work!
12
+ - Zero deps, ~0.5KB
13
+
14
+ ## Examples
15
+
16
+ ### Using WebSocket
17
+
18
+ When using WebSocket, you need to pass your custom serializer and deserializer.
19
+
20
+ #### Client
21
+
22
+ ```ts
23
+ import type { ServerFunctions } from './types'
24
+
25
+ const ws = new WebSocket('ws://url')
26
+
27
+ const clientFunctions: ClientFunctions = {
28
+ hey(name: string) {
29
+ return `Hey ${name} from client`
30
+ }
31
+ }
32
+
33
+ const rpc = createBirpc<ServerFunctions>(
34
+ clientFunctions,
35
+ {
36
+ post: data => ws.send(data),
37
+ on: fn => ws.on('message', fn),
38
+ // these are required when using WebSocket
39
+ serialize: v => JSON.stringify(v),
40
+ deserialize: v => JSON.parse(v),
41
+ },
42
+ )
43
+
44
+ await rpc.hi('Client') // Hi Client from server
45
+ ```
46
+
47
+ #### Server
48
+
49
+ ```ts
50
+ import type { ClientFunctions } from './types'
51
+ import { WebSocketServer } from 'ws'
52
+
53
+ const serverFunctions: ServerFunctions = {
54
+ hi(name: string) {
55
+ return `Hi ${name} from server`
56
+ }
57
+ }
58
+
59
+ const wss = new WebSocketServer()
60
+
61
+ wss.on('connection', (ws) => {
62
+ const rpc = createBirpc<ClientFunctions>(
63
+ serverFunctions,
64
+ {
65
+ post: data => ws.send(data),
66
+ on: fn => ws.on('message', fn),
67
+ serialize: v => JSON.stringify(v),
68
+ deserialize: v => JSON.parse(v),
69
+ },
70
+ )
71
+
72
+ await rpc.hey('Server') // Hey Server from client
73
+ })
74
+ ```
75
+
76
+ ### Circular References
77
+
78
+ As `JSON.stringify` does not supporting circular references, we recommend using [`structured-clone-es`](https://github.com/antfu/structured-clone-es) as the serializer when you expect to have circular references.
79
+
80
+ ```ts
81
+ import { parse, stringify } from 'structured-clone-es'
82
+
83
+ const rpc = createBirpc<ServerFunctions>(
84
+ functions,
85
+ {
86
+ post: data => ws.send(data),
87
+ on: fn => ws.on('message', fn),
88
+ // use structured-clone-es as serializer
89
+ serialize: v => stringify(v),
90
+ deserialize: v => parse(v),
91
+ },
92
+ )
93
+ ```
94
+
95
+ ### Using MessageChannel
96
+
97
+ [MessageChannel](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel) will automatically serialize the message and support circular references out-of-box.
98
+
99
+ ```ts
100
+ export const channel = new MessageChannel()
101
+ ```
102
+
103
+ #### Bob
104
+
105
+ ``` ts
106
+ import type { AliceFunctions } from './types'
107
+ import { channel } from './channel'
108
+
109
+ const Bob: BobFunctions = {
110
+ hey(name: string) {
111
+ return `Hey ${name}, I am Bob`
112
+ }
113
+ }
114
+
115
+ const rpc = createBirpc<AliceFunctions>(
116
+ Bob,
117
+ {
118
+ post: data => channel.port1.postMessage(data),
119
+ on: fn => channel.port1.on('message', fn),
120
+ },
121
+ )
122
+
123
+ await rpc.hi('Bob') // Hi Bob, I am Alice
124
+ ```
125
+
126
+ #### Alice
127
+
128
+ ``` ts
129
+ import type { BobFunctions } from './types'
130
+ import { channel } from './channel'
131
+
132
+ const Alice: AliceFunctions = {
133
+ hi(name: string) {
134
+ return `Hi ${name}, I am Alice`
135
+ }
136
+ }
137
+
138
+ const rpc = createBirpc<BobFunctions>(
139
+ Alice,
140
+ {
141
+ post: data => channel.port2.postMessage(data),
142
+ on: fn => channel.port2.on('message', fn),
143
+ },
144
+ )
145
+
146
+ await rpc.hey('Alice') // Hey Alice, I am Bob
147
+ ```
148
+
149
+ ### One-to-multiple Communication
150
+
151
+ Refer to [./test/group.test.ts](./test/group.test.ts) as an example.
152
+
153
+ ## Sponsors
154
+
155
+ <p align="center">
156
+ <a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
157
+ <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
158
+ </a>
159
+ </p>
160
+
161
+ ## License
162
+
163
+ [MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)
node_modules/birpc/package.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "birpc",
3
+ "type": "module",
4
+ "version": "4.0.0",
5
+ "description": "Message based Two-way remote procedure call",
6
+ "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
+ "license": "MIT",
8
+ "funding": "https://github.com/sponsors/antfu",
9
+ "homepage": "https://github.com/antfu-collective/birpc#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/antfu-collective/birpc.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/antfu-collective/birpc/issues"
16
+ },
17
+ "keywords": [
18
+ "rpc",
19
+ "messages"
20
+ ],
21
+ "sideEffects": false,
22
+ "exports": {
23
+ ".": "./dist/index.mjs",
24
+ "./package.json": "./package.json"
25
+ },
26
+ "main": "./dist/index.mjs",
27
+ "module": "./dist/index.mjs",
28
+ "types": "./dist/index.d.mts",
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "devDependencies": {
33
+ "@antfu/eslint-config": "^6.3.0",
34
+ "@antfu/ni": "^28.0.0",
35
+ "@types/node": "^24.10.1",
36
+ "@vitest/coverage-v8": "^4.0.15",
37
+ "bumpp": "^10.3.2",
38
+ "eslint": "^9.39.1",
39
+ "tinyexec": "^1.0.2",
40
+ "tsdown": "0.17.0-beta.5",
41
+ "tsx": "^4.21.0",
42
+ "typescript": "^5.9.3",
43
+ "vite": "^7.2.6",
44
+ "vitest": "^4.0.15",
45
+ "vitest-package-exports": "^0.1.1",
46
+ "yaml": "^2.8.2"
47
+ },
48
+ "scripts": {
49
+ "build": "tsdown",
50
+ "watch": "tsdown --watch",
51
+ "lint": "eslint .",
52
+ "release": "bumpp",
53
+ "start": "tsx src/index.ts",
54
+ "typecheck": "tsc --noEmit",
55
+ "test": "vitest"
56
+ }
57
+ }
node_modules/bl/.travis.yml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ sudo: false
2
+ arch:
3
+ - amd64
4
+ - ppc64le
5
+ language: node_js
6
+ node_js:
7
+ - '6'
8
+ - '8'
9
+ - '10'
10
+ - '12'
11
+ - '14'
12
+ - '15'
13
+ - lts/*
14
+ notifications:
15
+ email:
16
+ - rod@vagg.org
17
+ - matteo.collina@gmail.com
node_modules/bl/BufferList.js ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const { Buffer } = require('buffer')
4
+ const symbol = Symbol.for('BufferList')
5
+
6
+ function BufferList (buf) {
7
+ if (!(this instanceof BufferList)) {
8
+ return new BufferList(buf)
9
+ }
10
+
11
+ BufferList._init.call(this, buf)
12
+ }
13
+
14
+ BufferList._init = function _init (buf) {
15
+ Object.defineProperty(this, symbol, { value: true })
16
+
17
+ this._bufs = []
18
+ this.length = 0
19
+
20
+ if (buf) {
21
+ this.append(buf)
22
+ }
23
+ }
24
+
25
+ BufferList.prototype._new = function _new (buf) {
26
+ return new BufferList(buf)
27
+ }
28
+
29
+ BufferList.prototype._offset = function _offset (offset) {
30
+ if (offset === 0) {
31
+ return [0, 0]
32
+ }
33
+
34
+ let tot = 0
35
+
36
+ for (let i = 0; i < this._bufs.length; i++) {
37
+ const _t = tot + this._bufs[i].length
38
+ if (offset < _t || i === this._bufs.length - 1) {
39
+ return [i, offset - tot]
40
+ }
41
+ tot = _t
42
+ }
43
+ }
44
+
45
+ BufferList.prototype._reverseOffset = function (blOffset) {
46
+ const bufferId = blOffset[0]
47
+ let offset = blOffset[1]
48
+
49
+ for (let i = 0; i < bufferId; i++) {
50
+ offset += this._bufs[i].length
51
+ }
52
+
53
+ return offset
54
+ }
55
+
56
+ BufferList.prototype.get = function get (index) {
57
+ if (index > this.length || index < 0) {
58
+ return undefined
59
+ }
60
+
61
+ const offset = this._offset(index)
62
+
63
+ return this._bufs[offset[0]][offset[1]]
64
+ }
65
+
66
+ BufferList.prototype.slice = function slice (start, end) {
67
+ if (typeof start === 'number' && start < 0) {
68
+ start += this.length
69
+ }
70
+
71
+ if (typeof end === 'number' && end < 0) {
72
+ end += this.length
73
+ }
74
+
75
+ return this.copy(null, 0, start, end)
76
+ }
77
+
78
+ BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
79
+ if (typeof srcStart !== 'number' || srcStart < 0) {
80
+ srcStart = 0
81
+ }
82
+
83
+ if (typeof srcEnd !== 'number' || srcEnd > this.length) {
84
+ srcEnd = this.length
85
+ }
86
+
87
+ if (srcStart >= this.length) {
88
+ return dst || Buffer.alloc(0)
89
+ }
90
+
91
+ if (srcEnd <= 0) {
92
+ return dst || Buffer.alloc(0)
93
+ }
94
+
95
+ const copy = !!dst
96
+ const off = this._offset(srcStart)
97
+ const len = srcEnd - srcStart
98
+ let bytes = len
99
+ let bufoff = (copy && dstStart) || 0
100
+ let start = off[1]
101
+
102
+ // copy/slice everything
103
+ if (srcStart === 0 && srcEnd === this.length) {
104
+ if (!copy) {
105
+ // slice, but full concat if multiple buffers
106
+ return this._bufs.length === 1
107
+ ? this._bufs[0]
108
+ : Buffer.concat(this._bufs, this.length)
109
+ }
110
+
111
+ // copy, need to copy individual buffers
112
+ for (let i = 0; i < this._bufs.length; i++) {
113
+ this._bufs[i].copy(dst, bufoff)
114
+ bufoff += this._bufs[i].length
115
+ }
116
+
117
+ return dst
118
+ }
119
+
120
+ // easy, cheap case where it's a subset of one of the buffers
121
+ if (bytes <= this._bufs[off[0]].length - start) {
122
+ return copy
123
+ ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
124
+ : this._bufs[off[0]].slice(start, start + bytes)
125
+ }
126
+
127
+ if (!copy) {
128
+ // a slice, we need something to copy in to
129
+ dst = Buffer.allocUnsafe(len)
130
+ }
131
+
132
+ for (let i = off[0]; i < this._bufs.length; i++) {
133
+ const l = this._bufs[i].length - start
134
+
135
+ if (bytes > l) {
136
+ this._bufs[i].copy(dst, bufoff, start)
137
+ bufoff += l
138
+ } else {
139
+ this._bufs[i].copy(dst, bufoff, start, start + bytes)
140
+ bufoff += l
141
+ break
142
+ }
143
+
144
+ bytes -= l
145
+
146
+ if (start) {
147
+ start = 0
148
+ }
149
+ }
150
+
151
+ // safeguard so that we don't return uninitialized memory
152
+ if (dst.length > bufoff) return dst.slice(0, bufoff)
153
+
154
+ return dst
155
+ }
156
+
157
+ BufferList.prototype.shallowSlice = function shallowSlice (start, end) {
158
+ start = start || 0
159
+ end = typeof end !== 'number' ? this.length : end
160
+
161
+ if (start < 0) {
162
+ start += this.length
163
+ }
164
+
165
+ if (end < 0) {
166
+ end += this.length
167
+ }
168
+
169
+ if (start === end) {
170
+ return this._new()
171
+ }
172
+
173
+ const startOffset = this._offset(start)
174
+ const endOffset = this._offset(end)
175
+ const buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)
176
+
177
+ if (endOffset[1] === 0) {
178
+ buffers.pop()
179
+ } else {
180
+ buffers[buffers.length - 1] = buffers[buffers.length - 1].slice(0, endOffset[1])
181
+ }
182
+
183
+ if (startOffset[1] !== 0) {
184
+ buffers[0] = buffers[0].slice(startOffset[1])
185
+ }
186
+
187
+ return this._new(buffers)
188
+ }
189
+
190
+ BufferList.prototype.toString = function toString (encoding, start, end) {
191
+ return this.slice(start, end).toString(encoding)
192
+ }
193
+
194
+ BufferList.prototype.consume = function consume (bytes) {
195
+ // first, normalize the argument, in accordance with how Buffer does it
196
+ bytes = Math.trunc(bytes)
197
+ // do nothing if not a positive number
198
+ if (Number.isNaN(bytes) || bytes <= 0) return this
199
+
200
+ while (this._bufs.length) {
201
+ if (bytes >= this._bufs[0].length) {
202
+ bytes -= this._bufs[0].length
203
+ this.length -= this._bufs[0].length
204
+ this._bufs.shift()
205
+ } else {
206
+ this._bufs[0] = this._bufs[0].slice(bytes)
207
+ this.length -= bytes
208
+ break
209
+ }
210
+ }
211
+
212
+ return this
213
+ }
214
+
215
+ BufferList.prototype.duplicate = function duplicate () {
216
+ const copy = this._new()
217
+
218
+ for (let i = 0; i < this._bufs.length; i++) {
219
+ copy.append(this._bufs[i])
220
+ }
221
+
222
+ return copy
223
+ }
224
+
225
+ BufferList.prototype.append = function append (buf) {
226
+ if (buf == null) {
227
+ return this
228
+ }
229
+
230
+ if (buf.buffer) {
231
+ // append a view of the underlying ArrayBuffer
232
+ this._appendBuffer(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength))
233
+ } else if (Array.isArray(buf)) {
234
+ for (let i = 0; i < buf.length; i++) {
235
+ this.append(buf[i])
236
+ }
237
+ } else if (this._isBufferList(buf)) {
238
+ // unwrap argument into individual BufferLists
239
+ for (let i = 0; i < buf._bufs.length; i++) {
240
+ this.append(buf._bufs[i])
241
+ }
242
+ } else {
243
+ // coerce number arguments to strings, since Buffer(number) does
244
+ // uninitialized memory allocation
245
+ if (typeof buf === 'number') {
246
+ buf = buf.toString()
247
+ }
248
+
249
+ this._appendBuffer(Buffer.from(buf))
250
+ }
251
+
252
+ return this
253
+ }
254
+
255
+ BufferList.prototype._appendBuffer = function appendBuffer (buf) {
256
+ this._bufs.push(buf)
257
+ this.length += buf.length
258
+ }
259
+
260
+ BufferList.prototype.indexOf = function (search, offset, encoding) {
261
+ if (encoding === undefined && typeof offset === 'string') {
262
+ encoding = offset
263
+ offset = undefined
264
+ }
265
+
266
+ if (typeof search === 'function' || Array.isArray(search)) {
267
+ throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.')
268
+ } else if (typeof search === 'number') {
269
+ search = Buffer.from([search])
270
+ } else if (typeof search === 'string') {
271
+ search = Buffer.from(search, encoding)
272
+ } else if (this._isBufferList(search)) {
273
+ search = search.slice()
274
+ } else if (Array.isArray(search.buffer)) {
275
+ search = Buffer.from(search.buffer, search.byteOffset, search.byteLength)
276
+ } else if (!Buffer.isBuffer(search)) {
277
+ search = Buffer.from(search)
278
+ }
279
+
280
+ offset = Number(offset || 0)
281
+
282
+ if (isNaN(offset)) {
283
+ offset = 0
284
+ }
285
+
286
+ if (offset < 0) {
287
+ offset = this.length + offset
288
+ }
289
+
290
+ if (offset < 0) {
291
+ offset = 0
292
+ }
293
+
294
+ if (search.length === 0) {
295
+ return offset > this.length ? this.length : offset
296
+ }
297
+
298
+ const blOffset = this._offset(offset)
299
+ let blIndex = blOffset[0] // index of which internal buffer we're working on
300
+ let buffOffset = blOffset[1] // offset of the internal buffer we're working on
301
+
302
+ // scan over each buffer
303
+ for (; blIndex < this._bufs.length; blIndex++) {
304
+ const buff = this._bufs[blIndex]
305
+
306
+ while (buffOffset < buff.length) {
307
+ const availableWindow = buff.length - buffOffset
308
+
309
+ if (availableWindow >= search.length) {
310
+ const nativeSearchResult = buff.indexOf(search, buffOffset)
311
+
312
+ if (nativeSearchResult !== -1) {
313
+ return this._reverseOffset([blIndex, nativeSearchResult])
314
+ }
315
+
316
+ buffOffset = buff.length - search.length + 1 // end of native search window
317
+ } else {
318
+ const revOffset = this._reverseOffset([blIndex, buffOffset])
319
+
320
+ if (this._match(revOffset, search)) {
321
+ return revOffset
322
+ }
323
+
324
+ buffOffset++
325
+ }
326
+ }
327
+
328
+ buffOffset = 0
329
+ }
330
+
331
+ return -1
332
+ }
333
+
334
+ BufferList.prototype._match = function (offset, search) {
335
+ if (this.length - offset < search.length) {
336
+ return false
337
+ }
338
+
339
+ for (let searchOffset = 0; searchOffset < search.length; searchOffset++) {
340
+ if (this.get(offset + searchOffset) !== search[searchOffset]) {
341
+ return false
342
+ }
343
+ }
344
+ return true
345
+ }
346
+
347
+ ;(function () {
348
+ const methods = {
349
+ readDoubleBE: 8,
350
+ readDoubleLE: 8,
351
+ readFloatBE: 4,
352
+ readFloatLE: 4,
353
+ readInt32BE: 4,
354
+ readInt32LE: 4,
355
+ readUInt32BE: 4,
356
+ readUInt32LE: 4,
357
+ readInt16BE: 2,
358
+ readInt16LE: 2,
359
+ readUInt16BE: 2,
360
+ readUInt16LE: 2,
361
+ readInt8: 1,
362
+ readUInt8: 1,
363
+ readIntBE: null,
364
+ readIntLE: null,
365
+ readUIntBE: null,
366
+ readUIntLE: null
367
+ }
368
+
369
+ for (const m in methods) {
370
+ (function (m) {
371
+ if (methods[m] === null) {
372
+ BufferList.prototype[m] = function (offset, byteLength) {
373
+ return this.slice(offset, offset + byteLength)[m](0, byteLength)
374
+ }
375
+ } else {
376
+ BufferList.prototype[m] = function (offset = 0) {
377
+ return this.slice(offset, offset + methods[m])[m](0)
378
+ }
379
+ }
380
+ }(m))
381
+ }
382
+ }())
383
+
384
+ // Used internally by the class and also as an indicator of this object being
385
+ // a `BufferList`. It's not possible to use `instanceof BufferList` in a browser
386
+ // environment because there could be multiple different copies of the
387
+ // BufferList class and some `BufferList`s might be `BufferList`s.
388
+ BufferList.prototype._isBufferList = function _isBufferList (b) {
389
+ return b instanceof BufferList || BufferList.isBufferList(b)
390
+ }
391
+
392
+ BufferList.isBufferList = function isBufferList (b) {
393
+ return b != null && b[symbol]
394
+ }
395
+
396
+ module.exports = BufferList
node_modules/bl/LICENSE.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+ =====================
3
+
4
+ Copyright (c) 2013-2019 bl contributors
5
+ ----------------------------------
6
+
7
+ *bl contributors listed at <https://github.com/rvagg/bl#contributors>*
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/bl/README.md ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bl *(BufferList)*
2
+
3
+ [![Build Status](https://api.travis-ci.com/rvagg/bl.svg?branch=master)](https://travis-ci.com/rvagg/bl/)
4
+
5
+ **A Node.js Buffer list collector, reader and streamer thingy.**
6
+
7
+ [![NPM](https://nodei.co/npm/bl.svg)](https://nodei.co/npm/bl/)
8
+
9
+ **bl** is a storage object for collections of Node Buffers, exposing them with the main Buffer readable API. Also works as a duplex stream so you can collect buffers from a stream that emits them and emit buffers to a stream that consumes them!
10
+
11
+ The original buffers are kept intact and copies are only done as necessary. Any reads that require the use of a single original buffer will return a slice of that buffer only (which references the same memory as the original buffer). Reads that span buffers perform concatenation as required and return the results transparently.
12
+
13
+ ```js
14
+ const { BufferList } = require('bl')
15
+
16
+ const bl = new BufferList()
17
+ bl.append(Buffer.from('abcd'))
18
+ bl.append(Buffer.from('efg'))
19
+ bl.append('hi') // bl will also accept & convert Strings
20
+ bl.append(Buffer.from('j'))
21
+ bl.append(Buffer.from([ 0x3, 0x4 ]))
22
+
23
+ console.log(bl.length) // 12
24
+
25
+ console.log(bl.slice(0, 10).toString('ascii')) // 'abcdefghij'
26
+ console.log(bl.slice(3, 10).toString('ascii')) // 'defghij'
27
+ console.log(bl.slice(3, 6).toString('ascii')) // 'def'
28
+ console.log(bl.slice(3, 8).toString('ascii')) // 'defgh'
29
+ console.log(bl.slice(5, 10).toString('ascii')) // 'fghij'
30
+
31
+ console.log(bl.indexOf('def')) // 3
32
+ console.log(bl.indexOf('asdf')) // -1
33
+
34
+ // or just use toString!
35
+ console.log(bl.toString()) // 'abcdefghij\u0003\u0004'
36
+ console.log(bl.toString('ascii', 3, 8)) // 'defgh'
37
+ console.log(bl.toString('ascii', 5, 10)) // 'fghij'
38
+
39
+ // other standard Buffer readables
40
+ console.log(bl.readUInt16BE(10)) // 0x0304
41
+ console.log(bl.readUInt16LE(10)) // 0x0403
42
+ ```
43
+
44
+ Give it a callback in the constructor and use it just like **[concat-stream](https://github.com/maxogden/node-concat-stream)**:
45
+
46
+ ```js
47
+ const { BufferListStream } = require('bl')
48
+ const fs = require('fs')
49
+
50
+ fs.createReadStream('README.md')
51
+ .pipe(BufferListStream((err, data) => { // note 'new' isn't strictly required
52
+ // `data` is a complete Buffer object containing the full data
53
+ console.log(data.toString())
54
+ }))
55
+ ```
56
+
57
+ Note that when you use the *callback* method like this, the resulting `data` parameter is a concatenation of all `Buffer` objects in the list. If you want to avoid the overhead of this concatenation (in cases of extreme performance consciousness), then avoid the *callback* method and just listen to `'end'` instead, like a standard Stream.
58
+
59
+ Or to fetch a URL using [hyperquest](https://github.com/substack/hyperquest) (should work with [request](http://github.com/mikeal/request) and even plain Node http too!):
60
+
61
+ ```js
62
+ const hyperquest = require('hyperquest')
63
+ const { BufferListStream } = require('bl')
64
+
65
+ const url = 'https://raw.github.com/rvagg/bl/master/README.md'
66
+
67
+ hyperquest(url).pipe(BufferListStream((err, data) => {
68
+ console.log(data.toString())
69
+ }))
70
+ ```
71
+
72
+ Or, use it as a readable stream to recompose a list of Buffers to an output source:
73
+
74
+ ```js
75
+ const { BufferListStream } = require('bl')
76
+ const fs = require('fs')
77
+
78
+ var bl = new BufferListStream()
79
+ bl.append(Buffer.from('abcd'))
80
+ bl.append(Buffer.from('efg'))
81
+ bl.append(Buffer.from('hi'))
82
+ bl.append(Buffer.from('j'))
83
+
84
+ bl.pipe(fs.createWriteStream('gibberish.txt'))
85
+ ```
86
+
87
+ ## API
88
+
89
+ * <a href="#ctor"><code><b>new BufferList([ buf ])</b></code></a>
90
+ * <a href="#isBufferList"><code><b>BufferList.isBufferList(obj)</b></code></a>
91
+ * <a href="#length"><code>bl.<b>length</b></code></a>
92
+ * <a href="#append"><code>bl.<b>append(buffer)</b></code></a>
93
+ * <a href="#get"><code>bl.<b>get(index)</b></code></a>
94
+ * <a href="#indexOf"><code>bl.<b>indexOf(value[, byteOffset][, encoding])</b></code></a>
95
+ * <a href="#slice"><code>bl.<b>slice([ start[, end ] ])</b></code></a>
96
+ * <a href="#shallowSlice"><code>bl.<b>shallowSlice([ start[, end ] ])</b></code></a>
97
+ * <a href="#copy"><code>bl.<b>copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])</b></code></a>
98
+ * <a href="#duplicate"><code>bl.<b>duplicate()</b></code></a>
99
+ * <a href="#consume"><code>bl.<b>consume(bytes)</b></code></a>
100
+ * <a href="#toString"><code>bl.<b>toString([encoding, [ start, [ end ]]])</b></code></a>
101
+ * <a href="#readXX"><code>bl.<b>readDoubleBE()</b></code>, <code>bl.<b>readDoubleLE()</b></code>, <code>bl.<b>readFloatBE()</b></code>, <code>bl.<b>readFloatLE()</b></code>, <code>bl.<b>readInt32BE()</b></code>, <code>bl.<b>readInt32LE()</b></code>, <code>bl.<b>readUInt32BE()</b></code>, <code>bl.<b>readUInt32LE()</b></code>, <code>bl.<b>readInt16BE()</b></code>, <code>bl.<b>readInt16LE()</b></code>, <code>bl.<b>readUInt16BE()</b></code>, <code>bl.<b>readUInt16LE()</b></code>, <code>bl.<b>readInt8()</b></code>, <code>bl.<b>readUInt8()</b></code></a>
102
+ * <a href="#ctorStream"><code><b>new BufferListStream([ callback ])</b></code></a>
103
+
104
+ --------------------------------------------------------
105
+ <a name="ctor"></a>
106
+ ### new BufferList([ Buffer | Buffer array | BufferList | BufferList array | String ])
107
+ No arguments are _required_ for the constructor, but you can initialise the list by passing in a single `Buffer` object or an array of `Buffer` objects.
108
+
109
+ `new` is not strictly required, if you don't instantiate a new object, it will be done automatically for you so you can create a new instance simply with:
110
+
111
+ ```js
112
+ const { BufferList } = require('bl')
113
+ const bl = BufferList()
114
+
115
+ // equivalent to:
116
+
117
+ const { BufferList } = require('bl')
118
+ const bl = new BufferList()
119
+ ```
120
+
121
+ --------------------------------------------------------
122
+ <a name="isBufferList"></a>
123
+ ### BufferList.isBufferList(obj)
124
+ Determines if the passed object is a `BufferList`. It will return `true` if the passed object is an instance of `BufferList` **or** `BufferListStream` and `false` otherwise.
125
+
126
+ N.B. this won't return `true` for `BufferList` or `BufferListStream` instances created by versions of this library before this static method was added.
127
+
128
+ --------------------------------------------------------
129
+ <a name="length"></a>
130
+ ### bl.length
131
+ Get the length of the list in bytes. This is the sum of the lengths of all of the buffers contained in the list, minus any initial offset for a semi-consumed buffer at the beginning. Should accurately represent the total number of bytes that can be read from the list.
132
+
133
+ --------------------------------------------------------
134
+ <a name="append"></a>
135
+ ### bl.append(Buffer | Buffer array | BufferList | BufferList array | String)
136
+ `append(buffer)` adds an additional buffer or BufferList to the internal list. `this` is returned so it can be chained.
137
+
138
+ --------------------------------------------------------
139
+ <a name="get"></a>
140
+ ### bl.get(index)
141
+ `get()` will return the byte at the specified index.
142
+
143
+ --------------------------------------------------------
144
+ <a name="indexOf"></a>
145
+ ### bl.indexOf(value[, byteOffset][, encoding])
146
+ `get()` will return the byte at the specified index.
147
+ `indexOf()` method returns the first index at which a given element can be found in the BufferList, or -1 if it is not present.
148
+
149
+ --------------------------------------------------------
150
+ <a name="slice"></a>
151
+ ### bl.slice([ start, [ end ] ])
152
+ `slice()` returns a new `Buffer` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.
153
+
154
+ If the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer.
155
+
156
+ --------------------------------------------------------
157
+ <a name="shallowSlice"></a>
158
+ ### bl.shallowSlice([ start, [ end ] ])
159
+ `shallowSlice()` returns a new `BufferList` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.
160
+
161
+ No copies will be performed. All buffers in the result share memory with the original list.
162
+
163
+ --------------------------------------------------------
164
+ <a name="copy"></a>
165
+ ### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])
166
+ `copy()` copies the content of the list in the `dest` buffer, starting from `destStart` and containing the bytes within the range specified with `srcStart` to `srcEnd`. `destStart`, `start` and `end` are optional and will default to the beginning of the `dest` buffer, and the beginning and end of the list respectively.
167
+
168
+ --------------------------------------------------------
169
+ <a name="duplicate"></a>
170
+ ### bl.duplicate()
171
+ `duplicate()` performs a **shallow-copy** of the list. The internal Buffers remains the same, so if you change the underlying Buffers, the change will be reflected in both the original and the duplicate. This method is needed if you want to call `consume()` or `pipe()` and still keep the original list.Example:
172
+
173
+ ```js
174
+ var bl = new BufferListStream()
175
+
176
+ bl.append('hello')
177
+ bl.append(' world')
178
+ bl.append('\n')
179
+
180
+ bl.duplicate().pipe(process.stdout, { end: false })
181
+
182
+ console.log(bl.toString())
183
+ ```
184
+
185
+ --------------------------------------------------------
186
+ <a name="consume"></a>
187
+ ### bl.consume(bytes)
188
+ `consume()` will shift bytes *off the start of the list*. The number of bytes consumed don't need to line up with the sizes of the internal Buffers&mdash;initial offsets will be calculated accordingly in order to give you a consistent view of the data.
189
+
190
+ --------------------------------------------------------
191
+ <a name="toString"></a>
192
+ ### bl.toString([encoding, [ start, [ end ]]])
193
+ `toString()` will return a string representation of the buffer. The optional `start` and `end` arguments are passed on to `slice()`, while the `encoding` is passed on to `toString()` of the resulting Buffer. See the [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end) documentation for more information.
194
+
195
+ --------------------------------------------------------
196
+ <a name="readXX"></a>
197
+ ### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8()
198
+
199
+ All of the standard byte-reading methods of the `Buffer` interface are implemented and will operate across internal Buffer boundaries transparently.
200
+
201
+ See the <b><code>[Buffer](http://nodejs.org/docs/latest/api/buffer.html)</code></b> documentation for how these work.
202
+
203
+ --------------------------------------------------------
204
+ <a name="ctorStream"></a>
205
+ ### new BufferListStream([ callback | Buffer | Buffer array | BufferList | BufferList array | String ])
206
+ **BufferListStream** is a Node **[Duplex Stream](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_duplex)**, so it can be read from and written to like a standard Node stream. You can also `pipe()` to and from a **BufferListStream** instance.
207
+
208
+ The constructor takes an optional callback, if supplied, the callback will be called with an error argument followed by a reference to the **bl** instance, when `bl.end()` is called (i.e. from a piped stream). This is a convenient method of collecting the entire contents of a stream, particularly when the stream is *chunky*, such as a network stream.
209
+
210
+ Normally, no arguments are required for the constructor, but you can initialise the list by passing in a single `Buffer` object or an array of `Buffer` object.
211
+
212
+ `new` is not strictly required, if you don't instantiate a new object, it will be done automatically for you so you can create a new instance simply with:
213
+
214
+ ```js
215
+ const { BufferListStream } = require('bl')
216
+ const bl = BufferListStream()
217
+
218
+ // equivalent to:
219
+
220
+ const { BufferListStream } = require('bl')
221
+ const bl = new BufferListStream()
222
+ ```
223
+
224
+ N.B. For backwards compatibility reasons, `BufferListStream` is the **default** export when you `require('bl')`:
225
+
226
+ ```js
227
+ const { BufferListStream } = require('bl')
228
+ // equivalent to:
229
+ const BufferListStream = require('bl')
230
+ ```
231
+
232
+ --------------------------------------------------------
233
+
234
+ ## Contributors
235
+
236
+ **bl** is brought to you by the following hackers:
237
+
238
+ * [Rod Vagg](https://github.com/rvagg)
239
+ * [Matteo Collina](https://github.com/mcollina)
240
+ * [Jarett Cruger](https://github.com/jcrugzz)
241
+
242
+ <a name="license"></a>
243
+ ## License &amp; copyright
244
+
245
+ Copyright (c) 2013-2019 bl contributors (listed above).
246
+
247
+ bl is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.
node_modules/bl/bl.js ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const DuplexStream = require('readable-stream').Duplex
4
+ const inherits = require('inherits')
5
+ const BufferList = require('./BufferList')
6
+
7
+ function BufferListStream (callback) {
8
+ if (!(this instanceof BufferListStream)) {
9
+ return new BufferListStream(callback)
10
+ }
11
+
12
+ if (typeof callback === 'function') {
13
+ this._callback = callback
14
+
15
+ const piper = function piper (err) {
16
+ if (this._callback) {
17
+ this._callback(err)
18
+ this._callback = null
19
+ }
20
+ }.bind(this)
21
+
22
+ this.on('pipe', function onPipe (src) {
23
+ src.on('error', piper)
24
+ })
25
+ this.on('unpipe', function onUnpipe (src) {
26
+ src.removeListener('error', piper)
27
+ })
28
+
29
+ callback = null
30
+ }
31
+
32
+ BufferList._init.call(this, callback)
33
+ DuplexStream.call(this)
34
+ }
35
+
36
+ inherits(BufferListStream, DuplexStream)
37
+ Object.assign(BufferListStream.prototype, BufferList.prototype)
38
+
39
+ BufferListStream.prototype._new = function _new (callback) {
40
+ return new BufferListStream(callback)
41
+ }
42
+
43
+ BufferListStream.prototype._write = function _write (buf, encoding, callback) {
44
+ this._appendBuffer(buf)
45
+
46
+ if (typeof callback === 'function') {
47
+ callback()
48
+ }
49
+ }
50
+
51
+ BufferListStream.prototype._read = function _read (size) {
52
+ if (!this.length) {
53
+ return this.push(null)
54
+ }
55
+
56
+ size = Math.min(size, this.length)
57
+ this.push(this.slice(0, size))
58
+ this.consume(size)
59
+ }
60
+
61
+ BufferListStream.prototype.end = function end (chunk) {
62
+ DuplexStream.prototype.end.call(this, chunk)
63
+
64
+ if (this._callback) {
65
+ this._callback(null, this.slice())
66
+ this._callback = null
67
+ }
68
+ }
69
+
70
+ BufferListStream.prototype._destroy = function _destroy (err, cb) {
71
+ this._bufs.length = 0
72
+ this.length = 0
73
+ cb(err)
74
+ }
75
+
76
+ BufferListStream.prototype._isBufferList = function _isBufferList (b) {
77
+ return b instanceof BufferListStream || b instanceof BufferList || BufferListStream.isBufferList(b)
78
+ }
79
+
80
+ BufferListStream.isBufferList = BufferList.isBufferList
81
+
82
+ module.exports = BufferListStream
83
+ module.exports.BufferListStream = BufferListStream
84
+ module.exports.BufferList = BufferList
node_modules/bl/package.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "bl",
3
+ "version": "4.1.0",
4
+ "description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!",
5
+ "license": "MIT",
6
+ "main": "bl.js",
7
+ "scripts": {
8
+ "lint": "standard *.js test/*.js",
9
+ "test": "npm run lint && node test/test.js | faucet"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/rvagg/bl.git"
14
+ },
15
+ "homepage": "https://github.com/rvagg/bl",
16
+ "authors": [
17
+ "Rod Vagg <rod@vagg.org> (https://github.com/rvagg)",
18
+ "Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
19
+ "Jarett Cruger <jcrugzz@gmail.com> (https://github.com/jcrugzz)"
20
+ ],
21
+ "keywords": [
22
+ "buffer",
23
+ "buffers",
24
+ "stream",
25
+ "awesomesauce"
26
+ ],
27
+ "dependencies": {
28
+ "buffer": "^5.5.0",
29
+ "inherits": "^2.0.4",
30
+ "readable-stream": "^3.4.0"
31
+ },
32
+ "devDependencies": {
33
+ "faucet": "~0.0.1",
34
+ "standard": "^14.3.0",
35
+ "tape": "^4.11.0"
36
+ }
37
+ }
node_modules/bl/test/convert.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const tape = require('tape')
4
+ const { BufferList, BufferListStream } = require('../')
5
+ const { Buffer } = require('buffer')
6
+
7
+ tape('convert from BufferList to BufferListStream', (t) => {
8
+ const data = Buffer.from(`TEST-${Date.now()}`)
9
+ const bl = new BufferList(data)
10
+ const bls = new BufferListStream(bl)
11
+ t.ok(bl.slice().equals(bls.slice()))
12
+ t.end()
13
+ })
14
+
15
+ tape('convert from BufferListStream to BufferList', (t) => {
16
+ const data = Buffer.from(`TEST-${Date.now()}`)
17
+ const bls = new BufferListStream(data)
18
+ const bl = new BufferList(bls)
19
+ t.ok(bl.slice().equals(bls.slice()))
20
+ t.end()
21
+ })
node_modules/bl/test/indexOf.js ADDED
@@ -0,0 +1,492 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const tape = require('tape')
4
+ const BufferList = require('../')
5
+ const { Buffer } = require('buffer')
6
+
7
+ tape('indexOf single byte needle', (t) => {
8
+ const bl = new BufferList(['abcdefg', 'abcdefg', '12345'])
9
+
10
+ t.equal(bl.indexOf('e'), 4)
11
+ t.equal(bl.indexOf('e', 5), 11)
12
+ t.equal(bl.indexOf('e', 12), -1)
13
+ t.equal(bl.indexOf('5'), 18)
14
+
15
+ t.end()
16
+ })
17
+
18
+ tape('indexOf multiple byte needle', (t) => {
19
+ const bl = new BufferList(['abcdefg', 'abcdefg'])
20
+
21
+ t.equal(bl.indexOf('ef'), 4)
22
+ t.equal(bl.indexOf('ef', 5), 11)
23
+
24
+ t.end()
25
+ })
26
+
27
+ tape('indexOf multiple byte needles across buffer boundaries', (t) => {
28
+ const bl = new BufferList(['abcdefg', 'abcdefg'])
29
+
30
+ t.equal(bl.indexOf('fgabc'), 5)
31
+
32
+ t.end()
33
+ })
34
+
35
+ tape('indexOf takes a Uint8Array search', (t) => {
36
+ const bl = new BufferList(['abcdefg', 'abcdefg'])
37
+ const search = new Uint8Array([102, 103, 97, 98, 99]) // fgabc
38
+
39
+ t.equal(bl.indexOf(search), 5)
40
+
41
+ t.end()
42
+ })
43
+
44
+ tape('indexOf takes a buffer list search', (t) => {
45
+ const bl = new BufferList(['abcdefg', 'abcdefg'])
46
+ const search = new BufferList('fgabc')
47
+
48
+ t.equal(bl.indexOf(search), 5)
49
+
50
+ t.end()
51
+ })
52
+
53
+ tape('indexOf a zero byte needle', (t) => {
54
+ const b = new BufferList('abcdef')
55
+ const bufEmpty = Buffer.from('')
56
+
57
+ t.equal(b.indexOf(''), 0)
58
+ t.equal(b.indexOf('', 1), 1)
59
+ t.equal(b.indexOf('', b.length + 1), b.length)
60
+ t.equal(b.indexOf('', Infinity), b.length)
61
+ t.equal(b.indexOf(bufEmpty), 0)
62
+ t.equal(b.indexOf(bufEmpty, 1), 1)
63
+ t.equal(b.indexOf(bufEmpty, b.length + 1), b.length)
64
+ t.equal(b.indexOf(bufEmpty, Infinity), b.length)
65
+
66
+ t.end()
67
+ })
68
+
69
+ tape('indexOf buffers smaller and larger than the needle', (t) => {
70
+ const bl = new BufferList(['abcdefg', 'a', 'bcdefg', 'a', 'bcfgab'])
71
+
72
+ t.equal(bl.indexOf('fgabc'), 5)
73
+ t.equal(bl.indexOf('fgabc', 6), 12)
74
+ t.equal(bl.indexOf('fgabc', 13), -1)
75
+
76
+ t.end()
77
+ })
78
+
79
+ // only present in node 6+
80
+ ;(process.version.substr(1).split('.')[0] >= 6) && tape('indexOf latin1 and binary encoding', (t) => {
81
+ const b = new BufferList('abcdef')
82
+
83
+ // test latin1 encoding
84
+ t.equal(
85
+ new BufferList(Buffer.from(b.toString('latin1'), 'latin1'))
86
+ .indexOf('d', 0, 'latin1'),
87
+ 3
88
+ )
89
+ t.equal(
90
+ new BufferList(Buffer.from(b.toString('latin1'), 'latin1'))
91
+ .indexOf(Buffer.from('d', 'latin1'), 0, 'latin1'),
92
+ 3
93
+ )
94
+ t.equal(
95
+ new BufferList(Buffer.from('aa\u00e8aa', 'latin1'))
96
+ .indexOf('\u00e8', 'latin1'),
97
+ 2
98
+ )
99
+ t.equal(
100
+ new BufferList(Buffer.from('\u00e8', 'latin1'))
101
+ .indexOf('\u00e8', 'latin1'),
102
+ 0
103
+ )
104
+ t.equal(
105
+ new BufferList(Buffer.from('\u00e8', 'latin1'))
106
+ .indexOf(Buffer.from('\u00e8', 'latin1'), 'latin1'),
107
+ 0
108
+ )
109
+
110
+ // test binary encoding
111
+ t.equal(
112
+ new BufferList(Buffer.from(b.toString('binary'), 'binary'))
113
+ .indexOf('d', 0, 'binary'),
114
+ 3
115
+ )
116
+ t.equal(
117
+ new BufferList(Buffer.from(b.toString('binary'), 'binary'))
118
+ .indexOf(Buffer.from('d', 'binary'), 0, 'binary'),
119
+ 3
120
+ )
121
+ t.equal(
122
+ new BufferList(Buffer.from('aa\u00e8aa', 'binary'))
123
+ .indexOf('\u00e8', 'binary'),
124
+ 2
125
+ )
126
+ t.equal(
127
+ new BufferList(Buffer.from('\u00e8', 'binary'))
128
+ .indexOf('\u00e8', 'binary'),
129
+ 0
130
+ )
131
+ t.equal(
132
+ new BufferList(Buffer.from('\u00e8', 'binary'))
133
+ .indexOf(Buffer.from('\u00e8', 'binary'), 'binary'),
134
+ 0
135
+ )
136
+
137
+ t.end()
138
+ })
139
+
140
+ tape('indexOf the entire nodejs10 buffer test suite', (t) => {
141
+ const b = new BufferList('abcdef')
142
+ const bufA = Buffer.from('a')
143
+ const bufBc = Buffer.from('bc')
144
+ const bufF = Buffer.from('f')
145
+ const bufZ = Buffer.from('z')
146
+
147
+ const stringComparison = 'abcdef'
148
+
149
+ t.equal(b.indexOf('a'), 0)
150
+ t.equal(b.indexOf('a', 1), -1)
151
+ t.equal(b.indexOf('a', -1), -1)
152
+ t.equal(b.indexOf('a', -4), -1)
153
+ t.equal(b.indexOf('a', -b.length), 0)
154
+ t.equal(b.indexOf('a', NaN), 0)
155
+ t.equal(b.indexOf('a', -Infinity), 0)
156
+ t.equal(b.indexOf('a', Infinity), -1)
157
+ t.equal(b.indexOf('bc'), 1)
158
+ t.equal(b.indexOf('bc', 2), -1)
159
+ t.equal(b.indexOf('bc', -1), -1)
160
+ t.equal(b.indexOf('bc', -3), -1)
161
+ t.equal(b.indexOf('bc', -5), 1)
162
+ t.equal(b.indexOf('bc', NaN), 1)
163
+ t.equal(b.indexOf('bc', -Infinity), 1)
164
+ t.equal(b.indexOf('bc', Infinity), -1)
165
+ t.equal(b.indexOf('f'), b.length - 1)
166
+ t.equal(b.indexOf('z'), -1)
167
+
168
+ // empty search tests
169
+ t.equal(b.indexOf(bufA), 0)
170
+ t.equal(b.indexOf(bufA, 1), -1)
171
+ t.equal(b.indexOf(bufA, -1), -1)
172
+ t.equal(b.indexOf(bufA, -4), -1)
173
+ t.equal(b.indexOf(bufA, -b.length), 0)
174
+ t.equal(b.indexOf(bufA, NaN), 0)
175
+ t.equal(b.indexOf(bufA, -Infinity), 0)
176
+ t.equal(b.indexOf(bufA, Infinity), -1)
177
+ t.equal(b.indexOf(bufBc), 1)
178
+ t.equal(b.indexOf(bufBc, 2), -1)
179
+ t.equal(b.indexOf(bufBc, -1), -1)
180
+ t.equal(b.indexOf(bufBc, -3), -1)
181
+ t.equal(b.indexOf(bufBc, -5), 1)
182
+ t.equal(b.indexOf(bufBc, NaN), 1)
183
+ t.equal(b.indexOf(bufBc, -Infinity), 1)
184
+ t.equal(b.indexOf(bufBc, Infinity), -1)
185
+ t.equal(b.indexOf(bufF), b.length - 1)
186
+ t.equal(b.indexOf(bufZ), -1)
187
+ t.equal(b.indexOf(0x61), 0)
188
+ t.equal(b.indexOf(0x61, 1), -1)
189
+ t.equal(b.indexOf(0x61, -1), -1)
190
+ t.equal(b.indexOf(0x61, -4), -1)
191
+ t.equal(b.indexOf(0x61, -b.length), 0)
192
+ t.equal(b.indexOf(0x61, NaN), 0)
193
+ t.equal(b.indexOf(0x61, -Infinity), 0)
194
+ t.equal(b.indexOf(0x61, Infinity), -1)
195
+ t.equal(b.indexOf(0x0), -1)
196
+
197
+ // test offsets
198
+ t.equal(b.indexOf('d', 2), 3)
199
+ t.equal(b.indexOf('f', 5), 5)
200
+ t.equal(b.indexOf('f', -1), 5)
201
+ t.equal(b.indexOf('f', 6), -1)
202
+
203
+ t.equal(b.indexOf(Buffer.from('d'), 2), 3)
204
+ t.equal(b.indexOf(Buffer.from('f'), 5), 5)
205
+ t.equal(b.indexOf(Buffer.from('f'), -1), 5)
206
+ t.equal(b.indexOf(Buffer.from('f'), 6), -1)
207
+
208
+ t.equal(Buffer.from('ff').indexOf(Buffer.from('f'), 1, 'ucs2'), -1)
209
+
210
+ // test invalid and uppercase encoding
211
+ t.equal(b.indexOf('b', 'utf8'), 1)
212
+ t.equal(b.indexOf('b', 'UTF8'), 1)
213
+ t.equal(b.indexOf('62', 'HEX'), 1)
214
+ t.throws(() => b.indexOf('bad', 'enc'), TypeError)
215
+
216
+ // test hex encoding
217
+ t.equal(
218
+ Buffer.from(b.toString('hex'), 'hex')
219
+ .indexOf('64', 0, 'hex'),
220
+ 3
221
+ )
222
+ t.equal(
223
+ Buffer.from(b.toString('hex'), 'hex')
224
+ .indexOf(Buffer.from('64', 'hex'), 0, 'hex'),
225
+ 3
226
+ )
227
+
228
+ // test base64 encoding
229
+ t.equal(
230
+ Buffer.from(b.toString('base64'), 'base64')
231
+ .indexOf('ZA==', 0, 'base64'),
232
+ 3
233
+ )
234
+ t.equal(
235
+ Buffer.from(b.toString('base64'), 'base64')
236
+ .indexOf(Buffer.from('ZA==', 'base64'), 0, 'base64'),
237
+ 3
238
+ )
239
+
240
+ // test ascii encoding
241
+ t.equal(
242
+ Buffer.from(b.toString('ascii'), 'ascii')
243
+ .indexOf('d', 0, 'ascii'),
244
+ 3
245
+ )
246
+ t.equal(
247
+ Buffer.from(b.toString('ascii'), 'ascii')
248
+ .indexOf(Buffer.from('d', 'ascii'), 0, 'ascii'),
249
+ 3
250
+ )
251
+
252
+ // test optional offset with passed encoding
253
+ t.equal(Buffer.from('aaaa0').indexOf('30', 'hex'), 4)
254
+ t.equal(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4)
255
+
256
+ {
257
+ // test usc2 encoding
258
+ const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2')
259
+
260
+ t.equal(8, twoByteString.indexOf('\u0395', 4, 'ucs2'))
261
+ t.equal(6, twoByteString.indexOf('\u03a3', -4, 'ucs2'))
262
+ t.equal(4, twoByteString.indexOf('\u03a3', -6, 'ucs2'))
263
+ t.equal(4, twoByteString.indexOf(
264
+ Buffer.from('\u03a3', 'ucs2'), -6, 'ucs2'))
265
+ t.equal(-1, twoByteString.indexOf('\u03a3', -2, 'ucs2'))
266
+ }
267
+
268
+ const mixedByteStringUcs2 =
269
+ Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395', 'ucs2')
270
+
271
+ t.equal(6, mixedByteStringUcs2.indexOf('bc', 0, 'ucs2'))
272
+ t.equal(10, mixedByteStringUcs2.indexOf('\u03a3', 0, 'ucs2'))
273
+ t.equal(-1, mixedByteStringUcs2.indexOf('\u0396', 0, 'ucs2'))
274
+
275
+ t.equal(
276
+ 6, mixedByteStringUcs2.indexOf(Buffer.from('bc', 'ucs2'), 0, 'ucs2'))
277
+ t.equal(
278
+ 10, mixedByteStringUcs2.indexOf(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2'))
279
+ t.equal(
280
+ -1, mixedByteStringUcs2.indexOf(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2'))
281
+
282
+ {
283
+ const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2')
284
+
285
+ // Test single char pattern
286
+ t.equal(0, twoByteString.indexOf('\u039a', 0, 'ucs2'))
287
+ let index = twoByteString.indexOf('\u0391', 0, 'ucs2')
288
+ t.equal(2, index, `Alpha - at index ${index}`)
289
+ index = twoByteString.indexOf('\u03a3', 0, 'ucs2')
290
+ t.equal(4, index, `First Sigma - at index ${index}`)
291
+ index = twoByteString.indexOf('\u03a3', 6, 'ucs2')
292
+ t.equal(6, index, `Second Sigma - at index ${index}`)
293
+ index = twoByteString.indexOf('\u0395', 0, 'ucs2')
294
+ t.equal(8, index, `Epsilon - at index ${index}`)
295
+ index = twoByteString.indexOf('\u0392', 0, 'ucs2')
296
+ t.equal(-1, index, `Not beta - at index ${index}`)
297
+
298
+ // Test multi-char pattern
299
+ index = twoByteString.indexOf('\u039a\u0391', 0, 'ucs2')
300
+ t.equal(0, index, `Lambda Alpha - at index ${index}`)
301
+ index = twoByteString.indexOf('\u0391\u03a3', 0, 'ucs2')
302
+ t.equal(2, index, `Alpha Sigma - at index ${index}`)
303
+ index = twoByteString.indexOf('\u03a3\u03a3', 0, 'ucs2')
304
+ t.equal(4, index, `Sigma Sigma - at index ${index}`)
305
+ index = twoByteString.indexOf('\u03a3\u0395', 0, 'ucs2')
306
+ t.equal(6, index, `Sigma Epsilon - at index ${index}`)
307
+ }
308
+
309
+ const mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395')
310
+
311
+ t.equal(5, mixedByteStringUtf8.indexOf('bc'))
312
+ t.equal(5, mixedByteStringUtf8.indexOf('bc', 5))
313
+ t.equal(5, mixedByteStringUtf8.indexOf('bc', -8))
314
+ t.equal(7, mixedByteStringUtf8.indexOf('\u03a3'))
315
+ t.equal(-1, mixedByteStringUtf8.indexOf('\u0396'))
316
+
317
+ // Test complex string indexOf algorithms. Only trigger for long strings.
318
+ // Long string that isn't a simple repeat of a shorter string.
319
+ let longString = 'A'
320
+ for (let i = 66; i < 76; i++) { // from 'B' to 'K'
321
+ longString = longString + String.fromCharCode(i) + longString
322
+ }
323
+
324
+ const longBufferString = Buffer.from(longString)
325
+
326
+ // pattern of 15 chars, repeated every 16 chars in long
327
+ let pattern = 'ABACABADABACABA'
328
+ for (let i = 0; i < longBufferString.length - pattern.length; i += 7) {
329
+ const index = longBufferString.indexOf(pattern, i)
330
+ t.equal((i + 15) & ~0xf, index,
331
+ `Long ABACABA...-string at index ${i}`)
332
+ }
333
+
334
+ let index = longBufferString.indexOf('AJABACA')
335
+ t.equal(510, index, `Long AJABACA, First J - at index ${index}`)
336
+ index = longBufferString.indexOf('AJABACA', 511)
337
+ t.equal(1534, index, `Long AJABACA, Second J - at index ${index}`)
338
+
339
+ pattern = 'JABACABADABACABA'
340
+ index = longBufferString.indexOf(pattern)
341
+ t.equal(511, index, `Long JABACABA..., First J - at index ${index}`)
342
+ index = longBufferString.indexOf(pattern, 512)
343
+ t.equal(
344
+ 1535, index, `Long JABACABA..., Second J - at index ${index}`)
345
+
346
+ // Search for a non-ASCII string in a pure ASCII string.
347
+ const asciiString = Buffer.from(
348
+ 'somethingnotatallsinisterwhichalsoworks')
349
+ t.equal(-1, asciiString.indexOf('\x2061'))
350
+ t.equal(3, asciiString.indexOf('eth', 0))
351
+
352
+ // Search in string containing many non-ASCII chars.
353
+ const allCodePoints = []
354
+ for (let i = 0; i < 65536; i++) {
355
+ allCodePoints[i] = i
356
+ }
357
+
358
+ const allCharsString = String.fromCharCode.apply(String, allCodePoints)
359
+ const allCharsBufferUtf8 = Buffer.from(allCharsString)
360
+ const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2')
361
+
362
+ // Search for string long enough to trigger complex search with ASCII pattern
363
+ // and UC16 subject.
364
+ t.equal(-1, allCharsBufferUtf8.indexOf('notfound'))
365
+ t.equal(-1, allCharsBufferUcs2.indexOf('notfound'))
366
+
367
+ // Needle is longer than haystack, but only because it's encoded as UTF-16
368
+ t.equal(Buffer.from('aaaa').indexOf('a'.repeat(4), 'ucs2'), -1)
369
+
370
+ t.equal(Buffer.from('aaaa').indexOf('a'.repeat(4), 'utf8'), 0)
371
+ t.equal(Buffer.from('aaaa').indexOf('你好', 'ucs2'), -1)
372
+
373
+ // Haystack has odd length, but the needle is UCS2.
374
+ t.equal(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1)
375
+
376
+ {
377
+ // Find substrings in Utf8.
378
+ const lengths = [1, 3, 15] // Single char, simple and complex.
379
+ const indices = [0x5, 0x60, 0x400, 0x680, 0x7ee, 0xFF02, 0x16610, 0x2f77b]
380
+ for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
381
+ for (let i = 0; i < indices.length; i++) {
382
+ const index = indices[i]
383
+ let length = lengths[lengthIndex]
384
+
385
+ if (index + length > 0x7F) {
386
+ length = 2 * length
387
+ }
388
+
389
+ if (index + length > 0x7FF) {
390
+ length = 3 * length
391
+ }
392
+
393
+ if (index + length > 0xFFFF) {
394
+ length = 4 * length
395
+ }
396
+
397
+ const patternBufferUtf8 = allCharsBufferUtf8.slice(index, index + length)
398
+ t.equal(index, allCharsBufferUtf8.indexOf(patternBufferUtf8))
399
+
400
+ const patternStringUtf8 = patternBufferUtf8.toString()
401
+ t.equal(index, allCharsBufferUtf8.indexOf(patternStringUtf8))
402
+ }
403
+ }
404
+ }
405
+
406
+ {
407
+ // Find substrings in Usc2.
408
+ const lengths = [2, 4, 16] // Single char, simple and complex.
409
+ const indices = [0x5, 0x65, 0x105, 0x205, 0x285, 0x2005, 0x2085, 0xfff0]
410
+
411
+ for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
412
+ for (let i = 0; i < indices.length; i++) {
413
+ const index = indices[i] * 2
414
+ const length = lengths[lengthIndex]
415
+
416
+ const patternBufferUcs2 =
417
+ allCharsBufferUcs2.slice(index, index + length)
418
+ t.equal(
419
+ index, allCharsBufferUcs2.indexOf(patternBufferUcs2, 0, 'ucs2'))
420
+
421
+ const patternStringUcs2 = patternBufferUcs2.toString('ucs2')
422
+ t.equal(
423
+ index, allCharsBufferUcs2.indexOf(patternStringUcs2, 0, 'ucs2'))
424
+ }
425
+ }
426
+ }
427
+
428
+ [
429
+ () => {},
430
+ {},
431
+ []
432
+ ].forEach((val) => {
433
+ t.throws(() => b.indexOf(val), TypeError, `"${JSON.stringify(val)}" should throw`)
434
+ })
435
+
436
+ // Test weird offset arguments.
437
+ // The following offsets coerce to NaN or 0, searching the whole Buffer
438
+ t.equal(b.indexOf('b', undefined), 1)
439
+ t.equal(b.indexOf('b', {}), 1)
440
+ t.equal(b.indexOf('b', 0), 1)
441
+ t.equal(b.indexOf('b', null), 1)
442
+ t.equal(b.indexOf('b', []), 1)
443
+
444
+ // The following offset coerces to 2, in other words +[2] === 2
445
+ t.equal(b.indexOf('b', [2]), -1)
446
+
447
+ // Behavior should match String.indexOf()
448
+ t.equal(
449
+ b.indexOf('b', undefined),
450
+ stringComparison.indexOf('b', undefined))
451
+ t.equal(
452
+ b.indexOf('b', {}),
453
+ stringComparison.indexOf('b', {}))
454
+ t.equal(
455
+ b.indexOf('b', 0),
456
+ stringComparison.indexOf('b', 0))
457
+ t.equal(
458
+ b.indexOf('b', null),
459
+ stringComparison.indexOf('b', null))
460
+ t.equal(
461
+ b.indexOf('b', []),
462
+ stringComparison.indexOf('b', []))
463
+ t.equal(
464
+ b.indexOf('b', [2]),
465
+ stringComparison.indexOf('b', [2]))
466
+
467
+ // test truncation of Number arguments to uint8
468
+ {
469
+ const buf = Buffer.from('this is a test')
470
+
471
+ t.equal(buf.indexOf(0x6973), 3)
472
+ t.equal(buf.indexOf(0x697320), 4)
473
+ t.equal(buf.indexOf(0x69732069), 2)
474
+ t.equal(buf.indexOf(0x697374657374), 0)
475
+ t.equal(buf.indexOf(0x69737374), 0)
476
+ t.equal(buf.indexOf(0x69737465), 11)
477
+ t.equal(buf.indexOf(0x69737465), 11)
478
+ t.equal(buf.indexOf(-140), 0)
479
+ t.equal(buf.indexOf(-152), 1)
480
+ t.equal(buf.indexOf(0xff), -1)
481
+ t.equal(buf.indexOf(0xffff), -1)
482
+ }
483
+
484
+ // Test that Uint8Array arguments are okay.
485
+ {
486
+ const needle = new Uint8Array([0x66, 0x6f, 0x6f])
487
+ const haystack = new BufferList(Buffer.from('a foo b foo'))
488
+ t.equal(haystack.indexOf(needle), 2)
489
+ }
490
+
491
+ t.end()
492
+ })
node_modules/bl/test/isBufferList.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const tape = require('tape')
4
+ const { BufferList, BufferListStream } = require('../')
5
+ const { Buffer } = require('buffer')
6
+
7
+ tape('isBufferList positives', (t) => {
8
+ t.ok(BufferList.isBufferList(new BufferList()))
9
+ t.ok(BufferList.isBufferList(new BufferListStream()))
10
+
11
+ t.end()
12
+ })
13
+
14
+ tape('isBufferList negatives', (t) => {
15
+ const types = [
16
+ null,
17
+ undefined,
18
+ NaN,
19
+ true,
20
+ false,
21
+ {},
22
+ [],
23
+ Buffer.alloc(0),
24
+ [Buffer.alloc(0)]
25
+ ]
26
+
27
+ for (const obj of types) {
28
+ t.notOk(BufferList.isBufferList(obj))
29
+ }
30
+
31
+ t.end()
32
+ })
node_modules/bl/test/test.js ADDED
@@ -0,0 +1,869 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const tape = require('tape')
4
+ const crypto = require('crypto')
5
+ const fs = require('fs')
6
+ const path = require('path')
7
+ const BufferList = require('../')
8
+ const { Buffer } = require('buffer')
9
+
10
+ const encodings =
11
+ ('hex utf8 utf-8 ascii binary base64' +
12
+ (process.browser ? '' : ' ucs2 ucs-2 utf16le utf-16le')).split(' ')
13
+
14
+ require('./indexOf')
15
+ require('./isBufferList')
16
+ require('./convert')
17
+
18
+ tape('single bytes from single buffer', function (t) {
19
+ const bl = new BufferList()
20
+
21
+ bl.append(Buffer.from('abcd'))
22
+
23
+ t.equal(bl.length, 4)
24
+ t.equal(bl.get(-1), undefined)
25
+ t.equal(bl.get(0), 97)
26
+ t.equal(bl.get(1), 98)
27
+ t.equal(bl.get(2), 99)
28
+ t.equal(bl.get(3), 100)
29
+ t.equal(bl.get(4), undefined)
30
+
31
+ t.end()
32
+ })
33
+
34
+ tape('single bytes from multiple buffers', function (t) {
35
+ const bl = new BufferList()
36
+
37
+ bl.append(Buffer.from('abcd'))
38
+ bl.append(Buffer.from('efg'))
39
+ bl.append(Buffer.from('hi'))
40
+ bl.append(Buffer.from('j'))
41
+
42
+ t.equal(bl.length, 10)
43
+
44
+ t.equal(bl.get(0), 97)
45
+ t.equal(bl.get(1), 98)
46
+ t.equal(bl.get(2), 99)
47
+ t.equal(bl.get(3), 100)
48
+ t.equal(bl.get(4), 101)
49
+ t.equal(bl.get(5), 102)
50
+ t.equal(bl.get(6), 103)
51
+ t.equal(bl.get(7), 104)
52
+ t.equal(bl.get(8), 105)
53
+ t.equal(bl.get(9), 106)
54
+
55
+ t.end()
56
+ })
57
+
58
+ tape('multi bytes from single buffer', function (t) {
59
+ const bl = new BufferList()
60
+
61
+ bl.append(Buffer.from('abcd'))
62
+
63
+ t.equal(bl.length, 4)
64
+
65
+ t.equal(bl.slice(0, 4).toString('ascii'), 'abcd')
66
+ t.equal(bl.slice(0, 3).toString('ascii'), 'abc')
67
+ t.equal(bl.slice(1, 4).toString('ascii'), 'bcd')
68
+ t.equal(bl.slice(-4, -1).toString('ascii'), 'abc')
69
+
70
+ t.end()
71
+ })
72
+
73
+ tape('multi bytes from single buffer (negative indexes)', function (t) {
74
+ const bl = new BufferList()
75
+
76
+ bl.append(Buffer.from('buffer'))
77
+
78
+ t.equal(bl.length, 6)
79
+
80
+ t.equal(bl.slice(-6, -1).toString('ascii'), 'buffe')
81
+ t.equal(bl.slice(-6, -2).toString('ascii'), 'buff')
82
+ t.equal(bl.slice(-5, -2).toString('ascii'), 'uff')
83
+
84
+ t.end()
85
+ })
86
+
87
+ tape('multiple bytes from multiple buffers', function (t) {
88
+ const bl = new BufferList()
89
+
90
+ bl.append(Buffer.from('abcd'))
91
+ bl.append(Buffer.from('efg'))
92
+ bl.append(Buffer.from('hi'))
93
+ bl.append(Buffer.from('j'))
94
+
95
+ t.equal(bl.length, 10)
96
+
97
+ t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
98
+ t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
99
+ t.equal(bl.slice(3, 6).toString('ascii'), 'def')
100
+ t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
101
+ t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
102
+ t.equal(bl.slice(-7, -4).toString('ascii'), 'def')
103
+
104
+ t.end()
105
+ })
106
+
107
+ tape('multiple bytes from multiple buffer lists', function (t) {
108
+ const bl = new BufferList()
109
+
110
+ bl.append(new BufferList([Buffer.from('abcd'), Buffer.from('efg')]))
111
+ bl.append(new BufferList([Buffer.from('hi'), Buffer.from('j')]))
112
+
113
+ t.equal(bl.length, 10)
114
+
115
+ t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
116
+
117
+ t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
118
+ t.equal(bl.slice(3, 6).toString('ascii'), 'def')
119
+ t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
120
+ t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
121
+
122
+ t.end()
123
+ })
124
+
125
+ // same data as previous test, just using nested constructors
126
+ tape('multiple bytes from crazy nested buffer lists', function (t) {
127
+ const bl = new BufferList()
128
+
129
+ bl.append(new BufferList([
130
+ new BufferList([
131
+ new BufferList(Buffer.from('abc')),
132
+ Buffer.from('d'),
133
+ new BufferList(Buffer.from('efg'))
134
+ ]),
135
+ new BufferList([Buffer.from('hi')]),
136
+ new BufferList(Buffer.from('j'))
137
+ ]))
138
+
139
+ t.equal(bl.length, 10)
140
+
141
+ t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
142
+
143
+ t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
144
+ t.equal(bl.slice(3, 6).toString('ascii'), 'def')
145
+ t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
146
+ t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
147
+
148
+ t.end()
149
+ })
150
+
151
+ tape('append accepts arrays of Buffers', function (t) {
152
+ const bl = new BufferList()
153
+
154
+ bl.append(Buffer.from('abc'))
155
+ bl.append([Buffer.from('def')])
156
+ bl.append([Buffer.from('ghi'), Buffer.from('jkl')])
157
+ bl.append([Buffer.from('mnop'), Buffer.from('qrstu'), Buffer.from('vwxyz')])
158
+ t.equal(bl.length, 26)
159
+ t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
160
+
161
+ t.end()
162
+ })
163
+
164
+ tape('append accepts arrays of Uint8Arrays', function (t) {
165
+ const bl = new BufferList()
166
+
167
+ bl.append(new Uint8Array([97, 98, 99]))
168
+ bl.append([Uint8Array.from([100, 101, 102])])
169
+ bl.append([new Uint8Array([103, 104, 105]), new Uint8Array([106, 107, 108])])
170
+ bl.append([new Uint8Array([109, 110, 111, 112]), new Uint8Array([113, 114, 115, 116, 117]), new Uint8Array([118, 119, 120, 121, 122])])
171
+ t.equal(bl.length, 26)
172
+ t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
173
+
174
+ t.end()
175
+ })
176
+
177
+ tape('append accepts arrays of BufferLists', function (t) {
178
+ const bl = new BufferList()
179
+
180
+ bl.append(Buffer.from('abc'))
181
+ bl.append([new BufferList('def')])
182
+ bl.append(new BufferList([Buffer.from('ghi'), new BufferList('jkl')]))
183
+ bl.append([Buffer.from('mnop'), new BufferList([Buffer.from('qrstu'), Buffer.from('vwxyz')])])
184
+ t.equal(bl.length, 26)
185
+ t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
186
+
187
+ t.end()
188
+ })
189
+
190
+ tape('append chainable', function (t) {
191
+ const bl = new BufferList()
192
+
193
+ t.ok(bl.append(Buffer.from('abcd')) === bl)
194
+ t.ok(bl.append([Buffer.from('abcd')]) === bl)
195
+ t.ok(bl.append(new BufferList(Buffer.from('abcd'))) === bl)
196
+ t.ok(bl.append([new BufferList(Buffer.from('abcd'))]) === bl)
197
+
198
+ t.end()
199
+ })
200
+
201
+ tape('append chainable (test results)', function (t) {
202
+ const bl = new BufferList('abc')
203
+ .append([new BufferList('def')])
204
+ .append(new BufferList([Buffer.from('ghi'), new BufferList('jkl')]))
205
+ .append([Buffer.from('mnop'), new BufferList([Buffer.from('qrstu'), Buffer.from('vwxyz')])])
206
+
207
+ t.equal(bl.length, 26)
208
+ t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
209
+
210
+ t.end()
211
+ })
212
+
213
+ tape('consuming from multiple buffers', function (t) {
214
+ const bl = new BufferList()
215
+
216
+ bl.append(Buffer.from('abcd'))
217
+ bl.append(Buffer.from('efg'))
218
+ bl.append(Buffer.from('hi'))
219
+ bl.append(Buffer.from('j'))
220
+
221
+ t.equal(bl.length, 10)
222
+
223
+ t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
224
+
225
+ bl.consume(3)
226
+ t.equal(bl.length, 7)
227
+ t.equal(bl.slice(0, 7).toString('ascii'), 'defghij')
228
+
229
+ bl.consume(2)
230
+ t.equal(bl.length, 5)
231
+ t.equal(bl.slice(0, 5).toString('ascii'), 'fghij')
232
+
233
+ bl.consume(1)
234
+ t.equal(bl.length, 4)
235
+ t.equal(bl.slice(0, 4).toString('ascii'), 'ghij')
236
+
237
+ bl.consume(1)
238
+ t.equal(bl.length, 3)
239
+ t.equal(bl.slice(0, 3).toString('ascii'), 'hij')
240
+
241
+ bl.consume(2)
242
+ t.equal(bl.length, 1)
243
+ t.equal(bl.slice(0, 1).toString('ascii'), 'j')
244
+
245
+ t.end()
246
+ })
247
+
248
+ tape('complete consumption', function (t) {
249
+ const bl = new BufferList()
250
+
251
+ bl.append(Buffer.from('a'))
252
+ bl.append(Buffer.from('b'))
253
+
254
+ bl.consume(2)
255
+
256
+ t.equal(bl.length, 0)
257
+ t.equal(bl._bufs.length, 0)
258
+
259
+ t.end()
260
+ })
261
+
262
+ tape('test readUInt8 / readInt8', function (t) {
263
+ const buf1 = Buffer.alloc(1)
264
+ const buf2 = Buffer.alloc(3)
265
+ const buf3 = Buffer.alloc(3)
266
+ const bl = new BufferList()
267
+
268
+ buf1[0] = 0x1
269
+ buf2[1] = 0x3
270
+ buf2[2] = 0x4
271
+ buf3[0] = 0x23
272
+ buf3[1] = 0x42
273
+
274
+ bl.append(buf1)
275
+ bl.append(buf2)
276
+ bl.append(buf3)
277
+
278
+ t.equal(bl.readUInt8(), 0x1)
279
+ t.equal(bl.readUInt8(2), 0x3)
280
+ t.equal(bl.readInt8(2), 0x3)
281
+ t.equal(bl.readUInt8(3), 0x4)
282
+ t.equal(bl.readInt8(3), 0x4)
283
+ t.equal(bl.readUInt8(4), 0x23)
284
+ t.equal(bl.readInt8(4), 0x23)
285
+ t.equal(bl.readUInt8(5), 0x42)
286
+ t.equal(bl.readInt8(5), 0x42)
287
+
288
+ t.end()
289
+ })
290
+
291
+ tape('test readUInt16LE / readUInt16BE / readInt16LE / readInt16BE', function (t) {
292
+ const buf1 = Buffer.alloc(1)
293
+ const buf2 = Buffer.alloc(3)
294
+ const buf3 = Buffer.alloc(3)
295
+ const bl = new BufferList()
296
+
297
+ buf1[0] = 0x1
298
+ buf2[1] = 0x3
299
+ buf2[2] = 0x4
300
+ buf3[0] = 0x23
301
+ buf3[1] = 0x42
302
+
303
+ bl.append(buf1)
304
+ bl.append(buf2)
305
+ bl.append(buf3)
306
+
307
+ t.equal(bl.readUInt16BE(), 0x0100)
308
+ t.equal(bl.readUInt16LE(), 0x0001)
309
+ t.equal(bl.readUInt16BE(2), 0x0304)
310
+ t.equal(bl.readUInt16LE(2), 0x0403)
311
+ t.equal(bl.readInt16BE(2), 0x0304)
312
+ t.equal(bl.readInt16LE(2), 0x0403)
313
+ t.equal(bl.readUInt16BE(3), 0x0423)
314
+ t.equal(bl.readUInt16LE(3), 0x2304)
315
+ t.equal(bl.readInt16BE(3), 0x0423)
316
+ t.equal(bl.readInt16LE(3), 0x2304)
317
+ t.equal(bl.readUInt16BE(4), 0x2342)
318
+ t.equal(bl.readUInt16LE(4), 0x4223)
319
+ t.equal(bl.readInt16BE(4), 0x2342)
320
+ t.equal(bl.readInt16LE(4), 0x4223)
321
+
322
+ t.end()
323
+ })
324
+
325
+ tape('test readUInt32LE / readUInt32BE / readInt32LE / readInt32BE', function (t) {
326
+ const buf1 = Buffer.alloc(1)
327
+ const buf2 = Buffer.alloc(3)
328
+ const buf3 = Buffer.alloc(3)
329
+ const bl = new BufferList()
330
+
331
+ buf1[0] = 0x1
332
+ buf2[1] = 0x3
333
+ buf2[2] = 0x4
334
+ buf3[0] = 0x23
335
+ buf3[1] = 0x42
336
+
337
+ bl.append(buf1)
338
+ bl.append(buf2)
339
+ bl.append(buf3)
340
+
341
+ t.equal(bl.readUInt32BE(), 0x01000304)
342
+ t.equal(bl.readUInt32LE(), 0x04030001)
343
+ t.equal(bl.readUInt32BE(2), 0x03042342)
344
+ t.equal(bl.readUInt32LE(2), 0x42230403)
345
+ t.equal(bl.readInt32BE(2), 0x03042342)
346
+ t.equal(bl.readInt32LE(2), 0x42230403)
347
+
348
+ t.end()
349
+ })
350
+
351
+ tape('test readUIntLE / readUIntBE / readIntLE / readIntBE', function (t) {
352
+ const buf1 = Buffer.alloc(1)
353
+ const buf2 = Buffer.alloc(3)
354
+ const buf3 = Buffer.alloc(3)
355
+ const bl = new BufferList()
356
+
357
+ buf2[0] = 0x2
358
+ buf2[1] = 0x3
359
+ buf2[2] = 0x4
360
+ buf3[0] = 0x23
361
+ buf3[1] = 0x42
362
+ buf3[2] = 0x61
363
+
364
+ bl.append(buf1)
365
+ bl.append(buf2)
366
+ bl.append(buf3)
367
+
368
+ t.equal(bl.readUIntBE(1, 1), 0x02)
369
+ t.equal(bl.readUIntBE(1, 2), 0x0203)
370
+ t.equal(bl.readUIntBE(1, 3), 0x020304)
371
+ t.equal(bl.readUIntBE(1, 4), 0x02030423)
372
+ t.equal(bl.readUIntBE(1, 5), 0x0203042342)
373
+ t.equal(bl.readUIntBE(1, 6), 0x020304234261)
374
+ t.equal(bl.readUIntLE(1, 1), 0x02)
375
+ t.equal(bl.readUIntLE(1, 2), 0x0302)
376
+ t.equal(bl.readUIntLE(1, 3), 0x040302)
377
+ t.equal(bl.readUIntLE(1, 4), 0x23040302)
378
+ t.equal(bl.readUIntLE(1, 5), 0x4223040302)
379
+ t.equal(bl.readUIntLE(1, 6), 0x614223040302)
380
+ t.equal(bl.readIntBE(1, 1), 0x02)
381
+ t.equal(bl.readIntBE(1, 2), 0x0203)
382
+ t.equal(bl.readIntBE(1, 3), 0x020304)
383
+ t.equal(bl.readIntBE(1, 4), 0x02030423)
384
+ t.equal(bl.readIntBE(1, 5), 0x0203042342)
385
+ t.equal(bl.readIntBE(1, 6), 0x020304234261)
386
+ t.equal(bl.readIntLE(1, 1), 0x02)
387
+ t.equal(bl.readIntLE(1, 2), 0x0302)
388
+ t.equal(bl.readIntLE(1, 3), 0x040302)
389
+ t.equal(bl.readIntLE(1, 4), 0x23040302)
390
+ t.equal(bl.readIntLE(1, 5), 0x4223040302)
391
+ t.equal(bl.readIntLE(1, 6), 0x614223040302)
392
+
393
+ t.end()
394
+ })
395
+
396
+ tape('test readFloatLE / readFloatBE', function (t) {
397
+ const buf1 = Buffer.alloc(1)
398
+ const buf2 = Buffer.alloc(3)
399
+ const buf3 = Buffer.alloc(3)
400
+ const bl = new BufferList()
401
+
402
+ buf1[0] = 0x01
403
+ buf2[1] = 0x00
404
+ buf2[2] = 0x00
405
+ buf3[0] = 0x80
406
+ buf3[1] = 0x3f
407
+
408
+ bl.append(buf1)
409
+ bl.append(buf2)
410
+ bl.append(buf3)
411
+
412
+ const canonical = Buffer.concat([buf1, buf2, buf3])
413
+ t.equal(bl.readFloatLE(), canonical.readFloatLE())
414
+ t.equal(bl.readFloatBE(), canonical.readFloatBE())
415
+ t.equal(bl.readFloatLE(2), canonical.readFloatLE(2))
416
+ t.equal(bl.readFloatBE(2), canonical.readFloatBE(2))
417
+
418
+ t.end()
419
+ })
420
+
421
+ tape('test readDoubleLE / readDoubleBE', function (t) {
422
+ const buf1 = Buffer.alloc(1)
423
+ const buf2 = Buffer.alloc(3)
424
+ const buf3 = Buffer.alloc(10)
425
+ const bl = new BufferList()
426
+
427
+ buf1[0] = 0x01
428
+ buf2[1] = 0x55
429
+ buf2[2] = 0x55
430
+ buf3[0] = 0x55
431
+ buf3[1] = 0x55
432
+ buf3[2] = 0x55
433
+ buf3[3] = 0x55
434
+ buf3[4] = 0xd5
435
+ buf3[5] = 0x3f
436
+
437
+ bl.append(buf1)
438
+ bl.append(buf2)
439
+ bl.append(buf3)
440
+
441
+ const canonical = Buffer.concat([buf1, buf2, buf3])
442
+ t.equal(bl.readDoubleBE(), canonical.readDoubleBE())
443
+ t.equal(bl.readDoubleLE(), canonical.readDoubleLE())
444
+ t.equal(bl.readDoubleBE(2), canonical.readDoubleBE(2))
445
+ t.equal(bl.readDoubleLE(2), canonical.readDoubleLE(2))
446
+
447
+ t.end()
448
+ })
449
+
450
+ tape('test toString', function (t) {
451
+ const bl = new BufferList()
452
+
453
+ bl.append(Buffer.from('abcd'))
454
+ bl.append(Buffer.from('efg'))
455
+ bl.append(Buffer.from('hi'))
456
+ bl.append(Buffer.from('j'))
457
+
458
+ t.equal(bl.toString('ascii', 0, 10), 'abcdefghij')
459
+ t.equal(bl.toString('ascii', 3, 10), 'defghij')
460
+ t.equal(bl.toString('ascii', 3, 6), 'def')
461
+ t.equal(bl.toString('ascii', 3, 8), 'defgh')
462
+ t.equal(bl.toString('ascii', 5, 10), 'fghij')
463
+
464
+ t.end()
465
+ })
466
+
467
+ tape('test toString encoding', function (t) {
468
+ const bl = new BufferList()
469
+ const b = Buffer.from('abcdefghij\xff\x00')
470
+
471
+ bl.append(Buffer.from('abcd'))
472
+ bl.append(Buffer.from('efg'))
473
+ bl.append(Buffer.from('hi'))
474
+ bl.append(Buffer.from('j'))
475
+ bl.append(Buffer.from('\xff\x00'))
476
+
477
+ encodings.forEach(function (enc) {
478
+ t.equal(bl.toString(enc), b.toString(enc), enc)
479
+ })
480
+
481
+ t.end()
482
+ })
483
+
484
+ tape('uninitialized memory', function (t) {
485
+ const secret = crypto.randomBytes(256)
486
+ for (let i = 0; i < 1e6; i++) {
487
+ const clone = Buffer.from(secret)
488
+ const bl = new BufferList()
489
+ bl.append(Buffer.from('a'))
490
+ bl.consume(-1024)
491
+ const buf = bl.slice(1)
492
+ if (buf.indexOf(clone) !== -1) {
493
+ t.fail(`Match (at ${i})`)
494
+ break
495
+ }
496
+ }
497
+ t.end()
498
+ })
499
+
500
+ !process.browser && tape('test stream', function (t) {
501
+ const random = crypto.randomBytes(65534)
502
+
503
+ const bl = new BufferList((err, buf) => {
504
+ t.ok(Buffer.isBuffer(buf))
505
+ t.ok(err === null)
506
+ t.ok(random.equals(bl.slice()))
507
+ t.ok(random.equals(buf.slice()))
508
+
509
+ bl.pipe(fs.createWriteStream('/tmp/bl_test_rnd_out.dat'))
510
+ .on('close', function () {
511
+ const rndhash = crypto.createHash('md5').update(random).digest('hex')
512
+ const md5sum = crypto.createHash('md5')
513
+ const s = fs.createReadStream('/tmp/bl_test_rnd_out.dat')
514
+
515
+ s.on('data', md5sum.update.bind(md5sum))
516
+ s.on('end', function () {
517
+ t.equal(rndhash, md5sum.digest('hex'), 'woohoo! correct hash!')
518
+ t.end()
519
+ })
520
+ })
521
+ })
522
+
523
+ fs.writeFileSync('/tmp/bl_test_rnd.dat', random)
524
+ fs.createReadStream('/tmp/bl_test_rnd.dat').pipe(bl)
525
+ })
526
+
527
+ tape('instantiation with Buffer', function (t) {
528
+ const buf = crypto.randomBytes(1024)
529
+ const buf2 = crypto.randomBytes(1024)
530
+ let b = BufferList(buf)
531
+
532
+ t.equal(buf.toString('hex'), b.slice().toString('hex'), 'same buffer')
533
+ b = BufferList([buf, buf2])
534
+ t.equal(b.slice().toString('hex'), Buffer.concat([buf, buf2]).toString('hex'), 'same buffer')
535
+
536
+ t.end()
537
+ })
538
+
539
+ tape('test String appendage', function (t) {
540
+ const bl = new BufferList()
541
+ const b = Buffer.from('abcdefghij\xff\x00')
542
+
543
+ bl.append('abcd')
544
+ bl.append('efg')
545
+ bl.append('hi')
546
+ bl.append('j')
547
+ bl.append('\xff\x00')
548
+
549
+ encodings.forEach(function (enc) {
550
+ t.equal(bl.toString(enc), b.toString(enc))
551
+ })
552
+
553
+ t.end()
554
+ })
555
+
556
+ tape('test Number appendage', function (t) {
557
+ const bl = new BufferList()
558
+ const b = Buffer.from('1234567890')
559
+
560
+ bl.append(1234)
561
+ bl.append(567)
562
+ bl.append(89)
563
+ bl.append(0)
564
+
565
+ encodings.forEach(function (enc) {
566
+ t.equal(bl.toString(enc), b.toString(enc))
567
+ })
568
+
569
+ t.end()
570
+ })
571
+
572
+ tape('write nothing, should get empty buffer', function (t) {
573
+ t.plan(3)
574
+ BufferList(function (err, data) {
575
+ t.notOk(err, 'no error')
576
+ t.ok(Buffer.isBuffer(data), 'got a buffer')
577
+ t.equal(0, data.length, 'got a zero-length buffer')
578
+ t.end()
579
+ }).end()
580
+ })
581
+
582
+ tape('unicode string', function (t) {
583
+ t.plan(2)
584
+
585
+ const inp1 = '\u2600'
586
+ const inp2 = '\u2603'
587
+ const exp = inp1 + ' and ' + inp2
588
+ const bl = BufferList()
589
+
590
+ bl.write(inp1)
591
+ bl.write(' and ')
592
+ bl.write(inp2)
593
+ t.equal(exp, bl.toString())
594
+ t.equal(Buffer.from(exp).toString('hex'), bl.toString('hex'))
595
+ })
596
+
597
+ tape('should emit finish', function (t) {
598
+ const source = BufferList()
599
+ const dest = BufferList()
600
+
601
+ source.write('hello')
602
+ source.pipe(dest)
603
+
604
+ dest.on('finish', function () {
605
+ t.equal(dest.toString('utf8'), 'hello')
606
+ t.end()
607
+ })
608
+ })
609
+
610
+ tape('basic copy', function (t) {
611
+ const buf = crypto.randomBytes(1024)
612
+ const buf2 = Buffer.alloc(1024)
613
+ const b = BufferList(buf)
614
+
615
+ b.copy(buf2)
616
+ t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
617
+
618
+ t.end()
619
+ })
620
+
621
+ tape('copy after many appends', function (t) {
622
+ const buf = crypto.randomBytes(512)
623
+ const buf2 = Buffer.alloc(1024)
624
+ const b = BufferList(buf)
625
+
626
+ b.append(buf)
627
+ b.copy(buf2)
628
+ t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
629
+
630
+ t.end()
631
+ })
632
+
633
+ tape('copy at a precise position', function (t) {
634
+ const buf = crypto.randomBytes(1004)
635
+ const buf2 = Buffer.alloc(1024)
636
+ const b = BufferList(buf)
637
+
638
+ b.copy(buf2, 20)
639
+ t.equal(b.slice().toString('hex'), buf2.slice(20).toString('hex'), 'same buffer')
640
+
641
+ t.end()
642
+ })
643
+
644
+ tape('copy starting from a precise location', function (t) {
645
+ const buf = crypto.randomBytes(10)
646
+ const buf2 = Buffer.alloc(5)
647
+ const b = BufferList(buf)
648
+
649
+ b.copy(buf2, 0, 5)
650
+ t.equal(b.slice(5).toString('hex'), buf2.toString('hex'), 'same buffer')
651
+
652
+ t.end()
653
+ })
654
+
655
+ tape('copy in an interval', function (t) {
656
+ const rnd = crypto.randomBytes(10)
657
+ const b = BufferList(rnd) // put the random bytes there
658
+ const actual = Buffer.alloc(3)
659
+ const expected = Buffer.alloc(3)
660
+
661
+ rnd.copy(expected, 0, 5, 8)
662
+ b.copy(actual, 0, 5, 8)
663
+
664
+ t.equal(actual.toString('hex'), expected.toString('hex'), 'same buffer')
665
+
666
+ t.end()
667
+ })
668
+
669
+ tape('copy an interval between two buffers', function (t) {
670
+ const buf = crypto.randomBytes(10)
671
+ const buf2 = Buffer.alloc(10)
672
+ const b = BufferList(buf)
673
+
674
+ b.append(buf)
675
+ b.copy(buf2, 0, 5, 15)
676
+
677
+ t.equal(b.slice(5, 15).toString('hex'), buf2.toString('hex'), 'same buffer')
678
+
679
+ t.end()
680
+ })
681
+
682
+ tape('shallow slice across buffer boundaries', function (t) {
683
+ const bl = new BufferList(['First', 'Second', 'Third'])
684
+
685
+ t.equal(bl.shallowSlice(3, 13).toString(), 'stSecondTh')
686
+
687
+ t.end()
688
+ })
689
+
690
+ tape('shallow slice within single buffer', function (t) {
691
+ t.plan(2)
692
+
693
+ const bl = new BufferList(['First', 'Second', 'Third'])
694
+
695
+ t.equal(bl.shallowSlice(5, 10).toString(), 'Secon')
696
+ t.equal(bl.shallowSlice(7, 10).toString(), 'con')
697
+
698
+ t.end()
699
+ })
700
+
701
+ tape('shallow slice single buffer', function (t) {
702
+ t.plan(3)
703
+
704
+ const bl = new BufferList(['First', 'Second', 'Third'])
705
+
706
+ t.equal(bl.shallowSlice(0, 5).toString(), 'First')
707
+ t.equal(bl.shallowSlice(5, 11).toString(), 'Second')
708
+ t.equal(bl.shallowSlice(11, 16).toString(), 'Third')
709
+ })
710
+
711
+ tape('shallow slice with negative or omitted indices', function (t) {
712
+ t.plan(4)
713
+
714
+ const bl = new BufferList(['First', 'Second', 'Third'])
715
+
716
+ t.equal(bl.shallowSlice().toString(), 'FirstSecondThird')
717
+ t.equal(bl.shallowSlice(5).toString(), 'SecondThird')
718
+ t.equal(bl.shallowSlice(5, -3).toString(), 'SecondTh')
719
+ t.equal(bl.shallowSlice(-8).toString(), 'ondThird')
720
+ })
721
+
722
+ tape('shallow slice does not make a copy', function (t) {
723
+ t.plan(1)
724
+
725
+ const buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
726
+ const bl = (new BufferList(buffers)).shallowSlice(5, -3)
727
+
728
+ buffers[1].fill('h')
729
+ buffers[2].fill('h')
730
+
731
+ t.equal(bl.toString(), 'hhhhhhhh')
732
+ })
733
+
734
+ tape('shallow slice with 0 length', function (t) {
735
+ t.plan(1)
736
+
737
+ const buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
738
+ const bl = (new BufferList(buffers)).shallowSlice(0, 0)
739
+
740
+ t.equal(bl.length, 0)
741
+ })
742
+
743
+ tape('shallow slice with 0 length from middle', function (t) {
744
+ t.plan(1)
745
+
746
+ const buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
747
+ const bl = (new BufferList(buffers)).shallowSlice(10, 10)
748
+
749
+ t.equal(bl.length, 0)
750
+ })
751
+
752
+ tape('duplicate', function (t) {
753
+ t.plan(2)
754
+
755
+ const bl = new BufferList('abcdefghij\xff\x00')
756
+ const dup = bl.duplicate()
757
+
758
+ t.equal(bl.prototype, dup.prototype)
759
+ t.equal(bl.toString('hex'), dup.toString('hex'))
760
+ })
761
+
762
+ tape('destroy no pipe', function (t) {
763
+ t.plan(2)
764
+
765
+ const bl = new BufferList('alsdkfja;lsdkfja;lsdk')
766
+
767
+ bl.destroy()
768
+
769
+ t.equal(bl._bufs.length, 0)
770
+ t.equal(bl.length, 0)
771
+ })
772
+
773
+ tape('destroy with error', function (t) {
774
+ t.plan(3)
775
+
776
+ const bl = new BufferList('alsdkfja;lsdkfja;lsdk')
777
+ const err = new Error('kaboom')
778
+
779
+ bl.destroy(err)
780
+ bl.on('error', function (_err) {
781
+ t.equal(_err, err)
782
+ })
783
+
784
+ t.equal(bl._bufs.length, 0)
785
+ t.equal(bl.length, 0)
786
+ })
787
+
788
+ !process.browser && tape('destroy with pipe before read end', function (t) {
789
+ t.plan(2)
790
+
791
+ const bl = new BufferList()
792
+ fs.createReadStream(path.join(__dirname, '/test.js'))
793
+ .pipe(bl)
794
+
795
+ bl.destroy()
796
+
797
+ t.equal(bl._bufs.length, 0)
798
+ t.equal(bl.length, 0)
799
+ })
800
+
801
+ !process.browser && tape('destroy with pipe before read end with race', function (t) {
802
+ t.plan(2)
803
+
804
+ const bl = new BufferList()
805
+
806
+ fs.createReadStream(path.join(__dirname, '/test.js'))
807
+ .pipe(bl)
808
+
809
+ setTimeout(function () {
810
+ bl.destroy()
811
+ setTimeout(function () {
812
+ t.equal(bl._bufs.length, 0)
813
+ t.equal(bl.length, 0)
814
+ }, 500)
815
+ }, 500)
816
+ })
817
+
818
+ !process.browser && tape('destroy with pipe after read end', function (t) {
819
+ t.plan(2)
820
+
821
+ const bl = new BufferList()
822
+
823
+ fs.createReadStream(path.join(__dirname, '/test.js'))
824
+ .on('end', onEnd)
825
+ .pipe(bl)
826
+
827
+ function onEnd () {
828
+ bl.destroy()
829
+
830
+ t.equal(bl._bufs.length, 0)
831
+ t.equal(bl.length, 0)
832
+ }
833
+ })
834
+
835
+ !process.browser && tape('destroy with pipe while writing to a destination', function (t) {
836
+ t.plan(4)
837
+
838
+ const bl = new BufferList()
839
+ const ds = new BufferList()
840
+
841
+ fs.createReadStream(path.join(__dirname, '/test.js'))
842
+ .on('end', onEnd)
843
+ .pipe(bl)
844
+
845
+ function onEnd () {
846
+ bl.pipe(ds)
847
+
848
+ setTimeout(function () {
849
+ bl.destroy()
850
+
851
+ t.equals(bl._bufs.length, 0)
852
+ t.equals(bl.length, 0)
853
+
854
+ ds.destroy()
855
+
856
+ t.equals(bl._bufs.length, 0)
857
+ t.equals(bl.length, 0)
858
+ }, 100)
859
+ }
860
+ })
861
+
862
+ !process.browser && tape('handle error', function (t) {
863
+ t.plan(2)
864
+
865
+ fs.createReadStream('/does/not/exist').pipe(BufferList(function (err, data) {
866
+ t.ok(err instanceof Error, 'has error')
867
+ t.notOk(data, 'no data')
868
+ }))
869
+ })
node_modules/bluebird/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013-2018 Petka Antonov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
node_modules/bluebird/README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <a href="http://promisesaplus.com/">
2
+ <img src="http://promisesaplus.com/assets/logo-small.png" alt="Promises/A+ logo"
3
+ title="Promises/A+ 1.1 compliant" align="right" />
4
+ </a>
5
+
6
+
7
+ [![Build Status](https://travis-ci.org/petkaantonov/bluebird.svg?branch=master)](https://travis-ci.org/petkaantonov/bluebird)
8
+ [![coverage-98%](https://img.shields.io/badge/coverage-98%25-brightgreen.svg?style=flat)](http://petkaantonov.github.io/bluebird/coverage/debug/index.html)
9
+
10
+ **Got a question?** Join us on [stackoverflow](http://stackoverflow.com/questions/tagged/bluebird), the [mailing list](https://groups.google.com/forum/#!forum/bluebird-js) or chat on [IRC](https://webchat.freenode.net/?channels=#promises)
11
+
12
+ # Introduction
13
+
14
+ Bluebird is a fully featured promise library with focus on innovative features and performance
15
+
16
+ See the [**bluebird website**](http://bluebirdjs.com/docs/getting-started.html) for further documentation, references and instructions. See the [**API reference**](http://bluebirdjs.com/docs/api-reference.html) here.
17
+
18
+ For bluebird 2.x documentation and files, see the [2.x tree](https://github.com/petkaantonov/bluebird/tree/2.x).
19
+
20
+ ### Note
21
+
22
+ Promises in Node.js 10 are significantly faster than before. Bluebird still includes a lot of features like cancellation, iteration methods and warnings that native promises don't. If you are using Bluebird for performance rather than for those - please consider giving native promises a shot and running the benchmarks yourself.
23
+
24
+ # Questions and issues
25
+
26
+ The [github issue tracker](https://github.com/petkaantonov/bluebird/issues) is **_only_** for bug reports and feature requests. Anything else, such as questions for help in using the library, should be posted in [StackOverflow](http://stackoverflow.com/questions/tagged/bluebird) under tags `promise` and `bluebird`.
27
+
28
+
29
+
30
+ ## Thanks
31
+
32
+ Thanks to BrowserStack for providing us with a free account which lets us support old browsers like IE8.
33
+
34
+ # License
35
+
36
+ The MIT License (MIT)
37
+
38
+ Copyright (c) 2013-2019 Petka Antonov
39
+
40
+ Permission is hereby granted, free of charge, to any person obtaining a copy
41
+ of this software and associated documentation files (the "Software"), to deal
42
+ in the Software without restriction, including without limitation the rights
43
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
44
+ copies of the Software, and to permit persons to whom the Software is
45
+ furnished to do so, subject to the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be included in
48
+ all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
53
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
56
+ THE SOFTWARE.
57
+
node_modules/bluebird/changelog.md ADDED
@@ -0,0 +1 @@
 
 
1
+ [http://bluebirdjs.com/docs/changelog.html](http://bluebirdjs.com/docs/changelog.html)
node_modules/bluebird/js/browser/bluebird.core.js ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/bluebird/js/browser/bluebird.core.min.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* @preserve
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2013-2018 Petka Antonov
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ */
25
+ /**
26
+ * bluebird build version 3.7.2
27
+ * Features enabled: core
28
+ * Features disabled: race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each
29
+ */
30
+ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Promise=t()}}(function(){var t,e,n;return function r(t,e,n){function o(a,s){if(!e[a]){if(!t[a]){var c="function"==typeof _dereq_&&_dereq_;if(!s&&c)return c(a,!0);if(i)return i(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=e[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return o(n?n:e)},u,u.exports,r,t,e,n)}return e[a].exports}for(var i="function"==typeof _dereq_&&_dereq_,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(t,e,n){"use strict";function r(){this._customScheduler=!1,this._isTickUsed=!1,this._lateQueue=new f(16),this._normalQueue=new f(16),this._haveDrainedQueues=!1;var t=this;this.drainQueues=function(){t._drainQueues()},this._schedule=p}function o(t,e,n){this._lateQueue.push(t,e,n),this._queueTick()}function i(t,e,n){this._normalQueue.push(t,e,n),this._queueTick()}function a(t){this._normalQueue._pushOne(t),this._queueTick()}function s(t){for(;t.length()>0;)c(t)}function c(t){var e=t.shift();if("function"!=typeof e)e._settlePromises();else{var n=t.shift(),r=t.shift();e.call(n,r)}}var l;try{throw new Error}catch(u){l=u}var p=t("./schedule"),f=t("./queue");r.prototype.setScheduler=function(t){var e=this._schedule;return this._schedule=t,this._customScheduler=!0,e},r.prototype.hasCustomScheduler=function(){return this._customScheduler},r.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues},r.prototype.fatalError=function(t,e){e?(process.stderr.write("Fatal "+(t instanceof Error?t.stack:t)+"\n"),process.exit(2)):this.throwLater(t)},r.prototype.throwLater=function(t,e){if(1===arguments.length&&(e=t,t=function(){throw e}),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(n){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")}},r.prototype.invokeLater=o,r.prototype.invoke=i,r.prototype.settlePromises=a,r.prototype._drainQueues=function(){s(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,s(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=r,e.exports.firstLineError=l},{"./queue":17,"./schedule":18}],2:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var o=!1,i=function(t,e){this._reject(e)},a=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(i,i,null,this,t)},s=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},c=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(i){o||(o=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var l=n(i),u=new t(e);u._propagateFrom(this,1);var p=this._target();if(u._setBoundTo(l),l instanceof t){var f={promiseRejectionQueued:!1,promise:u,target:p,bindingPromise:l};p._then(e,a,void 0,u,f),l._then(s,c,void 0,u,f),u._setOnCancel(l)}else u._resolveCallback(p);return u},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],3:[function(t,e,n){"use strict";function r(){try{Promise===i&&(Promise=o)}catch(t){}return i}var o;"undefined"!=typeof Promise&&(o=Promise);var i=t("./promise")();i.noConflict=r,e.exports=i},{"./promise":15}],4:[function(t,e,n){"use strict";e.exports=function(e,n,r,o){var i=t("./util"),a=i.tryCatch,s=i.errorObj,c=e._async;e.prototype["break"]=e.prototype.cancel=function(){if(!o.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),c.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(i.isArray(t))for(var n=0;n<t.length;++n)this._doInvokeOnCancel(t[n],e);else if(void 0!==t)if("function"==typeof t){if(!e){var r=a(t).call(this._boundValue());r===s&&(this._attachExtraTrace(r.e),c.throwLater(r.e))}}else t._resultCancelled(this)},e.prototype._invokeOnCancel=function(){var t=this._onCancel();this._unsetOnCancel(),c.invoke(this._doInvokeOnCancel,this,t)},e.prototype._invokeInternalOnCancel=function(){this._isCancellable()&&(this._doInvokeOnCancel(this._onCancel(),!0),this._unsetOnCancel())},e.prototype._resultCancelled=function(){this.cancel()}}},{"./util":21}],5:[function(t,e,n){"use strict";e.exports=function(e){function n(t,n,s){return function(c){var l=s._boundValue();t:for(var u=0;u<t.length;++u){var p=t[u];if(p===Error||null!=p&&p.prototype instanceof Error){if(c instanceof p)return i(n).call(l,c)}else if("function"==typeof p){var f=i(p).call(l,c);if(f===a)return f;if(f)return i(n).call(l,c)}else if(r.isObject(c)){for(var h=o(p),d=0;d<h.length;++d){var _=h[d];if(p[_]!=c[_])continue t}return i(n).call(l,c)}}return e}}var r=t("./util"),o=t("./es5").keys,i=r.tryCatch,a=r.errorObj;return n}},{"./es5":10,"./util":21}],6:[function(t,e,n){"use strict";e.exports=function(t){function e(){this._trace=new e.CapturedTrace(r())}function n(){return o?new e:void 0}function r(){var t=i.length-1;return t>=0?i[t]:void 0}var o=!1,i=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,i.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=i.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=n,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var n=t.prototype._pushContext,i=t.prototype._popContext,a=t._peekContext,s=t.prototype._peekContext,c=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=i,t._peekContext=a,t.prototype._peekContext=s,t.prototype._promiseCreated=c,o=!1},o=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=r,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],7:[function(t,e,n){"use strict";e.exports=function(e,n,r,o){function i(t,e){return{promise:e}}function a(){return!1}function s(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+V.toString(t));r._attachCancellationCallback(t)})}catch(o){return o}}function c(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?V.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function l(){return this._onCancelField}function u(t){this._onCancelField=t}function p(){this._cancellationParent=void 0,this._onCancelField=void 0}function f(t,e){if(0!==(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function h(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function d(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function _(){this._trace=new H(this._peekContext())}function v(t,e){if(q(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=F(t);V.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),V.notEnumerableProp(t,"__stackCleaned__",!0)}}}function y(){this._trace=void 0}function g(t,e,n,r,o){if(void 0===t&&null!==e&&Z){if(void 0!==o&&o._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var i="",a="";if(e._trace){for(var s=e._trace.stack.split("\n"),c=E(s),l=c.length-1;l>=0;--l){var u=c[l];if(!M.test(u)){var p=u.match(W);p&&(i="at "+p[1]+":"+p[2]+":"+p[3]+" ");break}}if(c.length>0)for(var f=c[0],l=0;l<s.length;++l)if(s[l]===f){l>0&&(a="\n"+s[l-1]);break}}var h="a promise was created in a "+n+"handler "+i+"but was not returned from it, see http://goo.gl/rRqMUw"+a;r._warn(h,!0,e)}}function m(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),b(n)}function b(t,n,r){if(ut.warnings){var o,i=new D(t);if(n)r._attachExtraTrace(i);else if(ut.longStackTraces&&(o=e._peekContext()))o.attachExtraTrace(i);else{var a=F(i);i.stack=a.message+"\n"+a.stack.join("\n")}it("warning",i)||T(i,"",!0)}}function C(t,e){for(var n=0;n<e.length-1;++n)e[n].push("From previous event:"),e[n]=e[n].join("\n");return n<e.length&&(e[n]=e[n].join("\n")),t+"\n"+e.join("\n")}function w(t){for(var e=0;e<t.length;++e)(0===t[e].length||e+1<t.length&&t[e][0]===t[e+1][0])&&(t.splice(e,1),e--)}function k(t){for(var e=t[0],n=1;n<t.length;++n){for(var r=t[n],o=e.length-1,i=e[o],a=-1,s=r.length-1;s>=0;--s)if(r[s]===i){a=s;break}for(var s=a;s>=0;--s){var c=r[s];if(e[o]!==c)break;e.pop(),o--}e=r}}function E(t){for(var e=[],n=0;n<t.length;++n){var r=t[n],o=" (No stack trace)"===r||$.test(r),i=o&&st(r);o&&!i&&(X&&" "!==r.charAt(0)&&(r=" "+r),e.push(r))}return e}function j(t){for(var e=t.stack.replace(/\s+$/g,"").split("\n"),n=0;n<e.length;++n){var r=e[n];if(" (No stack trace)"===r||$.test(r))break}return n>0&&"SyntaxError"!=t.name&&(e=e.slice(n)),e}function F(t){var e=t.stack,n=t.toString();return e="string"==typeof e&&e.length>0?j(t):[" (No stack trace)"],{message:n,stack:"SyntaxError"==t.name?e:E(e)}}function T(t,e,n){if("undefined"!=typeof console){var r;if(V.isObject(t)){var o=t.stack;r=e+z(o,t)}else r=e+String(t);"function"==typeof B?B(r,n):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}}function x(t,e,n,r){var o=!1;try{"function"==typeof e&&(o=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(i){I.throwLater(i)}"unhandledRejection"===t?it(t,n,r)||o||T(n,"Unhandled rejection "):it(t,r)}function R(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():V.toString(t);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(e))try{var r=JSON.stringify(t);e=r}catch(o){}0===e.length&&(e="(empty array)")}return"(<"+S(e)+">, no stack trace)"}function S(t){var e=41;return t.length<e?t:t.substr(0,e-3)+"..."}function P(){return"function"==typeof lt}function O(t){var e=t.match(ct);return e?{fileName:e[1],line:parseInt(e[2],10)}:void 0}function A(t,e){if(P()){for(var n,r,o=(t.stack||"").split("\n"),i=(e.stack||"").split("\n"),a=-1,s=-1,c=0;c<o.length;++c){var l=O(o[c]);if(l){n=l.fileName,a=l.line;break}}for(var c=0;c<i.length;++c){var l=O(i[c]);if(l){r=l.fileName,s=l.line;break}}0>a||0>s||!n||!r||n!==r||a>=s||(st=function(t){if(G.test(t))return!0;var e=O(t);return e&&e.fileName===n&&a<=e.line&&e.line<=s?!0:!1})}}function H(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);lt(this,H),e>32&&this.uncycle()}var N,L,B,U,I=e._async,D=t("./errors").Warning,V=t("./util"),Q=t("./es5"),q=V.canAttachTrace,G=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,M=/\((?:timers\.js):\d+:\d+\)/,W=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,$=null,z=null,X=!1,K=!(0==V.env("BLUEBIRD_DEBUG")||!V.env("BLUEBIRD_DEBUG")&&"development"!==V.env("NODE_ENV")),J=!(0==V.env("BLUEBIRD_WARNINGS")||!K&&!V.env("BLUEBIRD_WARNINGS")),Y=!(0==V.env("BLUEBIRD_LONG_STACK_TRACES")||!K&&!V.env("BLUEBIRD_LONG_STACK_TRACES")),Z=0!=V.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(J||!!V.env("BLUEBIRD_W_FORGOTTEN_RETURN"));!function(){function t(){for(var t=0;t<r.length;++t)r[t]._notifyUnhandledRejection();n()}function n(){r.length=0}var r=[];U=function(e){r.push(e),setTimeout(t,1)},Q.defineProperty(e,"_unhandledRejectionCheck",{value:t}),Q.defineProperty(e,"_unhandledRejectionClear",{value:n})}(),e.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},e.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),U(this))},e.prototype._notifyUnhandledRejectionIsHandled=function(){x("rejectionHandled",N,void 0,this)},e.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},e.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),x("unhandledRejection",L,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},e.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},e.prototype._warn=function(t,e,n){return b(t,e,n||this)},e.onPossiblyUnhandledRejection=function(t){var n=e._getContext();L=V.contextBind(n,t)},e.onUnhandledRejectionHandled=function(t){var n=e._getContext();N=V.contextBind(n,t)};var tt=function(){};e.longStackTraces=function(){if(I.haveItemsQueued()&&!ut.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!ut.longStackTraces&&P()){var t=e.prototype._captureStackTrace,r=e.prototype._attachExtraTrace,o=e.prototype._dereferenceTrace;ut.longStackTraces=!0,tt=function(){if(I.haveItemsQueued()&&!ut.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");e.prototype._captureStackTrace=t,e.prototype._attachExtraTrace=r,e.prototype._dereferenceTrace=o,n.deactivateLongStackTraces(),ut.longStackTraces=!1},e.prototype._captureStackTrace=_,e.prototype._attachExtraTrace=v,e.prototype._dereferenceTrace=y,n.activateLongStackTraces()}},e.hasLongStackTraces=function(){return ut.longStackTraces&&P()};var et={unhandledrejection:{before:function(){var t=V.global.onunhandledrejection;return V.global.onunhandledrejection=null,t},after:function(t){V.global.onunhandledrejection=t}},rejectionhandled:{before:function(){var t=V.global.onrejectionhandled;return V.global.onrejectionhandled=null,t},after:function(t){V.global.onrejectionhandled=t}}},nt=function(){var t=function(t,e){if(!t)return!V.global.dispatchEvent(e);var n;try{return n=t.before(),!V.global.dispatchEvent(e)}finally{t.after(n)}};try{if("function"==typeof CustomEvent){var e=new CustomEvent("CustomEvent");return V.global.dispatchEvent(e),function(e,n){e=e.toLowerCase();var r={detail:n,cancelable:!0},o=new CustomEvent(e,r);return Q.defineProperty(o,"promise",{value:n.promise}),Q.defineProperty(o,"reason",{value:n.reason}),t(et[e],o)}}if("function"==typeof Event){var e=new Event("CustomEvent");return V.global.dispatchEvent(e),function(e,n){e=e.toLowerCase();var r=new Event(e,{cancelable:!0});return r.detail=n,Q.defineProperty(r,"promise",{value:n.promise}),Q.defineProperty(r,"reason",{value:n.reason}),t(et[e],r)}}var e=document.createEvent("CustomEvent");return e.initCustomEvent("testingtheevent",!1,!0,{}),V.global.dispatchEvent(e),function(e,n){e=e.toLowerCase();var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,!1,!0,n),t(et[e],r)}}catch(n){}return function(){return!1}}(),rt=function(){return V.isNode?function(){return process.emit.apply(process,arguments)}:V.global?function(t){var e="on"+t.toLowerCase(),n=V.global[e];return n?(n.apply(V.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),ot={promiseCreated:i,promiseFulfilled:i,promiseRejected:i,promiseResolved:i,promiseCancelled:i,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:i},it=function(t){var e=!1;try{e=rt.apply(null,arguments)}catch(n){I.throwLater(n),e=!0}var r=!1;try{r=nt(t,ot[t].apply(null,arguments))}catch(n){I.throwLater(n),r=!0}return r||e};e.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?e.longStackTraces():!t.longStackTraces&&e.hasLongStackTraces()&&tt()),"warnings"in t){var n=t.warnings;ut.warnings=!!n,Z=ut.warnings,V.isObject(n)&&"wForgottenReturn"in n&&(Z=!!n.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!ut.cancellation){if(I.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");e.prototype._clearCancellationData=p,e.prototype._propagateFrom=f,e.prototype._onCancel=l,e.prototype._setOnCancel=u,e.prototype._attachCancellationCallback=c,e.prototype._execute=s,at=f,ut.cancellation=!0}if("monitoring"in t&&(t.monitoring&&!ut.monitoring?(ut.monitoring=!0,e.prototype._fireEvent=it):!t.monitoring&&ut.monitoring&&(ut.monitoring=!1,e.prototype._fireEvent=a)),"asyncHooks"in t&&V.nodeSupportsAsyncResource){var i=ut.asyncHooks,h=!!t.asyncHooks;i!==h&&(ut.asyncHooks=h,h?r():o())}return e},e.prototype._fireEvent=a,e.prototype._execute=function(t,e,n){try{t(e,n)}catch(r){return r}},e.prototype._onCancel=function(){},e.prototype._setOnCancel=function(t){},e.prototype._attachCancellationCallback=function(t){},e.prototype._captureStackTrace=function(){},e.prototype._attachExtraTrace=function(){},e.prototype._dereferenceTrace=function(){},e.prototype._clearCancellationData=function(){},e.prototype._propagateFrom=function(t,e){};var at=h,st=function(){return!1},ct=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;V.inherits(H,Error),n.CapturedTrace=H,H.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],n={},r=0,o=this;void 0!==o;++r)e.push(o),o=o._parent;t=this._length=r;for(var r=t-1;r>=0;--r){var i=e[r].stack;void 0===n[i]&&(n[i]=r)}for(var r=0;t>r;++r){var a=e[r].stack,s=n[a];if(void 0!==s&&s!==r){s>0&&(e[s-1]._parent=void 0,e[s-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var c=r>0?e[r-1]:this;t-1>s?(c._parent=e[s+1],c._parent.uncycle(),c._length=c._parent._length+1):(c._parent=void 0,c._length=1);for(var l=c._length+1,u=r-2;u>=0;--u)e[u]._length=l,l++;return}}}},H.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=F(t),n=e.message,r=[e.stack],o=this;void 0!==o;)r.push(E(o.stack.split("\n"))),o=o._parent;k(r),w(r),V.notEnumerableProp(t,"stack",C(n,r)),V.notEnumerableProp(t,"__stackCleaned__",!0)}};var lt=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():R(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,$=t,z=e;var n=Error.captureStackTrace;return st=function(t){return G.test(t)},function(t,e){Error.stackTraceLimit+=6,n(t,e),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return $=/@/,z=e,X=!0,function(t){t.stack=(new Error).stack};var o;try{throw new Error}catch(i){o="stack"in i}return"stack"in r||!o||"number"!=typeof Error.stackTraceLimit?(z=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?R(e):e.toString()},null):($=t,z=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(B=function(t){console.warn(t)},V.isNode&&process.stderr.isTTY?B=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:V.isNode||"string"!=typeof(new Error).stack||(B=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var ut={warnings:J,longStackTraces:!1,cancellation:!1,monitoring:!1,asyncHooks:!1};return Y&&e.longStackTraces(),{asyncHooks:function(){return ut.asyncHooks},longStackTraces:function(){return ut.longStackTraces},warnings:function(){return ut.warnings},cancellation:function(){return ut.cancellation},monitoring:function(){return ut.monitoring},propagateFromFunction:function(){return at},boundValueFunction:function(){return d},checkForgottenReturns:g,setBounds:A,warn:b,deprecated:m,CapturedTrace:H,fireDomEvent:nt,fireGlobalEvent:rt}}},{"./errors":9,"./es5":10,"./util":21}],8:[function(t,e,n){"use strict";e.exports=function(t){function e(){return this.value}function n(){throw this.reason}t.prototype["return"]=t.prototype.thenReturn=function(n){return n instanceof t&&n.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:n},void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return this._then(n,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:t},void 0);var e=arguments[1],r=function(){throw e};return this.caught(t,r)},t.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof t&&n.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:n},void 0);var r=arguments[1];r instanceof t&&r.suppressUnhandledRejections();var o=function(){return r};return this.caught(n,o)}}},{}],9:[function(t,e,n){"use strict";function r(t,e){function n(r){return this instanceof n?(p(this,"message","string"==typeof r?r:e),p(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return u(n,Error),n}function o(t){return this instanceof o?(p(this,"name","OperationalError"),p(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(p(this,"message",t.message),p(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new o(t)}var i,a,s=t("./es5"),c=s.freeze,l=t("./util"),u=l.inherits,p=l.notEnumerableProp,f=r("Warning","warning"),h=r("CancellationError","cancellation error"),d=r("TimeoutError","timeout error"),_=r("AggregateError","aggregate error");try{i=TypeError,a=RangeError}catch(v){i=r("TypeError","type error"),a=r("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),g=0;g<y.length;++g)"function"==typeof Array.prototype[y[g]]&&(_.prototype[y[g]]=Array.prototype[y[g]]);s.defineProperty(_.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),_.prototype.isOperational=!0;var m=0;_.prototype.toString=function(){var t=Array(4*m+1).join(" "),e="\n"+t+"AggregateError of:\n";m++,t=Array(4*m+1).join(" ");for(var n=0;n<this.length;++n){for(var r=this[n]===this?"[Circular AggregateError]":this[n]+"",o=r.split("\n"),i=0;i<o.length;++i)o[i]=t+o[i];r=o.join("\n"),e+=r+"\n"}return m--,e},u(o,Error);var b=Error.__BluebirdErrorTypes__;b||(b=c({CancellationError:h,TimeoutError:d,OperationalError:o,RejectionError:o,AggregateError:_}),s.defineProperty(Error,"__BluebirdErrorTypes__",{value:b,writable:!1,enumerable:!1,configurable:!1})),e.exports={Error:Error,TypeError:i,RangeError:a,CancellationError:b.CancellationError,OperationalError:b.OperationalError,TimeoutError:b.TimeoutError,AggregateError:b.AggregateError,Warning:f}},{"./es5":10,"./util":21}],10:[function(t,e,n){var r=function(){"use strict";return void 0===this}();if(r)e.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:r,propertyIsWritable:function(t,e){var n=Object.getOwnPropertyDescriptor(t,e);return!(n&&!n.writable&&!n.set)}};else{var o={}.hasOwnProperty,i={}.toString,a={}.constructor.prototype,s=function(t){var e=[];for(var n in t)o.call(t,n)&&e.push(n);return e},c=function(t,e){return{value:t[e]}},l=function(t,e,n){return t[e]=n.value,t},u=function(t){return t},p=function(t){try{return Object(t).constructor.prototype}catch(e){return a}},f=function(t){try{return"[object Array]"===i.call(t)}catch(e){return!1}};e.exports={isArray:f,keys:s,names:s,defineProperty:l,getDescriptor:c,freeze:u,getPrototypeOf:p,isES5:r,propertyIsWritable:function(){return!0}}}},{}],11:[function(t,e,n){"use strict";e.exports=function(e,n,r){function o(t,e,n){this.promise=t,this.type=e,this.handler=n,this.called=!1,this.cancelPromise=null}function i(t){this.finallyHandler=t}function a(t,e){return null!=t.cancelPromise?(arguments.length>1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0):!1}function s(){return l.call(this,this.promise._target()._settledValue())}function c(t){return a(this,t)?void 0:(f.e=t,f)}function l(t){var o=this.promise,l=this.handler;if(!this.called){this.called=!0;var u=this.isFinallyHandler()?l.call(o._boundValue()):l.call(o._boundValue(),t);if(u===r)return u;if(void 0!==u){o._setReturnedNonUndefined();var h=n(u,o);if(h instanceof e){if(null!=this.cancelPromise){if(h._isCancelled()){var d=new p("late cancellation observer");return o._attachExtraTrace(d),f.e=d,f}h.isPending()&&h._attachCancellationCallback(new i(this))}return h._then(s,c,void 0,this,void 0)}}}return o.isRejected()?(a(this),f.e=t,f):(a(this),t)}var u=t("./util"),p=e.CancellationError,f=u.errorObj,h=t("./catch_filter")(r);return o.prototype.isFinallyHandler=function(){return 0===this.type},i.prototype._resultCancelled=function(){a(this.finallyHandler)},e.prototype._passThrough=function(t,e,n,r){return"function"!=typeof t?this.then():this._then(n,r,void 0,new o(this,e,t),void 0)},e.prototype.lastly=e.prototype["finally"]=function(t){return this._passThrough(t,0,l,l)},e.prototype.tap=function(t){return this._passThrough(t,1,l)},e.prototype.tapCatch=function(t){var n=arguments.length;if(1===n)return this._passThrough(t,1,void 0,l);var r,o=new Array(n-1),i=0;for(r=0;n-1>r;++r){var a=arguments[r];if(!u.isObject(a))return e.reject(new TypeError("tapCatch statement predicate: expecting an object but got "+u.classString(a)));o[i++]=a}o.length=i;var s=arguments[r];return this._passThrough(h(o,s,this),1,void 0,l)},o}},{"./catch_filter":5,"./util":21}],12:[function(t,e,n){"use strict";e.exports=function(e,n,r,o,i){var a=t("./util");a.canEvaluate,a.tryCatch,a.errorObj;e.join=function(){var t,e=arguments.length-1;if(e>0&&"function"==typeof arguments[e]){t=arguments[e];var r}var o=[].slice.call(arguments);t&&o.pop();var r=new n(o).promise();return void 0!==t?r.spread(t):r}}},{"./util":21}],13:[function(t,e,n){"use strict";e.exports=function(e,n,r,o,i){var a=t("./util"),s=a.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("expecting a function but got "+a.classString(t));return function(){var r=new e(n);r._captureStackTrace(),r._pushContext();var o=s(t).apply(this,arguments),a=r._popContext();return i.checkForgottenReturns(o,a,"Promise.method",r),r._resolveFromSyncValue(o),r}},e.attempt=e["try"]=function(t){if("function"!=typeof t)return o("expecting a function but got "+a.classString(t));var r=new e(n);r._captureStackTrace(),r._pushContext();var c;if(arguments.length>1){i.deprecated("calling Promise.try with more than 1 argument");var l=arguments[1],u=arguments[2];c=a.isArray(l)?s(t).apply(u,l):s(t).call(u,l)}else c=s(t)();var p=r._popContext();return i.checkForgottenReturns(c,p,"Promise.try",r),r._resolveFromSyncValue(c),r},e.prototype._resolveFromSyncValue=function(t){t===a.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":21}],14:[function(t,e,n){"use strict";function r(t){return t instanceof Error&&u.getPrototypeOf(t)===Error.prototype}function o(t){var e;if(r(t)){e=new l(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=u.keys(t),o=0;o<n.length;++o){var i=n[o];p.test(i)||(e[i]=t[i])}return e}return a.markAsOriginatingFromRejection(t),t}function i(t,e){return function(n,r){if(null!==t){if(n){var i=o(s(n));t._attachExtraTrace(i),t._reject(i)}else if(e){var a=[].slice.call(arguments,1);t._fulfill(a)}else t._fulfill(r);t=null}}}var a=t("./util"),s=a.maybeWrapAsError,c=t("./errors"),l=c.OperationalError,u=t("./es5"),p=/^(?:name|message|stack|cause)$/;e.exports=i},{"./errors":9,"./es5":10,"./util":21}],15:[function(t,e,n){"use strict";e.exports=function(){function n(){}function r(t,e){if(null==t||t.constructor!==o)throw new j("the promise constructor cannot be invoked directly\n\n See http://goo.gl/MqrFmX\n");if("function"!=typeof e)throw new j("expecting a function but got "+f.classString(e))}function o(t){t!==T&&r(this,t),this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._resolveFromExecutor(t),this._promiseCreated(),this._fireEvent("promiseCreated",this)}function i(t){this.promise._resolveCallback(t)}function a(t){this.promise._rejectCallback(t,!1)}function s(t){var e=new o(T);e._fulfillmentHandler0=t,e._rejectionHandler0=t,e._promise0=t,e._receiver0=t}var c=function(){return new j("circular promise resolution chain\n\n See http://goo.gl/MqrFmX\n")},l=function(){return new o.PromiseInspection(this._target())},u=function(t){return o.reject(new j(t))},p={},f=t("./util");f.setReflectHandler(l);var h=function(){var t=process.domain;return void 0===t?null:t},d=function(){return null},_=function(){return{domain:h(),async:null}},v=f.isNode&&f.nodeSupportsAsyncResource?t("async_hooks").AsyncResource:null,y=function(){return{domain:h(),async:new v("Bluebird::Promise")}},g=f.isNode?_:d;f.notEnumerableProp(o,"_getContext",g);var m=function(){g=y,f.notEnumerableProp(o,"_getContext",y)},b=function(){g=_,f.notEnumerableProp(o,"_getContext",_)},C=t("./es5"),w=t("./async"),k=new w;C.defineProperty(o,"_async",{value:k});var E=t("./errors"),j=o.TypeError=E.TypeError;o.RangeError=E.RangeError;var F=o.CancellationError=E.CancellationError;o.TimeoutError=E.TimeoutError,o.OperationalError=E.OperationalError,o.RejectionError=E.OperationalError,o.AggregateError=E.AggregateError;var T=function(){},x={},R={},S=t("./thenables")(o,T),P=t("./promise_array")(o,T,S,u,n),O=t("./context")(o),A=(O.create,t("./debuggability")(o,O,m,b)),H=(A.CapturedTrace,t("./finally")(o,S,R)),N=t("./catch_filter")(R),L=t("./nodeback"),B=f.errorObj,U=f.tryCatch;return o.prototype.toString=function(){return"[object Promise]"},o.prototype.caught=o.prototype["catch"]=function(t){var e=arguments.length;if(e>1){var n,r=new Array(e-1),o=0;
31
+ for(n=0;e-1>n;++n){var i=arguments[n];if(!f.isObject(i))return u("Catch statement predicate: expecting an object but got "+f.classString(i));r[o++]=i}if(r.length=o,t=arguments[n],"function"!=typeof t)throw new j("The last argument to .catch() must be a function, got "+f.toString(t));return this.then(void 0,N(r,t,this))}return this.then(void 0,t)},o.prototype.reflect=function(){return this._then(l,l,void 0,this,void 0)},o.prototype.then=function(t,e){if(A.warnings()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+f.classString(t);arguments.length>1&&(n+=", "+f.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},o.prototype.done=function(t,e){var n=this._then(t,e,void 0,void 0,void 0);n._setIsFinal()},o.prototype.spread=function(t){return"function"!=typeof t?u("expecting a function but got "+f.classString(t)):this.all()._then(t,void 0,void 0,x,void 0)},o.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},o.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new P(this).promise()},o.prototype.error=function(t){return this.caught(f.originatesFromRejection,t)},o.getNewLibraryCopy=e.exports,o.is=function(t){return t instanceof o},o.fromNode=o.fromCallback=function(t){var e=new o(T);e._captureStackTrace();var n=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=U(t)(L(e,n));return r===B&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},o.all=function(t){return new P(t).promise()},o.cast=function(t){var e=S(t);return e instanceof o||(e=new o(T),e._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},o.resolve=o.fulfilled=o.cast,o.reject=o.rejected=function(t){var e=new o(T);return e._captureStackTrace(),e._rejectCallback(t,!0),e},o.setScheduler=function(t){if("function"!=typeof t)throw new j("expecting a function but got "+f.classString(t));return k.setScheduler(t)},o.prototype._then=function(t,e,n,r,i){var a=void 0!==i,s=a?i:new o(T),c=this._target(),l=c._bitField;a||(s._propagateFrom(this,3),s._captureStackTrace(),void 0===r&&0!==(2097152&this._bitField)&&(r=0!==(50397184&l)?this._boundValue():c===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,s));var u=g();if(0!==(50397184&l)){var p,h,d=c._settlePromiseCtx;0!==(33554432&l)?(h=c._rejectionHandler0,p=t):0!==(16777216&l)?(h=c._fulfillmentHandler0,p=e,c._unsetRejectionIsUnhandled()):(d=c._settlePromiseLateCancellationObserver,h=new F("late cancellation observer"),c._attachExtraTrace(h),p=e),k.invoke(d,c,{handler:f.contextBind(u,p),promise:s,receiver:r,value:h})}else c._addCallbacks(t,e,s,r,u);return s},o.prototype._length=function(){return 65535&this._bitField},o.prototype._isFateSealed=function(){return 0!==(117506048&this._bitField)},o.prototype._isFollowing=function(){return 67108864===(67108864&this._bitField)},o.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},o.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},o.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},o.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},o.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},o.prototype._isFinal=function(){return(4194304&this._bitField)>0},o.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},o.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},o.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},o.prototype._setAsyncGuaranteed=function(){if(!k.hasCustomScheduler()){var t=this._bitField;this._bitField=t|(536870912&t)>>2^134217728}},o.prototype._setNoAsyncGuarantee=function(){this._bitField=-134217729&(536870912|this._bitField)},o.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];return e===p?void 0:void 0===e&&this._isBound()?this._boundValue():e},o.prototype._promiseAt=function(t){return this[4*t-4+2]},o.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},o.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},o.prototype._boundValue=function(){},o.prototype._migrateCallback0=function(t){var e=(t._bitField,t._fulfillmentHandler0),n=t._rejectionHandler0,r=t._promise0,o=t._receiverAt(0);void 0===o&&(o=p),this._addCallbacks(e,n,r,o,null)},o.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),o=t._promiseAt(e),i=t._receiverAt(e);void 0===i&&(i=p),this._addCallbacks(n,r,o,i,null)},o.prototype._addCallbacks=function(t,e,n,r,o){var i=this._length();if(i>=65531&&(i=0,this._setLength(0)),0===i)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=f.contextBind(o,t)),"function"==typeof e&&(this._rejectionHandler0=f.contextBind(o,e));else{var a=4*i-4;this[a+2]=n,this[a+3]=r,"function"==typeof t&&(this[a+0]=f.contextBind(o,t)),"function"==typeof e&&(this[a+1]=f.contextBind(o,e))}return this._setLength(i+1),i},o.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},o.prototype._resolveCallback=function(t,e){if(0===(117506048&this._bitField)){if(t===this)return this._rejectCallback(c(),!1);var n=S(t,this);if(!(n instanceof o))return this._fulfill(t);e&&this._propagateFrom(n,2);var r=n._target();if(r===this)return void this._reject(c());var i=r._bitField;if(0===(50397184&i)){var a=this._length();a>0&&r._migrateCallback0(this);for(var s=1;a>s;++s)r._migrateCallbackAt(this,s);this._setFollowing(),this._setLength(0),this._setFollowee(n)}else if(0!==(33554432&i))this._fulfill(r._value());else if(0!==(16777216&i))this._reject(r._reason());else{var l=new F("late cancellation observer");r._attachExtraTrace(l),this._reject(l)}}},o.prototype._rejectCallback=function(t,e,n){var r=f.ensureErrorObject(t),o=r===t;if(!o&&!n&&A.warnings()){var i="a promise was rejected with a non-error: "+f.classString(t);this._warn(i,!0)}this._attachExtraTrace(r,e?o:!1),this._reject(t)},o.prototype._resolveFromExecutor=function(t){if(t!==T){var e=this;this._captureStackTrace(),this._pushContext();var n=!0,r=this._execute(t,function(t){e._resolveCallback(t)},function(t){e._rejectCallback(t,n)});n=!1,this._popContext(),void 0!==r&&e._rejectCallback(r,!0)}},o.prototype._settlePromiseFromHandler=function(t,e,n,r){var o=r._bitField;if(0===(65536&o)){r._pushContext();var i;e===x?n&&"number"==typeof n.length?i=U(t).apply(this._boundValue(),n):(i=B,i.e=new j("cannot .spread() a non-array: "+f.classString(n))):i=U(t).call(e,n);var a=r._popContext();o=r._bitField,0===(65536&o)&&(i===R?r._reject(n):i===B?r._rejectCallback(i.e,!1):(A.checkForgottenReturns(i,a,"",r,this),r._resolveCallback(i)))}},o.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},o.prototype._followee=function(){return this._rejectionHandler0},o.prototype._setFollowee=function(t){this._rejectionHandler0=t},o.prototype._settlePromise=function(t,e,r,i){var a=t instanceof o,s=this._bitField,c=0!==(134217728&s);0!==(65536&s)?(a&&t._invokeInternalOnCancel(),r instanceof H&&r.isFinallyHandler()?(r.cancelPromise=t,U(e).call(r,i)===B&&t._reject(B.e)):e===l?t._fulfill(l.call(r)):r instanceof n?r._promiseCancelled(t):a||t instanceof P?t._cancel():r.cancel()):"function"==typeof e?a?(c&&t._setAsyncGuaranteed(),this._settlePromiseFromHandler(e,r,i,t)):e.call(r,i,t):r instanceof n?r._isResolved()||(0!==(33554432&s)?r._promiseFulfilled(i,t):r._promiseRejected(i,t)):a&&(c&&t._setAsyncGuaranteed(),0!==(33554432&s)?t._fulfill(i):t._reject(i))},o.prototype._settlePromiseLateCancellationObserver=function(t){var e=t.handler,n=t.promise,r=t.receiver,i=t.value;"function"==typeof e?n instanceof o?this._settlePromiseFromHandler(e,r,i,n):e.call(r,i,n):n instanceof o&&n._reject(i)},o.prototype._settlePromiseCtx=function(t){this._settlePromise(t.promise,t.handler,t.receiver,t.value)},o.prototype._settlePromise0=function(t,e,n){var r=this._promise0,o=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(r,t,o,e)},o.prototype._clearCallbackDataAtIndex=function(t){var e=4*t-4;this[e+2]=this[e+3]=this[e+0]=this[e+1]=void 0},o.prototype._fulfill=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(t===this){var n=c();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!==(134217728&e)?this._settlePromises():k.settlePromises(this),this._dereferenceTrace())}},o.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16))return this._setRejected(),this._fulfillmentHandler0=t,this._isFinal()?k.fatalError(t,f.isNode):void((65535&e)>0?k.settlePromises(this):this._ensurePossibleRejectionHandled())},o.prototype._fulfillPromises=function(t,e){for(var n=1;t>n;n++){var r=this._fulfillmentHandlerAt(n),o=this._promiseAt(n),i=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(o,r,i,e)}},o.prototype._rejectPromises=function(t,e){for(var n=1;t>n;n++){var r=this._rejectionHandlerAt(n),o=this._promiseAt(n),i=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(o,r,i,e)}},o.prototype._settlePromises=function(){var t=this._bitField,e=65535&t;if(e>0){if(0!==(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},o.prototype._settledValue=function(){var t=this._bitField;return 0!==(33554432&t)?this._rejectionHandler0:0!==(16777216&t)?this._fulfillmentHandler0:void 0},"undefined"!=typeof Symbol&&Symbol.toStringTag&&C.defineProperty(o.prototype,Symbol.toStringTag,{get:function(){return"Object"}}),o.defer=o.pending=function(){A.deprecated("Promise.defer","new Promise");var t=new o(T);return{promise:t,resolve:i,reject:a}},f.notEnumerableProp(o,"_makeSelfResolutionError",c),t("./method")(o,T,S,u,A),t("./bind")(o,T,S,A),t("./cancel")(o,P,u,A),t("./direct_resolve")(o),t("./synchronous_inspection")(o),t("./join")(o,P,S,T,k),o.Promise=o,o.version="3.7.2",f.toFastProperties(o),f.toFastProperties(o.prototype),s({a:1}),s({b:2}),s({c:3}),s(1),s(function(){}),s(void 0),s(!1),s(new o(T)),A.setBounds(w.firstLineError,f.lastLineError),o}},{"./async":1,"./bind":2,"./cancel":4,"./catch_filter":5,"./context":6,"./debuggability":7,"./direct_resolve":8,"./errors":9,"./es5":10,"./finally":11,"./join":12,"./method":13,"./nodeback":14,"./promise_array":16,"./synchronous_inspection":19,"./thenables":20,"./util":21,async_hooks:void 0}],16:[function(t,e,n){"use strict";e.exports=function(e,n,r,o,i){function a(t){switch(t){case-2:return[];case-3:return{};case-6:return new Map}}function s(t){var r=this._promise=new e(n);t instanceof e&&(r._propagateFrom(t,3),t.suppressUnhandledRejections()),r._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var c=t("./util");c.isArray;return c.inherits(s,i),s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function l(t,n){var i=r(this._values,this._promise);if(i instanceof e){i=i._target();var s=i._bitField;if(this._values=i,0===(50397184&s))return this._promise._setAsyncGuaranteed(),i._then(l,this._reject,void 0,this,n);if(0===(33554432&s))return 0!==(16777216&s)?this._reject(i._reason()):this._cancel();i=i._value()}if(i=c.asArray(i),null===i){var u=o("expecting an array or an iterable object but got "+c.classString(i)).reason();return void this._promise._rejectCallback(u,!1)}return 0===i.length?void(-5===n?this._resolveEmptyArray():this._resolve(a(n))):void this._iterate(i)},s.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var o=this._promise,i=!1,a=null,s=0;n>s;++s){var c=r(t[s],o);c instanceof e?(c=c._target(),a=c._bitField):a=null,i?null!==a&&c.suppressUnhandledRejections():null!==a?0===(50397184&a)?(c._proxy(this,s),this._values[s]=c):i=0!==(33554432&a)?this._promiseFulfilled(c._value(),s):0!==(16777216&a)?this._promiseRejected(c._reason(),s):this._promiseCancelled(s):i=this._promiseFulfilled(c,s)}i||o._setAsyncGuaranteed()},s.prototype._isResolved=function(){return null===this._values},s.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},s.prototype._cancel=function(){!this._isResolved()&&this._promise._isCancellable()&&(this._values=null,this._promise._cancel())},s.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1)},s.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},s.prototype._promiseCancelled=function(){return this._cancel(),!0},s.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},s.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;n<t.length;++n)t[n]instanceof e&&t[n].cancel()}},s.prototype.shouldCopyValues=function(){return!0},s.prototype.getActualLength=function(t){return t},s}},{"./util":21}],17:[function(t,e,n){"use strict";function r(t,e,n,r,o){for(var i=0;o>i;++i)n[i+r]=t[i+e],t[i+e]=void 0}function o(t){this._capacity=t,this._length=0,this._front=0}o.prototype._willBeOverCapacity=function(t){return this._capacity<t},o.prototype._pushOne=function(t){var e=this.length();this._checkCapacity(e+1);var n=this._front+e&this._capacity-1;this[n]=t,this._length=e+1},o.prototype.push=function(t,e,n){var r=this.length()+3;if(this._willBeOverCapacity(r))return this._pushOne(t),this._pushOne(e),void this._pushOne(n);var o=this._front+r-3;this._checkCapacity(r);var i=this._capacity-1;this[o+0&i]=t,this[o+1&i]=e,this[o+2&i]=n,this._length=r},o.prototype.shift=function(){var t=this._front,e=this[t];return this[t]=void 0,this._front=t+1&this._capacity-1,this._length--,e},o.prototype.length=function(){return this._length},o.prototype._checkCapacity=function(t){this._capacity<t&&this._resizeTo(this._capacity<<1)},o.prototype._resizeTo=function(t){var e=this._capacity;this._capacity=t;var n=this._front,o=this._length,i=n+o&e-1;r(this,0,this,e,i)},e.exports=o},{}],18:[function(t,e,n){"use strict";var r,o=t("./util"),i=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")},a=o.getNativePromise();if(o.isNode&&"undefined"==typeof MutationObserver){var s=global.setImmediate,c=process.nextTick;r=o.isRecentNode?function(t){s.call(global,t)}:function(t){c.call(process,t)}}else if("function"==typeof a&&"function"==typeof a.resolve){var l=a.resolve();r=function(t){l.then(t)}}else r="undefined"!=typeof MutationObserver&&("undefined"==typeof window||!window.navigator||!window.navigator.standalone&&!window.cordova)&&"classList"in document.documentElement?function(){var t=document.createElement("div"),e={attributes:!0},n=!1,r=document.createElement("div"),o=new MutationObserver(function(){t.classList.toggle("foo"),n=!1});o.observe(r,e);var i=function(){n||(n=!0,r.classList.toggle("foo"))};return function(n){var r=new MutationObserver(function(){r.disconnect(),n()});r.observe(t,e),i()}}():"undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:i;e.exports=r},{"./util":21}],19:[function(t,e,n){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var n=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},r=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},o=e.prototype.isFulfilled=function(){return 0!==(33554432&this._bitField)},i=e.prototype.isRejected=function(){return 0!==(16777216&this._bitField)},a=e.prototype.isPending=function(){return 0===(50397184&this._bitField)},s=e.prototype.isResolved=function(){return 0!==(50331648&this._bitField)};e.prototype.isCancelled=function(){return 0!==(8454144&this._bitField)},t.prototype.__isCancelled=function(){return 65536===(65536&this._bitField)},t.prototype._isCancelled=function(){return this._target().__isCancelled()},t.prototype.isCancelled=function(){return 0!==(8454144&this._target()._bitField)},t.prototype.isPending=function(){return a.call(this._target())},t.prototype.isRejected=function(){return i.call(this._target())},t.prototype.isFulfilled=function(){return o.call(this._target())},t.prototype.isResolved=function(){return s.call(this._target())},t.prototype.value=function(){return n.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),r.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],20:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,r){if(u(t)){if(t instanceof e)return t;var o=i(t);if(o===l){r&&r._pushContext();var c=e.reject(o.e);return r&&r._popContext(),c}if("function"==typeof o){if(a(t)){var c=new e(n);return t._then(c._fulfill,c._reject,void 0,c,null),c}return s(t,o,r)}}return t}function o(t){return t.then}function i(t){try{return o(t)}catch(e){return l.e=e,l}}function a(t){try{return p.call(t,"_promise0")}catch(e){return!1}}function s(t,r,o){function i(t){s&&(s._resolveCallback(t),s=null)}function a(t){s&&(s._rejectCallback(t,p,!0),s=null)}var s=new e(n),u=s;o&&o._pushContext(),s._captureStackTrace(),o&&o._popContext();var p=!0,f=c.tryCatch(r).call(t,i,a);return p=!1,s&&f===l&&(s._rejectCallback(f.e,!0,!0),s=null),u}var c=t("./util"),l=c.errorObj,u=c.isObject,p={}.hasOwnProperty;return r}},{"./util":21}],21:[function(t,e,n){"use strict";function r(){try{var t=R;return R=null,t.apply(this,arguments)}catch(e){return x.e=e,x}}function o(t){return R=t,r}function i(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function a(t){return"function"==typeof t||"object"==typeof t&&null!==t}function s(t){return i(t)?new Error(v(t)):t}function c(t,e){var n,r=t.length,o=new Array(r+1);for(n=0;r>n;++n)o[n]=t[n];return o[n]=e,o}function l(t,e,n){if(!F.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var r=Object.getOwnPropertyDescriptor(t,e);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function u(t,e,n){if(i(t))return t;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return F.defineProperty(t,e,r),t}function p(t){throw t}function f(t){try{if("function"==typeof t){var e=F.names(t.prototype),n=F.isES5&&e.length>1,r=e.length>0&&!(1===e.length&&"constructor"===e[0]),o=A.test(t+"")&&F.names(t).length>0;if(n||r||o)return!0}return!1}catch(i){return!1}}function h(t){function e(){}function n(){return typeof r.foo}e.prototype=t;var r=new e;return n(),n(),t}function d(t){return H.test(t)}function _(t,e,n){for(var r=new Array(t),o=0;t>o;++o)r[o]=e+o+n;return r}function v(t){try{return t+""}catch(e){return"[no string representation]"}}function y(t){return t instanceof Error||null!==t&&"object"==typeof t&&"string"==typeof t.message&&"string"==typeof t.name}function g(t){try{u(t,"isOperational",!0)}catch(e){}}function m(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function b(t){return y(t)&&F.propertyIsWritable(t,"stack")}function C(t){return{}.toString.call(t)}function w(t,e,n){for(var r=F.names(t),o=0;o<r.length;++o){var i=r[o];if(n(i))try{F.defineProperty(e,i,F.getDescriptor(t,i))}catch(a){}}}function k(t){return I?process.env[t]:void 0}function E(){if("function"==typeof Promise)try{var t=new Promise(function(){});if("[object Promise]"===C(t))return Promise}catch(e){}}function j(t,e){if(null===t||"function"!=typeof e||e===D)return e;null!==t.domain&&(e=t.domain.bind(e));var n=t.async;if(null!==n){var r=e;e=function(){var t=new Array(2).concat([].slice.call(arguments));return t[0]=r,t[1]=this,n.runInAsyncScope.apply(n,t)}}return e}var F=t("./es5"),T="undefined"==typeof navigator,x={e:{}},R,S="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0!==this?this:null,P=function(t,e){function n(){this.constructor=t,this.constructor$=e;for(var n in e.prototype)r.call(e.prototype,n)&&"$"!==n.charAt(n.length-1)&&(this[n+"$"]=e.prototype[n])}var r={}.hasOwnProperty;return n.prototype=e.prototype,t.prototype=new n,t.prototype},O=function(){var t=[Array.prototype,Object.prototype,Function.prototype],e=function(e){for(var n=0;n<t.length;++n)if(t[n]===e)return!0;return!1};if(F.isES5){var n=Object.getOwnPropertyNames;return function(t){for(var r=[],o=Object.create(null);null!=t&&!e(t);){var i;try{i=n(t)}catch(a){return r}for(var s=0;s<i.length;++s){var c=i[s];if(!o[c]){o[c]=!0;var l=Object.getOwnPropertyDescriptor(t,c);null!=l&&null==l.get&&null==l.set&&r.push(c)}}t=F.getPrototypeOf(t)}return r}}var r={}.hasOwnProperty;return function(n){if(e(n))return[];var o=[];t:for(var i in n)if(r.call(n,i))o.push(i);else{for(var a=0;a<t.length;++a)if(r.call(t[a],i))continue t;o.push(i)}return o}}(),A=/this\s*\.\s*\S+\s*=/,H=/^[a-z$_][a-z$_0-9]*$/i,N=function(){return"stack"in new Error?function(t){return b(t)?t:new Error(v(t))}:function(t){if(b(t))return t;try{throw new Error(v(t))}catch(e){return e}}}(),L=function(t){return F.isArray(t)?t:null};if("undefined"!=typeof Symbol&&Symbol.iterator){var B="function"==typeof Array.from?function(t){return Array.from(t)}:function(t){for(var e,n=[],r=t[Symbol.iterator]();!(e=r.next()).done;)n.push(e.value);return n};L=function(t){return F.isArray(t)?t:null!=t&&"function"==typeof t[Symbol.iterator]?B(t):null}}var U="undefined"!=typeof process&&"[object process]"===C(process).toLowerCase(),I="undefined"!=typeof process&&"undefined"!=typeof process.env,D,V={setReflectHandler:function(t){D=t},isClass:f,isIdentifier:d,inheritedDataKeys:O,getDataPropertyOrDefault:l,thrower:p,isArray:F.isArray,asArray:L,notEnumerableProp:u,isPrimitive:i,isObject:a,isError:y,canEvaluate:T,errorObj:x,tryCatch:o,inherits:P,withAppended:c,maybeWrapAsError:s,toFastProperties:h,filledRange:_,toString:v,canAttachTrace:b,ensureErrorObject:N,originatesFromRejection:m,markAsOriginatingFromRejection:g,classString:C,copyDescriptors:w,isNode:U,hasEnvVariables:I,env:k,global:S,getNativePromise:E,contextBind:j};V.isRecentNode=V.isNode&&function(){var t;return process.versions&&process.versions.node?t=process.versions.node.split(".").map(Number):process.version&&(t=process.version.split(".").map(Number)),0===t[0]&&t[1]>10||t[0]>0}(),V.nodeSupportsAsyncResource=V.isNode&&function(){var e=!1;try{var n=t("async_hooks").AsyncResource;e="function"==typeof n.prototype.runInAsyncScope}catch(r){e=!1}return e}(),V.isNode&&V.toFastProperties(process);try{throw new Error}catch(Q){V.lastLineError=Q}e.exports=V},{"./es5":10,async_hooks:void 0}]},{},[3])(3)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise);
node_modules/bluebird/js/browser/bluebird.js ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/bluebird/js/browser/bluebird.min.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* @preserve
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2013-2018 Petka Antonov
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ */
25
+ /**
26
+ * bluebird build version 3.7.2
27
+ * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each
28
+ */
29
+ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Promise=t()}}(function(){var t,e,n;return function r(t,e,n){function i(s,a){if(!e[s]){if(!t[s]){var c="function"==typeof _dereq_&&_dereq_;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=e[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return i(n?n:e)},l,l.exports,r,t,e,n)}return e[s].exports}for(var o="function"==typeof _dereq_&&_dereq_,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(t,e,n){"use strict";e.exports=function(t){function e(t){var e=new n(t),r=e.promise();return e.setHowMany(1),e.setUnwrap(),e.init(),r}var n=t._SomePromiseArray;t.any=function(t){return e(t)},t.prototype.any=function(){return e(this)}}},{}],2:[function(t,e,n){"use strict";function r(){this._customScheduler=!1,this._isTickUsed=!1,this._lateQueue=new f(16),this._normalQueue=new f(16),this._haveDrainedQueues=!1;var t=this;this.drainQueues=function(){t._drainQueues()},this._schedule=p}function i(t,e,n){this._lateQueue.push(t,e,n),this._queueTick()}function o(t,e,n){this._normalQueue.push(t,e,n),this._queueTick()}function s(t){this._normalQueue._pushOne(t),this._queueTick()}function a(t){for(;t.length()>0;)c(t)}function c(t){var e=t.shift();if("function"!=typeof e)e._settlePromises();else{var n=t.shift(),r=t.shift();e.call(n,r)}}var u;try{throw new Error}catch(l){u=l}var p=t("./schedule"),f=t("./queue");r.prototype.setScheduler=function(t){var e=this._schedule;return this._schedule=t,this._customScheduler=!0,e},r.prototype.hasCustomScheduler=function(){return this._customScheduler},r.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues},r.prototype.fatalError=function(t,e){e?(process.stderr.write("Fatal "+(t instanceof Error?t.stack:t)+"\n"),process.exit(2)):this.throwLater(t)},r.prototype.throwLater=function(t,e){if(1===arguments.length&&(e=t,t=function(){throw e}),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(n){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")}},r.prototype.invokeLater=i,r.prototype.invoke=o,r.prototype.settlePromises=s,r.prototype._drainQueues=function(){a(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,a(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=r,e.exports.firstLineError=u},{"./queue":26,"./schedule":29}],3:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,o=function(t,e){this._reject(e)},s=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(o,o,null,this,t)},a=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},c=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(o){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var u=n(o),l=new t(e);l._propagateFrom(this,1);var p=this._target();if(l._setBoundTo(u),u instanceof t){var f={promiseRejectionQueued:!1,promise:l,target:p,bindingPromise:u};p._then(e,s,void 0,l,f),u._then(a,c,void 0,l,f),l._setOnCancel(u)}else l._resolveCallback(p);return l},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],4:[function(t,e,n){"use strict";function r(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise")();o.noConflict=r,e.exports=o},{"./promise":22}],5:[function(t,e,n){"use strict";var r=Object.create;if(r){var i=r(null),o=r(null);i[" size"]=o[" size"]=0}e.exports=function(e){function n(t,n){var r;if(null!=t&&(r=t[n]),"function"!=typeof r){var i="Object "+a.classString(t)+" has no method '"+a.toString(n)+"'";throw new e.TypeError(i)}return r}function r(t){var e=this.pop(),r=n(t,e);return r.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}var s,a=t("./util"),c=a.canEvaluate;a.isIdentifier;e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(r,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e,n="number"==typeof t;if(n)e=o;else if(c){var r=s(t);e=null!==r?r:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var o=t("./util"),s=o.tryCatch,a=o.errorObj,c=e._async;e.prototype["break"]=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),c.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var n=0;n<t.length;++n)this._doInvokeOnCancel(t[n],e);else if(void 0!==t)if("function"==typeof t){if(!e){var r=s(t).call(this._boundValue());r===a&&(this._attachExtraTrace(r.e),c.throwLater(r.e))}}else t._resultCancelled(this)},e.prototype._invokeOnCancel=function(){var t=this._onCancel();this._unsetOnCancel(),c.invoke(this._doInvokeOnCancel,this,t)},e.prototype._invokeInternalOnCancel=function(){this._isCancellable()&&(this._doInvokeOnCancel(this._onCancel(),!0),this._unsetOnCancel())},e.prototype._resultCancelled=function(){this.cancel()}}},{"./util":36}],7:[function(t,e,n){"use strict";e.exports=function(e){function n(t,n,a){return function(c){var u=a._boundValue();t:for(var l=0;l<t.length;++l){var p=t[l];if(p===Error||null!=p&&p.prototype instanceof Error){if(c instanceof p)return o(n).call(u,c)}else if("function"==typeof p){var f=o(p).call(u,c);if(f===s)return f;if(f)return o(n).call(u,c)}else if(r.isObject(c)){for(var h=i(p),_=0;_<h.length;++_){var d=h[_];if(p[d]!=c[d])continue t}return o(n).call(u,c)}}return e}}var r=t("./util"),i=t("./es5").keys,o=r.tryCatch,s=r.errorObj;return n}},{"./es5":13,"./util":36}],8:[function(t,e,n){"use strict";e.exports=function(t){function e(){this._trace=new e.CapturedTrace(r())}function n(){return i?new e:void 0}function r(){var t=o.length-1;return t>=0?o[t]:void 0}var i=!1,o=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=o.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=n,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var n=t.prototype._pushContext,o=t.prototype._popContext,s=t._peekContext,a=t.prototype._peekContext,c=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=o,t._peekContext=s,t.prototype._peekContext=a,t.prototype._promiseCreated=c,i=!1},i=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=r,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],9:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){function o(t,e){return{promise:e}}function s(){return!1}function a(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+B.toString(t));r._attachCancellationCallback(t)})}catch(i){return i}}function c(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?B.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function u(){return this._onCancelField}function l(t){this._onCancelField=t}function p(){this._cancellationParent=void 0,this._onCancelField=void 0}function f(t,e){if(0!==(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function h(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function _(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function d(){this._trace=new V(this._peekContext())}function v(t,e){if(q(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=F(t);B.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),B.notEnumerableProp(t,"__stackCleaned__",!0)}}}function y(){this._trace=void 0}function g(t,e,n,r,i){if(void 0===t&&null!==e&&Z){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var o="",s="";if(e._trace){for(var a=e._trace.stack.split("\n"),c=k(a),u=c.length-1;u>=0;--u){var l=c[u];if(!Q.test(l)){var p=l.match(G);p&&(o="at "+p[1]+":"+p[2]+":"+p[3]+" ");break}}if(c.length>0)for(var f=c[0],u=0;u<a.length;++u)if(a[u]===f){u>0&&(s="\n"+a[u-1]);break}}var h="a promise was created in a "+n+"handler "+o+"but was not returned from it, see http://goo.gl/rRqMUw"+s;r._warn(h,!0,e)}}function m(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),b(n)}function b(t,n,r){if(lt.warnings){var i,o=new U(t);if(n)r._attachExtraTrace(o);else if(lt.longStackTraces&&(i=e._peekContext()))i.attachExtraTrace(o);else{var s=F(o);o.stack=s.message+"\n"+s.stack.join("\n")}ot("warning",o)||x(o,"",!0)}}function w(t,e){for(var n=0;n<e.length-1;++n)e[n].push("From previous event:"),e[n]=e[n].join("\n");return n<e.length&&(e[n]=e[n].join("\n")),t+"\n"+e.join("\n")}function C(t){for(var e=0;e<t.length;++e)(0===t[e].length||e+1<t.length&&t[e][0]===t[e+1][0])&&(t.splice(e,1),e--)}function j(t){for(var e=t[0],n=1;n<t.length;++n){for(var r=t[n],i=e.length-1,o=e[i],s=-1,a=r.length-1;a>=0;--a)if(r[a]===o){s=a;break}for(var a=s;a>=0;--a){var c=r[a];if(e[i]!==c)break;e.pop(),i--}e=r}}function k(t){for(var e=[],n=0;n<t.length;++n){var r=t[n],i=" (No stack trace)"===r||z.test(r),o=i&&at(r);i&&!o&&(W&&" "!==r.charAt(0)&&(r=" "+r),e.push(r))}return e}function E(t){for(var e=t.stack.replace(/\s+$/g,"").split("\n"),n=0;n<e.length;++n){var r=e[n];if(" (No stack trace)"===r||z.test(r))break}return n>0&&"SyntaxError"!=t.name&&(e=e.slice(n)),e}function F(t){var e=t.stack,n=t.toString();return e="string"==typeof e&&e.length>0?E(t):[" (No stack trace)"],{message:n,stack:"SyntaxError"==t.name?e:k(e)}}function x(t,e,n){if("undefined"!=typeof console){var r;if(B.isObject(t)){var i=t.stack;r=e+X(i,t)}else r=e+String(t);"function"==typeof I?I(r,n):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}}function T(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(o){N.throwLater(o)}"unhandledRejection"===t?ot(t,n,r)||i||x(n,"Unhandled rejection "):ot(t,r)}function P(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():B.toString(t);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(e))try{var r=JSON.stringify(t);e=r}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+R(e)+">, no stack trace)"}function R(t){var e=41;return t.length<e?t:t.substr(0,e-3)+"..."}function S(){return"function"==typeof ut}function O(t){var e=t.match(ct);return e?{fileName:e[1],line:parseInt(e[2],10)}:void 0}function A(t,e){if(S()){for(var n,r,i=(t.stack||"").split("\n"),o=(e.stack||"").split("\n"),s=-1,a=-1,c=0;c<i.length;++c){var u=O(i[c]);if(u){n=u.fileName,s=u.line;break}}for(var c=0;c<o.length;++c){var u=O(o[c]);if(u){r=u.fileName,a=u.line;break}}0>s||0>a||!n||!r||n!==r||s>=a||(at=function(t){if($.test(t))return!0;var e=O(t);return e&&e.fileName===n&&s<=e.line&&e.line<=a?!0:!1})}}function V(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);ut(this,V),e>32&&this.uncycle()}var H,D,I,L,N=e._async,U=t("./errors").Warning,B=t("./util"),M=t("./es5"),q=B.canAttachTrace,$=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,Q=/\((?:timers\.js):\d+:\d+\)/,G=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,z=null,X=null,W=!1,K=!(0==B.env("BLUEBIRD_DEBUG")||!B.env("BLUEBIRD_DEBUG")&&"development"!==B.env("NODE_ENV")),J=!(0==B.env("BLUEBIRD_WARNINGS")||!K&&!B.env("BLUEBIRD_WARNINGS")),Y=!(0==B.env("BLUEBIRD_LONG_STACK_TRACES")||!K&&!B.env("BLUEBIRD_LONG_STACK_TRACES")),Z=0!=B.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(J||!!B.env("BLUEBIRD_W_FORGOTTEN_RETURN"));!function(){function t(){for(var t=0;t<r.length;++t)r[t]._notifyUnhandledRejection();n()}function n(){r.length=0}var r=[];L=function(e){r.push(e),setTimeout(t,1)},M.defineProperty(e,"_unhandledRejectionCheck",{value:t}),M.defineProperty(e,"_unhandledRejectionClear",{value:n})}(),e.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},e.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),L(this))},e.prototype._notifyUnhandledRejectionIsHandled=function(){T("rejectionHandled",H,void 0,this)},e.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},e.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),T("unhandledRejection",D,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},e.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},e.prototype._warn=function(t,e,n){return b(t,e,n||this)},e.onPossiblyUnhandledRejection=function(t){var n=e._getContext();D=B.contextBind(n,t)},e.onUnhandledRejectionHandled=function(t){var n=e._getContext();H=B.contextBind(n,t)};var tt=function(){};e.longStackTraces=function(){if(N.haveItemsQueued()&&!lt.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!lt.longStackTraces&&S()){var t=e.prototype._captureStackTrace,r=e.prototype._attachExtraTrace,i=e.prototype._dereferenceTrace;lt.longStackTraces=!0,tt=function(){if(N.haveItemsQueued()&&!lt.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");e.prototype._captureStackTrace=t,e.prototype._attachExtraTrace=r,e.prototype._dereferenceTrace=i,n.deactivateLongStackTraces(),lt.longStackTraces=!1},e.prototype._captureStackTrace=d,e.prototype._attachExtraTrace=v,e.prototype._dereferenceTrace=y,n.activateLongStackTraces()}},e.hasLongStackTraces=function(){return lt.longStackTraces&&S()};var et={unhandledrejection:{before:function(){var t=B.global.onunhandledrejection;return B.global.onunhandledrejection=null,t},after:function(t){B.global.onunhandledrejection=t}},rejectionhandled:{before:function(){var t=B.global.onrejectionhandled;return B.global.onrejectionhandled=null,t},after:function(t){B.global.onrejectionhandled=t}}},nt=function(){var t=function(t,e){if(!t)return!B.global.dispatchEvent(e);var n;try{return n=t.before(),!B.global.dispatchEvent(e)}finally{t.after(n)}};try{if("function"==typeof CustomEvent){var e=new CustomEvent("CustomEvent");return B.global.dispatchEvent(e),function(e,n){e=e.toLowerCase();var r={detail:n,cancelable:!0},i=new CustomEvent(e,r);return M.defineProperty(i,"promise",{value:n.promise}),M.defineProperty(i,"reason",{value:n.reason}),t(et[e],i)}}if("function"==typeof Event){var e=new Event("CustomEvent");return B.global.dispatchEvent(e),function(e,n){e=e.toLowerCase();var r=new Event(e,{cancelable:!0});return r.detail=n,M.defineProperty(r,"promise",{value:n.promise}),M.defineProperty(r,"reason",{value:n.reason}),t(et[e],r)}}var e=document.createEvent("CustomEvent");return e.initCustomEvent("testingtheevent",!1,!0,{}),B.global.dispatchEvent(e),function(e,n){e=e.toLowerCase();var r=document.createEvent("CustomEvent");return r.initCustomEvent(e,!1,!0,n),t(et[e],r)}}catch(n){}return function(){return!1}}(),rt=function(){return B.isNode?function(){return process.emit.apply(process,arguments)}:B.global?function(t){var e="on"+t.toLowerCase(),n=B.global[e];return n?(n.apply(B.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),it={promiseCreated:o,promiseFulfilled:o,promiseRejected:o,promiseResolved:o,promiseCancelled:o,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:o},ot=function(t){var e=!1;try{e=rt.apply(null,arguments)}catch(n){N.throwLater(n),e=!0}var r=!1;try{r=nt(t,it[t].apply(null,arguments))}catch(n){N.throwLater(n),r=!0}return r||e};e.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?e.longStackTraces():!t.longStackTraces&&e.hasLongStackTraces()&&tt()),"warnings"in t){var n=t.warnings;lt.warnings=!!n,Z=lt.warnings,B.isObject(n)&&"wForgottenReturn"in n&&(Z=!!n.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!lt.cancellation){if(N.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");e.prototype._clearCancellationData=p,e.prototype._propagateFrom=f,e.prototype._onCancel=u,e.prototype._setOnCancel=l,e.prototype._attachCancellationCallback=c,e.prototype._execute=a,st=f,lt.cancellation=!0}if("monitoring"in t&&(t.monitoring&&!lt.monitoring?(lt.monitoring=!0,e.prototype._fireEvent=ot):!t.monitoring&&lt.monitoring&&(lt.monitoring=!1,e.prototype._fireEvent=s)),"asyncHooks"in t&&B.nodeSupportsAsyncResource){var o=lt.asyncHooks,h=!!t.asyncHooks;o!==h&&(lt.asyncHooks=h,h?r():i())}return e},e.prototype._fireEvent=s,e.prototype._execute=function(t,e,n){try{t(e,n)}catch(r){return r}},e.prototype._onCancel=function(){},e.prototype._setOnCancel=function(t){},e.prototype._attachCancellationCallback=function(t){},e.prototype._captureStackTrace=function(){},e.prototype._attachExtraTrace=function(){},e.prototype._dereferenceTrace=function(){},e.prototype._clearCancellationData=function(){},e.prototype._propagateFrom=function(t,e){};var st=h,at=function(){return!1},ct=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;B.inherits(V,Error),n.CapturedTrace=V,V.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;t=this._length=r;for(var r=t-1;r>=0;--r){var o=e[r].stack;void 0===n[o]&&(n[o]=r)}for(var r=0;t>r;++r){var s=e[r].stack,a=n[s];if(void 0!==a&&a!==r){a>0&&(e[a-1]._parent=void 0,e[a-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var c=r>0?e[r-1]:this;t-1>a?(c._parent=e[a+1],c._parent.uncycle(),c._length=c._parent._length+1):(c._parent=void 0,c._length=1);for(var u=c._length+1,l=r-2;l>=0;--l)e[l]._length=u,u++;return}}}},V.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=F(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(k(i.stack.split("\n"))),i=i._parent;j(r),C(r),B.notEnumerableProp(t,"stack",w(n,r)),B.notEnumerableProp(t,"__stackCleaned__",!0)}};var ut=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():P(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,z=t,X=e;var n=Error.captureStackTrace;return at=function(t){return $.test(t)},function(t,e){Error.stackTraceLimit+=6,n(t,e),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return z=/@/,X=e,W=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(X=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?P(e):e.toString()},null):(z=t,X=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(I=function(t){console.warn(t)},B.isNode&&process.stderr.isTTY?I=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:B.isNode||"string"!=typeof(new Error).stack||(I=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var lt={warnings:J,longStackTraces:!1,cancellation:!1,monitoring:!1,asyncHooks:!1};return Y&&e.longStackTraces(),{asyncHooks:function(){return lt.asyncHooks},longStackTraces:function(){return lt.longStackTraces},warnings:function(){return lt.warnings},cancellation:function(){return lt.cancellation},monitoring:function(){return lt.monitoring},propagateFromFunction:function(){return st},boundValueFunction:function(){return _},checkForgottenReturns:g,setBounds:A,warn:b,deprecated:m,CapturedTrace:V,fireDomEvent:nt,fireGlobalEvent:rt}}},{"./errors":12,"./es5":13,"./util":36}],10:[function(t,e,n){"use strict";e.exports=function(t){function e(){return this.value}function n(){throw this.reason}t.prototype["return"]=t.prototype.thenReturn=function(n){return n instanceof t&&n.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:n},void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return this._then(n,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:t},void 0);var e=arguments[1],r=function(){throw e};return this.caught(t,r)},t.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof t&&n.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:n},void 0);var r=arguments[1];r instanceof t&&r.suppressUnhandledRejections();var i=function(){return r};return this.caught(n,i)}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){function n(){return o(this)}function r(t,n){return i(t,n,e,e)}var i=t.reduce,o=t.all;t.prototype.each=function(t){return i(this,t,e,0)._then(n,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return i(this,t,e,e)},t.each=function(t,r){return i(t,r,e,0)._then(n,void 0,void 0,t,void 0)},t.mapSeries=r}},{}],12:[function(t,e,n){"use strict";function r(t,e){function n(r){return this instanceof n?(p(this,"message","string"==typeof r?r:e),p(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return l(n,Error),n}function i(t){return this instanceof i?(p(this,"name","OperationalError"),p(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(p(this,"message",t.message),p(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,s,a=t("./es5"),c=a.freeze,u=t("./util"),l=u.inherits,p=u.notEnumerableProp,f=r("Warning","warning"),h=r("CancellationError","cancellation error"),_=r("TimeoutError","timeout error"),d=r("AggregateError","aggregate error");try{o=TypeError,s=RangeError}catch(v){o=r("TypeError","type error"),s=r("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),g=0;g<y.length;++g)"function"==typeof Array.prototype[y[g]]&&(d.prototype[y[g]]=Array.prototype[y[g]]);a.defineProperty(d.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),d.prototype.isOperational=!0;var m=0;d.prototype.toString=function(){var t=Array(4*m+1).join(" "),e="\n"+t+"AggregateError of:\n";m++,t=Array(4*m+1).join(" ");for(var n=0;n<this.length;++n){for(var r=this[n]===this?"[Circular AggregateError]":this[n]+"",i=r.split("\n"),o=0;o<i.length;++o)i[o]=t+i[o];r=i.join("\n"),e+=r+"\n"}return m--,e},l(i,Error);var b=Error.__BluebirdErrorTypes__;b||(b=c({CancellationError:h,TimeoutError:_,OperationalError:i,RejectionError:i,AggregateError:d}),a.defineProperty(Error,"__BluebirdErrorTypes__",{value:b,writable:!1,enumerable:!1,configurable:!1})),e.exports={Error:Error,TypeError:o,RangeError:s,CancellationError:b.CancellationError,OperationalError:b.OperationalError,TimeoutError:b.TimeoutError,AggregateError:b.AggregateError,Warning:f}},{"./es5":13,"./util":36}],13:[function(t,e,n){var r=function(){"use strict";return void 0===this}();if(r)e.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:r,propertyIsWritable:function(t,e){var n=Object.getOwnPropertyDescriptor(t,e);return!(n&&!n.writable&&!n.set)}};else{var i={}.hasOwnProperty,o={}.toString,s={}.constructor.prototype,a=function(t){var e=[];for(var n in t)i.call(t,n)&&e.push(n);return e},c=function(t,e){return{value:t[e]}},u=function(t,e,n){return t[e]=n.value,t},l=function(t){return t},p=function(t){try{return Object(t).constructor.prototype}catch(e){return s}},f=function(t){try{return"[object Array]"===o.call(t)}catch(e){return!1}};e.exports={isArray:f,keys:a,names:a,defineProperty:u,getDescriptor:c,freeze:l,getPrototypeOf:p,isES5:r,propertyIsWritable:function(){return!0}}}},{}],14:[function(t,e,n){"use strict";e.exports=function(t,e){var n=t.map;t.prototype.filter=function(t,r){return n(this,t,r,e)},t.filter=function(t,r,i){return n(t,r,i,e)}}},{}],15:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t,e,n){this.promise=t,this.type=e,this.handler=n,this.called=!1,this.cancelPromise=null}function o(t){this.finallyHandler=t}function s(t,e){return null!=t.cancelPromise?(arguments.length>1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0):!1}function a(){return u.call(this,this.promise._target()._settledValue())}function c(t){return s(this,t)?void 0:(f.e=t,f)}function u(t){var i=this.promise,u=this.handler;if(!this.called){this.called=!0;var l=this.isFinallyHandler()?u.call(i._boundValue()):u.call(i._boundValue(),t);if(l===r)return l;if(void 0!==l){i._setReturnedNonUndefined();var h=n(l,i);if(h instanceof e){if(null!=this.cancelPromise){if(h._isCancelled()){var _=new p("late cancellation observer");return i._attachExtraTrace(_),f.e=_,f}h.isPending()&&h._attachCancellationCallback(new o(this))}return h._then(a,c,void 0,this,void 0)}}}return i.isRejected()?(s(this),f.e=t,f):(s(this),t)}var l=t("./util"),p=e.CancellationError,f=l.errorObj,h=t("./catch_filter")(r);return i.prototype.isFinallyHandler=function(){return 0===this.type},o.prototype._resultCancelled=function(){s(this.finallyHandler)},e.prototype._passThrough=function(t,e,n,r){return"function"!=typeof t?this.then():this._then(n,r,void 0,new i(this,e,t),void 0)},e.prototype.lastly=e.prototype["finally"]=function(t){return this._passThrough(t,0,u,u)},e.prototype.tap=function(t){return this._passThrough(t,1,u)},e.prototype.tapCatch=function(t){var n=arguments.length;if(1===n)return this._passThrough(t,1,void 0,u);var r,i=new Array(n-1),o=0;for(r=0;n-1>r;++r){var s=arguments[r];if(!l.isObject(s))return e.reject(new TypeError("tapCatch statement predicate: expecting an object but got "+l.classString(s)));i[o++]=s}i.length=o;var a=arguments[r];return this._passThrough(h(i,a,this),1,void 0,u)},i}},{"./catch_filter":7,"./util":36}],16:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,n,r){for(var o=0;o<n.length;++o){r._pushContext();var s=h(n[o])(t);if(r._popContext(),s===f){r._pushContext();var a=e.reject(f.e);return r._popContext(),a}var c=i(s,r);if(c instanceof e)return c}return null}function c(t,n,i,o){if(s.cancellation()){var a=new e(r),c=this._finallyPromise=new e(r);this._promise=a.lastly(function(){return c}),a._captureStackTrace(),a._setOnCancel(this)}else{var u=this._promise=new e(r);u._captureStackTrace()}this._stack=o,this._generatorFunction=t,this._receiver=n,this._generator=void 0,this._yieldHandlers="function"==typeof i?[i].concat(_):_,this._yieldedPromise=null,this._cancellationPhase=!1}var u=t("./errors"),l=u.TypeError,p=t("./util"),f=p.errorObj,h=p.tryCatch,_=[];p.inherits(c,o),c.prototype._isResolved=function(){return null===this._promise},c.prototype._cleanup=function(){this._promise=this._generator=null,s.cancellation()&&null!==this._finallyPromise&&(this._finallyPromise._fulfill(),this._finallyPromise=null)},c.prototype._promiseCancelled=function(){if(!this._isResolved()){var t,n="undefined"!=typeof this._generator["return"];if(n)this._promise._pushContext(),t=h(this._generator["return"]).call(this._generator,void 0),this._promise._popContext();else{var r=new e.CancellationError("generator .return() sentinel");e.coroutine.returnSentinel=r,this._promise._attachExtraTrace(r),this._promise._pushContext(),t=h(this._generator["throw"]).call(this._generator,r),this._promise._popContext()}this._cancellationPhase=!0,this._yieldedPromise=null,this._continue(t)}},c.prototype._promiseFulfilled=function(t){this._yieldedPromise=null,this._promise._pushContext();var e=h(this._generator.next).call(this._generator,t);this._promise._popContext(),this._continue(e)},c.prototype._promiseRejected=function(t){this._yieldedPromise=null,this._promise._attachExtraTrace(t),this._promise._pushContext();var e=h(this._generator["throw"]).call(this._generator,t);this._promise._popContext(),this._continue(e)},c.prototype._resultCancelled=function(){if(this._yieldedPromise instanceof e){var t=this._yieldedPromise;this._yieldedPromise=null,t.cancel()}},c.prototype.promise=function(){return this._promise},c.prototype._run=function(){this._generator=this._generatorFunction.call(this._receiver),this._receiver=this._generatorFunction=void 0,this._promiseFulfilled(void 0)},c.prototype._continue=function(t){var n=this._promise;if(t===f)return this._cleanup(),this._cancellationPhase?n.cancel():n._rejectCallback(t.e,!1);var r=t.value;if(t.done===!0)return this._cleanup(),this._cancellationPhase?n.cancel():n._resolveCallback(r);
30
+ var o=i(r,this._promise);if(!(o instanceof e)&&(o=a(o,this._yieldHandlers,this._promise),null===o))return void this._promiseRejected(new l("A value %s was yielded that could not be treated as a promise\n\n See http://goo.gl/MqrFmX\n\n".replace("%s",String(r))+"From coroutine:\n"+this._stack.split("\n").slice(1,-7).join("\n")));o=o._target();var s=o._bitField;0===(50397184&s)?(this._yieldedPromise=o,o._proxy(this,null)):0!==(33554432&s)?e._async.invoke(this._promiseFulfilled,this,o._value()):0!==(16777216&s)?e._async.invoke(this._promiseRejected,this,o._reason()):this._promiseCancelled()},e.coroutine=function(t,e){if("function"!=typeof t)throw new l("generatorFunction must be a function\n\n See http://goo.gl/MqrFmX\n");var n=Object(e).yieldHandler,r=c,i=(new Error).stack;return function(){var e=t.apply(this,arguments),o=new r(void 0,void 0,n,i),s=o.promise();return o._generator=e,o._promiseFulfilled(void 0),s}},e.coroutine.addYieldHandler=function(t){if("function"!=typeof t)throw new l("expecting a function but got "+p.classString(t));_.push(t)},e.spawn=function(t){if(s.deprecated("Promise.spawn()","Promise.coroutine()"),"function"!=typeof t)return n("generatorFunction must be a function\n\n See http://goo.gl/MqrFmX\n");var r=new c(t,this),i=r.promise();return r._run(e.spawn),i}}},{"./errors":12,"./util":36}],17:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){var s=t("./util");s.canEvaluate,s.tryCatch,s.errorObj;e.join=function(){var t,e=arguments.length-1;if(e>0&&"function"==typeof arguments[e]){t=arguments[e];var r}var i=[].slice.call(arguments);t&&i.pop();var r=new n(i).promise();return void 0!==t?r.spread(t):r}}},{"./util":36}],18:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,n,r,i){this.constructor$(t),this._promise._captureStackTrace();var s=e._getContext();if(this._callback=u.contextBind(s,n),this._preservedValues=i===o?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=[],f.invoke(this._asyncInit,this,void 0),u.isArray(t))for(var a=0;a<t.length;++a){var c=t[a];c instanceof e&&c.suppressUnhandledRejections()}}function c(t,n,i,o){if("function"!=typeof n)return r("expecting a function but got "+u.classString(n));var s=0;if(void 0!==i){if("object"!=typeof i||null===i)return e.reject(new TypeError("options argument must be an object but it is "+u.classString(i)));if("number"!=typeof i.concurrency)return e.reject(new TypeError("'concurrency' must be a number but it is "+u.classString(i.concurrency)));s=i.concurrency}return s="number"==typeof s&&isFinite(s)&&s>=1?s:0,new a(t,n,s,o).promise()}var u=t("./util"),l=u.tryCatch,p=u.errorObj,f=e._async;u.inherits(a,n),a.prototype._asyncInit=function(){this._init$(void 0,-2)},a.prototype._init=function(){},a.prototype._promiseFulfilled=function(t,n){var r=this._values,o=this.length(),a=this._preservedValues,c=this._limit;if(0>n){if(n=-1*n-1,r[n]=t,c>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(c>=1&&this._inFlight>=c)return r[n]=t,this._queue.push(n),!1;null!==a&&(a[n]=t);var u=this._promise,f=this._callback,h=u._boundValue();u._pushContext();var _=l(f).call(h,t,n,o),d=u._popContext();if(s.checkForgottenReturns(_,d,null!==a?"Promise.filter":"Promise.map",u),_===p)return this._reject(_.e),!0;var v=i(_,this._promise);if(v instanceof e){v=v._target();var y=v._bitField;if(0===(50397184&y))return c>=1&&this._inFlight++,r[n]=v,v._proxy(this,-1*(n+1)),!1;if(0===(33554432&y))return 0!==(16777216&y)?(this._reject(v._reason()),!0):(this._cancel(),!0);_=v._value()}r[n]=_}var g=++this._totalResolved;return g>=o?(null!==a?this._filter(r,a):this._resolve(r),!0):!1},a.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,n=this._values;t.length>0&&this._inFlight<e;){if(this._isResolved())return;var r=t.pop();this._promiseFulfilled(n[r],r)}},a.prototype._filter=function(t,e){for(var n=e.length,r=new Array(n),i=0,o=0;n>o;++o)t[o]&&(r[i++]=e[o]);r.length=i,this._resolve(r)},a.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return c(this,t,e,null)},e.map=function(t,e,n,r){return c(t,e,n,r)}}},{"./util":36}],19:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){var s=t("./util"),a=s.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("expecting a function but got "+s.classString(t));return function(){var r=new e(n);r._captureStackTrace(),r._pushContext();var i=a(t).apply(this,arguments),s=r._popContext();return o.checkForgottenReturns(i,s,"Promise.method",r),r._resolveFromSyncValue(i),r}},e.attempt=e["try"]=function(t){if("function"!=typeof t)return i("expecting a function but got "+s.classString(t));var r=new e(n);r._captureStackTrace(),r._pushContext();var c;if(arguments.length>1){o.deprecated("calling Promise.try with more than 1 argument");var u=arguments[1],l=arguments[2];c=s.isArray(u)?a(t).apply(l,u):a(t).call(l,u)}else c=a(t)();var p=r._popContext();return o.checkForgottenReturns(c,p,"Promise.try",r),r._resolveFromSyncValue(c),r},e.prototype._resolveFromSyncValue=function(t){t===s.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":36}],20:[function(t,e,n){"use strict";function r(t){return t instanceof Error&&l.getPrototypeOf(t)===Error.prototype}function i(t){var e;if(r(t)){e=new u(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=l.keys(t),i=0;i<n.length;++i){var o=n[i];p.test(o)||(e[o]=t[o])}return e}return s.markAsOriginatingFromRejection(t),t}function o(t,e){return function(n,r){if(null!==t){if(n){var o=i(a(n));t._attachExtraTrace(o),t._reject(o)}else if(e){var s=[].slice.call(arguments,1);t._fulfill(s)}else t._fulfill(r);t=null}}}var s=t("./util"),a=s.maybeWrapAsError,c=t("./errors"),u=c.OperationalError,l=t("./es5"),p=/^(?:name|message|stack|cause)$/;e.exports=o},{"./errors":12,"./es5":13,"./util":36}],21:[function(t,e,n){"use strict";e.exports=function(e){function n(t,e){var n=this;if(!o.isArray(t))return r.call(n,t,e);var i=a(e).apply(n._boundValue(),[null].concat(t));i===c&&s.throwLater(i.e)}function r(t,e){var n=this,r=n._boundValue(),i=void 0===t?a(e).call(r,null):a(e).call(r,null,t);i===c&&s.throwLater(i.e)}function i(t,e){var n=this;if(!t){var r=new Error(t+"");r.cause=t,t=r}var i=a(e).call(n._boundValue(),t);i===c&&s.throwLater(i.e)}var o=t("./util"),s=e._async,a=o.tryCatch,c=o.errorObj;e.prototype.asCallback=e.prototype.nodeify=function(t,e){if("function"==typeof t){var o=r;void 0!==e&&Object(e).spread&&(o=n),this._then(o,i,void 0,this,t)}return this}}},{"./util":36}],22:[function(t,e,n){"use strict";e.exports=function(){function n(){}function r(t,e){if(null==t||t.constructor!==i)throw new E("the promise constructor cannot be invoked directly\n\n See http://goo.gl/MqrFmX\n");if("function"!=typeof e)throw new E("expecting a function but got "+f.classString(e))}function i(t){t!==x&&r(this,t),this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._resolveFromExecutor(t),this._promiseCreated(),this._fireEvent("promiseCreated",this)}function o(t){this.promise._resolveCallback(t)}function s(t){this.promise._rejectCallback(t,!1)}function a(t){var e=new i(x);e._fulfillmentHandler0=t,e._rejectionHandler0=t,e._promise0=t,e._receiver0=t}var c=function(){return new E("circular promise resolution chain\n\n See http://goo.gl/MqrFmX\n")},u=function(){return new i.PromiseInspection(this._target())},l=function(t){return i.reject(new E(t))},p={},f=t("./util");f.setReflectHandler(u);var h=function(){var t=process.domain;return void 0===t?null:t},_=function(){return null},d=function(){return{domain:h(),async:null}},v=f.isNode&&f.nodeSupportsAsyncResource?t("async_hooks").AsyncResource:null,y=function(){return{domain:h(),async:new v("Bluebird::Promise")}},g=f.isNode?d:_;f.notEnumerableProp(i,"_getContext",g);var m=function(){g=y,f.notEnumerableProp(i,"_getContext",y)},b=function(){g=d,f.notEnumerableProp(i,"_getContext",d)},w=t("./es5"),C=t("./async"),j=new C;w.defineProperty(i,"_async",{value:j});var k=t("./errors"),E=i.TypeError=k.TypeError;i.RangeError=k.RangeError;var F=i.CancellationError=k.CancellationError;i.TimeoutError=k.TimeoutError,i.OperationalError=k.OperationalError,i.RejectionError=k.OperationalError,i.AggregateError=k.AggregateError;var x=function(){},T={},P={},R=t("./thenables")(i,x),S=t("./promise_array")(i,x,R,l,n),O=t("./context")(i),A=O.create,V=t("./debuggability")(i,O,m,b),H=(V.CapturedTrace,t("./finally")(i,R,P)),D=t("./catch_filter")(P),I=t("./nodeback"),L=f.errorObj,N=f.tryCatch;return i.prototype.toString=function(){return"[object Promise]"},i.prototype.caught=i.prototype["catch"]=function(t){var e=arguments.length;if(e>1){var n,r=new Array(e-1),i=0;for(n=0;e-1>n;++n){var o=arguments[n];if(!f.isObject(o))return l("Catch statement predicate: expecting an object but got "+f.classString(o));r[i++]=o}if(r.length=i,t=arguments[n],"function"!=typeof t)throw new E("The last argument to .catch() must be a function, got "+f.toString(t));return this.then(void 0,D(r,t,this))}return this.then(void 0,t)},i.prototype.reflect=function(){return this._then(u,u,void 0,this,void 0)},i.prototype.then=function(t,e){if(V.warnings()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+f.classString(t);arguments.length>1&&(n+=", "+f.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},i.prototype.done=function(t,e){var n=this._then(t,e,void 0,void 0,void 0);n._setIsFinal()},i.prototype.spread=function(t){return"function"!=typeof t?l("expecting a function but got "+f.classString(t)):this.all()._then(t,void 0,void 0,T,void 0)},i.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},i.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new S(this).promise()},i.prototype.error=function(t){return this.caught(f.originatesFromRejection,t)},i.getNewLibraryCopy=e.exports,i.is=function(t){return t instanceof i},i.fromNode=i.fromCallback=function(t){var e=new i(x);e._captureStackTrace();var n=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=N(t)(I(e,n));return r===L&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},i.all=function(t){return new S(t).promise()},i.cast=function(t){var e=R(t);return e instanceof i||(e=new i(x),e._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},i.resolve=i.fulfilled=i.cast,i.reject=i.rejected=function(t){var e=new i(x);return e._captureStackTrace(),e._rejectCallback(t,!0),e},i.setScheduler=function(t){if("function"!=typeof t)throw new E("expecting a function but got "+f.classString(t));return j.setScheduler(t)},i.prototype._then=function(t,e,n,r,o){var s=void 0!==o,a=s?o:new i(x),c=this._target(),u=c._bitField;s||(a._propagateFrom(this,3),a._captureStackTrace(),void 0===r&&0!==(2097152&this._bitField)&&(r=0!==(50397184&u)?this._boundValue():c===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,a));var l=g();if(0!==(50397184&u)){var p,h,_=c._settlePromiseCtx;0!==(33554432&u)?(h=c._rejectionHandler0,p=t):0!==(16777216&u)?(h=c._fulfillmentHandler0,p=e,c._unsetRejectionIsUnhandled()):(_=c._settlePromiseLateCancellationObserver,h=new F("late cancellation observer"),c._attachExtraTrace(h),p=e),j.invoke(_,c,{handler:f.contextBind(l,p),promise:a,receiver:r,value:h})}else c._addCallbacks(t,e,a,r,l);return a},i.prototype._length=function(){return 65535&this._bitField},i.prototype._isFateSealed=function(){return 0!==(117506048&this._bitField)},i.prototype._isFollowing=function(){return 67108864===(67108864&this._bitField)},i.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},i.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},i.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},i.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},i.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},i.prototype._isFinal=function(){return(4194304&this._bitField)>0},i.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},i.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},i.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},i.prototype._setAsyncGuaranteed=function(){if(!j.hasCustomScheduler()){var t=this._bitField;this._bitField=t|(536870912&t)>>2^134217728}},i.prototype._setNoAsyncGuarantee=function(){this._bitField=-134217729&(536870912|this._bitField)},i.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];return e===p?void 0:void 0===e&&this._isBound()?this._boundValue():e},i.prototype._promiseAt=function(t){return this[4*t-4+2]},i.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},i.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},i.prototype._boundValue=function(){},i.prototype._migrateCallback0=function(t){var e=(t._bitField,t._fulfillmentHandler0),n=t._rejectionHandler0,r=t._promise0,i=t._receiverAt(0);void 0===i&&(i=p),this._addCallbacks(e,n,r,i,null)},i.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),i=t._promiseAt(e),o=t._receiverAt(e);void 0===o&&(o=p),this._addCallbacks(n,r,i,o,null)},i.prototype._addCallbacks=function(t,e,n,r,i){var o=this._length();if(o>=65531&&(o=0,this._setLength(0)),0===o)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=f.contextBind(i,t)),"function"==typeof e&&(this._rejectionHandler0=f.contextBind(i,e));else{var s=4*o-4;this[s+2]=n,this[s+3]=r,"function"==typeof t&&(this[s+0]=f.contextBind(i,t)),"function"==typeof e&&(this[s+1]=f.contextBind(i,e))}return this._setLength(o+1),o},i.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},i.prototype._resolveCallback=function(t,e){if(0===(117506048&this._bitField)){if(t===this)return this._rejectCallback(c(),!1);var n=R(t,this);if(!(n instanceof i))return this._fulfill(t);e&&this._propagateFrom(n,2);var r=n._target();if(r===this)return void this._reject(c());var o=r._bitField;if(0===(50397184&o)){var s=this._length();s>0&&r._migrateCallback0(this);for(var a=1;s>a;++a)r._migrateCallbackAt(this,a);this._setFollowing(),this._setLength(0),this._setFollowee(n)}else if(0!==(33554432&o))this._fulfill(r._value());else if(0!==(16777216&o))this._reject(r._reason());else{var u=new F("late cancellation observer");r._attachExtraTrace(u),this._reject(u)}}},i.prototype._rejectCallback=function(t,e,n){var r=f.ensureErrorObject(t),i=r===t;if(!i&&!n&&V.warnings()){var o="a promise was rejected with a non-error: "+f.classString(t);this._warn(o,!0)}this._attachExtraTrace(r,e?i:!1),this._reject(t)},i.prototype._resolveFromExecutor=function(t){if(t!==x){var e=this;this._captureStackTrace(),this._pushContext();var n=!0,r=this._execute(t,function(t){e._resolveCallback(t)},function(t){e._rejectCallback(t,n)});n=!1,this._popContext(),void 0!==r&&e._rejectCallback(r,!0)}},i.prototype._settlePromiseFromHandler=function(t,e,n,r){var i=r._bitField;if(0===(65536&i)){r._pushContext();var o;e===T?n&&"number"==typeof n.length?o=N(t).apply(this._boundValue(),n):(o=L,o.e=new E("cannot .spread() a non-array: "+f.classString(n))):o=N(t).call(e,n);var s=r._popContext();i=r._bitField,0===(65536&i)&&(o===P?r._reject(n):o===L?r._rejectCallback(o.e,!1):(V.checkForgottenReturns(o,s,"",r,this),r._resolveCallback(o)))}},i.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},i.prototype._followee=function(){return this._rejectionHandler0},i.prototype._setFollowee=function(t){this._rejectionHandler0=t},i.prototype._settlePromise=function(t,e,r,o){var s=t instanceof i,a=this._bitField,c=0!==(134217728&a);0!==(65536&a)?(s&&t._invokeInternalOnCancel(),r instanceof H&&r.isFinallyHandler()?(r.cancelPromise=t,N(e).call(r,o)===L&&t._reject(L.e)):e===u?t._fulfill(u.call(r)):r instanceof n?r._promiseCancelled(t):s||t instanceof S?t._cancel():r.cancel()):"function"==typeof e?s?(c&&t._setAsyncGuaranteed(),this._settlePromiseFromHandler(e,r,o,t)):e.call(r,o,t):r instanceof n?r._isResolved()||(0!==(33554432&a)?r._promiseFulfilled(o,t):r._promiseRejected(o,t)):s&&(c&&t._setAsyncGuaranteed(),0!==(33554432&a)?t._fulfill(o):t._reject(o))},i.prototype._settlePromiseLateCancellationObserver=function(t){var e=t.handler,n=t.promise,r=t.receiver,o=t.value;"function"==typeof e?n instanceof i?this._settlePromiseFromHandler(e,r,o,n):e.call(r,o,n):n instanceof i&&n._reject(o)},i.prototype._settlePromiseCtx=function(t){this._settlePromise(t.promise,t.handler,t.receiver,t.value)},i.prototype._settlePromise0=function(t,e,n){var r=this._promise0,i=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(r,t,i,e)},i.prototype._clearCallbackDataAtIndex=function(t){var e=4*t-4;this[e+2]=this[e+3]=this[e+0]=this[e+1]=void 0},i.prototype._fulfill=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(t===this){var n=c();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!==(134217728&e)?this._settlePromises():j.settlePromises(this),this._dereferenceTrace())}},i.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16))return this._setRejected(),this._fulfillmentHandler0=t,this._isFinal()?j.fatalError(t,f.isNode):void((65535&e)>0?j.settlePromises(this):this._ensurePossibleRejectionHandled())},i.prototype._fulfillPromises=function(t,e){for(var n=1;t>n;n++){var r=this._fulfillmentHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._rejectPromises=function(t,e){for(var n=1;t>n;n++){var r=this._rejectionHandlerAt(n),i=this._promiseAt(n),o=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(i,r,o,e)}},i.prototype._settlePromises=function(){var t=this._bitField,e=65535&t;if(e>0){if(0!==(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},i.prototype._settledValue=function(){var t=this._bitField;return 0!==(33554432&t)?this._rejectionHandler0:0!==(16777216&t)?this._fulfillmentHandler0:void 0},"undefined"!=typeof Symbol&&Symbol.toStringTag&&w.defineProperty(i.prototype,Symbol.toStringTag,{get:function(){return"Object"}}),i.defer=i.pending=function(){V.deprecated("Promise.defer","new Promise");var t=new i(x);return{promise:t,resolve:o,reject:s}},f.notEnumerableProp(i,"_makeSelfResolutionError",c),t("./method")(i,x,R,l,V),t("./bind")(i,x,R,V),t("./cancel")(i,S,l,V),t("./direct_resolve")(i),t("./synchronous_inspection")(i),t("./join")(i,S,R,x,j),i.Promise=i,i.version="3.7.2",t("./call_get.js")(i),t("./generators.js")(i,l,x,R,n,V),t("./map.js")(i,S,l,R,x,V),t("./nodeify.js")(i),t("./promisify.js")(i,x),t("./props.js")(i,S,R,l),t("./race.js")(i,x,R,l),t("./reduce.js")(i,S,l,R,x,V),t("./settle.js")(i,S,V),t("./some.js")(i,S,l),t("./timers.js")(i,x,V),t("./using.js")(i,l,R,A,x,V),t("./any.js")(i),t("./each.js")(i,x),t("./filter.js")(i,x),f.toFastProperties(i),f.toFastProperties(i.prototype),a({a:1}),a({b:2}),a({c:3}),a(1),a(function(){}),a(void 0),a(!1),a(new i(x)),V.setBounds(C.firstLineError,f.lastLineError),i}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36,async_hooks:void 0}],23:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o){function s(t){switch(t){case-2:return[];case-3:return{};case-6:return new Map}}function a(t){var r=this._promise=new e(n);t instanceof e&&(r._propagateFrom(t,3),t.suppressUnhandledRejections()),r._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var c=t("./util");c.isArray;return c.inherits(a,o),a.prototype.length=function(){return this._length},a.prototype.promise=function(){return this._promise},a.prototype._init=function u(t,n){var o=r(this._values,this._promise);if(o instanceof e){o=o._target();var a=o._bitField;if(this._values=o,0===(50397184&a))return this._promise._setAsyncGuaranteed(),o._then(u,this._reject,void 0,this,n);if(0===(33554432&a))return 0!==(16777216&a)?this._reject(o._reason()):this._cancel();o=o._value()}if(o=c.asArray(o),null===o){var l=i("expecting an array or an iterable object but got "+c.classString(o)).reason();return void this._promise._rejectCallback(l,!1)}return 0===o.length?void(-5===n?this._resolveEmptyArray():this._resolve(s(n))):void this._iterate(o)},a.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var i=this._promise,o=!1,s=null,a=0;n>a;++a){var c=r(t[a],i);c instanceof e?(c=c._target(),s=c._bitField):s=null,o?null!==s&&c.suppressUnhandledRejections():null!==s?0===(50397184&s)?(c._proxy(this,a),this._values[a]=c):o=0!==(33554432&s)?this._promiseFulfilled(c._value(),a):0!==(16777216&s)?this._promiseRejected(c._reason(),a):this._promiseCancelled(a):o=this._promiseFulfilled(c,a)}o||i._setAsyncGuaranteed()},a.prototype._isResolved=function(){return null===this._values},a.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},a.prototype._cancel=function(){!this._isResolved()&&this._promise._isCancellable()&&(this._values=null,this._promise._cancel())},a.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1)},a.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},a.prototype._promiseCancelled=function(){return this._cancel(),!0},a.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},a.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;n<t.length;++n)t[n]instanceof e&&t[n].cancel()}},a.prototype.shouldCopyValues=function(){return!0},a.prototype.getActualLength=function(t){return t},a}},{"./util":36}],24:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t){return!C.test(t)}function i(t){try{return t.__isPromisified__===!0}catch(e){return!1}}function o(t,e,n){var r=h.getDataPropertyOrDefault(t,e+n,b);return r?i(r):!1}function s(t,e,n){for(var r=0;r<t.length;r+=2){var i=t[r];if(n.test(i))for(var o=i.replace(n,""),s=0;s<t.length;s+=2)if(t[s]===o)throw new g("Cannot promisify an API that has normal methods with '%s'-suffix\n\n See http://goo.gl/MqrFmX\n".replace("%s",e))}}function a(t,e,n,r){for(var a=h.inheritedDataKeys(t),c=[],u=0;u<a.length;++u){var l=a[u],p=t[l],f=r===j?!0:j(l,p,t);"function"!=typeof p||i(p)||o(t,l,e)||!r(l,p,t,f)||c.push(l,p)}return s(c,e,n),c}function c(t,r,i,o,s,a){function c(){var i=r;r===f&&(i=this);var o=new e(n);o._captureStackTrace();var s="string"==typeof l&&this!==u?this[l]:t,c=_(o,a);try{s.apply(i,d(arguments,c))}catch(p){o._rejectCallback(v(p),!0,!0)}return o._isFateSealed()||o._setAsyncGuaranteed(),o}var u=function(){return this}(),l=t;return"string"==typeof l&&(t=o),h.notEnumerableProp(c,"__isPromisified__",!0),c}function u(t,e,n,r,i){for(var o=new RegExp(k(e)+"$"),s=a(t,e,o,n),c=0,u=s.length;u>c;c+=2){var l=s[c],p=s[c+1],_=l+e;if(r===E)t[_]=E(l,f,l,p,e,i);else{var d=r(p,function(){return E(l,f,l,p,e,i)});h.notEnumerableProp(d,"__isPromisified__",!0),t[_]=d}}return h.toFastProperties(t),t}function l(t,e,n){return E(t,e,void 0,t,null,n)}var p,f={},h=t("./util"),_=t("./nodeback"),d=h.withAppended,v=h.maybeWrapAsError,y=h.canEvaluate,g=t("./errors").TypeError,m="Async",b={__isPromisified__:!0},w=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],C=new RegExp("^(?:"+w.join("|")+")$"),j=function(t){return h.isIdentifier(t)&&"_"!==t.charAt(0)&&"constructor"!==t},k=function(t){return t.replace(/([$])/,"\\$")},E=y?p:c;e.promisify=function(t,e){if("function"!=typeof t)throw new g("expecting a function but got "+h.classString(t));if(i(t))return t;e=Object(e);var n=void 0===e.context?f:e.context,o=!!e.multiArgs,s=l(t,n,o);return h.copyDescriptors(t,s,r),s},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new g("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/MqrFmX\n");e=Object(e);var n=!!e.multiArgs,r=e.suffix;"string"!=typeof r&&(r=m);var i=e.filter;"function"!=typeof i&&(i=j);var o=e.promisifier;if("function"!=typeof o&&(o=E),!h.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/MqrFmX\n");for(var s=h.inheritedDataKeys(t),a=0;a<s.length;++a){var c=t[s[a]];"constructor"!==s[a]&&h.isClass(c)&&(u(c.prototype,r,i,o,n),u(c,r,i,o,n))}return u(t,r,i,o,n)}}},{"./errors":12,"./nodeback":20,"./util":36}],25:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){function o(t){var e,n=!1;if(void 0!==a&&t instanceof a)e=p(t),n=!0;else{var r=l.keys(t),i=r.length;e=new Array(2*i);for(var o=0;i>o;++o){var s=r[o];e[o]=t[s],e[o+i]=s}}this.constructor$(e),this._isMap=n,this._init$(void 0,n?-6:-3)}function s(t){var n,s=r(t);return u(s)?(n=s instanceof e?s._then(e.props,void 0,void 0,void 0,void 0):new o(s).promise(),s instanceof e&&n._propagateFrom(s,2),n):i("cannot await properties of a non-object\n\n See http://goo.gl/MqrFmX\n")}var a,c=t("./util"),u=c.isObject,l=t("./es5");"function"==typeof Map&&(a=Map);var p=function(){function t(t,r){this[e]=t,this[e+n]=r,e++}var e=0,n=0;return function(r){n=r.size,e=0;var i=new Array(2*r.size);return r.forEach(t,i),i}}(),f=function(t){for(var e=new a,n=t.length/2|0,r=0;n>r;++r){var i=t[n+r],o=t[r];e.set(i,o)}return e};c.inherits(o,n),o.prototype._init=function(){},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var n=++this._totalResolved;if(n>=this._length){var r;if(this._isMap)r=f(this._values);else{r={};for(var i=this.length(),o=0,s=this.length();s>o;++o)r[this._values[o+i]]=this._values[o]}return this._resolve(r),!0}return!1},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return s(this)},e.props=function(t){return s(t)}}},{"./es5":13,"./util":36}],26:[function(t,e,n){"use strict";function r(t,e,n,r,i){for(var o=0;i>o;++o)n[o+r]=t[o+e],t[o+e]=void 0}function i(t){this._capacity=t,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(t){return this._capacity<t},i.prototype._pushOne=function(t){var e=this.length();this._checkCapacity(e+1);var n=this._front+e&this._capacity-1;this[n]=t,this._length=e+1},i.prototype.push=function(t,e,n){var r=this.length()+3;if(this._willBeOverCapacity(r))return this._pushOne(t),this._pushOne(e),void this._pushOne(n);var i=this._front+r-3;this._checkCapacity(r);var o=this._capacity-1;this[i+0&o]=t,this[i+1&o]=e,this[i+2&o]=n,this._length=r},i.prototype.shift=function(){var t=this._front,e=this[t];return this[t]=void 0,this._front=t+1&this._capacity-1,this._length--,e},i.prototype.length=function(){return this._length},i.prototype._checkCapacity=function(t){this._capacity<t&&this._resizeTo(this._capacity<<1)},i.prototype._resizeTo=function(t){var e=this._capacity;this._capacity=t;var n=this._front,i=this._length,o=n+i&e-1;r(this,0,this,e,o)},e.exports=i},{}],27:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){function o(t,o){var c=r(t);if(c instanceof e)return a(c);if(t=s.asArray(t),null===t)return i("expecting an array or an iterable object but got "+s.classString(t));var u=new e(n);void 0!==o&&u._propagateFrom(o,3);for(var l=u._fulfill,p=u._reject,f=0,h=t.length;h>f;++f){var _=t[f];(void 0!==_||f in t)&&e.cast(_)._then(l,p,void 0,u,null)}return u}var s=t("./util"),a=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util":36}],28:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t,n,r,i){this.constructor$(t);var s=e._getContext();this._fn=f.contextBind(s,n),void 0!==r&&(r=e.resolve(r),r._attachCancellationCallback(this)),this._initialValue=r,this._currentCancellable=null,i===o?this._eachValues=Array(this._length):0===i?this._eachValues=null:this._eachValues=void 0,this._promise._captureStackTrace(),this._init$(void 0,-5)}function c(t,e){this.isFulfilled()?e._resolve(t):e._reject(t)}function u(t,e,n,i){if("function"!=typeof e)return r("expecting a function but got "+f.classString(e));var o=new a(t,e,n,i);return o.promise()}function l(t){this.accum=t,this.array._gotAccum(t);var n=i(this.value,this.array._promise);return n instanceof e?(this.array._currentCancellable=n,n._then(p,void 0,void 0,this,void 0)):p.call(this,n)}function p(t){var n=this.array,r=n._promise,i=h(n._fn);r._pushContext();var o;o=void 0!==n._eachValues?i.call(r._boundValue(),t,this.index,this.length):i.call(r._boundValue(),this.accum,t,this.index,this.length),o instanceof e&&(n._currentCancellable=o);var a=r._popContext();return s.checkForgottenReturns(o,a,void 0!==n._eachValues?"Promise.each":"Promise.reduce",r),o}var f=t("./util"),h=f.tryCatch;f.inherits(a,n),a.prototype._gotAccum=function(t){void 0!==this._eachValues&&null!==this._eachValues&&t!==o&&this._eachValues.push(t)},a.prototype._eachComplete=function(t){return null!==this._eachValues&&this._eachValues.push(t),this._eachValues},a.prototype._init=function(){},a.prototype._resolveEmptyArray=function(){this._resolve(void 0!==this._eachValues?this._eachValues:this._initialValue)},a.prototype.shouldCopyValues=function(){return!1},a.prototype._resolve=function(t){this._promise._resolveCallback(t),this._values=null},a.prototype._resultCancelled=function(t){return t===this._initialValue?this._cancel():void(this._isResolved()||(this._resultCancelled$(),this._currentCancellable instanceof e&&this._currentCancellable.cancel(),this._initialValue instanceof e&&this._initialValue.cancel()))},a.prototype._iterate=function(t){this._values=t;var n,r,i=t.length;void 0!==this._initialValue?(n=this._initialValue,r=0):(n=e.resolve(t[0]),r=1),this._currentCancellable=n;for(var o=r;i>o;++o){var s=t[o];s instanceof e&&s.suppressUnhandledRejections()}if(!n.isRejected())for(;i>r;++r){var a={accum:null,value:t[r],index:r,length:i,array:this};n=n._then(l,void 0,void 0,a,void 0),0===(127&r)&&n._setNoAsyncGuarantee()}void 0!==this._eachValues&&(n=n._then(this._eachComplete,void 0,void 0,this,void 0)),n._then(c,c,void 0,n,this)},e.prototype.reduce=function(t,e){return u(this,t,e,null)},e.reduce=function(t,e,n,r){return u(t,e,n,r)}}},{"./util":36}],29:[function(t,e,n){"use strict";var r,i=t("./util"),o=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")},s=i.getNativePromise();if(i.isNode&&"undefined"==typeof MutationObserver){var a=global.setImmediate,c=process.nextTick;r=i.isRecentNode?function(t){a.call(global,t)}:function(t){c.call(process,t)}}else if("function"==typeof s&&"function"==typeof s.resolve){
31
+ var u=s.resolve();r=function(t){u.then(t)}}else r="undefined"!=typeof MutationObserver&&("undefined"==typeof window||!window.navigator||!window.navigator.standalone&&!window.cordova)&&"classList"in document.documentElement?function(){var t=document.createElement("div"),e={attributes:!0},n=!1,r=document.createElement("div"),i=new MutationObserver(function(){t.classList.toggle("foo"),n=!1});i.observe(r,e);var o=function(){n||(n=!0,r.classList.toggle("foo"))};return function(n){var r=new MutationObserver(function(){r.disconnect(),n()});r.observe(t,e),o()}}():"undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:o;e.exports=r},{"./util":36}],30:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.constructor$(t)}var o=e.PromiseInspection,s=t("./util");s.inherits(i,n),i.prototype._promiseResolved=function(t,e){this._values[t]=e;var n=++this._totalResolved;return n>=this._length?(this._resolve(this._values),!0):!1},i.prototype._promiseFulfilled=function(t,e){var n=new o;return n._bitField=33554432,n._settledValueField=t,this._promiseResolved(e,n)},i.prototype._promiseRejected=function(t,e){var n=new o;return n._bitField=16777216,n._settledValueField=t,this._promiseResolved(e,n)},e.settle=function(t){return r.deprecated(".settle()",".reflect()"),new i(t).promise()},e.allSettled=function(t){return new i(t).promise()},e.prototype.settle=function(){return e.settle(this)}}},{"./util":36}],31:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return r("expecting a positive integer\n\n See http://goo.gl/MqrFmX\n");var n=new i(t),o=n.promise();return n.setHowMany(e),n.init(),o}var s=t("./util"),a=t("./errors").RangeError,c=t("./errors").AggregateError,u=s.isArray,l={};s.inherits(i,n),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=u(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()?(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0):!1},i.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},i.prototype._promiseCancelled=function(){return this._values instanceof e||null==this._values?this._cancel():(this._addRejected(l),this._checkOutcome())},i.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new c,e=this.length();e<this._values.length;++e)this._values[e]!==l&&t.push(this._values[e]);return t.length>0?this._reject(t):this._cancel(),!0}return!1},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(t){this._values.push(t)},i.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return o(t,e)},e.prototype.some=function(t){return o(this,t)},e._SomePromiseArray=i}},{"./errors":12,"./util":36}],32:[function(t,e,n){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var n=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},r=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=e.prototype.isFulfilled=function(){return 0!==(33554432&this._bitField)},o=e.prototype.isRejected=function(){return 0!==(16777216&this._bitField)},s=e.prototype.isPending=function(){return 0===(50397184&this._bitField)},a=e.prototype.isResolved=function(){return 0!==(50331648&this._bitField)};e.prototype.isCancelled=function(){return 0!==(8454144&this._bitField)},t.prototype.__isCancelled=function(){return 65536===(65536&this._bitField)},t.prototype._isCancelled=function(){return this._target().__isCancelled()},t.prototype.isCancelled=function(){return 0!==(8454144&this._target()._bitField)},t.prototype.isPending=function(){return s.call(this._target())},t.prototype.isRejected=function(){return o.call(this._target())},t.prototype.isFulfilled=function(){return i.call(this._target())},t.prototype.isResolved=function(){return a.call(this._target())},t.prototype.value=function(){return n.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),r.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,n){"use strict";e.exports=function(e,n){function r(t,r){if(l(t)){if(t instanceof e)return t;var i=o(t);if(i===u){r&&r._pushContext();var c=e.reject(i.e);return r&&r._popContext(),c}if("function"==typeof i){if(s(t)){var c=new e(n);return t._then(c._fulfill,c._reject,void 0,c,null),c}return a(t,i,r)}}return t}function i(t){return t.then}function o(t){try{return i(t)}catch(e){return u.e=e,u}}function s(t){try{return p.call(t,"_promise0")}catch(e){return!1}}function a(t,r,i){function o(t){a&&(a._resolveCallback(t),a=null)}function s(t){a&&(a._rejectCallback(t,p,!0),a=null)}var a=new e(n),l=a;i&&i._pushContext(),a._captureStackTrace(),i&&i._popContext();var p=!0,f=c.tryCatch(r).call(t,o,s);return p=!1,a&&f===u&&(a._rejectCallback(f.e,!0,!0),a=null),l}var c=t("./util"),u=c.errorObj,l=c.isObject,p={}.hasOwnProperty;return r}},{"./util":36}],34:[function(t,e,n){"use strict";e.exports=function(e,n,r){function i(t){this.handle=t}function o(t){return clearTimeout(this.handle),t}function s(t){throw clearTimeout(this.handle),t}var a=t("./util"),c=e.TimeoutError;i.prototype._resultCancelled=function(){clearTimeout(this.handle)};var u=function(t){return l(+this).thenReturn(t)},l=e.delay=function(t,o){var s,a;return void 0!==o?(s=e.resolve(o)._then(u,null,null,t,void 0),r.cancellation()&&o instanceof e&&s._setOnCancel(o)):(s=new e(n),a=setTimeout(function(){s._fulfill()},+t),r.cancellation()&&s._setOnCancel(new i(a)),s._captureStackTrace()),s._setAsyncGuaranteed(),s};e.prototype.delay=function(t){return l(t,this)};var p=function(t,e,n){var r;r="string"!=typeof e?e instanceof Error?e:new c("operation timed out"):new c(e),a.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._reject(r),null!=n&&n.cancel()};e.prototype.timeout=function(t,e){t=+t;var n,a,c=new i(setTimeout(function(){n.isPending()&&p(n,e,a)},t));return r.cancellation()?(a=this.then(),n=a._then(o,s,void 0,c,void 0),n._setOnCancel(c)):n=this._then(o,s,void 0,c,void 0),n}}},{"./util":36}],35:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,o,s){function a(t){setTimeout(function(){throw t},0)}function c(t){var e=r(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function u(t,n){function i(){if(s>=u)return l._fulfill();var o=c(t[s++]);if(o instanceof e&&o._isDisposable()){try{o=r(o._getDisposer().tryDispose(n),t.promise)}catch(p){return a(p)}if(o instanceof e)return o._then(i,a,null,null,null)}i()}var s=0,u=t.length,l=new e(o);return i(),l}function l(t,e,n){this._data=t,this._promise=e,this._context=n}function p(t,e,n){this.constructor$(t,e,n)}function f(t){return l.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}function h(t){this.length=t,this.promise=null,this[t-1]=null}var _=t("./util"),d=t("./errors").TypeError,v=t("./util").inherits,y=_.errorObj,g=_.tryCatch,m={};l.prototype.data=function(){return this._data},l.prototype.promise=function(){return this._promise},l.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():m},l.prototype.tryDispose=function(t){var e=this.resource(),n=this._context;void 0!==n&&n._pushContext();var r=e!==m?this.doDispose(e,t):null;return void 0!==n&&n._popContext(),this._promise._unsetDisposable(),this._data=null,r},l.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},v(p,l),p.prototype.doDispose=function(t,e){var n=this.data();return n.call(t,t,e)},h.prototype._resultCancelled=function(){for(var t=this.length,n=0;t>n;++n){var r=this[n];r instanceof e&&r.cancel()}},e.using=function(){var t=arguments.length;if(2>t)return n("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return n("expecting a function but got "+_.classString(i));var o,a=!0;2===t&&Array.isArray(arguments[0])?(o=arguments[0],t=o.length,a=!1):(o=arguments,t--);for(var c=new h(t),p=0;t>p;++p){var d=o[p];if(l.isDisposer(d)){var v=d;d=d.promise(),d._setDisposable(v)}else{var m=r(d);m instanceof e&&(d=m._then(f,null,null,{resources:c,index:p},void 0))}c[p]=d}for(var b=new Array(c.length),p=0;p<b.length;++p)b[p]=e.resolve(c[p]).reflect();var w=e.all(b).then(function(t){for(var e=0;e<t.length;++e){var n=t[e];if(n.isRejected())return y.e=n.error(),y;if(!n.isFulfilled())return void w.cancel();t[e]=n.value()}C._pushContext(),i=g(i);var r=a?i.apply(void 0,t):i(t),o=C._popContext();return s.checkForgottenReturns(r,o,"Promise.using",C),r}),C=w.lastly(function(){var t=new e.PromiseInspection(w);return u(c,t)});return c.promise=C,C._setOnCancel(c),C},e.prototype._setDisposable=function(t){this._bitField=131072|this._bitField,this._disposer=t},e.prototype._isDisposable=function(){return(131072&this._bitField)>0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new p(t,this,i());throw new d}}},{"./errors":12,"./util":36}],36:[function(t,e,n){"use strict";function r(){try{var t=P;return P=null,t.apply(this,arguments)}catch(e){return T.e=e,T}}function i(t){return P=t,r}function o(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function s(t){return"function"==typeof t||"object"==typeof t&&null!==t}function a(t){return o(t)?new Error(v(t)):t}function c(t,e){var n,r=t.length,i=new Array(r+1);for(n=0;r>n;++n)i[n]=t[n];return i[n]=e,i}function u(t,e,n){if(!F.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var r=Object.getOwnPropertyDescriptor(t,e);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function l(t,e,n){if(o(t))return t;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return F.defineProperty(t,e,r),t}function p(t){throw t}function f(t){try{if("function"==typeof t){var e=F.names(t.prototype),n=F.isES5&&e.length>1,r=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=A.test(t+"")&&F.names(t).length>0;if(n||r||i)return!0}return!1}catch(o){return!1}}function h(t){function e(){}function n(){return typeof r.foo}e.prototype=t;var r=new e;return n(),n(),t}function _(t){return V.test(t)}function d(t,e,n){for(var r=new Array(t),i=0;t>i;++i)r[i]=e+i+n;return r}function v(t){try{return t+""}catch(e){return"[no string representation]"}}function y(t){return t instanceof Error||null!==t&&"object"==typeof t&&"string"==typeof t.message&&"string"==typeof t.name}function g(t){try{l(t,"isOperational",!0)}catch(e){}}function m(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function b(t){return y(t)&&F.propertyIsWritable(t,"stack")}function w(t){return{}.toString.call(t)}function C(t,e,n){for(var r=F.names(t),i=0;i<r.length;++i){var o=r[i];if(n(o))try{F.defineProperty(e,o,F.getDescriptor(t,o))}catch(s){}}}function j(t){return N?process.env[t]:void 0}function k(){if("function"==typeof Promise)try{var t=new Promise(function(){});if("[object Promise]"===w(t))return Promise}catch(e){}}function E(t,e){if(null===t||"function"!=typeof e||e===U)return e;null!==t.domain&&(e=t.domain.bind(e));var n=t.async;if(null!==n){var r=e;e=function(){var t=new Array(2).concat([].slice.call(arguments));return t[0]=r,t[1]=this,n.runInAsyncScope.apply(n,t)}}return e}var F=t("./es5"),x="undefined"==typeof navigator,T={e:{}},P,R="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0!==this?this:null,S=function(t,e){function n(){this.constructor=t,this.constructor$=e;for(var n in e.prototype)r.call(e.prototype,n)&&"$"!==n.charAt(n.length-1)&&(this[n+"$"]=e.prototype[n])}var r={}.hasOwnProperty;return n.prototype=e.prototype,t.prototype=new n,t.prototype},O=function(){var t=[Array.prototype,Object.prototype,Function.prototype],e=function(e){for(var n=0;n<t.length;++n)if(t[n]===e)return!0;return!1};if(F.isES5){var n=Object.getOwnPropertyNames;return function(t){for(var r=[],i=Object.create(null);null!=t&&!e(t);){var o;try{o=n(t)}catch(s){return r}for(var a=0;a<o.length;++a){var c=o[a];if(!i[c]){i[c]=!0;var u=Object.getOwnPropertyDescriptor(t,c);null!=u&&null==u.get&&null==u.set&&r.push(c)}}t=F.getPrototypeOf(t)}return r}}var r={}.hasOwnProperty;return function(n){if(e(n))return[];var i=[];t:for(var o in n)if(r.call(n,o))i.push(o);else{for(var s=0;s<t.length;++s)if(r.call(t[s],o))continue t;i.push(o)}return i}}(),A=/this\s*\.\s*\S+\s*=/,V=/^[a-z$_][a-z$_0-9]*$/i,H=function(){return"stack"in new Error?function(t){return b(t)?t:new Error(v(t))}:function(t){if(b(t))return t;try{throw new Error(v(t))}catch(e){return e}}}(),D=function(t){return F.isArray(t)?t:null};if("undefined"!=typeof Symbol&&Symbol.iterator){var I="function"==typeof Array.from?function(t){return Array.from(t)}:function(t){for(var e,n=[],r=t[Symbol.iterator]();!(e=r.next()).done;)n.push(e.value);return n};D=function(t){return F.isArray(t)?t:null!=t&&"function"==typeof t[Symbol.iterator]?I(t):null}}var L="undefined"!=typeof process&&"[object process]"===w(process).toLowerCase(),N="undefined"!=typeof process&&"undefined"!=typeof process.env,U,B={setReflectHandler:function(t){U=t},isClass:f,isIdentifier:_,inheritedDataKeys:O,getDataPropertyOrDefault:u,thrower:p,isArray:F.isArray,asArray:D,notEnumerableProp:l,isPrimitive:o,isObject:s,isError:y,canEvaluate:x,errorObj:T,tryCatch:i,inherits:S,withAppended:c,maybeWrapAsError:a,toFastProperties:h,filledRange:d,toString:v,canAttachTrace:b,ensureErrorObject:H,originatesFromRejection:m,markAsOriginatingFromRejection:g,classString:w,copyDescriptors:C,isNode:L,hasEnvVariables:N,env:j,global:R,getNativePromise:k,contextBind:E};B.isRecentNode=B.isNode&&function(){var t;return process.versions&&process.versions.node?t=process.versions.node.split(".").map(Number):process.version&&(t=process.version.split(".").map(Number)),0===t[0]&&t[1]>10||t[0]>0}(),B.nodeSupportsAsyncResource=B.isNode&&function(){var e=!1;try{var n=t("async_hooks").AsyncResource;e="function"==typeof n.prototype.runInAsyncScope}catch(r){e=!1}return e}(),B.isNode&&B.toFastProperties(process);try{throw new Error}catch(M){B.lastLineError=M}e.exports=B},{"./es5":13,async_hooks:void 0}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise);
node_modules/bluebird/js/release/any.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise) {
3
+ var SomePromiseArray = Promise._SomePromiseArray;
4
+ function any(promises) {
5
+ var ret = new SomePromiseArray(promises);
6
+ var promise = ret.promise();
7
+ ret.setHowMany(1);
8
+ ret.setUnwrap();
9
+ ret.init();
10
+ return promise;
11
+ }
12
+
13
+ Promise.any = function (promises) {
14
+ return any(promises);
15
+ };
16
+
17
+ Promise.prototype.any = function () {
18
+ return any(this);
19
+ };
20
+
21
+ };
node_modules/bluebird/js/release/assert.js ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = (function(){
3
+ var AssertionError = (function() {
4
+ function AssertionError(a) {
5
+ this.constructor$(a);
6
+ this.message = a;
7
+ this.name = "AssertionError";
8
+ }
9
+ AssertionError.prototype = new Error();
10
+ AssertionError.prototype.constructor = AssertionError;
11
+ AssertionError.prototype.constructor$ = Error;
12
+ return AssertionError;
13
+ })();
14
+
15
+ function getParams(args) {
16
+ var params = [];
17
+ for (var i = 0; i < args.length; ++i) params.push("arg" + i);
18
+ return params;
19
+ }
20
+
21
+ function nativeAssert(callName, args, expect) {
22
+ try {
23
+ var params = getParams(args);
24
+ var constructorArgs = params;
25
+ constructorArgs.push("return " +
26
+ callName + "("+ params.join(",") + ");");
27
+ var fn = Function.apply(null, constructorArgs);
28
+ return fn.apply(null, args);
29
+ } catch (e) {
30
+ if (!(e instanceof SyntaxError)) {
31
+ throw e;
32
+ } else {
33
+ return expect;
34
+ }
35
+ }
36
+ }
37
+
38
+ return function assert(boolExpr, message) {
39
+ if (boolExpr === true) return;
40
+
41
+ if (typeof boolExpr === "string" &&
42
+ boolExpr.charAt(0) === "%") {
43
+ var nativeCallName = boolExpr;
44
+ var $_len = arguments.length;var args = new Array(Math.max($_len - 2, 0)); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];};
45
+ if (nativeAssert(nativeCallName, args, message) === message) return;
46
+ message = (nativeCallName + " !== " + message);
47
+ }
48
+
49
+ var ret = new AssertionError(message);
50
+ if (Error.captureStackTrace) {
51
+ Error.captureStackTrace(ret, assert);
52
+ }
53
+ throw ret;
54
+ };
55
+ })();
node_modules/bluebird/js/release/async.js ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var firstLineError;
3
+ try {throw new Error(); } catch (e) {firstLineError = e;}
4
+ var schedule = require("./schedule");
5
+ var Queue = require("./queue");
6
+
7
+ function Async() {
8
+ this._customScheduler = false;
9
+ this._isTickUsed = false;
10
+ this._lateQueue = new Queue(16);
11
+ this._normalQueue = new Queue(16);
12
+ this._haveDrainedQueues = false;
13
+ var self = this;
14
+ this.drainQueues = function () {
15
+ self._drainQueues();
16
+ };
17
+ this._schedule = schedule;
18
+ }
19
+
20
+ Async.prototype.setScheduler = function(fn) {
21
+ var prev = this._schedule;
22
+ this._schedule = fn;
23
+ this._customScheduler = true;
24
+ return prev;
25
+ };
26
+
27
+ Async.prototype.hasCustomScheduler = function() {
28
+ return this._customScheduler;
29
+ };
30
+
31
+ Async.prototype.haveItemsQueued = function () {
32
+ return this._isTickUsed || this._haveDrainedQueues;
33
+ };
34
+
35
+
36
+ Async.prototype.fatalError = function(e, isNode) {
37
+ if (isNode) {
38
+ process.stderr.write("Fatal " + (e instanceof Error ? e.stack : e) +
39
+ "\n");
40
+ process.exit(2);
41
+ } else {
42
+ this.throwLater(e);
43
+ }
44
+ };
45
+
46
+ Async.prototype.throwLater = function(fn, arg) {
47
+ if (arguments.length === 1) {
48
+ arg = fn;
49
+ fn = function () { throw arg; };
50
+ }
51
+ if (typeof setTimeout !== "undefined") {
52
+ setTimeout(function() {
53
+ fn(arg);
54
+ }, 0);
55
+ } else try {
56
+ this._schedule(function() {
57
+ fn(arg);
58
+ });
59
+ } catch (e) {
60
+ throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
61
+ }
62
+ };
63
+
64
+ function AsyncInvokeLater(fn, receiver, arg) {
65
+ this._lateQueue.push(fn, receiver, arg);
66
+ this._queueTick();
67
+ }
68
+
69
+ function AsyncInvoke(fn, receiver, arg) {
70
+ this._normalQueue.push(fn, receiver, arg);
71
+ this._queueTick();
72
+ }
73
+
74
+ function AsyncSettlePromises(promise) {
75
+ this._normalQueue._pushOne(promise);
76
+ this._queueTick();
77
+ }
78
+
79
+ Async.prototype.invokeLater = AsyncInvokeLater;
80
+ Async.prototype.invoke = AsyncInvoke;
81
+ Async.prototype.settlePromises = AsyncSettlePromises;
82
+
83
+
84
+ function _drainQueue(queue) {
85
+ while (queue.length() > 0) {
86
+ _drainQueueStep(queue);
87
+ }
88
+ }
89
+
90
+ function _drainQueueStep(queue) {
91
+ var fn = queue.shift();
92
+ if (typeof fn !== "function") {
93
+ fn._settlePromises();
94
+ } else {
95
+ var receiver = queue.shift();
96
+ var arg = queue.shift();
97
+ fn.call(receiver, arg);
98
+ }
99
+ }
100
+
101
+ Async.prototype._drainQueues = function () {
102
+ _drainQueue(this._normalQueue);
103
+ this._reset();
104
+ this._haveDrainedQueues = true;
105
+ _drainQueue(this._lateQueue);
106
+ };
107
+
108
+ Async.prototype._queueTick = function () {
109
+ if (!this._isTickUsed) {
110
+ this._isTickUsed = true;
111
+ this._schedule(this.drainQueues);
112
+ }
113
+ };
114
+
115
+ Async.prototype._reset = function () {
116
+ this._isTickUsed = false;
117
+ };
118
+
119
+ module.exports = Async;
120
+ module.exports.firstLineError = firstLineError;
node_modules/bluebird/js/release/bind.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) {
3
+ var calledBind = false;
4
+ var rejectThis = function(_, e) {
5
+ this._reject(e);
6
+ };
7
+
8
+ var targetRejected = function(e, context) {
9
+ context.promiseRejectionQueued = true;
10
+ context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
11
+ };
12
+
13
+ var bindingResolved = function(thisArg, context) {
14
+ if (((this._bitField & 50397184) === 0)) {
15
+ this._resolveCallback(context.target);
16
+ }
17
+ };
18
+
19
+ var bindingRejected = function(e, context) {
20
+ if (!context.promiseRejectionQueued) this._reject(e);
21
+ };
22
+
23
+ Promise.prototype.bind = function (thisArg) {
24
+ if (!calledBind) {
25
+ calledBind = true;
26
+ Promise.prototype._propagateFrom = debug.propagateFromFunction();
27
+ Promise.prototype._boundValue = debug.boundValueFunction();
28
+ }
29
+ var maybePromise = tryConvertToPromise(thisArg);
30
+ var ret = new Promise(INTERNAL);
31
+ ret._propagateFrom(this, 1);
32
+ var target = this._target();
33
+ ret._setBoundTo(maybePromise);
34
+ if (maybePromise instanceof Promise) {
35
+ var context = {
36
+ promiseRejectionQueued: false,
37
+ promise: ret,
38
+ target: target,
39
+ bindingPromise: maybePromise
40
+ };
41
+ target._then(INTERNAL, targetRejected, undefined, ret, context);
42
+ maybePromise._then(
43
+ bindingResolved, bindingRejected, undefined, ret, context);
44
+ ret._setOnCancel(maybePromise);
45
+ } else {
46
+ ret._resolveCallback(target);
47
+ }
48
+ return ret;
49
+ };
50
+
51
+ Promise.prototype._setBoundTo = function (obj) {
52
+ if (obj !== undefined) {
53
+ this._bitField = this._bitField | 2097152;
54
+ this._boundTo = obj;
55
+ } else {
56
+ this._bitField = this._bitField & (~2097152);
57
+ }
58
+ };
59
+
60
+ Promise.prototype._isBound = function () {
61
+ return (this._bitField & 2097152) === 2097152;
62
+ };
63
+
64
+ Promise.bind = function (thisArg, value) {
65
+ return Promise.resolve(value).bind(thisArg);
66
+ };
67
+ };
node_modules/bluebird/js/release/bluebird.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var old;
3
+ if (typeof Promise !== "undefined") old = Promise;
4
+ function noConflict() {
5
+ try { if (Promise === bluebird) Promise = old; }
6
+ catch (e) {}
7
+ return bluebird;
8
+ }
9
+ var bluebird = require("./promise")();
10
+ bluebird.noConflict = noConflict;
11
+ module.exports = bluebird;
node_modules/bluebird/js/release/call_get.js ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var cr = Object.create;
3
+ if (cr) {
4
+ var callerCache = cr(null);
5
+ var getterCache = cr(null);
6
+ callerCache[" size"] = getterCache[" size"] = 0;
7
+ }
8
+
9
+ module.exports = function(Promise) {
10
+ var util = require("./util");
11
+ var canEvaluate = util.canEvaluate;
12
+ var isIdentifier = util.isIdentifier;
13
+
14
+ var getMethodCaller;
15
+ var getGetter;
16
+ if (!false) {
17
+ var makeMethodCaller = function (methodName) {
18
+ return new Function("ensureMethod", " \n\
19
+ return function(obj) { \n\
20
+ 'use strict' \n\
21
+ var len = this.length; \n\
22
+ ensureMethod(obj, 'methodName'); \n\
23
+ switch(len) { \n\
24
+ case 1: return obj.methodName(this[0]); \n\
25
+ case 2: return obj.methodName(this[0], this[1]); \n\
26
+ case 3: return obj.methodName(this[0], this[1], this[2]); \n\
27
+ case 0: return obj.methodName(); \n\
28
+ default: \n\
29
+ return obj.methodName.apply(obj, this); \n\
30
+ } \n\
31
+ }; \n\
32
+ ".replace(/methodName/g, methodName))(ensureMethod);
33
+ };
34
+
35
+ var makeGetter = function (propertyName) {
36
+ return new Function("obj", " \n\
37
+ 'use strict'; \n\
38
+ return obj.propertyName; \n\
39
+ ".replace("propertyName", propertyName));
40
+ };
41
+
42
+ var getCompiled = function(name, compiler, cache) {
43
+ var ret = cache[name];
44
+ if (typeof ret !== "function") {
45
+ if (!isIdentifier(name)) {
46
+ return null;
47
+ }
48
+ ret = compiler(name);
49
+ cache[name] = ret;
50
+ cache[" size"]++;
51
+ if (cache[" size"] > 512) {
52
+ var keys = Object.keys(cache);
53
+ for (var i = 0; i < 256; ++i) delete cache[keys[i]];
54
+ cache[" size"] = keys.length - 256;
55
+ }
56
+ }
57
+ return ret;
58
+ };
59
+
60
+ getMethodCaller = function(name) {
61
+ return getCompiled(name, makeMethodCaller, callerCache);
62
+ };
63
+
64
+ getGetter = function(name) {
65
+ return getCompiled(name, makeGetter, getterCache);
66
+ };
67
+ }
68
+
69
+ function ensureMethod(obj, methodName) {
70
+ var fn;
71
+ if (obj != null) fn = obj[methodName];
72
+ if (typeof fn !== "function") {
73
+ var message = "Object " + util.classString(obj) + " has no method '" +
74
+ util.toString(methodName) + "'";
75
+ throw new Promise.TypeError(message);
76
+ }
77
+ return fn;
78
+ }
79
+
80
+ function caller(obj) {
81
+ var methodName = this.pop();
82
+ var fn = ensureMethod(obj, methodName);
83
+ return fn.apply(obj, this);
84
+ }
85
+ Promise.prototype.call = function (methodName) {
86
+ var $_len = arguments.length;var args = new Array(Math.max($_len - 1, 0)); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];};
87
+ if (!false) {
88
+ if (canEvaluate) {
89
+ var maybeCaller = getMethodCaller(methodName);
90
+ if (maybeCaller !== null) {
91
+ return this._then(
92
+ maybeCaller, undefined, undefined, args, undefined);
93
+ }
94
+ }
95
+ }
96
+ args.push(methodName);
97
+ return this._then(caller, undefined, undefined, args, undefined);
98
+ };
99
+
100
+ function namedGetter(obj) {
101
+ return obj[this];
102
+ }
103
+ function indexedGetter(obj) {
104
+ var index = +this;
105
+ if (index < 0) index = Math.max(0, index + obj.length);
106
+ return obj[index];
107
+ }
108
+ Promise.prototype.get = function (propertyName) {
109
+ var isIndex = (typeof propertyName === "number");
110
+ var getter;
111
+ if (!isIndex) {
112
+ if (canEvaluate) {
113
+ var maybeGetter = getGetter(propertyName);
114
+ getter = maybeGetter !== null ? maybeGetter : namedGetter;
115
+ } else {
116
+ getter = namedGetter;
117
+ }
118
+ } else {
119
+ getter = indexedGetter;
120
+ }
121
+ return this._then(getter, undefined, undefined, propertyName, undefined);
122
+ };
123
+ };
node_modules/bluebird/js/release/cancel.js ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise, PromiseArray, apiRejection, debug) {
3
+ var util = require("./util");
4
+ var tryCatch = util.tryCatch;
5
+ var errorObj = util.errorObj;
6
+ var async = Promise._async;
7
+
8
+ Promise.prototype["break"] = Promise.prototype.cancel = function() {
9
+ if (!debug.cancellation()) return this._warn("cancellation is disabled");
10
+
11
+ var promise = this;
12
+ var child = promise;
13
+ while (promise._isCancellable()) {
14
+ if (!promise._cancelBy(child)) {
15
+ if (child._isFollowing()) {
16
+ child._followee().cancel();
17
+ } else {
18
+ child._cancelBranched();
19
+ }
20
+ break;
21
+ }
22
+
23
+ var parent = promise._cancellationParent;
24
+ if (parent == null || !parent._isCancellable()) {
25
+ if (promise._isFollowing()) {
26
+ promise._followee().cancel();
27
+ } else {
28
+ promise._cancelBranched();
29
+ }
30
+ break;
31
+ } else {
32
+ if (promise._isFollowing()) promise._followee().cancel();
33
+ promise._setWillBeCancelled();
34
+ child = promise;
35
+ promise = parent;
36
+ }
37
+ }
38
+ };
39
+
40
+ Promise.prototype._branchHasCancelled = function() {
41
+ this._branchesRemainingToCancel--;
42
+ };
43
+
44
+ Promise.prototype._enoughBranchesHaveCancelled = function() {
45
+ return this._branchesRemainingToCancel === undefined ||
46
+ this._branchesRemainingToCancel <= 0;
47
+ };
48
+
49
+ Promise.prototype._cancelBy = function(canceller) {
50
+ if (canceller === this) {
51
+ this._branchesRemainingToCancel = 0;
52
+ this._invokeOnCancel();
53
+ return true;
54
+ } else {
55
+ this._branchHasCancelled();
56
+ if (this._enoughBranchesHaveCancelled()) {
57
+ this._invokeOnCancel();
58
+ return true;
59
+ }
60
+ }
61
+ return false;
62
+ };
63
+
64
+ Promise.prototype._cancelBranched = function() {
65
+ if (this._enoughBranchesHaveCancelled()) {
66
+ this._cancel();
67
+ }
68
+ };
69
+
70
+ Promise.prototype._cancel = function() {
71
+ if (!this._isCancellable()) return;
72
+ this._setCancelled();
73
+ async.invoke(this._cancelPromises, this, undefined);
74
+ };
75
+
76
+ Promise.prototype._cancelPromises = function() {
77
+ if (this._length() > 0) this._settlePromises();
78
+ };
79
+
80
+ Promise.prototype._unsetOnCancel = function() {
81
+ this._onCancelField = undefined;
82
+ };
83
+
84
+ Promise.prototype._isCancellable = function() {
85
+ return this.isPending() && !this._isCancelled();
86
+ };
87
+
88
+ Promise.prototype.isCancellable = function() {
89
+ return this.isPending() && !this.isCancelled();
90
+ };
91
+
92
+ Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) {
93
+ if (util.isArray(onCancelCallback)) {
94
+ for (var i = 0; i < onCancelCallback.length; ++i) {
95
+ this._doInvokeOnCancel(onCancelCallback[i], internalOnly);
96
+ }
97
+ } else if (onCancelCallback !== undefined) {
98
+ if (typeof onCancelCallback === "function") {
99
+ if (!internalOnly) {
100
+ var e = tryCatch(onCancelCallback).call(this._boundValue());
101
+ if (e === errorObj) {
102
+ this._attachExtraTrace(e.e);
103
+ async.throwLater(e.e);
104
+ }
105
+ }
106
+ } else {
107
+ onCancelCallback._resultCancelled(this);
108
+ }
109
+ }
110
+ };
111
+
112
+ Promise.prototype._invokeOnCancel = function() {
113
+ var onCancelCallback = this._onCancel();
114
+ this._unsetOnCancel();
115
+ async.invoke(this._doInvokeOnCancel, this, onCancelCallback);
116
+ };
117
+
118
+ Promise.prototype._invokeInternalOnCancel = function() {
119
+ if (this._isCancellable()) {
120
+ this._doInvokeOnCancel(this._onCancel(), true);
121
+ this._unsetOnCancel();
122
+ }
123
+ };
124
+
125
+ Promise.prototype._resultCancelled = function() {
126
+ this.cancel();
127
+ };
128
+
129
+ };
node_modules/bluebird/js/release/catch_filter.js ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(NEXT_FILTER) {
3
+ var util = require("./util");
4
+ var getKeys = require("./es5").keys;
5
+ var tryCatch = util.tryCatch;
6
+ var errorObj = util.errorObj;
7
+
8
+ function catchFilter(instances, cb, promise) {
9
+ return function(e) {
10
+ var boundTo = promise._boundValue();
11
+ predicateLoop: for (var i = 0; i < instances.length; ++i) {
12
+ var item = instances[i];
13
+
14
+ if (item === Error ||
15
+ (item != null && item.prototype instanceof Error)) {
16
+ if (e instanceof item) {
17
+ return tryCatch(cb).call(boundTo, e);
18
+ }
19
+ } else if (typeof item === "function") {
20
+ var matchesPredicate = tryCatch(item).call(boundTo, e);
21
+ if (matchesPredicate === errorObj) {
22
+ return matchesPredicate;
23
+ } else if (matchesPredicate) {
24
+ return tryCatch(cb).call(boundTo, e);
25
+ }
26
+ } else if (util.isObject(e)) {
27
+ var keys = getKeys(item);
28
+ for (var j = 0; j < keys.length; ++j) {
29
+ var key = keys[j];
30
+ if (item[key] != e[key]) {
31
+ continue predicateLoop;
32
+ }
33
+ }
34
+ return tryCatch(cb).call(boundTo, e);
35
+ }
36
+ }
37
+ return NEXT_FILTER;
38
+ };
39
+ }
40
+
41
+ return catchFilter;
42
+ };
node_modules/bluebird/js/release/context.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise) {
3
+ var longStackTraces = false;
4
+ var contextStack = [];
5
+
6
+ Promise.prototype._promiseCreated = function() {};
7
+ Promise.prototype._pushContext = function() {};
8
+ Promise.prototype._popContext = function() {return null;};
9
+ Promise._peekContext = Promise.prototype._peekContext = function() {};
10
+
11
+ function Context() {
12
+ this._trace = new Context.CapturedTrace(peekContext());
13
+ }
14
+ Context.prototype._pushContext = function () {
15
+ if (this._trace !== undefined) {
16
+ this._trace._promiseCreated = null;
17
+ contextStack.push(this._trace);
18
+ }
19
+ };
20
+
21
+ Context.prototype._popContext = function () {
22
+ if (this._trace !== undefined) {
23
+ var trace = contextStack.pop();
24
+ var ret = trace._promiseCreated;
25
+ trace._promiseCreated = null;
26
+ return ret;
27
+ }
28
+ return null;
29
+ };
30
+
31
+ function createContext() {
32
+ if (longStackTraces) return new Context();
33
+ }
34
+
35
+ function peekContext() {
36
+ var lastIndex = contextStack.length - 1;
37
+ if (lastIndex >= 0) {
38
+ return contextStack[lastIndex];
39
+ }
40
+ return undefined;
41
+ }
42
+ Context.CapturedTrace = null;
43
+ Context.create = createContext;
44
+ Context.deactivateLongStackTraces = function() {};
45
+ Context.activateLongStackTraces = function() {
46
+ var Promise_pushContext = Promise.prototype._pushContext;
47
+ var Promise_popContext = Promise.prototype._popContext;
48
+ var Promise_PeekContext = Promise._peekContext;
49
+ var Promise_peekContext = Promise.prototype._peekContext;
50
+ var Promise_promiseCreated = Promise.prototype._promiseCreated;
51
+ Context.deactivateLongStackTraces = function() {
52
+ Promise.prototype._pushContext = Promise_pushContext;
53
+ Promise.prototype._popContext = Promise_popContext;
54
+ Promise._peekContext = Promise_PeekContext;
55
+ Promise.prototype._peekContext = Promise_peekContext;
56
+ Promise.prototype._promiseCreated = Promise_promiseCreated;
57
+ longStackTraces = false;
58
+ };
59
+ longStackTraces = true;
60
+ Promise.prototype._pushContext = Context.prototype._pushContext;
61
+ Promise.prototype._popContext = Context.prototype._popContext;
62
+ Promise._peekContext = Promise.prototype._peekContext = peekContext;
63
+ Promise.prototype._promiseCreated = function() {
64
+ var ctx = this._peekContext();
65
+ if (ctx && ctx._promiseCreated == null) ctx._promiseCreated = this;
66
+ };
67
+ };
68
+ return Context;
69
+ };
node_modules/bluebird/js/release/debuggability.js ADDED
@@ -0,0 +1,1009 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise, Context,
3
+ enableAsyncHooks, disableAsyncHooks) {
4
+ var async = Promise._async;
5
+ var Warning = require("./errors").Warning;
6
+ var util = require("./util");
7
+ var es5 = require("./es5");
8
+ var canAttachTrace = util.canAttachTrace;
9
+ var unhandledRejectionHandled;
10
+ var possiblyUnhandledRejection;
11
+ var bluebirdFramePattern =
12
+ /[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/;
13
+ var nodeFramePattern = /\((?:timers\.js):\d+:\d+\)/;
14
+ var parseLinePattern = /[\/<\(](.+?):(\d+):(\d+)\)?\s*$/;
15
+ var stackFramePattern = null;
16
+ var formatStack = null;
17
+ var indentStackFrames = false;
18
+ var printWarning;
19
+ var debugging = !!(util.env("BLUEBIRD_DEBUG") != 0 &&
20
+ (false ||
21
+ util.env("BLUEBIRD_DEBUG") ||
22
+ util.env("NODE_ENV") === "development"));
23
+
24
+ var warnings = !!(util.env("BLUEBIRD_WARNINGS") != 0 &&
25
+ (debugging || util.env("BLUEBIRD_WARNINGS")));
26
+
27
+ var longStackTraces = !!(util.env("BLUEBIRD_LONG_STACK_TRACES") != 0 &&
28
+ (debugging || util.env("BLUEBIRD_LONG_STACK_TRACES")));
29
+
30
+ var wForgottenReturn = util.env("BLUEBIRD_W_FORGOTTEN_RETURN") != 0 &&
31
+ (warnings || !!util.env("BLUEBIRD_W_FORGOTTEN_RETURN"));
32
+
33
+ var deferUnhandledRejectionCheck;
34
+ (function() {
35
+ var promises = [];
36
+
37
+ function unhandledRejectionCheck() {
38
+ for (var i = 0; i < promises.length; ++i) {
39
+ promises[i]._notifyUnhandledRejection();
40
+ }
41
+ unhandledRejectionClear();
42
+ }
43
+
44
+ function unhandledRejectionClear() {
45
+ promises.length = 0;
46
+ }
47
+
48
+ deferUnhandledRejectionCheck = function(promise) {
49
+ promises.push(promise);
50
+ setTimeout(unhandledRejectionCheck, 1);
51
+ };
52
+
53
+ es5.defineProperty(Promise, "_unhandledRejectionCheck", {
54
+ value: unhandledRejectionCheck
55
+ });
56
+ es5.defineProperty(Promise, "_unhandledRejectionClear", {
57
+ value: unhandledRejectionClear
58
+ });
59
+ })();
60
+
61
+ Promise.prototype.suppressUnhandledRejections = function() {
62
+ var target = this._target();
63
+ target._bitField = ((target._bitField & (~1048576)) |
64
+ 524288);
65
+ };
66
+
67
+ Promise.prototype._ensurePossibleRejectionHandled = function () {
68
+ if ((this._bitField & 524288) !== 0) return;
69
+ this._setRejectionIsUnhandled();
70
+ deferUnhandledRejectionCheck(this);
71
+ };
72
+
73
+ Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
74
+ fireRejectionEvent("rejectionHandled",
75
+ unhandledRejectionHandled, undefined, this);
76
+ };
77
+
78
+ Promise.prototype._setReturnedNonUndefined = function() {
79
+ this._bitField = this._bitField | 268435456;
80
+ };
81
+
82
+ Promise.prototype._returnedNonUndefined = function() {
83
+ return (this._bitField & 268435456) !== 0;
84
+ };
85
+
86
+ Promise.prototype._notifyUnhandledRejection = function () {
87
+ if (this._isRejectionUnhandled()) {
88
+ var reason = this._settledValue();
89
+ this._setUnhandledRejectionIsNotified();
90
+ fireRejectionEvent("unhandledRejection",
91
+ possiblyUnhandledRejection, reason, this);
92
+ }
93
+ };
94
+
95
+ Promise.prototype._setUnhandledRejectionIsNotified = function () {
96
+ this._bitField = this._bitField | 262144;
97
+ };
98
+
99
+ Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
100
+ this._bitField = this._bitField & (~262144);
101
+ };
102
+
103
+ Promise.prototype._isUnhandledRejectionNotified = function () {
104
+ return (this._bitField & 262144) > 0;
105
+ };
106
+
107
+ Promise.prototype._setRejectionIsUnhandled = function () {
108
+ this._bitField = this._bitField | 1048576;
109
+ };
110
+
111
+ Promise.prototype._unsetRejectionIsUnhandled = function () {
112
+ this._bitField = this._bitField & (~1048576);
113
+ if (this._isUnhandledRejectionNotified()) {
114
+ this._unsetUnhandledRejectionIsNotified();
115
+ this._notifyUnhandledRejectionIsHandled();
116
+ }
117
+ };
118
+
119
+ Promise.prototype._isRejectionUnhandled = function () {
120
+ return (this._bitField & 1048576) > 0;
121
+ };
122
+
123
+ Promise.prototype._warn = function(message, shouldUseOwnTrace, promise) {
124
+ return warn(message, shouldUseOwnTrace, promise || this);
125
+ };
126
+
127
+ Promise.onPossiblyUnhandledRejection = function (fn) {
128
+ var context = Promise._getContext();
129
+ possiblyUnhandledRejection = util.contextBind(context, fn);
130
+ };
131
+
132
+ Promise.onUnhandledRejectionHandled = function (fn) {
133
+ var context = Promise._getContext();
134
+ unhandledRejectionHandled = util.contextBind(context, fn);
135
+ };
136
+
137
+ var disableLongStackTraces = function() {};
138
+ Promise.longStackTraces = function () {
139
+ if (async.haveItemsQueued() && !config.longStackTraces) {
140
+ throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
141
+ }
142
+ if (!config.longStackTraces && longStackTracesIsSupported()) {
143
+ var Promise_captureStackTrace = Promise.prototype._captureStackTrace;
144
+ var Promise_attachExtraTrace = Promise.prototype._attachExtraTrace;
145
+ var Promise_dereferenceTrace = Promise.prototype._dereferenceTrace;
146
+ config.longStackTraces = true;
147
+ disableLongStackTraces = function() {
148
+ if (async.haveItemsQueued() && !config.longStackTraces) {
149
+ throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
150
+ }
151
+ Promise.prototype._captureStackTrace = Promise_captureStackTrace;
152
+ Promise.prototype._attachExtraTrace = Promise_attachExtraTrace;
153
+ Promise.prototype._dereferenceTrace = Promise_dereferenceTrace;
154
+ Context.deactivateLongStackTraces();
155
+ config.longStackTraces = false;
156
+ };
157
+ Promise.prototype._captureStackTrace = longStackTracesCaptureStackTrace;
158
+ Promise.prototype._attachExtraTrace = longStackTracesAttachExtraTrace;
159
+ Promise.prototype._dereferenceTrace = longStackTracesDereferenceTrace;
160
+ Context.activateLongStackTraces();
161
+ }
162
+ };
163
+
164
+ Promise.hasLongStackTraces = function () {
165
+ return config.longStackTraces && longStackTracesIsSupported();
166
+ };
167
+
168
+
169
+ var legacyHandlers = {
170
+ unhandledrejection: {
171
+ before: function() {
172
+ var ret = util.global.onunhandledrejection;
173
+ util.global.onunhandledrejection = null;
174
+ return ret;
175
+ },
176
+ after: function(fn) {
177
+ util.global.onunhandledrejection = fn;
178
+ }
179
+ },
180
+ rejectionhandled: {
181
+ before: function() {
182
+ var ret = util.global.onrejectionhandled;
183
+ util.global.onrejectionhandled = null;
184
+ return ret;
185
+ },
186
+ after: function(fn) {
187
+ util.global.onrejectionhandled = fn;
188
+ }
189
+ }
190
+ };
191
+
192
+ var fireDomEvent = (function() {
193
+ var dispatch = function(legacy, e) {
194
+ if (legacy) {
195
+ var fn;
196
+ try {
197
+ fn = legacy.before();
198
+ return !util.global.dispatchEvent(e);
199
+ } finally {
200
+ legacy.after(fn);
201
+ }
202
+ } else {
203
+ return !util.global.dispatchEvent(e);
204
+ }
205
+ };
206
+ try {
207
+ if (typeof CustomEvent === "function") {
208
+ var event = new CustomEvent("CustomEvent");
209
+ util.global.dispatchEvent(event);
210
+ return function(name, event) {
211
+ name = name.toLowerCase();
212
+ var eventData = {
213
+ detail: event,
214
+ cancelable: true
215
+ };
216
+ var domEvent = new CustomEvent(name, eventData);
217
+ es5.defineProperty(
218
+ domEvent, "promise", {value: event.promise});
219
+ es5.defineProperty(
220
+ domEvent, "reason", {value: event.reason});
221
+
222
+ return dispatch(legacyHandlers[name], domEvent);
223
+ };
224
+ } else if (typeof Event === "function") {
225
+ var event = new Event("CustomEvent");
226
+ util.global.dispatchEvent(event);
227
+ return function(name, event) {
228
+ name = name.toLowerCase();
229
+ var domEvent = new Event(name, {
230
+ cancelable: true
231
+ });
232
+ domEvent.detail = event;
233
+ es5.defineProperty(domEvent, "promise", {value: event.promise});
234
+ es5.defineProperty(domEvent, "reason", {value: event.reason});
235
+ return dispatch(legacyHandlers[name], domEvent);
236
+ };
237
+ } else {
238
+ var event = document.createEvent("CustomEvent");
239
+ event.initCustomEvent("testingtheevent", false, true, {});
240
+ util.global.dispatchEvent(event);
241
+ return function(name, event) {
242
+ name = name.toLowerCase();
243
+ var domEvent = document.createEvent("CustomEvent");
244
+ domEvent.initCustomEvent(name, false, true,
245
+ event);
246
+ return dispatch(legacyHandlers[name], domEvent);
247
+ };
248
+ }
249
+ } catch (e) {}
250
+ return function() {
251
+ return false;
252
+ };
253
+ })();
254
+
255
+ var fireGlobalEvent = (function() {
256
+ if (util.isNode) {
257
+ return function() {
258
+ return process.emit.apply(process, arguments);
259
+ };
260
+ } else {
261
+ if (!util.global) {
262
+ return function() {
263
+ return false;
264
+ };
265
+ }
266
+ return function(name) {
267
+ var methodName = "on" + name.toLowerCase();
268
+ var method = util.global[methodName];
269
+ if (!method) return false;
270
+ method.apply(util.global, [].slice.call(arguments, 1));
271
+ return true;
272
+ };
273
+ }
274
+ })();
275
+
276
+ function generatePromiseLifecycleEventObject(name, promise) {
277
+ return {promise: promise};
278
+ }
279
+
280
+ var eventToObjectGenerator = {
281
+ promiseCreated: generatePromiseLifecycleEventObject,
282
+ promiseFulfilled: generatePromiseLifecycleEventObject,
283
+ promiseRejected: generatePromiseLifecycleEventObject,
284
+ promiseResolved: generatePromiseLifecycleEventObject,
285
+ promiseCancelled: generatePromiseLifecycleEventObject,
286
+ promiseChained: function(name, promise, child) {
287
+ return {promise: promise, child: child};
288
+ },
289
+ warning: function(name, warning) {
290
+ return {warning: warning};
291
+ },
292
+ unhandledRejection: function (name, reason, promise) {
293
+ return {reason: reason, promise: promise};
294
+ },
295
+ rejectionHandled: generatePromiseLifecycleEventObject
296
+ };
297
+
298
+ var activeFireEvent = function (name) {
299
+ var globalEventFired = false;
300
+ try {
301
+ globalEventFired = fireGlobalEvent.apply(null, arguments);
302
+ } catch (e) {
303
+ async.throwLater(e);
304
+ globalEventFired = true;
305
+ }
306
+
307
+ var domEventFired = false;
308
+ try {
309
+ domEventFired = fireDomEvent(name,
310
+ eventToObjectGenerator[name].apply(null, arguments));
311
+ } catch (e) {
312
+ async.throwLater(e);
313
+ domEventFired = true;
314
+ }
315
+
316
+ return domEventFired || globalEventFired;
317
+ };
318
+
319
+ Promise.config = function(opts) {
320
+ opts = Object(opts);
321
+ if ("longStackTraces" in opts) {
322
+ if (opts.longStackTraces) {
323
+ Promise.longStackTraces();
324
+ } else if (!opts.longStackTraces && Promise.hasLongStackTraces()) {
325
+ disableLongStackTraces();
326
+ }
327
+ }
328
+ if ("warnings" in opts) {
329
+ var warningsOption = opts.warnings;
330
+ config.warnings = !!warningsOption;
331
+ wForgottenReturn = config.warnings;
332
+
333
+ if (util.isObject(warningsOption)) {
334
+ if ("wForgottenReturn" in warningsOption) {
335
+ wForgottenReturn = !!warningsOption.wForgottenReturn;
336
+ }
337
+ }
338
+ }
339
+ if ("cancellation" in opts && opts.cancellation && !config.cancellation) {
340
+ if (async.haveItemsQueued()) {
341
+ throw new Error(
342
+ "cannot enable cancellation after promises are in use");
343
+ }
344
+ Promise.prototype._clearCancellationData =
345
+ cancellationClearCancellationData;
346
+ Promise.prototype._propagateFrom = cancellationPropagateFrom;
347
+ Promise.prototype._onCancel = cancellationOnCancel;
348
+ Promise.prototype._setOnCancel = cancellationSetOnCancel;
349
+ Promise.prototype._attachCancellationCallback =
350
+ cancellationAttachCancellationCallback;
351
+ Promise.prototype._execute = cancellationExecute;
352
+ propagateFromFunction = cancellationPropagateFrom;
353
+ config.cancellation = true;
354
+ }
355
+ if ("monitoring" in opts) {
356
+ if (opts.monitoring && !config.monitoring) {
357
+ config.monitoring = true;
358
+ Promise.prototype._fireEvent = activeFireEvent;
359
+ } else if (!opts.monitoring && config.monitoring) {
360
+ config.monitoring = false;
361
+ Promise.prototype._fireEvent = defaultFireEvent;
362
+ }
363
+ }
364
+ if ("asyncHooks" in opts && util.nodeSupportsAsyncResource) {
365
+ var prev = config.asyncHooks;
366
+ var cur = !!opts.asyncHooks;
367
+ if (prev !== cur) {
368
+ config.asyncHooks = cur;
369
+ if (cur) {
370
+ enableAsyncHooks();
371
+ } else {
372
+ disableAsyncHooks();
373
+ }
374
+ }
375
+ }
376
+ return Promise;
377
+ };
378
+
379
+ function defaultFireEvent() { return false; }
380
+
381
+ Promise.prototype._fireEvent = defaultFireEvent;
382
+ Promise.prototype._execute = function(executor, resolve, reject) {
383
+ try {
384
+ executor(resolve, reject);
385
+ } catch (e) {
386
+ return e;
387
+ }
388
+ };
389
+ Promise.prototype._onCancel = function () {};
390
+ Promise.prototype._setOnCancel = function (handler) { ; };
391
+ Promise.prototype._attachCancellationCallback = function(onCancel) {
392
+ ;
393
+ };
394
+ Promise.prototype._captureStackTrace = function () {};
395
+ Promise.prototype._attachExtraTrace = function () {};
396
+ Promise.prototype._dereferenceTrace = function () {};
397
+ Promise.prototype._clearCancellationData = function() {};
398
+ Promise.prototype._propagateFrom = function (parent, flags) {
399
+ ;
400
+ ;
401
+ };
402
+
403
+ function cancellationExecute(executor, resolve, reject) {
404
+ var promise = this;
405
+ try {
406
+ executor(resolve, reject, function(onCancel) {
407
+ if (typeof onCancel !== "function") {
408
+ throw new TypeError("onCancel must be a function, got: " +
409
+ util.toString(onCancel));
410
+ }
411
+ promise._attachCancellationCallback(onCancel);
412
+ });
413
+ } catch (e) {
414
+ return e;
415
+ }
416
+ }
417
+
418
+ function cancellationAttachCancellationCallback(onCancel) {
419
+ if (!this._isCancellable()) return this;
420
+
421
+ var previousOnCancel = this._onCancel();
422
+ if (previousOnCancel !== undefined) {
423
+ if (util.isArray(previousOnCancel)) {
424
+ previousOnCancel.push(onCancel);
425
+ } else {
426
+ this._setOnCancel([previousOnCancel, onCancel]);
427
+ }
428
+ } else {
429
+ this._setOnCancel(onCancel);
430
+ }
431
+ }
432
+
433
+ function cancellationOnCancel() {
434
+ return this._onCancelField;
435
+ }
436
+
437
+ function cancellationSetOnCancel(onCancel) {
438
+ this._onCancelField = onCancel;
439
+ }
440
+
441
+ function cancellationClearCancellationData() {
442
+ this._cancellationParent = undefined;
443
+ this._onCancelField = undefined;
444
+ }
445
+
446
+ function cancellationPropagateFrom(parent, flags) {
447
+ if ((flags & 1) !== 0) {
448
+ this._cancellationParent = parent;
449
+ var branchesRemainingToCancel = parent._branchesRemainingToCancel;
450
+ if (branchesRemainingToCancel === undefined) {
451
+ branchesRemainingToCancel = 0;
452
+ }
453
+ parent._branchesRemainingToCancel = branchesRemainingToCancel + 1;
454
+ }
455
+ if ((flags & 2) !== 0 && parent._isBound()) {
456
+ this._setBoundTo(parent._boundTo);
457
+ }
458
+ }
459
+
460
+ function bindingPropagateFrom(parent, flags) {
461
+ if ((flags & 2) !== 0 && parent._isBound()) {
462
+ this._setBoundTo(parent._boundTo);
463
+ }
464
+ }
465
+ var propagateFromFunction = bindingPropagateFrom;
466
+
467
+ function boundValueFunction() {
468
+ var ret = this._boundTo;
469
+ if (ret !== undefined) {
470
+ if (ret instanceof Promise) {
471
+ if (ret.isFulfilled()) {
472
+ return ret.value();
473
+ } else {
474
+ return undefined;
475
+ }
476
+ }
477
+ }
478
+ return ret;
479
+ }
480
+
481
+ function longStackTracesCaptureStackTrace() {
482
+ this._trace = new CapturedTrace(this._peekContext());
483
+ }
484
+
485
+ function longStackTracesAttachExtraTrace(error, ignoreSelf) {
486
+ if (canAttachTrace(error)) {
487
+ var trace = this._trace;
488
+ if (trace !== undefined) {
489
+ if (ignoreSelf) trace = trace._parent;
490
+ }
491
+ if (trace !== undefined) {
492
+ trace.attachExtraTrace(error);
493
+ } else if (!error.__stackCleaned__) {
494
+ var parsed = parseStackAndMessage(error);
495
+ util.notEnumerableProp(error, "stack",
496
+ parsed.message + "\n" + parsed.stack.join("\n"));
497
+ util.notEnumerableProp(error, "__stackCleaned__", true);
498
+ }
499
+ }
500
+ }
501
+
502
+ function longStackTracesDereferenceTrace() {
503
+ this._trace = undefined;
504
+ }
505
+
506
+ function checkForgottenReturns(returnValue, promiseCreated, name, promise,
507
+ parent) {
508
+ if (returnValue === undefined && promiseCreated !== null &&
509
+ wForgottenReturn) {
510
+ if (parent !== undefined && parent._returnedNonUndefined()) return;
511
+ if ((promise._bitField & 65535) === 0) return;
512
+
513
+ if (name) name = name + " ";
514
+ var handlerLine = "";
515
+ var creatorLine = "";
516
+ if (promiseCreated._trace) {
517
+ var traceLines = promiseCreated._trace.stack.split("\n");
518
+ var stack = cleanStack(traceLines);
519
+ for (var i = stack.length - 1; i >= 0; --i) {
520
+ var line = stack[i];
521
+ if (!nodeFramePattern.test(line)) {
522
+ var lineMatches = line.match(parseLinePattern);
523
+ if (lineMatches) {
524
+ handlerLine = "at " + lineMatches[1] +
525
+ ":" + lineMatches[2] + ":" + lineMatches[3] + " ";
526
+ }
527
+ break;
528
+ }
529
+ }
530
+
531
+ if (stack.length > 0) {
532
+ var firstUserLine = stack[0];
533
+ for (var i = 0; i < traceLines.length; ++i) {
534
+
535
+ if (traceLines[i] === firstUserLine) {
536
+ if (i > 0) {
537
+ creatorLine = "\n" + traceLines[i - 1];
538
+ }
539
+ break;
540
+ }
541
+ }
542
+
543
+ }
544
+ }
545
+ var msg = "a promise was created in a " + name +
546
+ "handler " + handlerLine + "but was not returned from it, " +
547
+ "see http://goo.gl/rRqMUw" +
548
+ creatorLine;
549
+ promise._warn(msg, true, promiseCreated);
550
+ }
551
+ }
552
+
553
+ function deprecated(name, replacement) {
554
+ var message = name +
555
+ " is deprecated and will be removed in a future version.";
556
+ if (replacement) message += " Use " + replacement + " instead.";
557
+ return warn(message);
558
+ }
559
+
560
+ function warn(message, shouldUseOwnTrace, promise) {
561
+ if (!config.warnings) return;
562
+ var warning = new Warning(message);
563
+ var ctx;
564
+ if (shouldUseOwnTrace) {
565
+ promise._attachExtraTrace(warning);
566
+ } else if (config.longStackTraces && (ctx = Promise._peekContext())) {
567
+ ctx.attachExtraTrace(warning);
568
+ } else {
569
+ var parsed = parseStackAndMessage(warning);
570
+ warning.stack = parsed.message + "\n" + parsed.stack.join("\n");
571
+ }
572
+
573
+ if (!activeFireEvent("warning", warning)) {
574
+ formatAndLogError(warning, "", true);
575
+ }
576
+ }
577
+
578
+ function reconstructStack(message, stacks) {
579
+ for (var i = 0; i < stacks.length - 1; ++i) {
580
+ stacks[i].push("From previous event:");
581
+ stacks[i] = stacks[i].join("\n");
582
+ }
583
+ if (i < stacks.length) {
584
+ stacks[i] = stacks[i].join("\n");
585
+ }
586
+ return message + "\n" + stacks.join("\n");
587
+ }
588
+
589
+ function removeDuplicateOrEmptyJumps(stacks) {
590
+ for (var i = 0; i < stacks.length; ++i) {
591
+ if (stacks[i].length === 0 ||
592
+ ((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) {
593
+ stacks.splice(i, 1);
594
+ i--;
595
+ }
596
+ }
597
+ }
598
+
599
+ function removeCommonRoots(stacks) {
600
+ var current = stacks[0];
601
+ for (var i = 1; i < stacks.length; ++i) {
602
+ var prev = stacks[i];
603
+ var currentLastIndex = current.length - 1;
604
+ var currentLastLine = current[currentLastIndex];
605
+ var commonRootMeetPoint = -1;
606
+
607
+ for (var j = prev.length - 1; j >= 0; --j) {
608
+ if (prev[j] === currentLastLine) {
609
+ commonRootMeetPoint = j;
610
+ break;
611
+ }
612
+ }
613
+
614
+ for (var j = commonRootMeetPoint; j >= 0; --j) {
615
+ var line = prev[j];
616
+ if (current[currentLastIndex] === line) {
617
+ current.pop();
618
+ currentLastIndex--;
619
+ } else {
620
+ break;
621
+ }
622
+ }
623
+ current = prev;
624
+ }
625
+ }
626
+
627
+ function cleanStack(stack) {
628
+ var ret = [];
629
+ for (var i = 0; i < stack.length; ++i) {
630
+ var line = stack[i];
631
+ var isTraceLine = " (No stack trace)" === line ||
632
+ stackFramePattern.test(line);
633
+ var isInternalFrame = isTraceLine && shouldIgnore(line);
634
+ if (isTraceLine && !isInternalFrame) {
635
+ if (indentStackFrames && line.charAt(0) !== " ") {
636
+ line = " " + line;
637
+ }
638
+ ret.push(line);
639
+ }
640
+ }
641
+ return ret;
642
+ }
643
+
644
+ function stackFramesAsArray(error) {
645
+ var stack = error.stack.replace(/\s+$/g, "").split("\n");
646
+ for (var i = 0; i < stack.length; ++i) {
647
+ var line = stack[i];
648
+ if (" (No stack trace)" === line || stackFramePattern.test(line)) {
649
+ break;
650
+ }
651
+ }
652
+ if (i > 0 && error.name != "SyntaxError") {
653
+ stack = stack.slice(i);
654
+ }
655
+ return stack;
656
+ }
657
+
658
+ function parseStackAndMessage(error) {
659
+ var stack = error.stack;
660
+ var message = error.toString();
661
+ stack = typeof stack === "string" && stack.length > 0
662
+ ? stackFramesAsArray(error) : [" (No stack trace)"];
663
+ return {
664
+ message: message,
665
+ stack: error.name == "SyntaxError" ? stack : cleanStack(stack)
666
+ };
667
+ }
668
+
669
+ function formatAndLogError(error, title, isSoft) {
670
+ if (typeof console !== "undefined") {
671
+ var message;
672
+ if (util.isObject(error)) {
673
+ var stack = error.stack;
674
+ message = title + formatStack(stack, error);
675
+ } else {
676
+ message = title + String(error);
677
+ }
678
+ if (typeof printWarning === "function") {
679
+ printWarning(message, isSoft);
680
+ } else if (typeof console.log === "function" ||
681
+ typeof console.log === "object") {
682
+ console.log(message);
683
+ }
684
+ }
685
+ }
686
+
687
+ function fireRejectionEvent(name, localHandler, reason, promise) {
688
+ var localEventFired = false;
689
+ try {
690
+ if (typeof localHandler === "function") {
691
+ localEventFired = true;
692
+ if (name === "rejectionHandled") {
693
+ localHandler(promise);
694
+ } else {
695
+ localHandler(reason, promise);
696
+ }
697
+ }
698
+ } catch (e) {
699
+ async.throwLater(e);
700
+ }
701
+
702
+ if (name === "unhandledRejection") {
703
+ if (!activeFireEvent(name, reason, promise) && !localEventFired) {
704
+ formatAndLogError(reason, "Unhandled rejection ");
705
+ }
706
+ } else {
707
+ activeFireEvent(name, promise);
708
+ }
709
+ }
710
+
711
+ function formatNonError(obj) {
712
+ var str;
713
+ if (typeof obj === "function") {
714
+ str = "[function " +
715
+ (obj.name || "anonymous") +
716
+ "]";
717
+ } else {
718
+ str = obj && typeof obj.toString === "function"
719
+ ? obj.toString() : util.toString(obj);
720
+ var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
721
+ if (ruselessToString.test(str)) {
722
+ try {
723
+ var newStr = JSON.stringify(obj);
724
+ str = newStr;
725
+ }
726
+ catch(e) {
727
+
728
+ }
729
+ }
730
+ if (str.length === 0) {
731
+ str = "(empty array)";
732
+ }
733
+ }
734
+ return ("(<" + snip(str) + ">, no stack trace)");
735
+ }
736
+
737
+ function snip(str) {
738
+ var maxChars = 41;
739
+ if (str.length < maxChars) {
740
+ return str;
741
+ }
742
+ return str.substr(0, maxChars - 3) + "...";
743
+ }
744
+
745
+ function longStackTracesIsSupported() {
746
+ return typeof captureStackTrace === "function";
747
+ }
748
+
749
+ var shouldIgnore = function() { return false; };
750
+ var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
751
+ function parseLineInfo(line) {
752
+ var matches = line.match(parseLineInfoRegex);
753
+ if (matches) {
754
+ return {
755
+ fileName: matches[1],
756
+ line: parseInt(matches[2], 10)
757
+ };
758
+ }
759
+ }
760
+
761
+ function setBounds(firstLineError, lastLineError) {
762
+ if (!longStackTracesIsSupported()) return;
763
+ var firstStackLines = (firstLineError.stack || "").split("\n");
764
+ var lastStackLines = (lastLineError.stack || "").split("\n");
765
+ var firstIndex = -1;
766
+ var lastIndex = -1;
767
+ var firstFileName;
768
+ var lastFileName;
769
+ for (var i = 0; i < firstStackLines.length; ++i) {
770
+ var result = parseLineInfo(firstStackLines[i]);
771
+ if (result) {
772
+ firstFileName = result.fileName;
773
+ firstIndex = result.line;
774
+ break;
775
+ }
776
+ }
777
+ for (var i = 0; i < lastStackLines.length; ++i) {
778
+ var result = parseLineInfo(lastStackLines[i]);
779
+ if (result) {
780
+ lastFileName = result.fileName;
781
+ lastIndex = result.line;
782
+ break;
783
+ }
784
+ }
785
+ if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName ||
786
+ firstFileName !== lastFileName || firstIndex >= lastIndex) {
787
+ return;
788
+ }
789
+
790
+ shouldIgnore = function(line) {
791
+ if (bluebirdFramePattern.test(line)) return true;
792
+ var info = parseLineInfo(line);
793
+ if (info) {
794
+ if (info.fileName === firstFileName &&
795
+ (firstIndex <= info.line && info.line <= lastIndex)) {
796
+ return true;
797
+ }
798
+ }
799
+ return false;
800
+ };
801
+ }
802
+
803
+ function CapturedTrace(parent) {
804
+ this._parent = parent;
805
+ this._promisesCreated = 0;
806
+ var length = this._length = 1 + (parent === undefined ? 0 : parent._length);
807
+ captureStackTrace(this, CapturedTrace);
808
+ if (length > 32) this.uncycle();
809
+ }
810
+ util.inherits(CapturedTrace, Error);
811
+ Context.CapturedTrace = CapturedTrace;
812
+
813
+ CapturedTrace.prototype.uncycle = function() {
814
+ var length = this._length;
815
+ if (length < 2) return;
816
+ var nodes = [];
817
+ var stackToIndex = {};
818
+
819
+ for (var i = 0, node = this; node !== undefined; ++i) {
820
+ nodes.push(node);
821
+ node = node._parent;
822
+ }
823
+ length = this._length = i;
824
+ for (var i = length - 1; i >= 0; --i) {
825
+ var stack = nodes[i].stack;
826
+ if (stackToIndex[stack] === undefined) {
827
+ stackToIndex[stack] = i;
828
+ }
829
+ }
830
+ for (var i = 0; i < length; ++i) {
831
+ var currentStack = nodes[i].stack;
832
+ var index = stackToIndex[currentStack];
833
+ if (index !== undefined && index !== i) {
834
+ if (index > 0) {
835
+ nodes[index - 1]._parent = undefined;
836
+ nodes[index - 1]._length = 1;
837
+ }
838
+ nodes[i]._parent = undefined;
839
+ nodes[i]._length = 1;
840
+ var cycleEdgeNode = i > 0 ? nodes[i - 1] : this;
841
+
842
+ if (index < length - 1) {
843
+ cycleEdgeNode._parent = nodes[index + 1];
844
+ cycleEdgeNode._parent.uncycle();
845
+ cycleEdgeNode._length =
846
+ cycleEdgeNode._parent._length + 1;
847
+ } else {
848
+ cycleEdgeNode._parent = undefined;
849
+ cycleEdgeNode._length = 1;
850
+ }
851
+ var currentChildLength = cycleEdgeNode._length + 1;
852
+ for (var j = i - 2; j >= 0; --j) {
853
+ nodes[j]._length = currentChildLength;
854
+ currentChildLength++;
855
+ }
856
+ return;
857
+ }
858
+ }
859
+ };
860
+
861
+ CapturedTrace.prototype.attachExtraTrace = function(error) {
862
+ if (error.__stackCleaned__) return;
863
+ this.uncycle();
864
+ var parsed = parseStackAndMessage(error);
865
+ var message = parsed.message;
866
+ var stacks = [parsed.stack];
867
+
868
+ var trace = this;
869
+ while (trace !== undefined) {
870
+ stacks.push(cleanStack(trace.stack.split("\n")));
871
+ trace = trace._parent;
872
+ }
873
+ removeCommonRoots(stacks);
874
+ removeDuplicateOrEmptyJumps(stacks);
875
+ util.notEnumerableProp(error, "stack", reconstructStack(message, stacks));
876
+ util.notEnumerableProp(error, "__stackCleaned__", true);
877
+ };
878
+
879
+ var captureStackTrace = (function stackDetection() {
880
+ var v8stackFramePattern = /^\s*at\s*/;
881
+ var v8stackFormatter = function(stack, error) {
882
+ if (typeof stack === "string") return stack;
883
+
884
+ if (error.name !== undefined &&
885
+ error.message !== undefined) {
886
+ return error.toString();
887
+ }
888
+ return formatNonError(error);
889
+ };
890
+
891
+ if (typeof Error.stackTraceLimit === "number" &&
892
+ typeof Error.captureStackTrace === "function") {
893
+ Error.stackTraceLimit += 6;
894
+ stackFramePattern = v8stackFramePattern;
895
+ formatStack = v8stackFormatter;
896
+ var captureStackTrace = Error.captureStackTrace;
897
+
898
+ shouldIgnore = function(line) {
899
+ return bluebirdFramePattern.test(line);
900
+ };
901
+ return function(receiver, ignoreUntil) {
902
+ Error.stackTraceLimit += 6;
903
+ captureStackTrace(receiver, ignoreUntil);
904
+ Error.stackTraceLimit -= 6;
905
+ };
906
+ }
907
+ var err = new Error();
908
+
909
+ if (typeof err.stack === "string" &&
910
+ err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) {
911
+ stackFramePattern = /@/;
912
+ formatStack = v8stackFormatter;
913
+ indentStackFrames = true;
914
+ return function captureStackTrace(o) {
915
+ o.stack = new Error().stack;
916
+ };
917
+ }
918
+
919
+ var hasStackAfterThrow;
920
+ try { throw new Error(); }
921
+ catch(e) {
922
+ hasStackAfterThrow = ("stack" in e);
923
+ }
924
+ if (!("stack" in err) && hasStackAfterThrow &&
925
+ typeof Error.stackTraceLimit === "number") {
926
+ stackFramePattern = v8stackFramePattern;
927
+ formatStack = v8stackFormatter;
928
+ return function captureStackTrace(o) {
929
+ Error.stackTraceLimit += 6;
930
+ try { throw new Error(); }
931
+ catch(e) { o.stack = e.stack; }
932
+ Error.stackTraceLimit -= 6;
933
+ };
934
+ }
935
+
936
+ formatStack = function(stack, error) {
937
+ if (typeof stack === "string") return stack;
938
+
939
+ if ((typeof error === "object" ||
940
+ typeof error === "function") &&
941
+ error.name !== undefined &&
942
+ error.message !== undefined) {
943
+ return error.toString();
944
+ }
945
+ return formatNonError(error);
946
+ };
947
+
948
+ return null;
949
+
950
+ })([]);
951
+
952
+ if (typeof console !== "undefined" && typeof console.warn !== "undefined") {
953
+ printWarning = function (message) {
954
+ console.warn(message);
955
+ };
956
+ if (util.isNode && process.stderr.isTTY) {
957
+ printWarning = function(message, isSoft) {
958
+ var color = isSoft ? "\u001b[33m" : "\u001b[31m";
959
+ console.warn(color + message + "\u001b[0m\n");
960
+ };
961
+ } else if (!util.isNode && typeof (new Error().stack) === "string") {
962
+ printWarning = function(message, isSoft) {
963
+ console.warn("%c" + message,
964
+ isSoft ? "color: darkorange" : "color: red");
965
+ };
966
+ }
967
+ }
968
+
969
+ var config = {
970
+ warnings: warnings,
971
+ longStackTraces: false,
972
+ cancellation: false,
973
+ monitoring: false,
974
+ asyncHooks: false
975
+ };
976
+
977
+ if (longStackTraces) Promise.longStackTraces();
978
+
979
+ return {
980
+ asyncHooks: function() {
981
+ return config.asyncHooks;
982
+ },
983
+ longStackTraces: function() {
984
+ return config.longStackTraces;
985
+ },
986
+ warnings: function() {
987
+ return config.warnings;
988
+ },
989
+ cancellation: function() {
990
+ return config.cancellation;
991
+ },
992
+ monitoring: function() {
993
+ return config.monitoring;
994
+ },
995
+ propagateFromFunction: function() {
996
+ return propagateFromFunction;
997
+ },
998
+ boundValueFunction: function() {
999
+ return boundValueFunction;
1000
+ },
1001
+ checkForgottenReturns: checkForgottenReturns,
1002
+ setBounds: setBounds,
1003
+ warn: warn,
1004
+ deprecated: deprecated,
1005
+ CapturedTrace: CapturedTrace,
1006
+ fireDomEvent: fireDomEvent,
1007
+ fireGlobalEvent: fireGlobalEvent
1008
+ };
1009
+ };
node_modules/bluebird/js/release/direct_resolve.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise) {
3
+ function returner() {
4
+ return this.value;
5
+ }
6
+ function thrower() {
7
+ throw this.reason;
8
+ }
9
+
10
+ Promise.prototype["return"] =
11
+ Promise.prototype.thenReturn = function (value) {
12
+ if (value instanceof Promise) value.suppressUnhandledRejections();
13
+ return this._then(
14
+ returner, undefined, undefined, {value: value}, undefined);
15
+ };
16
+
17
+ Promise.prototype["throw"] =
18
+ Promise.prototype.thenThrow = function (reason) {
19
+ return this._then(
20
+ thrower, undefined, undefined, {reason: reason}, undefined);
21
+ };
22
+
23
+ Promise.prototype.catchThrow = function (reason) {
24
+ if (arguments.length <= 1) {
25
+ return this._then(
26
+ undefined, thrower, undefined, {reason: reason}, undefined);
27
+ } else {
28
+ var _reason = arguments[1];
29
+ var handler = function() {throw _reason;};
30
+ return this.caught(reason, handler);
31
+ }
32
+ };
33
+
34
+ Promise.prototype.catchReturn = function (value) {
35
+ if (arguments.length <= 1) {
36
+ if (value instanceof Promise) value.suppressUnhandledRejections();
37
+ return this._then(
38
+ undefined, returner, undefined, {value: value}, undefined);
39
+ } else {
40
+ var _value = arguments[1];
41
+ if (_value instanceof Promise) _value.suppressUnhandledRejections();
42
+ var handler = function() {return _value;};
43
+ return this.caught(value, handler);
44
+ }
45
+ };
46
+ };
node_modules/bluebird/js/release/each.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise, INTERNAL) {
3
+ var PromiseReduce = Promise.reduce;
4
+ var PromiseAll = Promise.all;
5
+
6
+ function promiseAllThis() {
7
+ return PromiseAll(this);
8
+ }
9
+
10
+ function PromiseMapSeries(promises, fn) {
11
+ return PromiseReduce(promises, fn, INTERNAL, INTERNAL);
12
+ }
13
+
14
+ Promise.prototype.each = function (fn) {
15
+ return PromiseReduce(this, fn, INTERNAL, 0)
16
+ ._then(promiseAllThis, undefined, undefined, this, undefined);
17
+ };
18
+
19
+ Promise.prototype.mapSeries = function (fn) {
20
+ return PromiseReduce(this, fn, INTERNAL, INTERNAL);
21
+ };
22
+
23
+ Promise.each = function (promises, fn) {
24
+ return PromiseReduce(promises, fn, INTERNAL, 0)
25
+ ._then(promiseAllThis, undefined, undefined, promises, undefined);
26
+ };
27
+
28
+ Promise.mapSeries = PromiseMapSeries;
29
+ };
30
+
node_modules/bluebird/js/release/errors.js ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var es5 = require("./es5");
3
+ var Objectfreeze = es5.freeze;
4
+ var util = require("./util");
5
+ var inherits = util.inherits;
6
+ var notEnumerableProp = util.notEnumerableProp;
7
+
8
+ function subError(nameProperty, defaultMessage) {
9
+ function SubError(message) {
10
+ if (!(this instanceof SubError)) return new SubError(message);
11
+ notEnumerableProp(this, "message",
12
+ typeof message === "string" ? message : defaultMessage);
13
+ notEnumerableProp(this, "name", nameProperty);
14
+ if (Error.captureStackTrace) {
15
+ Error.captureStackTrace(this, this.constructor);
16
+ } else {
17
+ Error.call(this);
18
+ }
19
+ }
20
+ inherits(SubError, Error);
21
+ return SubError;
22
+ }
23
+
24
+ var _TypeError, _RangeError;
25
+ var Warning = subError("Warning", "warning");
26
+ var CancellationError = subError("CancellationError", "cancellation error");
27
+ var TimeoutError = subError("TimeoutError", "timeout error");
28
+ var AggregateError = subError("AggregateError", "aggregate error");
29
+ try {
30
+ _TypeError = TypeError;
31
+ _RangeError = RangeError;
32
+ } catch(e) {
33
+ _TypeError = subError("TypeError", "type error");
34
+ _RangeError = subError("RangeError", "range error");
35
+ }
36
+
37
+ var methods = ("join pop push shift unshift slice filter forEach some " +
38
+ "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
39
+
40
+ for (var i = 0; i < methods.length; ++i) {
41
+ if (typeof Array.prototype[methods[i]] === "function") {
42
+ AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
43
+ }
44
+ }
45
+
46
+ es5.defineProperty(AggregateError.prototype, "length", {
47
+ value: 0,
48
+ configurable: false,
49
+ writable: true,
50
+ enumerable: true
51
+ });
52
+ AggregateError.prototype["isOperational"] = true;
53
+ var level = 0;
54
+ AggregateError.prototype.toString = function() {
55
+ var indent = Array(level * 4 + 1).join(" ");
56
+ var ret = "\n" + indent + "AggregateError of:" + "\n";
57
+ level++;
58
+ indent = Array(level * 4 + 1).join(" ");
59
+ for (var i = 0; i < this.length; ++i) {
60
+ var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
61
+ var lines = str.split("\n");
62
+ for (var j = 0; j < lines.length; ++j) {
63
+ lines[j] = indent + lines[j];
64
+ }
65
+ str = lines.join("\n");
66
+ ret += str + "\n";
67
+ }
68
+ level--;
69
+ return ret;
70
+ };
71
+
72
+ function OperationalError(message) {
73
+ if (!(this instanceof OperationalError))
74
+ return new OperationalError(message);
75
+ notEnumerableProp(this, "name", "OperationalError");
76
+ notEnumerableProp(this, "message", message);
77
+ this.cause = message;
78
+ this["isOperational"] = true;
79
+
80
+ if (message instanceof Error) {
81
+ notEnumerableProp(this, "message", message.message);
82
+ notEnumerableProp(this, "stack", message.stack);
83
+ } else if (Error.captureStackTrace) {
84
+ Error.captureStackTrace(this, this.constructor);
85
+ }
86
+
87
+ }
88
+ inherits(OperationalError, Error);
89
+
90
+ var errorTypes = Error["__BluebirdErrorTypes__"];
91
+ if (!errorTypes) {
92
+ errorTypes = Objectfreeze({
93
+ CancellationError: CancellationError,
94
+ TimeoutError: TimeoutError,
95
+ OperationalError: OperationalError,
96
+ RejectionError: OperationalError,
97
+ AggregateError: AggregateError
98
+ });
99
+ es5.defineProperty(Error, "__BluebirdErrorTypes__", {
100
+ value: errorTypes,
101
+ writable: false,
102
+ enumerable: false,
103
+ configurable: false
104
+ });
105
+ }
106
+
107
+ module.exports = {
108
+ Error: Error,
109
+ TypeError: _TypeError,
110
+ RangeError: _RangeError,
111
+ CancellationError: errorTypes.CancellationError,
112
+ OperationalError: errorTypes.OperationalError,
113
+ TimeoutError: errorTypes.TimeoutError,
114
+ AggregateError: errorTypes.AggregateError,
115
+ Warning: Warning
116
+ };
node_modules/bluebird/js/release/es5.js ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var isES5 = (function(){
2
+ "use strict";
3
+ return this === undefined;
4
+ })();
5
+
6
+ if (isES5) {
7
+ module.exports = {
8
+ freeze: Object.freeze,
9
+ defineProperty: Object.defineProperty,
10
+ getDescriptor: Object.getOwnPropertyDescriptor,
11
+ keys: Object.keys,
12
+ names: Object.getOwnPropertyNames,
13
+ getPrototypeOf: Object.getPrototypeOf,
14
+ isArray: Array.isArray,
15
+ isES5: isES5,
16
+ propertyIsWritable: function(obj, prop) {
17
+ var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
18
+ return !!(!descriptor || descriptor.writable || descriptor.set);
19
+ }
20
+ };
21
+ } else {
22
+ var has = {}.hasOwnProperty;
23
+ var str = {}.toString;
24
+ var proto = {}.constructor.prototype;
25
+
26
+ var ObjectKeys = function (o) {
27
+ var ret = [];
28
+ for (var key in o) {
29
+ if (has.call(o, key)) {
30
+ ret.push(key);
31
+ }
32
+ }
33
+ return ret;
34
+ };
35
+
36
+ var ObjectGetDescriptor = function(o, key) {
37
+ return {value: o[key]};
38
+ };
39
+
40
+ var ObjectDefineProperty = function (o, key, desc) {
41
+ o[key] = desc.value;
42
+ return o;
43
+ };
44
+
45
+ var ObjectFreeze = function (obj) {
46
+ return obj;
47
+ };
48
+
49
+ var ObjectGetPrototypeOf = function (obj) {
50
+ try {
51
+ return Object(obj).constructor.prototype;
52
+ }
53
+ catch (e) {
54
+ return proto;
55
+ }
56
+ };
57
+
58
+ var ArrayIsArray = function (obj) {
59
+ try {
60
+ return str.call(obj) === "[object Array]";
61
+ }
62
+ catch(e) {
63
+ return false;
64
+ }
65
+ };
66
+
67
+ module.exports = {
68
+ isArray: ArrayIsArray,
69
+ keys: ObjectKeys,
70
+ names: ObjectKeys,
71
+ defineProperty: ObjectDefineProperty,
72
+ getDescriptor: ObjectGetDescriptor,
73
+ freeze: ObjectFreeze,
74
+ getPrototypeOf: ObjectGetPrototypeOf,
75
+ isES5: isES5,
76
+ propertyIsWritable: function() {
77
+ return true;
78
+ }
79
+ };
80
+ }
node_modules/bluebird/js/release/filter.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise, INTERNAL) {
3
+ var PromiseMap = Promise.map;
4
+
5
+ Promise.prototype.filter = function (fn, options) {
6
+ return PromiseMap(this, fn, options, INTERNAL);
7
+ };
8
+
9
+ Promise.filter = function (promises, fn, options) {
10
+ return PromiseMap(promises, fn, options, INTERNAL);
11
+ };
12
+ };
node_modules/bluebird/js/release/finally.js ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise, tryConvertToPromise, NEXT_FILTER) {
3
+ var util = require("./util");
4
+ var CancellationError = Promise.CancellationError;
5
+ var errorObj = util.errorObj;
6
+ var catchFilter = require("./catch_filter")(NEXT_FILTER);
7
+
8
+ function PassThroughHandlerContext(promise, type, handler) {
9
+ this.promise = promise;
10
+ this.type = type;
11
+ this.handler = handler;
12
+ this.called = false;
13
+ this.cancelPromise = null;
14
+ }
15
+
16
+ PassThroughHandlerContext.prototype.isFinallyHandler = function() {
17
+ return this.type === 0;
18
+ };
19
+
20
+ function FinallyHandlerCancelReaction(finallyHandler) {
21
+ this.finallyHandler = finallyHandler;
22
+ }
23
+
24
+ FinallyHandlerCancelReaction.prototype._resultCancelled = function() {
25
+ checkCancel(this.finallyHandler);
26
+ };
27
+
28
+ function checkCancel(ctx, reason) {
29
+ if (ctx.cancelPromise != null) {
30
+ if (arguments.length > 1) {
31
+ ctx.cancelPromise._reject(reason);
32
+ } else {
33
+ ctx.cancelPromise._cancel();
34
+ }
35
+ ctx.cancelPromise = null;
36
+ return true;
37
+ }
38
+ return false;
39
+ }
40
+
41
+ function succeed() {
42
+ return finallyHandler.call(this, this.promise._target()._settledValue());
43
+ }
44
+ function fail(reason) {
45
+ if (checkCancel(this, reason)) return;
46
+ errorObj.e = reason;
47
+ return errorObj;
48
+ }
49
+ function finallyHandler(reasonOrValue) {
50
+ var promise = this.promise;
51
+ var handler = this.handler;
52
+
53
+ if (!this.called) {
54
+ this.called = true;
55
+ var ret = this.isFinallyHandler()
56
+ ? handler.call(promise._boundValue())
57
+ : handler.call(promise._boundValue(), reasonOrValue);
58
+ if (ret === NEXT_FILTER) {
59
+ return ret;
60
+ } else if (ret !== undefined) {
61
+ promise._setReturnedNonUndefined();
62
+ var maybePromise = tryConvertToPromise(ret, promise);
63
+ if (maybePromise instanceof Promise) {
64
+ if (this.cancelPromise != null) {
65
+ if (maybePromise._isCancelled()) {
66
+ var reason =
67
+ new CancellationError("late cancellation observer");
68
+ promise._attachExtraTrace(reason);
69
+ errorObj.e = reason;
70
+ return errorObj;
71
+ } else if (maybePromise.isPending()) {
72
+ maybePromise._attachCancellationCallback(
73
+ new FinallyHandlerCancelReaction(this));
74
+ }
75
+ }
76
+ return maybePromise._then(
77
+ succeed, fail, undefined, this, undefined);
78
+ }
79
+ }
80
+ }
81
+
82
+ if (promise.isRejected()) {
83
+ checkCancel(this);
84
+ errorObj.e = reasonOrValue;
85
+ return errorObj;
86
+ } else {
87
+ checkCancel(this);
88
+ return reasonOrValue;
89
+ }
90
+ }
91
+
92
+ Promise.prototype._passThrough = function(handler, type, success, fail) {
93
+ if (typeof handler !== "function") return this.then();
94
+ return this._then(success,
95
+ fail,
96
+ undefined,
97
+ new PassThroughHandlerContext(this, type, handler),
98
+ undefined);
99
+ };
100
+
101
+ Promise.prototype.lastly =
102
+ Promise.prototype["finally"] = function (handler) {
103
+ return this._passThrough(handler,
104
+ 0,
105
+ finallyHandler,
106
+ finallyHandler);
107
+ };
108
+
109
+
110
+ Promise.prototype.tap = function (handler) {
111
+ return this._passThrough(handler, 1, finallyHandler);
112
+ };
113
+
114
+ Promise.prototype.tapCatch = function (handlerOrPredicate) {
115
+ var len = arguments.length;
116
+ if(len === 1) {
117
+ return this._passThrough(handlerOrPredicate,
118
+ 1,
119
+ undefined,
120
+ finallyHandler);
121
+ } else {
122
+ var catchInstances = new Array(len - 1),
123
+ j = 0, i;
124
+ for (i = 0; i < len - 1; ++i) {
125
+ var item = arguments[i];
126
+ if (util.isObject(item)) {
127
+ catchInstances[j++] = item;
128
+ } else {
129
+ return Promise.reject(new TypeError(
130
+ "tapCatch statement predicate: "
131
+ + "expecting an object but got " + util.classString(item)
132
+ ));
133
+ }
134
+ }
135
+ catchInstances.length = j;
136
+ var handler = arguments[i];
137
+ return this._passThrough(catchFilter(catchInstances, handler, this),
138
+ 1,
139
+ undefined,
140
+ finallyHandler);
141
+ }
142
+
143
+ };
144
+
145
+ return PassThroughHandlerContext;
146
+ };
node_modules/bluebird/js/release/generators.js ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise,
3
+ apiRejection,
4
+ INTERNAL,
5
+ tryConvertToPromise,
6
+ Proxyable,
7
+ debug) {
8
+ var errors = require("./errors");
9
+ var TypeError = errors.TypeError;
10
+ var util = require("./util");
11
+ var errorObj = util.errorObj;
12
+ var tryCatch = util.tryCatch;
13
+ var yieldHandlers = [];
14
+
15
+ function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
16
+ for (var i = 0; i < yieldHandlers.length; ++i) {
17
+ traceParent._pushContext();
18
+ var result = tryCatch(yieldHandlers[i])(value);
19
+ traceParent._popContext();
20
+ if (result === errorObj) {
21
+ traceParent._pushContext();
22
+ var ret = Promise.reject(errorObj.e);
23
+ traceParent._popContext();
24
+ return ret;
25
+ }
26
+ var maybePromise = tryConvertToPromise(result, traceParent);
27
+ if (maybePromise instanceof Promise) return maybePromise;
28
+ }
29
+ return null;
30
+ }
31
+
32
+ function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
33
+ if (debug.cancellation()) {
34
+ var internal = new Promise(INTERNAL);
35
+ var _finallyPromise = this._finallyPromise = new Promise(INTERNAL);
36
+ this._promise = internal.lastly(function() {
37
+ return _finallyPromise;
38
+ });
39
+ internal._captureStackTrace();
40
+ internal._setOnCancel(this);
41
+ } else {
42
+ var promise = this._promise = new Promise(INTERNAL);
43
+ promise._captureStackTrace();
44
+ }
45
+ this._stack = stack;
46
+ this._generatorFunction = generatorFunction;
47
+ this._receiver = receiver;
48
+ this._generator = undefined;
49
+ this._yieldHandlers = typeof yieldHandler === "function"
50
+ ? [yieldHandler].concat(yieldHandlers)
51
+ : yieldHandlers;
52
+ this._yieldedPromise = null;
53
+ this._cancellationPhase = false;
54
+ }
55
+ util.inherits(PromiseSpawn, Proxyable);
56
+
57
+ PromiseSpawn.prototype._isResolved = function() {
58
+ return this._promise === null;
59
+ };
60
+
61
+ PromiseSpawn.prototype._cleanup = function() {
62
+ this._promise = this._generator = null;
63
+ if (debug.cancellation() && this._finallyPromise !== null) {
64
+ this._finallyPromise._fulfill();
65
+ this._finallyPromise = null;
66
+ }
67
+ };
68
+
69
+ PromiseSpawn.prototype._promiseCancelled = function() {
70
+ if (this._isResolved()) return;
71
+ var implementsReturn = typeof this._generator["return"] !== "undefined";
72
+
73
+ var result;
74
+ if (!implementsReturn) {
75
+ var reason = new Promise.CancellationError(
76
+ "generator .return() sentinel");
77
+ Promise.coroutine.returnSentinel = reason;
78
+ this._promise._attachExtraTrace(reason);
79
+ this._promise._pushContext();
80
+ result = tryCatch(this._generator["throw"]).call(this._generator,
81
+ reason);
82
+ this._promise._popContext();
83
+ } else {
84
+ this._promise._pushContext();
85
+ result = tryCatch(this._generator["return"]).call(this._generator,
86
+ undefined);
87
+ this._promise._popContext();
88
+ }
89
+ this._cancellationPhase = true;
90
+ this._yieldedPromise = null;
91
+ this._continue(result);
92
+ };
93
+
94
+ PromiseSpawn.prototype._promiseFulfilled = function(value) {
95
+ this._yieldedPromise = null;
96
+ this._promise._pushContext();
97
+ var result = tryCatch(this._generator.next).call(this._generator, value);
98
+ this._promise._popContext();
99
+ this._continue(result);
100
+ };
101
+
102
+ PromiseSpawn.prototype._promiseRejected = function(reason) {
103
+ this._yieldedPromise = null;
104
+ this._promise._attachExtraTrace(reason);
105
+ this._promise._pushContext();
106
+ var result = tryCatch(this._generator["throw"])
107
+ .call(this._generator, reason);
108
+ this._promise._popContext();
109
+ this._continue(result);
110
+ };
111
+
112
+ PromiseSpawn.prototype._resultCancelled = function() {
113
+ if (this._yieldedPromise instanceof Promise) {
114
+ var promise = this._yieldedPromise;
115
+ this._yieldedPromise = null;
116
+ promise.cancel();
117
+ }
118
+ };
119
+
120
+ PromiseSpawn.prototype.promise = function () {
121
+ return this._promise;
122
+ };
123
+
124
+ PromiseSpawn.prototype._run = function () {
125
+ this._generator = this._generatorFunction.call(this._receiver);
126
+ this._receiver =
127
+ this._generatorFunction = undefined;
128
+ this._promiseFulfilled(undefined);
129
+ };
130
+
131
+ PromiseSpawn.prototype._continue = function (result) {
132
+ var promise = this._promise;
133
+ if (result === errorObj) {
134
+ this._cleanup();
135
+ if (this._cancellationPhase) {
136
+ return promise.cancel();
137
+ } else {
138
+ return promise._rejectCallback(result.e, false);
139
+ }
140
+ }
141
+
142
+ var value = result.value;
143
+ if (result.done === true) {
144
+ this._cleanup();
145
+ if (this._cancellationPhase) {
146
+ return promise.cancel();
147
+ } else {
148
+ return promise._resolveCallback(value);
149
+ }
150
+ } else {
151
+ var maybePromise = tryConvertToPromise(value, this._promise);
152
+ if (!(maybePromise instanceof Promise)) {
153
+ maybePromise =
154
+ promiseFromYieldHandler(maybePromise,
155
+ this._yieldHandlers,
156
+ this._promise);
157
+ if (maybePromise === null) {
158
+ this._promiseRejected(
159
+ new TypeError(
160
+ "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", String(value)) +
161
+ "From coroutine:\u000a" +
162
+ this._stack.split("\n").slice(1, -7).join("\n")
163
+ )
164
+ );
165
+ return;
166
+ }
167
+ }
168
+ maybePromise = maybePromise._target();
169
+ var bitField = maybePromise._bitField;
170
+ ;
171
+ if (((bitField & 50397184) === 0)) {
172
+ this._yieldedPromise = maybePromise;
173
+ maybePromise._proxy(this, null);
174
+ } else if (((bitField & 33554432) !== 0)) {
175
+ Promise._async.invoke(
176
+ this._promiseFulfilled, this, maybePromise._value()
177
+ );
178
+ } else if (((bitField & 16777216) !== 0)) {
179
+ Promise._async.invoke(
180
+ this._promiseRejected, this, maybePromise._reason()
181
+ );
182
+ } else {
183
+ this._promiseCancelled();
184
+ }
185
+ }
186
+ };
187
+
188
+ Promise.coroutine = function (generatorFunction, options) {
189
+ if (typeof generatorFunction !== "function") {
190
+ throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
191
+ }
192
+ var yieldHandler = Object(options).yieldHandler;
193
+ var PromiseSpawn$ = PromiseSpawn;
194
+ var stack = new Error().stack;
195
+ return function () {
196
+ var generator = generatorFunction.apply(this, arguments);
197
+ var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
198
+ stack);
199
+ var ret = spawn.promise();
200
+ spawn._generator = generator;
201
+ spawn._promiseFulfilled(undefined);
202
+ return ret;
203
+ };
204
+ };
205
+
206
+ Promise.coroutine.addYieldHandler = function(fn) {
207
+ if (typeof fn !== "function") {
208
+ throw new TypeError("expecting a function but got " + util.classString(fn));
209
+ }
210
+ yieldHandlers.push(fn);
211
+ };
212
+
213
+ Promise.spawn = function (generatorFunction) {
214
+ debug.deprecated("Promise.spawn()", "Promise.coroutine()");
215
+ if (typeof generatorFunction !== "function") {
216
+ return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
217
+ }
218
+ var spawn = new PromiseSpawn(generatorFunction, this);
219
+ var ret = spawn.promise();
220
+ spawn._run(Promise.spawn);
221
+ return ret;
222
+ };
223
+ };
node_modules/bluebird/js/release/join.js ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports =
3
+ function(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async) {
4
+ var util = require("./util");
5
+ var canEvaluate = util.canEvaluate;
6
+ var tryCatch = util.tryCatch;
7
+ var errorObj = util.errorObj;
8
+ var reject;
9
+
10
+ if (!false) {
11
+ if (canEvaluate) {
12
+ var thenCallback = function(i) {
13
+ return new Function("value", "holder", " \n\
14
+ 'use strict'; \n\
15
+ holder.pIndex = value; \n\
16
+ holder.checkFulfillment(this); \n\
17
+ ".replace(/Index/g, i));
18
+ };
19
+
20
+ var promiseSetter = function(i) {
21
+ return new Function("promise", "holder", " \n\
22
+ 'use strict'; \n\
23
+ holder.pIndex = promise; \n\
24
+ ".replace(/Index/g, i));
25
+ };
26
+
27
+ var generateHolderClass = function(total) {
28
+ var props = new Array(total);
29
+ for (var i = 0; i < props.length; ++i) {
30
+ props[i] = "this.p" + (i+1);
31
+ }
32
+ var assignment = props.join(" = ") + " = null;";
33
+ var cancellationCode= "var promise;\n" + props.map(function(prop) {
34
+ return " \n\
35
+ promise = " + prop + "; \n\
36
+ if (promise instanceof Promise) { \n\
37
+ promise.cancel(); \n\
38
+ } \n\
39
+ ";
40
+ }).join("\n");
41
+ var passedArguments = props.join(", ");
42
+ var name = "Holder$" + total;
43
+
44
+
45
+ var code = "return function(tryCatch, errorObj, Promise, async) { \n\
46
+ 'use strict'; \n\
47
+ function [TheName](fn) { \n\
48
+ [TheProperties] \n\
49
+ this.fn = fn; \n\
50
+ this.asyncNeeded = true; \n\
51
+ this.now = 0; \n\
52
+ } \n\
53
+ \n\
54
+ [TheName].prototype._callFunction = function(promise) { \n\
55
+ promise._pushContext(); \n\
56
+ var ret = tryCatch(this.fn)([ThePassedArguments]); \n\
57
+ promise._popContext(); \n\
58
+ if (ret === errorObj) { \n\
59
+ promise._rejectCallback(ret.e, false); \n\
60
+ } else { \n\
61
+ promise._resolveCallback(ret); \n\
62
+ } \n\
63
+ }; \n\
64
+ \n\
65
+ [TheName].prototype.checkFulfillment = function(promise) { \n\
66
+ var now = ++this.now; \n\
67
+ if (now === [TheTotal]) { \n\
68
+ if (this.asyncNeeded) { \n\
69
+ async.invoke(this._callFunction, this, promise); \n\
70
+ } else { \n\
71
+ this._callFunction(promise); \n\
72
+ } \n\
73
+ \n\
74
+ } \n\
75
+ }; \n\
76
+ \n\
77
+ [TheName].prototype._resultCancelled = function() { \n\
78
+ [CancellationCode] \n\
79
+ }; \n\
80
+ \n\
81
+ return [TheName]; \n\
82
+ }(tryCatch, errorObj, Promise, async); \n\
83
+ ";
84
+
85
+ code = code.replace(/\[TheName\]/g, name)
86
+ .replace(/\[TheTotal\]/g, total)
87
+ .replace(/\[ThePassedArguments\]/g, passedArguments)
88
+ .replace(/\[TheProperties\]/g, assignment)
89
+ .replace(/\[CancellationCode\]/g, cancellationCode);
90
+
91
+ return new Function("tryCatch", "errorObj", "Promise", "async", code)
92
+ (tryCatch, errorObj, Promise, async);
93
+ };
94
+
95
+ var holderClasses = [];
96
+ var thenCallbacks = [];
97
+ var promiseSetters = [];
98
+
99
+ for (var i = 0; i < 8; ++i) {
100
+ holderClasses.push(generateHolderClass(i + 1));
101
+ thenCallbacks.push(thenCallback(i + 1));
102
+ promiseSetters.push(promiseSetter(i + 1));
103
+ }
104
+
105
+ reject = function (reason) {
106
+ this._reject(reason);
107
+ };
108
+ }}
109
+
110
+ Promise.join = function () {
111
+ var last = arguments.length - 1;
112
+ var fn;
113
+ if (last > 0 && typeof arguments[last] === "function") {
114
+ fn = arguments[last];
115
+ if (!false) {
116
+ if (last <= 8 && canEvaluate) {
117
+ var ret = new Promise(INTERNAL);
118
+ ret._captureStackTrace();
119
+ var HolderClass = holderClasses[last - 1];
120
+ var holder = new HolderClass(fn);
121
+ var callbacks = thenCallbacks;
122
+
123
+ for (var i = 0; i < last; ++i) {
124
+ var maybePromise = tryConvertToPromise(arguments[i], ret);
125
+ if (maybePromise instanceof Promise) {
126
+ maybePromise = maybePromise._target();
127
+ var bitField = maybePromise._bitField;
128
+ ;
129
+ if (((bitField & 50397184) === 0)) {
130
+ maybePromise._then(callbacks[i], reject,
131
+ undefined, ret, holder);
132
+ promiseSetters[i](maybePromise, holder);
133
+ holder.asyncNeeded = false;
134
+ } else if (((bitField & 33554432) !== 0)) {
135
+ callbacks[i].call(ret,
136
+ maybePromise._value(), holder);
137
+ } else if (((bitField & 16777216) !== 0)) {
138
+ ret._reject(maybePromise._reason());
139
+ } else {
140
+ ret._cancel();
141
+ }
142
+ } else {
143
+ callbacks[i].call(ret, maybePromise, holder);
144
+ }
145
+ }
146
+
147
+ if (!ret._isFateSealed()) {
148
+ if (holder.asyncNeeded) {
149
+ var context = Promise._getContext();
150
+ holder.fn = util.contextBind(context, holder.fn);
151
+ }
152
+ ret._setAsyncGuaranteed();
153
+ ret._setOnCancel(holder);
154
+ }
155
+ return ret;
156
+ }
157
+ }
158
+ }
159
+ var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len ; ++$_i) {args[$_i] = arguments[$_i ];};
160
+ if (fn) args.pop();
161
+ var ret = new PromiseArray(args).promise();
162
+ return fn !== undefined ? ret.spread(fn) : ret;
163
+ };
164
+
165
+ };
node_modules/bluebird/js/release/map.js ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports = function(Promise,
3
+ PromiseArray,
4
+ apiRejection,
5
+ tryConvertToPromise,
6
+ INTERNAL,
7
+ debug) {
8
+ var util = require("./util");
9
+ var tryCatch = util.tryCatch;
10
+ var errorObj = util.errorObj;
11
+ var async = Promise._async;
12
+
13
+ function MappingPromiseArray(promises, fn, limit, _filter) {
14
+ this.constructor$(promises);
15
+ this._promise._captureStackTrace();
16
+ var context = Promise._getContext();
17
+ this._callback = util.contextBind(context, fn);
18
+ this._preservedValues = _filter === INTERNAL
19
+ ? new Array(this.length())
20
+ : null;
21
+ this._limit = limit;
22
+ this._inFlight = 0;
23
+ this._queue = [];
24
+ async.invoke(this._asyncInit, this, undefined);
25
+ if (util.isArray(promises)) {
26
+ for (var i = 0; i < promises.length; ++i) {
27
+ var maybePromise = promises[i];
28
+ if (maybePromise instanceof Promise) {
29
+ maybePromise.suppressUnhandledRejections();
30
+ }
31
+ }
32
+ }
33
+ }
34
+ util.inherits(MappingPromiseArray, PromiseArray);
35
+
36
+ MappingPromiseArray.prototype._asyncInit = function() {
37
+ this._init$(undefined, -2);
38
+ };
39
+
40
+ MappingPromiseArray.prototype._init = function () {};
41
+
42
+ MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
43
+ var values = this._values;
44
+ var length = this.length();
45
+ var preservedValues = this._preservedValues;
46
+ var limit = this._limit;
47
+
48
+ if (index < 0) {
49
+ index = (index * -1) - 1;
50
+ values[index] = value;
51
+ if (limit >= 1) {
52
+ this._inFlight--;
53
+ this._drainQueue();
54
+ if (this._isResolved()) return true;
55
+ }
56
+ } else {
57
+ if (limit >= 1 && this._inFlight >= limit) {
58
+ values[index] = value;
59
+ this._queue.push(index);
60
+ return false;
61
+ }
62
+ if (preservedValues !== null) preservedValues[index] = value;
63
+
64
+ var promise = this._promise;
65
+ var callback = this._callback;
66
+ var receiver = promise._boundValue();
67
+ promise._pushContext();
68
+ var ret = tryCatch(callback).call(receiver, value, index, length);
69
+ var promiseCreated = promise._popContext();
70
+ debug.checkForgottenReturns(
71
+ ret,
72
+ promiseCreated,
73
+ preservedValues !== null ? "Promise.filter" : "Promise.map",
74
+ promise
75
+ );
76
+ if (ret === errorObj) {
77
+ this._reject(ret.e);
78
+ return true;
79
+ }
80
+
81
+ var maybePromise = tryConvertToPromise(ret, this._promise);
82
+ if (maybePromise instanceof Promise) {
83
+ maybePromise = maybePromise._target();
84
+ var bitField = maybePromise._bitField;
85
+ ;
86
+ if (((bitField & 50397184) === 0)) {
87
+ if (limit >= 1) this._inFlight++;
88
+ values[index] = maybePromise;
89
+ maybePromise._proxy(this, (index + 1) * -1);
90
+ return false;
91
+ } else if (((bitField & 33554432) !== 0)) {
92
+ ret = maybePromise._value();
93
+ } else if (((bitField & 16777216) !== 0)) {
94
+ this._reject(maybePromise._reason());
95
+ return true;
96
+ } else {
97
+ this._cancel();
98
+ return true;
99
+ }
100
+ }
101
+ values[index] = ret;
102
+ }
103
+ var totalResolved = ++this._totalResolved;
104
+ if (totalResolved >= length) {
105
+ if (preservedValues !== null) {
106
+ this._filter(values, preservedValues);
107
+ } else {
108
+ this._resolve(values);
109
+ }
110
+ return true;
111
+ }
112
+ return false;
113
+ };
114
+
115
+ MappingPromiseArray.prototype._drainQueue = function () {
116
+ var queue = this._queue;
117
+ var limit = this._limit;
118
+ var values = this._values;
119
+ while (queue.length > 0 && this._inFlight < limit) {
120
+ if (this._isResolved()) return;
121
+ var index = queue.pop();
122
+ this._promiseFulfilled(values[index], index);
123
+ }
124
+ };
125
+
126
+ MappingPromiseArray.prototype._filter = function (booleans, values) {
127
+ var len = values.length;
128
+ var ret = new Array(len);
129
+ var j = 0;
130
+ for (var i = 0; i < len; ++i) {
131
+ if (booleans[i]) ret[j++] = values[i];
132
+ }
133
+ ret.length = j;
134
+ this._resolve(ret);
135
+ };
136
+
137
+ MappingPromiseArray.prototype.preservedValues = function () {
138
+ return this._preservedValues;
139
+ };
140
+
141
+ function map(promises, fn, options, _filter) {
142
+ if (typeof fn !== "function") {
143
+ return apiRejection("expecting a function but got " + util.classString(fn));
144
+ }
145
+
146
+ var limit = 0;
147
+ if (options !== undefined) {
148
+ if (typeof options === "object" && options !== null) {
149
+ if (typeof options.concurrency !== "number") {
150
+ return Promise.reject(
151
+ new TypeError("'concurrency' must be a number but it is " +
152
+ util.classString(options.concurrency)));
153
+ }
154
+ limit = options.concurrency;
155
+ } else {
156
+ return Promise.reject(new TypeError(
157
+ "options argument must be an object but it is " +
158
+ util.classString(options)));
159
+ }
160
+ }
161
+ limit = typeof limit === "number" &&
162
+ isFinite(limit) && limit >= 1 ? limit : 0;
163
+ return new MappingPromiseArray(promises, fn, limit, _filter).promise();
164
+ }
165
+
166
+ Promise.prototype.map = function (fn, options) {
167
+ return map(this, fn, options, null);
168
+ };
169
+
170
+ Promise.map = function (promises, fn, options, _filter) {
171
+ return map(promises, fn, options, _filter);
172
+ };
173
+
174
+
175
+ };
node_modules/bluebird/js/release/method.js ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ module.exports =
3
+ function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) {
4
+ var util = require("./util");
5
+ var tryCatch = util.tryCatch;
6
+
7
+ Promise.method = function (fn) {
8
+ if (typeof fn !== "function") {
9
+ throw new Promise.TypeError("expecting a function but got " + util.classString(fn));
10
+ }
11
+ return function () {
12
+ var ret = new Promise(INTERNAL);
13
+ ret._captureStackTrace();
14
+ ret._pushContext();
15
+ var value = tryCatch(fn).apply(this, arguments);
16
+ var promiseCreated = ret._popContext();
17
+ debug.checkForgottenReturns(
18
+ value, promiseCreated, "Promise.method", ret);
19
+ ret._resolveFromSyncValue(value);
20
+ return ret;
21
+ };
22
+ };
23
+
24
+ Promise.attempt = Promise["try"] = function (fn) {
25
+ if (typeof fn !== "function") {
26
+ return apiRejection("expecting a function but got " + util.classString(fn));
27
+ }
28
+ var ret = new Promise(INTERNAL);
29
+ ret._captureStackTrace();
30
+ ret._pushContext();
31
+ var value;
32
+ if (arguments.length > 1) {
33
+ debug.deprecated("calling Promise.try with more than 1 argument");
34
+ var arg = arguments[1];
35
+ var ctx = arguments[2];
36
+ value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg)
37
+ : tryCatch(fn).call(ctx, arg);
38
+ } else {
39
+ value = tryCatch(fn)();
40
+ }
41
+ var promiseCreated = ret._popContext();
42
+ debug.checkForgottenReturns(
43
+ value, promiseCreated, "Promise.try", ret);
44
+ ret._resolveFromSyncValue(value);
45
+ return ret;
46
+ };
47
+
48
+ Promise.prototype._resolveFromSyncValue = function (value) {
49
+ if (value === util.errorObj) {
50
+ this._rejectCallback(value.e, false);
51
+ } else {
52
+ this._resolveCallback(value, true);
53
+ }
54
+ };
55
+ };