Leon4gr45 commited on
Commit
5832e08
·
verified ·
1 Parent(s): 0553e35

Upload folder using huggingface_hub (part 4)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +14 -0
  2. node_modules/async/unmemoize.js +25 -0
  3. node_modules/async/until.js +61 -0
  4. node_modules/async/waterfall.js +105 -0
  5. node_modules/async/whilst.js +78 -0
  6. node_modules/async/wrapSync.js +118 -0
  7. node_modules/asynckit/LICENSE +21 -0
  8. node_modules/asynckit/README.md +233 -0
  9. node_modules/asynckit/bench.js +76 -0
  10. node_modules/asynckit/index.js +6 -0
  11. node_modules/asynckit/lib/abort.js +29 -0
  12. node_modules/asynckit/lib/async.js +34 -0
  13. node_modules/asynckit/lib/defer.js +26 -0
  14. node_modules/asynckit/lib/iterate.js +75 -0
  15. node_modules/asynckit/lib/readable_asynckit.js +91 -0
  16. node_modules/asynckit/lib/readable_parallel.js +25 -0
  17. node_modules/asynckit/lib/readable_serial.js +25 -0
  18. node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  19. node_modules/asynckit/lib/state.js +37 -0
  20. node_modules/asynckit/lib/streamify.js +141 -0
  21. node_modules/asynckit/lib/terminator.js +29 -0
  22. node_modules/asynckit/package.json +63 -0
  23. node_modules/asynckit/parallel.js +43 -0
  24. node_modules/asynckit/serial.js +17 -0
  25. node_modules/asynckit/serialOrdered.js +75 -0
  26. node_modules/asynckit/stream.js +21 -0
  27. node_modules/await-to-js/LICENSE +7 -0
  28. node_modules/await-to-js/README.md +82 -0
  29. node_modules/await-to-js/package.json +107 -0
  30. node_modules/b4a/LICENSE +201 -0
  31. node_modules/b4a/README.md +153 -0
  32. node_modules/b4a/browser.js +541 -0
  33. node_modules/b4a/index.js +188 -0
  34. node_modules/b4a/lib/ascii.js +31 -0
  35. node_modules/b4a/lib/base64.js +64 -0
  36. node_modules/b4a/lib/hex.js +51 -0
  37. node_modules/b4a/lib/latin1.js +31 -0
  38. node_modules/b4a/lib/utf16le.js +40 -0
  39. node_modules/b4a/lib/utf8.js +144 -0
  40. node_modules/b4a/package.json +51 -0
  41. node_modules/b4a/react-native.js +5 -0
  42. node_modules/balanced-match/.github/FUNDING.yml +2 -0
  43. node_modules/balanced-match/LICENSE.md +21 -0
  44. node_modules/balanced-match/README.md +97 -0
  45. node_modules/balanced-match/index.js +62 -0
  46. node_modules/balanced-match/package.json +48 -0
  47. node_modules/bare-events/LICENSE +201 -0
  48. node_modules/bare-events/README.md +25 -0
  49. node_modules/bare-events/global.d.ts +15 -0
  50. node_modules/bare-events/global.js +5 -0
.gitattributes CHANGED
@@ -25,3 +25,17 @@
25
  *.eot binary
26
  *.pdf binary
27
  *.zip binary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  *.eot binary
26
  *.pdf binary
27
  *.zip binary
28
+ node_modules/bare-fs/prebuilds/ios-arm64/bare-fs.bare filter=lfs diff=lfs merge=lfs -text
29
+ node_modules/bare-fs/prebuilds/win32-arm64/bare-fs.bare filter=lfs diff=lfs merge=lfs -text
30
+ node_modules/bare-fs/prebuilds/win32-x64/bare-fs.bare filter=lfs diff=lfs merge=lfs -text
31
+ node_modules/bare-os/prebuilds/win32-arm64/bare-os.bare filter=lfs diff=lfs merge=lfs -text
32
+ node_modules/bare-os/prebuilds/win32-x64/bare-os.bare filter=lfs diff=lfs merge=lfs -text
33
+ node_modules/bare-url/prebuilds/android-arm64/bare-url.bare filter=lfs diff=lfs merge=lfs -text
34
+ node_modules/bare-url/prebuilds/android-x64/bare-url.bare filter=lfs diff=lfs merge=lfs -text
35
+ node_modules/bare-url/prebuilds/darwin-arm64/bare-url.bare filter=lfs diff=lfs merge=lfs -text
36
+ node_modules/bare-url/prebuilds/ios-arm64/bare-url.bare filter=lfs diff=lfs merge=lfs -text
37
+ node_modules/bare-url/prebuilds/ios-arm64-simulator/bare-url.bare filter=lfs diff=lfs merge=lfs -text
38
+ node_modules/bare-url/prebuilds/linux-x64/bare-url.bare filter=lfs diff=lfs merge=lfs -text
39
+ node_modules/bare-url/prebuilds/win32-arm64/bare-url.bare filter=lfs diff=lfs merge=lfs -text
40
+ node_modules/bare-url/prebuilds/win32-x64/bare-url.bare filter=lfs diff=lfs merge=lfs -text
41
+ node_modules/better-sqlite3/build/Release/better_sqlite3.node filter=lfs diff=lfs merge=lfs -text
node_modules/async/unmemoize.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = unmemoize;
7
+ /**
8
+ * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
9
+ * unmemoized form. Handy for testing.
10
+ *
11
+ * @name unmemoize
12
+ * @static
13
+ * @memberOf module:Utils
14
+ * @method
15
+ * @see [async.memoize]{@link module:Utils.memoize}
16
+ * @category Util
17
+ * @param {AsyncFunction} fn - the memoized function
18
+ * @returns {AsyncFunction} a function that calls the original unmemoized function
19
+ */
20
+ function unmemoize(fn) {
21
+ return (...args) => {
22
+ return (fn.unmemoized || fn)(...args);
23
+ };
24
+ }
25
+ module.exports = exports.default;
node_modules/async/until.js ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = until;
7
+
8
+ var _whilst = require('./whilst.js');
9
+
10
+ var _whilst2 = _interopRequireDefault(_whilst);
11
+
12
+ var _wrapAsync = require('./internal/wrapAsync.js');
13
+
14
+ var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ /**
19
+ * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when
20
+ * stopped, or an error occurs. `callback` will be passed an error and any
21
+ * arguments passed to the final `iteratee`'s callback.
22
+ *
23
+ * The inverse of [whilst]{@link module:ControlFlow.whilst}.
24
+ *
25
+ * @name until
26
+ * @static
27
+ * @memberOf module:ControlFlow
28
+ * @method
29
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
30
+ * @category Control Flow
31
+ * @param {AsyncFunction} test - asynchronous truth test to perform before each
32
+ * execution of `iteratee`. Invoked with (callback).
33
+ * @param {AsyncFunction} iteratee - An async function which is called each time
34
+ * `test` fails. Invoked with (callback).
35
+ * @param {Function} [callback] - A callback which is called after the test
36
+ * function has passed and repeated execution of `iteratee` has stopped. `callback`
37
+ * will be passed an error and any arguments passed to the final `iteratee`'s
38
+ * callback. Invoked with (err, [results]);
39
+ * @returns {Promise} a promise, if a callback is not passed
40
+ *
41
+ * @example
42
+ * const results = []
43
+ * let finished = false
44
+ * async.until(function test(cb) {
45
+ * cb(null, finished)
46
+ * }, function iter(next) {
47
+ * fetchPage(url, (err, body) => {
48
+ * if (err) return next(err)
49
+ * results = results.concat(body.objects)
50
+ * finished = !!body.next
51
+ * next(err)
52
+ * })
53
+ * }, function done (err) {
54
+ * // all pages have been fetched
55
+ * })
56
+ */
57
+ function until(test, iteratee, callback) {
58
+ const _test = (0, _wrapAsync2.default)(test);
59
+ return (0, _whilst2.default)(cb => _test((err, truth) => cb(err, !truth)), iteratee, callback);
60
+ }
61
+ module.exports = exports.default;
node_modules/async/waterfall.js ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _once = require('./internal/once.js');
8
+
9
+ var _once2 = _interopRequireDefault(_once);
10
+
11
+ var _onlyOnce = require('./internal/onlyOnce.js');
12
+
13
+ var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
14
+
15
+ var _wrapAsync = require('./internal/wrapAsync.js');
16
+
17
+ var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18
+
19
+ var _awaitify = require('./internal/awaitify.js');
20
+
21
+ var _awaitify2 = _interopRequireDefault(_awaitify);
22
+
23
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+
25
+ /**
26
+ * Runs the `tasks` array of functions in series, each passing their results to
27
+ * the next in the array. However, if any of the `tasks` pass an error to their
28
+ * own callback, the next function is not executed, and the main `callback` is
29
+ * immediately called with the error.
30
+ *
31
+ * @name waterfall
32
+ * @static
33
+ * @memberOf module:ControlFlow
34
+ * @method
35
+ * @category Control Flow
36
+ * @param {Array} tasks - An array of [async functions]{@link AsyncFunction}
37
+ * to run.
38
+ * Each function should complete with any number of `result` values.
39
+ * The `result` values will be passed as arguments, in order, to the next task.
40
+ * @param {Function} [callback] - An optional callback to run once all the
41
+ * functions have completed. This will be passed the results of the last task's
42
+ * callback. Invoked with (err, [results]).
43
+ * @returns {Promise} a promise, if a callback is omitted
44
+ * @example
45
+ *
46
+ * async.waterfall([
47
+ * function(callback) {
48
+ * callback(null, 'one', 'two');
49
+ * },
50
+ * function(arg1, arg2, callback) {
51
+ * // arg1 now equals 'one' and arg2 now equals 'two'
52
+ * callback(null, 'three');
53
+ * },
54
+ * function(arg1, callback) {
55
+ * // arg1 now equals 'three'
56
+ * callback(null, 'done');
57
+ * }
58
+ * ], function (err, result) {
59
+ * // result now equals 'done'
60
+ * });
61
+ *
62
+ * // Or, with named functions:
63
+ * async.waterfall([
64
+ * myFirstFunction,
65
+ * mySecondFunction,
66
+ * myLastFunction,
67
+ * ], function (err, result) {
68
+ * // result now equals 'done'
69
+ * });
70
+ * function myFirstFunction(callback) {
71
+ * callback(null, 'one', 'two');
72
+ * }
73
+ * function mySecondFunction(arg1, arg2, callback) {
74
+ * // arg1 now equals 'one' and arg2 now equals 'two'
75
+ * callback(null, 'three');
76
+ * }
77
+ * function myLastFunction(arg1, callback) {
78
+ * // arg1 now equals 'three'
79
+ * callback(null, 'done');
80
+ * }
81
+ */
82
+ function waterfall(tasks, callback) {
83
+ callback = (0, _once2.default)(callback);
84
+ if (!Array.isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
85
+ if (!tasks.length) return callback();
86
+ var taskIndex = 0;
87
+
88
+ function nextTask(args) {
89
+ var task = (0, _wrapAsync2.default)(tasks[taskIndex++]);
90
+ task(...args, (0, _onlyOnce2.default)(next));
91
+ }
92
+
93
+ function next(err, ...args) {
94
+ if (err === false) return;
95
+ if (err || taskIndex === tasks.length) {
96
+ return callback(err, ...args);
97
+ }
98
+ nextTask(args);
99
+ }
100
+
101
+ nextTask([]);
102
+ }
103
+
104
+ exports.default = (0, _awaitify2.default)(waterfall);
105
+ module.exports = exports.default;
node_modules/async/whilst.js ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _onlyOnce = require('./internal/onlyOnce.js');
8
+
9
+ var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
10
+
11
+ var _wrapAsync = require('./internal/wrapAsync.js');
12
+
13
+ var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14
+
15
+ var _awaitify = require('./internal/awaitify.js');
16
+
17
+ var _awaitify2 = _interopRequireDefault(_awaitify);
18
+
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+
21
+ /**
22
+ * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
23
+ * stopped, or an error occurs.
24
+ *
25
+ * @name whilst
26
+ * @static
27
+ * @memberOf module:ControlFlow
28
+ * @method
29
+ * @category Control Flow
30
+ * @param {AsyncFunction} test - asynchronous truth test to perform before each
31
+ * execution of `iteratee`. Invoked with (callback).
32
+ * @param {AsyncFunction} iteratee - An async function which is called each time
33
+ * `test` passes. Invoked with (callback).
34
+ * @param {Function} [callback] - A callback which is called after the test
35
+ * function has failed and repeated execution of `iteratee` has stopped. `callback`
36
+ * will be passed an error and any arguments passed to the final `iteratee`'s
37
+ * callback. Invoked with (err, [results]);
38
+ * @returns {Promise} a promise, if no callback is passed
39
+ * @example
40
+ *
41
+ * var count = 0;
42
+ * async.whilst(
43
+ * function test(cb) { cb(null, count < 5); },
44
+ * function iter(callback) {
45
+ * count++;
46
+ * setTimeout(function() {
47
+ * callback(null, count);
48
+ * }, 1000);
49
+ * },
50
+ * function (err, n) {
51
+ * // 5 seconds have passed, n = 5
52
+ * }
53
+ * );
54
+ */
55
+ function whilst(test, iteratee, callback) {
56
+ callback = (0, _onlyOnce2.default)(callback);
57
+ var _fn = (0, _wrapAsync2.default)(iteratee);
58
+ var _test = (0, _wrapAsync2.default)(test);
59
+ var results = [];
60
+
61
+ function next(err, ...rest) {
62
+ if (err) return callback(err);
63
+ results = rest;
64
+ if (err === false) return;
65
+ _test(check);
66
+ }
67
+
68
+ function check(err, truth) {
69
+ if (err) return callback(err);
70
+ if (err === false) return;
71
+ if (!truth) return callback(null, ...results);
72
+ _fn(next);
73
+ }
74
+
75
+ return _test(check);
76
+ }
77
+ exports.default = (0, _awaitify2.default)(whilst, 3);
78
+ module.exports = exports.default;
node_modules/async/wrapSync.js ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = asyncify;
7
+
8
+ var _initialParams = require('./internal/initialParams.js');
9
+
10
+ var _initialParams2 = _interopRequireDefault(_initialParams);
11
+
12
+ var _setImmediate = require('./internal/setImmediate.js');
13
+
14
+ var _setImmediate2 = _interopRequireDefault(_setImmediate);
15
+
16
+ var _wrapAsync = require('./internal/wrapAsync.js');
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ /**
21
+ * Take a sync function and make it async, passing its return value to a
22
+ * callback. This is useful for plugging sync functions into a waterfall,
23
+ * series, or other async functions. Any arguments passed to the generated
24
+ * function will be passed to the wrapped function (except for the final
25
+ * callback argument). Errors thrown will be passed to the callback.
26
+ *
27
+ * If the function passed to `asyncify` returns a Promise, that promises's
28
+ * resolved/rejected state will be used to call the callback, rather than simply
29
+ * the synchronous return value.
30
+ *
31
+ * This also means you can asyncify ES2017 `async` functions.
32
+ *
33
+ * @name asyncify
34
+ * @static
35
+ * @memberOf module:Utils
36
+ * @method
37
+ * @alias wrapSync
38
+ * @category Util
39
+ * @param {Function} func - The synchronous function, or Promise-returning
40
+ * function to convert to an {@link AsyncFunction}.
41
+ * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
42
+ * invoked with `(args..., callback)`.
43
+ * @example
44
+ *
45
+ * // passing a regular synchronous function
46
+ * async.waterfall([
47
+ * async.apply(fs.readFile, filename, "utf8"),
48
+ * async.asyncify(JSON.parse),
49
+ * function (data, next) {
50
+ * // data is the result of parsing the text.
51
+ * // If there was a parsing error, it would have been caught.
52
+ * }
53
+ * ], callback);
54
+ *
55
+ * // passing a function returning a promise
56
+ * async.waterfall([
57
+ * async.apply(fs.readFile, filename, "utf8"),
58
+ * async.asyncify(function (contents) {
59
+ * return db.model.create(contents);
60
+ * }),
61
+ * function (model, next) {
62
+ * // `model` is the instantiated model object.
63
+ * // If there was an error, this function would be skipped.
64
+ * }
65
+ * ], callback);
66
+ *
67
+ * // es2017 example, though `asyncify` is not needed if your JS environment
68
+ * // supports async functions out of the box
69
+ * var q = async.queue(async.asyncify(async function(file) {
70
+ * var intermediateStep = await processFile(file);
71
+ * return await somePromise(intermediateStep)
72
+ * }));
73
+ *
74
+ * q.push(files);
75
+ */
76
+ function asyncify(func) {
77
+ if ((0, _wrapAsync.isAsync)(func)) {
78
+ return function (...args /*, callback*/) {
79
+ const callback = args.pop();
80
+ const promise = func.apply(this, args);
81
+ return handlePromise(promise, callback);
82
+ };
83
+ }
84
+
85
+ return (0, _initialParams2.default)(function (args, callback) {
86
+ var result;
87
+ try {
88
+ result = func.apply(this, args);
89
+ } catch (e) {
90
+ return callback(e);
91
+ }
92
+ // if result is Promise object
93
+ if (result && typeof result.then === 'function') {
94
+ return handlePromise(result, callback);
95
+ } else {
96
+ callback(null, result);
97
+ }
98
+ });
99
+ }
100
+
101
+ function handlePromise(promise, callback) {
102
+ return promise.then(value => {
103
+ invokeCallback(callback, null, value);
104
+ }, err => {
105
+ invokeCallback(callback, err && (err instanceof Error || err.message) ? err : new Error(err));
106
+ });
107
+ }
108
+
109
+ function invokeCallback(callback, error, value) {
110
+ try {
111
+ callback(error, value);
112
+ } catch (err) {
113
+ (0, _setImmediate2.default)(e => {
114
+ throw e;
115
+ }, err);
116
+ }
117
+ }
118
+ module.exports = exports.default;
node_modules/asynckit/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Alex Indigo
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/asynckit/README.md ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # asynckit [![NPM Module](https://img.shields.io/npm/v/asynckit.svg?style=flat)](https://www.npmjs.com/package/asynckit)
2
+
3
+ Minimal async jobs utility library, with streams support.
4
+
5
+ [![PhantomJS Build](https://img.shields.io/travis/alexindigo/asynckit/v0.4.0.svg?label=browser&style=flat)](https://travis-ci.org/alexindigo/asynckit)
6
+ [![Linux Build](https://img.shields.io/travis/alexindigo/asynckit/v0.4.0.svg?label=linux:0.12-6.x&style=flat)](https://travis-ci.org/alexindigo/asynckit)
7
+ [![Windows Build](https://img.shields.io/appveyor/ci/alexindigo/asynckit/v0.4.0.svg?label=windows:0.12-6.x&style=flat)](https://ci.appveyor.com/project/alexindigo/asynckit)
8
+
9
+ [![Coverage Status](https://img.shields.io/coveralls/alexindigo/asynckit/v0.4.0.svg?label=code+coverage&style=flat)](https://coveralls.io/github/alexindigo/asynckit?branch=master)
10
+ [![Dependency Status](https://img.shields.io/david/alexindigo/asynckit/v0.4.0.svg?style=flat)](https://david-dm.org/alexindigo/asynckit)
11
+ [![bitHound Overall Score](https://www.bithound.io/github/alexindigo/asynckit/badges/score.svg)](https://www.bithound.io/github/alexindigo/asynckit)
12
+
13
+ <!-- [![Readme](https://img.shields.io/badge/readme-tested-brightgreen.svg?style=flat)](https://www.npmjs.com/package/reamde) -->
14
+
15
+ AsyncKit provides harness for `parallel` and `serial` iterators over list of items represented by arrays or objects.
16
+ Optionally it accepts abort function (should be synchronously return by iterator for each item), and terminates left over jobs upon an error event. For specific iteration order built-in (`ascending` and `descending`) and custom sort helpers also supported, via `asynckit.serialOrdered` method.
17
+
18
+ It ensures async operations to keep behavior more stable and prevent `Maximum call stack size exceeded` errors, from sync iterators.
19
+
20
+ | compression | size |
21
+ | :----------------- | -------: |
22
+ | asynckit.js | 12.34 kB |
23
+ | asynckit.min.js | 4.11 kB |
24
+ | asynckit.min.js.gz | 1.47 kB |
25
+
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ $ npm install --save asynckit
31
+ ```
32
+
33
+ ## Examples
34
+
35
+ ### Parallel Jobs
36
+
37
+ Runs iterator over provided array in parallel. Stores output in the `result` array,
38
+ on the matching positions. In unlikely event of an error from one of the jobs,
39
+ will terminate rest of the active jobs (if abort function is provided)
40
+ and return error along with salvaged data to the main callback function.
41
+
42
+ #### Input Array
43
+
44
+ ```javascript
45
+ var parallel = require('asynckit').parallel
46
+ , assert = require('assert')
47
+ ;
48
+
49
+ var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
50
+ , expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
51
+ , expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ]
52
+ , target = []
53
+ ;
54
+
55
+ parallel(source, asyncJob, function(err, result)
56
+ {
57
+ assert.deepEqual(result, expectedResult);
58
+ assert.deepEqual(target, expectedTarget);
59
+ });
60
+
61
+ // async job accepts one element from the array
62
+ // and a callback function
63
+ function asyncJob(item, cb)
64
+ {
65
+ // different delays (in ms) per item
66
+ var delay = item * 25;
67
+
68
+ // pretend different jobs take different time to finish
69
+ // and not in consequential order
70
+ var timeoutId = setTimeout(function() {
71
+ target.push(item);
72
+ cb(null, item * 2);
73
+ }, delay);
74
+
75
+ // allow to cancel "leftover" jobs upon error
76
+ // return function, invoking of which will abort this job
77
+ return clearTimeout.bind(null, timeoutId);
78
+ }
79
+ ```
80
+
81
+ More examples could be found in [test/test-parallel-array.js](test/test-parallel-array.js).
82
+
83
+ #### Input Object
84
+
85
+ Also it supports named jobs, listed via object.
86
+
87
+ ```javascript
88
+ var parallel = require('asynckit/parallel')
89
+ , assert = require('assert')
90
+ ;
91
+
92
+ var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
93
+ , expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
94
+ , expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ]
95
+ , expectedKeys = [ 'first', 'one', 'two', 'four', 'eight', 'sixteen', 'thirtyTwo', 'sixtyFour' ]
96
+ , target = []
97
+ , keys = []
98
+ ;
99
+
100
+ parallel(source, asyncJob, function(err, result)
101
+ {
102
+ assert.deepEqual(result, expectedResult);
103
+ assert.deepEqual(target, expectedTarget);
104
+ assert.deepEqual(keys, expectedKeys);
105
+ });
106
+
107
+ // supports full value, key, callback (shortcut) interface
108
+ function asyncJob(item, key, cb)
109
+ {
110
+ // different delays (in ms) per item
111
+ var delay = item * 25;
112
+
113
+ // pretend different jobs take different time to finish
114
+ // and not in consequential order
115
+ var timeoutId = setTimeout(function() {
116
+ keys.push(key);
117
+ target.push(item);
118
+ cb(null, item * 2);
119
+ }, delay);
120
+
121
+ // allow to cancel "leftover" jobs upon error
122
+ // return function, invoking of which will abort this job
123
+ return clearTimeout.bind(null, timeoutId);
124
+ }
125
+ ```
126
+
127
+ More examples could be found in [test/test-parallel-object.js](test/test-parallel-object.js).
128
+
129
+ ### Serial Jobs
130
+
131
+ Runs iterator over provided array sequentially. Stores output in the `result` array,
132
+ on the matching positions. In unlikely event of an error from one of the jobs,
133
+ will not proceed to the rest of the items in the list
134
+ and return error along with salvaged data to the main callback function.
135
+
136
+ #### Input Array
137
+
138
+ ```javascript
139
+ var serial = require('asynckit/serial')
140
+ , assert = require('assert')
141
+ ;
142
+
143
+ var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
144
+ , expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
145
+ , expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ]
146
+ , target = []
147
+ ;
148
+
149
+ serial(source, asyncJob, function(err, result)
150
+ {
151
+ assert.deepEqual(result, expectedResult);
152
+ assert.deepEqual(target, expectedTarget);
153
+ });
154
+
155
+ // extended interface (item, key, callback)
156
+ // also supported for arrays
157
+ function asyncJob(item, key, cb)
158
+ {
159
+ target.push(key);
160
+
161
+ // it will be automatically made async
162
+ // even it iterator "returns" in the same event loop
163
+ cb(null, item * 2);
164
+ }
165
+ ```
166
+
167
+ More examples could be found in [test/test-serial-array.js](test/test-serial-array.js).
168
+
169
+ #### Input Object
170
+
171
+ Also it supports named jobs, listed via object.
172
+
173
+ ```javascript
174
+ var serial = require('asynckit').serial
175
+ , assert = require('assert')
176
+ ;
177
+
178
+ var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
179
+ , expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
180
+ , expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ]
181
+ , target = []
182
+ ;
183
+
184
+ var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
185
+ , expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
186
+ , expectedTarget = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
187
+ , target = []
188
+ ;
189
+
190
+
191
+ serial(source, asyncJob, function(err, result)
192
+ {
193
+ assert.deepEqual(result, expectedResult);
194
+ assert.deepEqual(target, expectedTarget);
195
+ });
196
+
197
+ // shortcut interface (item, callback)
198
+ // works for object as well as for the arrays
199
+ function asyncJob(item, cb)
200
+ {
201
+ target.push(item);
202
+
203
+ // it will be automatically made async
204
+ // even it iterator "returns" in the same event loop
205
+ cb(null, item * 2);
206
+ }
207
+ ```
208
+
209
+ More examples could be found in [test/test-serial-object.js](test/test-serial-object.js).
210
+
211
+ _Note: Since _object_ is an _unordered_ collection of properties,
212
+ it may produce unexpected results with sequential iterations.
213
+ Whenever order of the jobs' execution is important please use `serialOrdered` method._
214
+
215
+ ### Ordered Serial Iterations
216
+
217
+ TBD
218
+
219
+ For example [compare-property](compare-property) package.
220
+
221
+ ### Streaming interface
222
+
223
+ TBD
224
+
225
+ ## Want to Know More?
226
+
227
+ More examples can be found in [test folder](test/).
228
+
229
+ Or open an [issue](https://github.com/alexindigo/asynckit/issues) with questions and/or suggestions.
230
+
231
+ ## License
232
+
233
+ AsyncKit is licensed under the MIT license.
node_modules/asynckit/bench.js ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* eslint no-console: "off" */
2
+
3
+ var asynckit = require('./')
4
+ , async = require('async')
5
+ , assert = require('assert')
6
+ , expected = 0
7
+ ;
8
+
9
+ var Benchmark = require('benchmark');
10
+ var suite = new Benchmark.Suite;
11
+
12
+ var source = [];
13
+ for (var z = 1; z < 100; z++)
14
+ {
15
+ source.push(z);
16
+ expected += z;
17
+ }
18
+
19
+ suite
20
+ // add tests
21
+
22
+ .add('async.map', function(deferred)
23
+ {
24
+ var total = 0;
25
+
26
+ async.map(source,
27
+ function(i, cb)
28
+ {
29
+ setImmediate(function()
30
+ {
31
+ total += i;
32
+ cb(null, total);
33
+ });
34
+ },
35
+ function(err, result)
36
+ {
37
+ assert.ifError(err);
38
+ assert.equal(result[result.length - 1], expected);
39
+ deferred.resolve();
40
+ });
41
+ }, {'defer': true})
42
+
43
+
44
+ .add('asynckit.parallel', function(deferred)
45
+ {
46
+ var total = 0;
47
+
48
+ asynckit.parallel(source,
49
+ function(i, cb)
50
+ {
51
+ setImmediate(function()
52
+ {
53
+ total += i;
54
+ cb(null, total);
55
+ });
56
+ },
57
+ function(err, result)
58
+ {
59
+ assert.ifError(err);
60
+ assert.equal(result[result.length - 1], expected);
61
+ deferred.resolve();
62
+ });
63
+ }, {'defer': true})
64
+
65
+
66
+ // add listeners
67
+ .on('cycle', function(ev)
68
+ {
69
+ console.log(String(ev.target));
70
+ })
71
+ .on('complete', function()
72
+ {
73
+ console.log('Fastest is ' + this.filter('fastest').map('name'));
74
+ })
75
+ // run async
76
+ .run({ 'async': true });
node_modules/asynckit/index.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ module.exports =
2
+ {
3
+ parallel : require('./parallel.js'),
4
+ serial : require('./serial.js'),
5
+ serialOrdered : require('./serialOrdered.js')
6
+ };
node_modules/asynckit/lib/abort.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // API
2
+ module.exports = abort;
3
+
4
+ /**
5
+ * Aborts leftover active jobs
6
+ *
7
+ * @param {object} state - current state object
8
+ */
9
+ function abort(state)
10
+ {
11
+ Object.keys(state.jobs).forEach(clean.bind(state));
12
+
13
+ // reset leftover jobs
14
+ state.jobs = {};
15
+ }
16
+
17
+ /**
18
+ * Cleans up leftover job by invoking abort function for the provided job id
19
+ *
20
+ * @this state
21
+ * @param {string|number} key - job id to abort
22
+ */
23
+ function clean(key)
24
+ {
25
+ if (typeof this.jobs[key] == 'function')
26
+ {
27
+ this.jobs[key]();
28
+ }
29
+ }
node_modules/asynckit/lib/async.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var defer = require('./defer.js');
2
+
3
+ // API
4
+ module.exports = async;
5
+
6
+ /**
7
+ * Runs provided callback asynchronously
8
+ * even if callback itself is not
9
+ *
10
+ * @param {function} callback - callback to invoke
11
+ * @returns {function} - augmented callback
12
+ */
13
+ function async(callback)
14
+ {
15
+ var isAsync = false;
16
+
17
+ // check if async happened
18
+ defer(function() { isAsync = true; });
19
+
20
+ return function async_callback(err, result)
21
+ {
22
+ if (isAsync)
23
+ {
24
+ callback(err, result);
25
+ }
26
+ else
27
+ {
28
+ defer(function nextTick_callback()
29
+ {
30
+ callback(err, result);
31
+ });
32
+ }
33
+ };
34
+ }
node_modules/asynckit/lib/defer.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = defer;
2
+
3
+ /**
4
+ * Runs provided function on next iteration of the event loop
5
+ *
6
+ * @param {function} fn - function to run
7
+ */
8
+ function defer(fn)
9
+ {
10
+ var nextTick = typeof setImmediate == 'function'
11
+ ? setImmediate
12
+ : (
13
+ typeof process == 'object' && typeof process.nextTick == 'function'
14
+ ? process.nextTick
15
+ : null
16
+ );
17
+
18
+ if (nextTick)
19
+ {
20
+ nextTick(fn);
21
+ }
22
+ else
23
+ {
24
+ setTimeout(fn, 0);
25
+ }
26
+ }
node_modules/asynckit/lib/iterate.js ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var async = require('./async.js')
2
+ , abort = require('./abort.js')
3
+ ;
4
+
5
+ // API
6
+ module.exports = iterate;
7
+
8
+ /**
9
+ * Iterates over each job object
10
+ *
11
+ * @param {array|object} list - array or object (named list) to iterate over
12
+ * @param {function} iterator - iterator to run
13
+ * @param {object} state - current job status
14
+ * @param {function} callback - invoked when all elements processed
15
+ */
16
+ function iterate(list, iterator, state, callback)
17
+ {
18
+ // store current index
19
+ var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
20
+
21
+ state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
22
+ {
23
+ // don't repeat yourself
24
+ // skip secondary callbacks
25
+ if (!(key in state.jobs))
26
+ {
27
+ return;
28
+ }
29
+
30
+ // clean up jobs
31
+ delete state.jobs[key];
32
+
33
+ if (error)
34
+ {
35
+ // don't process rest of the results
36
+ // stop still active jobs
37
+ // and reset the list
38
+ abort(state);
39
+ }
40
+ else
41
+ {
42
+ state.results[key] = output;
43
+ }
44
+
45
+ // return salvaged results
46
+ callback(error, state.results);
47
+ });
48
+ }
49
+
50
+ /**
51
+ * Runs iterator over provided job element
52
+ *
53
+ * @param {function} iterator - iterator to invoke
54
+ * @param {string|number} key - key/index of the element in the list of jobs
55
+ * @param {mixed} item - job description
56
+ * @param {function} callback - invoked after iterator is done with the job
57
+ * @returns {function|mixed} - job abort function or something else
58
+ */
59
+ function runJob(iterator, key, item, callback)
60
+ {
61
+ var aborter;
62
+
63
+ // allow shortcut if iterator expects only two arguments
64
+ if (iterator.length == 2)
65
+ {
66
+ aborter = iterator(item, async(callback));
67
+ }
68
+ // otherwise go with full three arguments
69
+ else
70
+ {
71
+ aborter = iterator(item, key, async(callback));
72
+ }
73
+
74
+ return aborter;
75
+ }
node_modules/asynckit/lib/readable_asynckit.js ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var streamify = require('./streamify.js')
2
+ , defer = require('./defer.js')
3
+ ;
4
+
5
+ // API
6
+ module.exports = ReadableAsyncKit;
7
+
8
+ /**
9
+ * Base constructor for all streams
10
+ * used to hold properties/methods
11
+ */
12
+ function ReadableAsyncKit()
13
+ {
14
+ ReadableAsyncKit.super_.apply(this, arguments);
15
+
16
+ // list of active jobs
17
+ this.jobs = {};
18
+
19
+ // add stream methods
20
+ this.destroy = destroy;
21
+ this._start = _start;
22
+ this._read = _read;
23
+ }
24
+
25
+ /**
26
+ * Destroys readable stream,
27
+ * by aborting outstanding jobs
28
+ *
29
+ * @returns {void}
30
+ */
31
+ function destroy()
32
+ {
33
+ if (this.destroyed)
34
+ {
35
+ return;
36
+ }
37
+
38
+ this.destroyed = true;
39
+
40
+ if (typeof this.terminator == 'function')
41
+ {
42
+ this.terminator();
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Starts provided jobs in async manner
48
+ *
49
+ * @private
50
+ */
51
+ function _start()
52
+ {
53
+ // first argument – runner function
54
+ var runner = arguments[0]
55
+ // take away first argument
56
+ , args = Array.prototype.slice.call(arguments, 1)
57
+ // second argument - input data
58
+ , input = args[0]
59
+ // last argument - result callback
60
+ , endCb = streamify.callback.call(this, args[args.length - 1])
61
+ ;
62
+
63
+ args[args.length - 1] = endCb;
64
+ // third argument - iterator
65
+ args[1] = streamify.iterator.call(this, args[1]);
66
+
67
+ // allow time for proper setup
68
+ defer(function()
69
+ {
70
+ if (!this.destroyed)
71
+ {
72
+ this.terminator = runner.apply(null, args);
73
+ }
74
+ else
75
+ {
76
+ endCb(null, Array.isArray(input) ? [] : {});
77
+ }
78
+ }.bind(this));
79
+ }
80
+
81
+
82
+ /**
83
+ * Implement _read to comply with Readable streams
84
+ * Doesn't really make sense for flowing object mode
85
+ *
86
+ * @private
87
+ */
88
+ function _read()
89
+ {
90
+
91
+ }
node_modules/asynckit/lib/readable_parallel.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var parallel = require('../parallel.js');
2
+
3
+ // API
4
+ module.exports = ReadableParallel;
5
+
6
+ /**
7
+ * Streaming wrapper to `asynckit.parallel`
8
+ *
9
+ * @param {array|object} list - array or object (named list) to iterate over
10
+ * @param {function} iterator - iterator to run
11
+ * @param {function} callback - invoked when all elements processed
12
+ * @returns {stream.Readable#}
13
+ */
14
+ function ReadableParallel(list, iterator, callback)
15
+ {
16
+ if (!(this instanceof ReadableParallel))
17
+ {
18
+ return new ReadableParallel(list, iterator, callback);
19
+ }
20
+
21
+ // turn on object mode
22
+ ReadableParallel.super_.call(this, {objectMode: true});
23
+
24
+ this._start(parallel, list, iterator, callback);
25
+ }
node_modules/asynckit/lib/readable_serial.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var serial = require('../serial.js');
2
+
3
+ // API
4
+ module.exports = ReadableSerial;
5
+
6
+ /**
7
+ * Streaming wrapper to `asynckit.serial`
8
+ *
9
+ * @param {array|object} list - array or object (named list) to iterate over
10
+ * @param {function} iterator - iterator to run
11
+ * @param {function} callback - invoked when all elements processed
12
+ * @returns {stream.Readable#}
13
+ */
14
+ function ReadableSerial(list, iterator, callback)
15
+ {
16
+ if (!(this instanceof ReadableSerial))
17
+ {
18
+ return new ReadableSerial(list, iterator, callback);
19
+ }
20
+
21
+ // turn on object mode
22
+ ReadableSerial.super_.call(this, {objectMode: true});
23
+
24
+ this._start(serial, list, iterator, callback);
25
+ }
node_modules/asynckit/lib/readable_serial_ordered.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var serialOrdered = require('../serialOrdered.js');
2
+
3
+ // API
4
+ module.exports = ReadableSerialOrdered;
5
+ // expose sort helpers
6
+ module.exports.ascending = serialOrdered.ascending;
7
+ module.exports.descending = serialOrdered.descending;
8
+
9
+ /**
10
+ * Streaming wrapper to `asynckit.serialOrdered`
11
+ *
12
+ * @param {array|object} list - array or object (named list) to iterate over
13
+ * @param {function} iterator - iterator to run
14
+ * @param {function} sortMethod - custom sort function
15
+ * @param {function} callback - invoked when all elements processed
16
+ * @returns {stream.Readable#}
17
+ */
18
+ function ReadableSerialOrdered(list, iterator, sortMethod, callback)
19
+ {
20
+ if (!(this instanceof ReadableSerialOrdered))
21
+ {
22
+ return new ReadableSerialOrdered(list, iterator, sortMethod, callback);
23
+ }
24
+
25
+ // turn on object mode
26
+ ReadableSerialOrdered.super_.call(this, {objectMode: true});
27
+
28
+ this._start(serialOrdered, list, iterator, sortMethod, callback);
29
+ }
node_modules/asynckit/lib/state.js ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // API
2
+ module.exports = state;
3
+
4
+ /**
5
+ * Creates initial state object
6
+ * for iteration over list
7
+ *
8
+ * @param {array|object} list - list to iterate over
9
+ * @param {function|null} sortMethod - function to use for keys sort,
10
+ * or `null` to keep them as is
11
+ * @returns {object} - initial state object
12
+ */
13
+ function state(list, sortMethod)
14
+ {
15
+ var isNamedList = !Array.isArray(list)
16
+ , initState =
17
+ {
18
+ index : 0,
19
+ keyedList: isNamedList || sortMethod ? Object.keys(list) : null,
20
+ jobs : {},
21
+ results : isNamedList ? {} : [],
22
+ size : isNamedList ? Object.keys(list).length : list.length
23
+ }
24
+ ;
25
+
26
+ if (sortMethod)
27
+ {
28
+ // sort array keys based on it's values
29
+ // sort object's keys just on own merit
30
+ initState.keyedList.sort(isNamedList ? sortMethod : function(a, b)
31
+ {
32
+ return sortMethod(list[a], list[b]);
33
+ });
34
+ }
35
+
36
+ return initState;
37
+ }
node_modules/asynckit/lib/streamify.js ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var async = require('./async.js');
2
+
3
+ // API
4
+ module.exports = {
5
+ iterator: wrapIterator,
6
+ callback: wrapCallback
7
+ };
8
+
9
+ /**
10
+ * Wraps iterators with long signature
11
+ *
12
+ * @this ReadableAsyncKit#
13
+ * @param {function} iterator - function to wrap
14
+ * @returns {function} - wrapped function
15
+ */
16
+ function wrapIterator(iterator)
17
+ {
18
+ var stream = this;
19
+
20
+ return function(item, key, cb)
21
+ {
22
+ var aborter
23
+ , wrappedCb = async(wrapIteratorCallback.call(stream, cb, key))
24
+ ;
25
+
26
+ stream.jobs[key] = wrappedCb;
27
+
28
+ // it's either shortcut (item, cb)
29
+ if (iterator.length == 2)
30
+ {
31
+ aborter = iterator(item, wrappedCb);
32
+ }
33
+ // or long format (item, key, cb)
34
+ else
35
+ {
36
+ aborter = iterator(item, key, wrappedCb);
37
+ }
38
+
39
+ return aborter;
40
+ };
41
+ }
42
+
43
+ /**
44
+ * Wraps provided callback function
45
+ * allowing to execute snitch function before
46
+ * real callback
47
+ *
48
+ * @this ReadableAsyncKit#
49
+ * @param {function} callback - function to wrap
50
+ * @returns {function} - wrapped function
51
+ */
52
+ function wrapCallback(callback)
53
+ {
54
+ var stream = this;
55
+
56
+ var wrapped = function(error, result)
57
+ {
58
+ return finisher.call(stream, error, result, callback);
59
+ };
60
+
61
+ return wrapped;
62
+ }
63
+
64
+ /**
65
+ * Wraps provided iterator callback function
66
+ * makes sure snitch only called once,
67
+ * but passes secondary calls to the original callback
68
+ *
69
+ * @this ReadableAsyncKit#
70
+ * @param {function} callback - callback to wrap
71
+ * @param {number|string} key - iteration key
72
+ * @returns {function} wrapped callback
73
+ */
74
+ function wrapIteratorCallback(callback, key)
75
+ {
76
+ var stream = this;
77
+
78
+ return function(error, output)
79
+ {
80
+ // don't repeat yourself
81
+ if (!(key in stream.jobs))
82
+ {
83
+ callback(error, output);
84
+ return;
85
+ }
86
+
87
+ // clean up jobs
88
+ delete stream.jobs[key];
89
+
90
+ return streamer.call(stream, error, {key: key, value: output}, callback);
91
+ };
92
+ }
93
+
94
+ /**
95
+ * Stream wrapper for iterator callback
96
+ *
97
+ * @this ReadableAsyncKit#
98
+ * @param {mixed} error - error response
99
+ * @param {mixed} output - iterator output
100
+ * @param {function} callback - callback that expects iterator results
101
+ */
102
+ function streamer(error, output, callback)
103
+ {
104
+ if (error && !this.error)
105
+ {
106
+ this.error = error;
107
+ this.pause();
108
+ this.emit('error', error);
109
+ // send back value only, as expected
110
+ callback(error, output && output.value);
111
+ return;
112
+ }
113
+
114
+ // stream stuff
115
+ this.push(output);
116
+
117
+ // back to original track
118
+ // send back value only, as expected
119
+ callback(error, output && output.value);
120
+ }
121
+
122
+ /**
123
+ * Stream wrapper for finishing callback
124
+ *
125
+ * @this ReadableAsyncKit#
126
+ * @param {mixed} error - error response
127
+ * @param {mixed} output - iterator output
128
+ * @param {function} callback - callback that expects final results
129
+ */
130
+ function finisher(error, output, callback)
131
+ {
132
+ // signal end of the stream
133
+ // only for successfully finished streams
134
+ if (!error)
135
+ {
136
+ this.push(null);
137
+ }
138
+
139
+ // back to original track
140
+ callback(error, output);
141
+ }
node_modules/asynckit/lib/terminator.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var abort = require('./abort.js')
2
+ , async = require('./async.js')
3
+ ;
4
+
5
+ // API
6
+ module.exports = terminator;
7
+
8
+ /**
9
+ * Terminates jobs in the attached state context
10
+ *
11
+ * @this AsyncKitState#
12
+ * @param {function} callback - final callback to invoke after termination
13
+ */
14
+ function terminator(callback)
15
+ {
16
+ if (!Object.keys(this.jobs).length)
17
+ {
18
+ return;
19
+ }
20
+
21
+ // fast forward iteration index
22
+ this.index = this.size;
23
+
24
+ // abort jobs
25
+ abort(this);
26
+
27
+ // send back results we have so far
28
+ async(callback)(null, this.results);
29
+ }
node_modules/asynckit/package.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "asynckit",
3
+ "version": "0.4.0",
4
+ "description": "Minimal async jobs utility library, with streams support",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "clean": "rimraf coverage",
8
+ "lint": "eslint *.js lib/*.js test/*.js",
9
+ "test": "istanbul cover --reporter=json tape -- 'test/test-*.js' | tap-spec",
10
+ "win-test": "tape test/test-*.js",
11
+ "browser": "browserify -t browserify-istanbul test/lib/browserify_adjustment.js test/test-*.js | obake --coverage | tap-spec",
12
+ "report": "istanbul report",
13
+ "size": "browserify index.js | size-table asynckit",
14
+ "debug": "tape test/test-*.js"
15
+ },
16
+ "pre-commit": [
17
+ "clean",
18
+ "lint",
19
+ "test",
20
+ "browser",
21
+ "report",
22
+ "size"
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/alexindigo/asynckit.git"
27
+ },
28
+ "keywords": [
29
+ "async",
30
+ "jobs",
31
+ "parallel",
32
+ "serial",
33
+ "iterator",
34
+ "array",
35
+ "object",
36
+ "stream",
37
+ "destroy",
38
+ "terminate",
39
+ "abort"
40
+ ],
41
+ "author": "Alex Indigo <iam@alexindigo.com>",
42
+ "license": "MIT",
43
+ "bugs": {
44
+ "url": "https://github.com/alexindigo/asynckit/issues"
45
+ },
46
+ "homepage": "https://github.com/alexindigo/asynckit#readme",
47
+ "devDependencies": {
48
+ "browserify": "^13.0.0",
49
+ "browserify-istanbul": "^2.0.0",
50
+ "coveralls": "^2.11.9",
51
+ "eslint": "^2.9.0",
52
+ "istanbul": "^0.4.3",
53
+ "obake": "^0.1.2",
54
+ "phantomjs-prebuilt": "^2.1.7",
55
+ "pre-commit": "^1.1.3",
56
+ "reamde": "^1.1.0",
57
+ "rimraf": "^2.5.2",
58
+ "size-table": "^0.2.0",
59
+ "tap-spec": "^4.1.1",
60
+ "tape": "^4.5.1"
61
+ },
62
+ "dependencies": {}
63
+ }
node_modules/asynckit/parallel.js ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var iterate = require('./lib/iterate.js')
2
+ , initState = require('./lib/state.js')
3
+ , terminator = require('./lib/terminator.js')
4
+ ;
5
+
6
+ // Public API
7
+ module.exports = parallel;
8
+
9
+ /**
10
+ * Runs iterator over provided array elements in parallel
11
+ *
12
+ * @param {array|object} list - array or object (named list) to iterate over
13
+ * @param {function} iterator - iterator to run
14
+ * @param {function} callback - invoked when all elements processed
15
+ * @returns {function} - jobs terminator
16
+ */
17
+ function parallel(list, iterator, callback)
18
+ {
19
+ var state = initState(list);
20
+
21
+ while (state.index < (state['keyedList'] || list).length)
22
+ {
23
+ iterate(list, iterator, state, function(error, result)
24
+ {
25
+ if (error)
26
+ {
27
+ callback(error, result);
28
+ return;
29
+ }
30
+
31
+ // looks like it's the last one
32
+ if (Object.keys(state.jobs).length === 0)
33
+ {
34
+ callback(null, state.results);
35
+ return;
36
+ }
37
+ });
38
+
39
+ state.index++;
40
+ }
41
+
42
+ return terminator.bind(state, callback);
43
+ }
node_modules/asynckit/serial.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var serialOrdered = require('./serialOrdered.js');
2
+
3
+ // Public API
4
+ module.exports = serial;
5
+
6
+ /**
7
+ * Runs iterator over provided array elements in series
8
+ *
9
+ * @param {array|object} list - array or object (named list) to iterate over
10
+ * @param {function} iterator - iterator to run
11
+ * @param {function} callback - invoked when all elements processed
12
+ * @returns {function} - jobs terminator
13
+ */
14
+ function serial(list, iterator, callback)
15
+ {
16
+ return serialOrdered(list, iterator, null, callback);
17
+ }
node_modules/asynckit/serialOrdered.js ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var iterate = require('./lib/iterate.js')
2
+ , initState = require('./lib/state.js')
3
+ , terminator = require('./lib/terminator.js')
4
+ ;
5
+
6
+ // Public API
7
+ module.exports = serialOrdered;
8
+ // sorting helpers
9
+ module.exports.ascending = ascending;
10
+ module.exports.descending = descending;
11
+
12
+ /**
13
+ * Runs iterator over provided sorted array elements in series
14
+ *
15
+ * @param {array|object} list - array or object (named list) to iterate over
16
+ * @param {function} iterator - iterator to run
17
+ * @param {function} sortMethod - custom sort function
18
+ * @param {function} callback - invoked when all elements processed
19
+ * @returns {function} - jobs terminator
20
+ */
21
+ function serialOrdered(list, iterator, sortMethod, callback)
22
+ {
23
+ var state = initState(list, sortMethod);
24
+
25
+ iterate(list, iterator, state, function iteratorHandler(error, result)
26
+ {
27
+ if (error)
28
+ {
29
+ callback(error, result);
30
+ return;
31
+ }
32
+
33
+ state.index++;
34
+
35
+ // are we there yet?
36
+ if (state.index < (state['keyedList'] || list).length)
37
+ {
38
+ iterate(list, iterator, state, iteratorHandler);
39
+ return;
40
+ }
41
+
42
+ // done here
43
+ callback(null, state.results);
44
+ });
45
+
46
+ return terminator.bind(state, callback);
47
+ }
48
+
49
+ /*
50
+ * -- Sort methods
51
+ */
52
+
53
+ /**
54
+ * sort helper to sort array elements in ascending order
55
+ *
56
+ * @param {mixed} a - an item to compare
57
+ * @param {mixed} b - an item to compare
58
+ * @returns {number} - comparison result
59
+ */
60
+ function ascending(a, b)
61
+ {
62
+ return a < b ? -1 : a > b ? 1 : 0;
63
+ }
64
+
65
+ /**
66
+ * sort helper to sort array elements in descending order
67
+ *
68
+ * @param {mixed} a - an item to compare
69
+ * @param {mixed} b - an item to compare
70
+ * @returns {number} - comparison result
71
+ */
72
+ function descending(a, b)
73
+ {
74
+ return -1 * ascending(a, b);
75
+ }
node_modules/asynckit/stream.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var inherits = require('util').inherits
2
+ , Readable = require('stream').Readable
3
+ , ReadableAsyncKit = require('./lib/readable_asynckit.js')
4
+ , ReadableParallel = require('./lib/readable_parallel.js')
5
+ , ReadableSerial = require('./lib/readable_serial.js')
6
+ , ReadableSerialOrdered = require('./lib/readable_serial_ordered.js')
7
+ ;
8
+
9
+ // API
10
+ module.exports =
11
+ {
12
+ parallel : ReadableParallel,
13
+ serial : ReadableSerial,
14
+ serialOrdered : ReadableSerialOrdered,
15
+ };
16
+
17
+ inherits(ReadableAsyncKit, Readable);
18
+
19
+ inherits(ReadableParallel, ReadableAsyncKit);
20
+ inherits(ReadableSerial, ReadableAsyncKit);
21
+ inherits(ReadableSerialOrdered, ReadableAsyncKit);
node_modules/await-to-js/LICENSE ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ Copyright 2017 Dima Grossman <dima@grossman.io>
2
+
3
+ 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:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ 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/await-to-js/README.md ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # await-to-js
2
+
3
+ [![NPM version][npm-image]][npm-url]
4
+ [![Downloads][download-badge]][npm-url]
5
+
6
+ > Async await wrapper for easy error handling
7
+
8
+ ## Pre-requisites
9
+ You need to use Node 7.6 (or later) or an ES7 transpiler in order to use async/await functionality.
10
+ You can use babel or typescript for that.
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ npm i await-to-js --save
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```js
21
+ import to from 'await-to-js';
22
+ // If you use CommonJS (i.e NodeJS environment), it should be:
23
+ // const to = require('await-to-js').default;
24
+
25
+ async function asyncTaskWithCb(cb) {
26
+ let err, user, savedTask, notification;
27
+
28
+ [ err, user ] = await to(UserModel.findById(1));
29
+ if(!user) return cb('No user found');
30
+
31
+ [ err, savedTask ] = await to(TaskModel({userId: user.id, name: 'Demo Task'}));
32
+ if(err) return cb('Error occurred while saving task');
33
+
34
+ if(user.notificationsEnabled) {
35
+ [ err ] = await to(NotificationService.sendNotification(user.id, 'Task Created'));
36
+ if(err) return cb('Error while sending notification');
37
+ }
38
+
39
+ if(savedTask.assignedUser.id !== user.id) {
40
+ [ err, notification ] = await to(NotificationService.sendNotification(savedTask.assignedUser.id, 'Task was created for you'));
41
+ if(err) return cb('Error while sending notification');
42
+ }
43
+
44
+ cb(null, savedTask);
45
+ }
46
+
47
+ async function asyncFunctionWithThrow() {
48
+ const [err, user] = await to(UserModel.findById(1));
49
+ if (!user) throw new Error('User not found');
50
+
51
+ }
52
+ ```
53
+
54
+ ## TypeScript usage
55
+ ```javascript
56
+ interface ServerResponse {
57
+ test: number;
58
+ }
59
+
60
+ const p = Promise.resolve({test: 123});
61
+
62
+ const [err, data] = await to<ServerResponse>(p);
63
+ console.log(data.test);
64
+ ```
65
+
66
+ ## License
67
+
68
+ MIT © [Dima Grossman](http://blog.grossman.io) && Tomer Barnea
69
+
70
+ [npm-url]: https://npmjs.org/package/await-to-js
71
+ [npm-image]: https://img.shields.io/npm/v/await-to-js.svg?style=flat-square
72
+
73
+ [travis-url]: https://travis-ci.org/scopsy/await-to-js
74
+ [travis-image]: https://img.shields.io/travis/scopsy/await-to-js.svg?style=flat-square
75
+
76
+ [coveralls-url]: https://coveralls.io/r/scopsy/await-to-js
77
+ [coveralls-image]: https://img.shields.io/coveralls/scopsy/await-to-js.svg?style=flat-square
78
+
79
+ [depstat-url]: https://david-dm.org/scopsy/await-to-js
80
+ [depstat-image]: https://david-dm.org/scopsy/await-to-js.svg?style=flat-square
81
+
82
+ [download-badge]: http://img.shields.io/npm/dm/await-to-js.svg?style=flat-square
node_modules/await-to-js/package.json ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "await-to-js",
3
+ "version": "3.0.0",
4
+ "description": "Async/await wrapper for easy error handling in js",
5
+ "keywords": [
6
+ "node",
7
+ "async",
8
+ "await",
9
+ "async await"
10
+ ],
11
+ "main": "dist/await-to-js.umd.js",
12
+ "module": "dist/await-to-js.es5.js",
13
+ "typings": "dist/types/await-to-js.d.ts",
14
+ "homepage": "https://github.com/scopsy/await-to-js#readme",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "author": "Dima Grossman <dima@grossman.io>, Tomer Barnea <tomer@barnea.io>",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/scopsy/await-to-js.git"
22
+ },
23
+ "license": "MIT",
24
+ "engines": {
25
+ "node": ">=6.0.0"
26
+ },
27
+ "scripts": {
28
+ "lint": "tslint -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
29
+ "prebuild": "rimraf dist",
30
+ "build": "tsc && rollup -c && rimraf compiled && typedoc --out dist/docs --target es6 --theme minimal src",
31
+ "start": "tsc -w & rollup -c -w",
32
+ "test": "jest",
33
+ "test:watch": "jest --watch",
34
+ "test:prod": "npm run lint && npm run test -- --coverage --no-cache",
35
+ "deploy-docs": "ts-node tools/gh-pages-publish",
36
+ "report-coverage": "cat ./coverage/lcov.info | coveralls",
37
+ "commit": "git-cz",
38
+ "semantic-release": "semantic-release pre && npm publish && semantic-release post",
39
+ "semantic-release-prepare": "ts-node tools/semantic-release-prepare",
40
+ "precommit": "lint-staged"
41
+ },
42
+ "lint-staged": {
43
+ "{src,test}/**/*.ts": [
44
+ "git add"
45
+ ]
46
+ },
47
+ "config": {
48
+ "commitizen": {
49
+ "path": "node_modules/cz-conventional-changelog"
50
+ },
51
+ "validate-commit-msg": {
52
+ "types": "conventional-commit-types",
53
+ "helpMessage": "Use \"npm run commit\" instead, we use conventional-changelog format :) (https://github.com/commitizen/cz-cli)"
54
+ }
55
+ },
56
+ "jest": {
57
+ "transform": {
58
+ ".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
59
+ },
60
+ "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
61
+ "moduleFileExtensions": [
62
+ "ts",
63
+ "tsx",
64
+ "js"
65
+ ],
66
+ "coveragePathIgnorePatterns": [
67
+ "/node_modules/",
68
+ "/test/"
69
+ ],
70
+ "coverageThreshold": {
71
+ "global": {
72
+ "branches": 90,
73
+ "functions": 95,
74
+ "lines": 95,
75
+ "statements": 95
76
+ }
77
+ }
78
+ },
79
+ "devDependencies": {
80
+ "@types/jest": "^21.1.0",
81
+ "@types/node": "^8.0.0",
82
+ "colors": "^1.1.2",
83
+ "commitizen": "^2.9.6",
84
+ "coveralls": "^2.13.1",
85
+ "cross-env": "^5.0.1",
86
+ "cz-conventional-changelog": "^2.0.0",
87
+ "husky": "^0.14.0",
88
+ "jest": "^21.0.0",
89
+ "lint-staged": "^4.0.0",
90
+ "lodash.camelcase": "^4.3.0",
91
+ "prompt": "^1.0.0",
92
+ "replace-in-file": "^3.0.0-beta.2",
93
+ "rimraf": "^2.6.1",
94
+ "rollup": "^0.50.0",
95
+ "rollup-plugin-commonjs": "^8.0.2",
96
+ "rollup-plugin-node-resolve": "^3.0.0",
97
+ "rollup-plugin-sourcemaps": "^0.4.2",
98
+ "semantic-release": "^8.0.0",
99
+ "ts-jest": "^21.0.0",
100
+ "ts-node": "^3.0.6",
101
+ "tslint": "^5.4.3",
102
+ "tslint-config-standard": "^6.0.0",
103
+ "typedoc": "^0.8.0",
104
+ "typescript": "^2.3.4",
105
+ "validate-commit-msg": "^2.12.2"
106
+ }
107
+ }
node_modules/b4a/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
node_modules/b4a/README.md ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Buffer for Array
2
+
3
+ Buffer for Array (B4A) provides a set of functions for bridging the gap between the Node.js `Buffer` class and the `Uint8Array` class. A browser compatibility layer is also included, making it possible to use B4A in both Node.js and browsers without having to worry about whether you're dealing with buffers or typed arrays.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm i b4a
9
+ ```
10
+
11
+ ### React Native
12
+
13
+ When imported from React Native `b4a` will make use of `react-native-b4a` for optimised buffer operations when available. All you need to do is install it:
14
+
15
+ ```sh
16
+ npm i react-native-b4a
17
+ ```
18
+
19
+ ## API
20
+
21
+ #### `b4a.isBuffer(value)`
22
+
23
+ See https://nodejs.org/api/buffer.html#static-method-bufferisbufferobj
24
+
25
+ This will also return `true` when passed a `Uint8Array`.
26
+
27
+ #### `b4a.isEncoding(encoding)`
28
+
29
+ See https://nodejs.org/api/buffer.html#static-method-bufferisencodingencoding
30
+
31
+ #### `b4a.alloc(size[, fill[, encoding]])`
32
+
33
+ See https://nodejs.org/api/buffer.html#static-method-bufferallocsize-fill-encoding
34
+
35
+ #### `b4a.allocUnsafe(size)`
36
+
37
+ See https://nodejs.org/api/buffer.html#static-method-bufferallocunsafesize
38
+
39
+ #### `b4a.allocUnsafeSlow(size)`
40
+
41
+ See https://nodejs.org/api/buffer.html#static-method-bufferallocunsafeslowsize
42
+
43
+ #### `b4a.byteLength(string)`
44
+
45
+ See https://nodejs.org/api/buffer.html#static-method-bufferbytelengthstring-encoding
46
+
47
+ #### `b4a.compare(buf1, buf2)`
48
+
49
+ See https://nodejs.org/api/buffer.html#static-method-buffercomparebuf1-buf2
50
+
51
+ #### `b4a.concat(buffers[, totalLength])`
52
+
53
+ See https://nodejs.org/api/buffer.html#static-method-bufferconcatlist-totallength
54
+
55
+ #### `b4a.copy(source, target[, targetStart[, sourceStart[, sourceEnd]]])`
56
+
57
+ See https://nodejs.org/api/buffer.html#bufcopytarget-targetstart-sourcestart-sourceend
58
+
59
+ #### `b4a.equals(buf1, buf2)`
60
+
61
+ See https://nodejs.org/api/buffer.html#bufequalsotherbuffer
62
+
63
+ #### `b4a.fill(buffer, value[, offset[, end]][, encoding])`
64
+
65
+ See https://nodejs.org/api/buffer.html#buffillvalue-offset-end-encoding
66
+
67
+ #### `b4a.from(array)`
68
+
69
+ See https://nodejs.org/api/buffer.html#static-method-bufferfromarray
70
+
71
+ #### `b4a.from(arrayBuffer[, byteOffset[, length]])`
72
+
73
+ See https://nodejs.org/api/buffer.html#static-method-bufferfromarraybuffer-byteoffset-length
74
+
75
+ #### `b4a.from(buffer)`
76
+
77
+ See https://nodejs.org/api/buffer.html#static-method-bufferfrombuffer
78
+
79
+ #### `b4a.from(string[, encoding])`
80
+
81
+ See https://nodejs.org/api/buffer.html#static-method-bufferfromstring-encoding
82
+
83
+ #### `b4a.includes(buffer, value[, byteOffset][, encoding])`
84
+
85
+ See https://nodejs.org/api/buffer.html#bufincludesvalue-byteoffset-encoding
86
+
87
+ #### `b4a.indexOf(buffer, value[, byteOffset][, encoding])`
88
+
89
+ See https://nodejs.org/api/buffer.html#bufindexofvalue-byteoffset-encoding
90
+
91
+ #### `b4a.lastIndexOf(buffer, value[, byteOffset][, encoding])`
92
+
93
+ See https://nodejs.org/api/buffer.html#buflastindexofvalue-byteoffset-encoding
94
+
95
+ #### `b4a.swap16(buffer)`
96
+
97
+ See https://nodejs.org/api/buffer.html#bufswap16
98
+
99
+ #### `b4a.swap32(buffer)`
100
+
101
+ See https://nodejs.org/api/buffer.html#bufswap32
102
+
103
+ #### `b4a.swap64(buffer)`
104
+
105
+ See https://nodejs.org/api/buffer.html#bufswap64
106
+
107
+ #### `b4a.toBuffer(buffer)`
108
+
109
+ Convert a buffer to its canonical representation. In Node.js, the canonical representation is a `Buffer`. In the browser, the canonical representation is a `Uint8Array`.
110
+
111
+ #### `b4a.toString(buffer, [encoding[, start[, end]]])`
112
+
113
+ See https://nodejs.org/api/buffer.html#buftostringencoding-start-end
114
+
115
+ #### `b4a.write(buffer, string[, offset[, length]][, encoding])`
116
+
117
+ See https://nodejs.org/api/buffer.html#bufwritestring-offset-length-encoding
118
+
119
+ #### `b4a.writeDoubleLE(buffer, value[, offset])`
120
+
121
+ See https://nodejs.org/api/buffer.html#bufwritedoublelevalue-offset
122
+
123
+ #### `b4a.writeFloatLE(buffer, value[, offset])`
124
+
125
+ See https://nodejs.org/api/buffer.html#bufwritefloatlevalue-offset
126
+
127
+ #### `b4a.writeUInt32LE(buffer, value[, offset])`
128
+
129
+ https://nodejs.org/api/buffer.html#bufwriteuint32levalue-offset
130
+
131
+ #### `b4a.writeInt32LE(buffer, value[, offset])`
132
+
133
+ See https://nodejs.org/api/buffer.html#bufwriteint32levalue-offset
134
+
135
+ #### `b4a.readDoubleLE(buffer[, offset])`
136
+
137
+ See https://nodejs.org/api/buffer.html#bufreaddoubleleoffset
138
+
139
+ #### `b4a.readFloatLE(buffer[, offset])`
140
+
141
+ See https://nodejs.org/api/buffer.html#bufreadfloatleoffset
142
+
143
+ #### `b4a.readUInt32LE(buffer[, offset])`
144
+
145
+ See https://nodejs.org/api/buffer.html#bufreaduint32leoffset
146
+
147
+ #### `b4a.readInt32LE(buffer[, offset])`
148
+
149
+ See https://nodejs.org/api/buffer.html#bufreadint32leoffset
150
+
151
+ ## License
152
+
153
+ Apache 2.0
node_modules/b4a/browser.js ADDED
@@ -0,0 +1,541 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const ascii = require('./lib/ascii')
2
+ const base64 = require('./lib/base64')
3
+ const hex = require('./lib/hex')
4
+ const latin1 = require('./lib/latin1')
5
+ const utf8 = require('./lib/utf8')
6
+ const utf16le = require('./lib/utf16le')
7
+
8
+ const LE = new Uint8Array(Uint16Array.of(0xff).buffer)[0] === 0xff
9
+
10
+ function codecFor(encoding) {
11
+ switch (encoding) {
12
+ case 'ascii':
13
+ return ascii
14
+ case 'base64':
15
+ return base64
16
+ case 'hex':
17
+ return hex
18
+ case 'binary':
19
+ case 'latin1':
20
+ return latin1
21
+ case 'utf8':
22
+ case 'utf-8':
23
+ case undefined:
24
+ case null:
25
+ return utf8
26
+ case 'ucs2':
27
+ case 'ucs-2':
28
+ case 'utf16le':
29
+ case 'utf-16le':
30
+ return utf16le
31
+ default:
32
+ throw new Error(`Unknown encoding '${encoding}'`)
33
+ }
34
+ }
35
+
36
+ function isBuffer(value) {
37
+ return value instanceof Uint8Array
38
+ }
39
+
40
+ function isEncoding(encoding) {
41
+ try {
42
+ codecFor(encoding)
43
+ return true
44
+ } catch {
45
+ return false
46
+ }
47
+ }
48
+
49
+ function alloc(size, fill, encoding) {
50
+ const buffer = new Uint8Array(size)
51
+ if (fill !== undefined) {
52
+ exports.fill(buffer, fill, 0, buffer.byteLength, encoding)
53
+ }
54
+ return buffer
55
+ }
56
+
57
+ function allocUnsafe(size) {
58
+ return new Uint8Array(size)
59
+ }
60
+
61
+ function allocUnsafeSlow(size) {
62
+ return new Uint8Array(size)
63
+ }
64
+
65
+ function byteLength(string, encoding) {
66
+ return codecFor(encoding).byteLength(string)
67
+ }
68
+
69
+ function compare(a, b) {
70
+ if (a === b) return 0
71
+
72
+ const len = Math.min(a.byteLength, b.byteLength)
73
+
74
+ a = new DataView(a.buffer, a.byteOffset, a.byteLength)
75
+ b = new DataView(b.buffer, b.byteOffset, b.byteLength)
76
+
77
+ let i = 0
78
+
79
+ for (let n = len - (len % 4); i < n; i += 4) {
80
+ const x = a.getUint32(i, LE)
81
+ const y = b.getUint32(i, LE)
82
+ if (x !== y) break
83
+ }
84
+
85
+ for (; i < len; i++) {
86
+ const x = a.getUint8(i)
87
+ const y = b.getUint8(i)
88
+ if (x < y) return -1
89
+ if (x > y) return 1
90
+ }
91
+
92
+ return a.byteLength > b.byteLength ? 1 : a.byteLength < b.byteLength ? -1 : 0
93
+ }
94
+
95
+ function concat(buffers, length) {
96
+ if (length === undefined) {
97
+ length = buffers.reduce((len, buffer) => len + buffer.byteLength, 0)
98
+ }
99
+
100
+ const result = new Uint8Array(length)
101
+
102
+ let offset = 0
103
+
104
+ for (const buffer of buffers) {
105
+ if (offset + buffer.byteLength > result.byteLength) {
106
+ result.set(buffer.subarray(0, result.byteLength - offset), offset)
107
+ return result
108
+ }
109
+
110
+ result.set(buffer, offset)
111
+ offset += buffer.byteLength
112
+ }
113
+
114
+ return result
115
+ }
116
+
117
+ function copy(source, target, targetStart = 0, sourceStart = 0, sourceEnd = source.byteLength) {
118
+ if (targetStart < 0) targetStart = 0
119
+ if (targetStart >= target.byteLength) return 0
120
+
121
+ const targetLength = target.byteLength - targetStart
122
+
123
+ if (sourceStart < 0) sourceStart = 0
124
+ if (sourceStart >= source.byteLength) return 0
125
+
126
+ if (sourceEnd <= sourceStart) return 0
127
+ if (sourceEnd > source.byteLength) sourceEnd = source.byteLength
128
+
129
+ if (sourceEnd - sourceStart > targetLength) {
130
+ sourceEnd = sourceStart + targetLength
131
+ }
132
+
133
+ const sourceLength = sourceEnd - sourceStart
134
+
135
+ if (source === target) {
136
+ target.copyWithin(targetStart, sourceStart, sourceEnd)
137
+ } else {
138
+ if (sourceStart !== 0 || sourceEnd !== source.byteLength) {
139
+ source = source.subarray(sourceStart, sourceEnd)
140
+ }
141
+
142
+ target.set(source, targetStart)
143
+ }
144
+
145
+ return sourceLength
146
+ }
147
+
148
+ function equals(a, b) {
149
+ if (a === b) return true
150
+ if (a.byteLength !== b.byteLength) return false
151
+
152
+ return compare(a, b) === 0
153
+ }
154
+
155
+ function fill(buffer, value, offset = 0, end = buffer.byteLength, encoding = 'utf8') {
156
+ if (typeof value === 'string') {
157
+ if (typeof offset === 'string') {
158
+ // fill(string, encoding)
159
+ encoding = offset
160
+ offset = 0
161
+ end = buffer.byteLength
162
+ } else if (typeof end === 'string') {
163
+ // fill(string, offset, encoding)
164
+ encoding = end
165
+ end = buffer.byteLength
166
+ }
167
+ } else if (typeof value === 'number') {
168
+ value = value & 0xff
169
+ } else if (typeof value === 'boolean') {
170
+ value = +value
171
+ }
172
+
173
+ if (offset < 0) offset = 0
174
+ if (offset >= buffer.byteLength) return buffer
175
+
176
+ if (end <= offset) return buffer
177
+ if (end > buffer.byteLength) end = buffer.byteLength
178
+
179
+ if (typeof value === 'number') return buffer.fill(value, offset, end)
180
+
181
+ if (typeof value === 'string') value = exports.from(value, encoding)
182
+
183
+ const len = value.byteLength
184
+
185
+ for (let i = 0, n = end - offset; i < n; ++i) {
186
+ buffer[i + offset] = value[i % len]
187
+ }
188
+
189
+ return buffer
190
+ }
191
+
192
+ function from(value, encodingOrOffset, length) {
193
+ // from(string, encoding)
194
+ if (typeof value === 'string') return fromString(value, encodingOrOffset)
195
+
196
+ // from(array)
197
+ if (Array.isArray(value)) return fromArray(value)
198
+
199
+ // from(buffer)
200
+ if (ArrayBuffer.isView(value)) return fromBuffer(value)
201
+
202
+ // from(arrayBuffer[, byteOffset[, length]])
203
+ return fromArrayBuffer(value, encodingOrOffset, length)
204
+ }
205
+
206
+ function fromString(string, encoding) {
207
+ const codec = codecFor(encoding)
208
+ const buffer = new Uint8Array(codec.byteLength(string))
209
+ codec.write(buffer, string)
210
+ return buffer
211
+ }
212
+
213
+ function fromArray(array) {
214
+ const buffer = new Uint8Array(array.length)
215
+ buffer.set(array)
216
+ return buffer
217
+ }
218
+
219
+ function fromBuffer(buffer) {
220
+ const copy = new Uint8Array(buffer.byteLength)
221
+ copy.set(buffer)
222
+ return copy
223
+ }
224
+
225
+ function fromArrayBuffer(arrayBuffer, byteOffset, length) {
226
+ return new Uint8Array(arrayBuffer, byteOffset, length)
227
+ }
228
+
229
+ function includes(buffer, value, byteOffset, encoding) {
230
+ return indexOf(buffer, value, byteOffset, encoding) !== -1
231
+ }
232
+
233
+ function indexOf(buffer, value, byteOffset, encoding) {
234
+ return bidirectionalIndexOf(buffer, value, byteOffset, encoding, true /* first */)
235
+ }
236
+
237
+ function lastIndexOf(buffer, value, byteOffset, encoding) {
238
+ return bidirectionalIndexOf(buffer, value, byteOffset, encoding, false /* last */)
239
+ }
240
+
241
+ function bidirectionalIndexOf(buffer, value, byteOffset, encoding, first) {
242
+ if (buffer.byteLength === 0) return -1
243
+
244
+ if (typeof byteOffset === 'string') {
245
+ encoding = byteOffset
246
+ byteOffset = 0
247
+ } else if (byteOffset === undefined) {
248
+ byteOffset = first ? 0 : buffer.length - 1
249
+ } else if (byteOffset < 0) {
250
+ byteOffset += buffer.byteLength
251
+ }
252
+
253
+ if (byteOffset >= buffer.byteLength) {
254
+ if (first) return -1
255
+ else byteOffset = buffer.byteLength - 1
256
+ } else if (byteOffset < 0) {
257
+ if (first) byteOffset = 0
258
+ else return -1
259
+ }
260
+
261
+ if (typeof value === 'string') {
262
+ value = from(value, encoding)
263
+ } else if (typeof value === 'number') {
264
+ value = value & 0xff
265
+
266
+ if (first) {
267
+ return buffer.indexOf(value, byteOffset)
268
+ } else {
269
+ return buffer.lastIndexOf(value, byteOffset)
270
+ }
271
+ }
272
+
273
+ if (value.byteLength === 0) return -1
274
+
275
+ if (first) {
276
+ let foundIndex = -1
277
+
278
+ for (let i = byteOffset; i < buffer.byteLength; i++) {
279
+ if (buffer[i] === value[foundIndex === -1 ? 0 : i - foundIndex]) {
280
+ if (foundIndex === -1) foundIndex = i
281
+ if (i - foundIndex + 1 === value.byteLength) return foundIndex
282
+ } else {
283
+ if (foundIndex !== -1) i -= i - foundIndex
284
+ foundIndex = -1
285
+ }
286
+ }
287
+ } else {
288
+ if (byteOffset + value.byteLength > buffer.byteLength) {
289
+ byteOffset = buffer.byteLength - value.byteLength
290
+ }
291
+
292
+ for (let i = byteOffset; i >= 0; i--) {
293
+ let found = true
294
+
295
+ for (let j = 0; j < value.byteLength; j++) {
296
+ if (buffer[i + j] !== value[j]) {
297
+ found = false
298
+ break
299
+ }
300
+ }
301
+
302
+ if (found) return i
303
+ }
304
+ }
305
+
306
+ return -1
307
+ }
308
+
309
+ function swap(buffer, n, m) {
310
+ const i = buffer[n]
311
+ buffer[n] = buffer[m]
312
+ buffer[m] = i
313
+ }
314
+
315
+ function swap16(buffer) {
316
+ const len = buffer.byteLength
317
+
318
+ if (len % 2 !== 0) {
319
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
320
+ }
321
+
322
+ for (let i = 0; i < len; i += 2) swap(buffer, i, i + 1)
323
+
324
+ return buffer
325
+ }
326
+
327
+ function swap32(buffer) {
328
+ const len = buffer.byteLength
329
+
330
+ if (len % 4 !== 0) {
331
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
332
+ }
333
+
334
+ for (let i = 0; i < len; i += 4) {
335
+ swap(buffer, i, i + 3)
336
+ swap(buffer, i + 1, i + 2)
337
+ }
338
+
339
+ return buffer
340
+ }
341
+
342
+ function swap64(buffer) {
343
+ const len = buffer.byteLength
344
+
345
+ if (len % 8 !== 0) {
346
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
347
+ }
348
+
349
+ for (let i = 0; i < len; i += 8) {
350
+ swap(buffer, i, i + 7)
351
+ swap(buffer, i + 1, i + 6)
352
+ swap(buffer, i + 2, i + 5)
353
+ swap(buffer, i + 3, i + 4)
354
+ }
355
+
356
+ return buffer
357
+ }
358
+
359
+ function toBuffer(buffer) {
360
+ return buffer
361
+ }
362
+
363
+ function toString(buffer, encoding = 'utf8', start = 0, end = buffer.byteLength) {
364
+ // toString(buffer)
365
+ if (arguments.length === 1) return utf8.toString(buffer)
366
+
367
+ // toString(buffer, encoding)
368
+ if (arguments.length === 2) return codecFor(encoding).toString(buffer)
369
+
370
+ if (start < 0) start = 0
371
+ if (start >= buffer.byteLength) return ''
372
+
373
+ if (end <= start) return ''
374
+ if (end > buffer.byteLength) end = buffer.byteLength
375
+
376
+ if (start !== 0 || end !== buffer.byteLength) {
377
+ buffer = buffer.subarray(start, end)
378
+ }
379
+
380
+ return codecFor(encoding).toString(buffer)
381
+ }
382
+
383
+ function write(buffer, string, offset = 0, length = buffer.byteLength, encoding) {
384
+ // write(buffer, string)
385
+ if (arguments.length === 2) return utf8.write(buffer, string)
386
+
387
+ if (typeof offset === 'string') {
388
+ // write(buffer, string, encoding)
389
+ encoding = offset
390
+ offset = 0
391
+ length = buffer.byteLength
392
+ } else if (typeof length === 'string') {
393
+ // write(buffer, string, offset, encoding)
394
+ encoding = length
395
+ length = buffer.byteLength - offset
396
+ }
397
+
398
+ length = Math.min(length, exports.byteLength(string, encoding))
399
+
400
+ let start = offset
401
+ if (start < 0) start = 0
402
+ if (start >= buffer.byteLength) return 0
403
+
404
+ let end = offset + length
405
+ if (end <= start) return 0
406
+ if (end > buffer.byteLength) end = buffer.byteLength
407
+
408
+ if (start !== 0 || end !== buffer.byteLength) {
409
+ buffer = buffer.subarray(start, end)
410
+ }
411
+
412
+ return codecFor(encoding).write(buffer, string)
413
+ }
414
+
415
+ function readDoubleBE(buffer, offset = 0) {
416
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
417
+ return view.getFloat64(offset, false)
418
+ }
419
+
420
+ function readDoubleLE(buffer, offset = 0) {
421
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
422
+ return view.getFloat64(offset, true)
423
+ }
424
+
425
+ function readFloatBE(buffer, offset = 0) {
426
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
427
+ return view.getFloat32(offset, false)
428
+ }
429
+
430
+ function readFloatLE(buffer, offset = 0) {
431
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
432
+ return view.getFloat32(offset, true)
433
+ }
434
+
435
+ function readInt32BE(buffer, offset = 0) {
436
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
437
+ return view.getInt32(offset, false)
438
+ }
439
+
440
+ function readInt32LE(buffer, offset = 0) {
441
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
442
+ return view.getInt32(offset, true)
443
+ }
444
+
445
+ function readUInt32BE(buffer, offset = 0) {
446
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
447
+ return view.getUint32(offset, false)
448
+ }
449
+
450
+ function readUInt32LE(buffer, offset = 0) {
451
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
452
+ return view.getUint32(offset, true)
453
+ }
454
+
455
+ function writeDoubleBE(buffer, value, offset = 0) {
456
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
457
+ view.setFloat64(offset, value, false)
458
+ return offset + 8
459
+ }
460
+
461
+ function writeDoubleLE(buffer, value, offset = 0) {
462
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
463
+ view.setFloat64(offset, value, true)
464
+ return offset + 8
465
+ }
466
+
467
+ function writeFloatBE(buffer, value, offset = 0) {
468
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
469
+ view.setFloat32(offset, value, false)
470
+ return offset + 4
471
+ }
472
+
473
+ function writeFloatLE(buffer, value, offset = 0) {
474
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
475
+ view.setFloat32(offset, value, true)
476
+ return offset + 4
477
+ }
478
+
479
+ function writeInt32BE(buffer, value, offset = 0) {
480
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
481
+ view.setInt32(offset, value, false)
482
+ return offset + 4
483
+ }
484
+
485
+ function writeInt32LE(buffer, value, offset = 0) {
486
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
487
+ view.setInt32(offset, value, true)
488
+ return offset + 4
489
+ }
490
+
491
+ function writeUInt32BE(buffer, value, offset = 0) {
492
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
493
+ view.setUint32(offset, value, false)
494
+ return offset + 4
495
+ }
496
+
497
+ function writeUInt32LE(buffer, value, offset = 0) {
498
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength)
499
+ view.setUint32(offset, value, true)
500
+ return offset + 4
501
+ }
502
+
503
+ module.exports = exports = {
504
+ isBuffer,
505
+ isEncoding,
506
+ alloc,
507
+ allocUnsafe,
508
+ allocUnsafeSlow,
509
+ byteLength,
510
+ compare,
511
+ concat,
512
+ copy,
513
+ equals,
514
+ fill,
515
+ from,
516
+ includes,
517
+ indexOf,
518
+ lastIndexOf,
519
+ swap16,
520
+ swap32,
521
+ swap64,
522
+ toBuffer,
523
+ toString,
524
+ write,
525
+ readDoubleBE,
526
+ readDoubleLE,
527
+ readFloatBE,
528
+ readFloatLE,
529
+ readInt32BE,
530
+ readInt32LE,
531
+ readUInt32BE,
532
+ readUInt32LE,
533
+ writeDoubleBE,
534
+ writeDoubleLE,
535
+ writeFloatBE,
536
+ writeFloatLE,
537
+ writeInt32BE,
538
+ writeInt32LE,
539
+ writeUInt32BE,
540
+ writeUInt32LE
541
+ }
node_modules/b4a/index.js ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function isBuffer(value) {
2
+ return Buffer.isBuffer(value) || value instanceof Uint8Array
3
+ }
4
+
5
+ function isEncoding(encoding) {
6
+ return Buffer.isEncoding(encoding)
7
+ }
8
+
9
+ function alloc(size, fill, encoding) {
10
+ return Buffer.alloc(size, fill, encoding)
11
+ }
12
+
13
+ function allocUnsafe(size) {
14
+ return Buffer.allocUnsafe(size)
15
+ }
16
+
17
+ function allocUnsafeSlow(size) {
18
+ return Buffer.allocUnsafeSlow(size)
19
+ }
20
+
21
+ function byteLength(string, encoding) {
22
+ return Buffer.byteLength(string, encoding)
23
+ }
24
+
25
+ function compare(a, b) {
26
+ return Buffer.compare(a, b)
27
+ }
28
+
29
+ function concat(buffers, totalLength) {
30
+ return Buffer.concat(buffers, totalLength)
31
+ }
32
+
33
+ function copy(source, target, targetStart, start, end) {
34
+ return toBuffer(source).copy(target, targetStart, start, end)
35
+ }
36
+
37
+ function equals(a, b) {
38
+ return toBuffer(a).equals(b)
39
+ }
40
+
41
+ function fill(buffer, value, offset, end, encoding) {
42
+ return toBuffer(buffer).fill(value, offset, end, encoding)
43
+ }
44
+
45
+ function from(value, encodingOrOffset, length) {
46
+ return Buffer.from(value, encodingOrOffset, length)
47
+ }
48
+
49
+ function includes(buffer, value, byteOffset, encoding) {
50
+ return toBuffer(buffer).includes(value, byteOffset, encoding)
51
+ }
52
+
53
+ function indexOf(buffer, value, byfeOffset, encoding) {
54
+ return toBuffer(buffer).indexOf(value, byfeOffset, encoding)
55
+ }
56
+
57
+ function lastIndexOf(buffer, value, byteOffset, encoding) {
58
+ return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding)
59
+ }
60
+
61
+ function swap16(buffer) {
62
+ return toBuffer(buffer).swap16()
63
+ }
64
+
65
+ function swap32(buffer) {
66
+ return toBuffer(buffer).swap32()
67
+ }
68
+
69
+ function swap64(buffer) {
70
+ return toBuffer(buffer).swap64()
71
+ }
72
+
73
+ function toBuffer(buffer) {
74
+ if (Buffer.isBuffer(buffer)) return buffer
75
+ return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength)
76
+ }
77
+
78
+ function toString(buffer, encoding, start, end) {
79
+ return toBuffer(buffer).toString(encoding, start, end)
80
+ }
81
+
82
+ function write(buffer, string, offset, length, encoding) {
83
+ return toBuffer(buffer).write(string, offset, length, encoding)
84
+ }
85
+
86
+ function readDoubleBE(buffer, offset) {
87
+ return toBuffer(buffer).readDoubleBE(offset)
88
+ }
89
+
90
+ function readDoubleLE(buffer, offset) {
91
+ return toBuffer(buffer).readDoubleLE(offset)
92
+ }
93
+
94
+ function readFloatBE(buffer, offset) {
95
+ return toBuffer(buffer).readFloatBE(offset)
96
+ }
97
+
98
+ function readFloatLE(buffer, offset) {
99
+ return toBuffer(buffer).readFloatLE(offset)
100
+ }
101
+
102
+ function readInt32BE(buffer, offset) {
103
+ return toBuffer(buffer).readInt32BE(offset)
104
+ }
105
+
106
+ function readInt32LE(buffer, offset) {
107
+ return toBuffer(buffer).readInt32LE(offset)
108
+ }
109
+
110
+ function readUInt32BE(buffer, offset) {
111
+ return toBuffer(buffer).readUInt32BE(offset)
112
+ }
113
+
114
+ function readUInt32LE(buffer, offset) {
115
+ return toBuffer(buffer).readUInt32LE(offset)
116
+ }
117
+
118
+ function writeDoubleBE(buffer, value, offset) {
119
+ return toBuffer(buffer).writeDoubleBE(value, offset)
120
+ }
121
+
122
+ function writeDoubleLE(buffer, value, offset) {
123
+ return toBuffer(buffer).writeDoubleLE(value, offset)
124
+ }
125
+
126
+ function writeFloatBE(buffer, value, offset) {
127
+ return toBuffer(buffer).writeFloatBE(value, offset)
128
+ }
129
+
130
+ function writeFloatLE(buffer, value, offset) {
131
+ return toBuffer(buffer).writeFloatLE(value, offset)
132
+ }
133
+
134
+ function writeInt32BE(buffer, value, offset) {
135
+ return toBuffer(buffer).writeInt32BE(value, offset)
136
+ }
137
+
138
+ function writeInt32LE(buffer, value, offset) {
139
+ return toBuffer(buffer).writeInt32LE(value, offset)
140
+ }
141
+
142
+ function writeUInt32BE(buffer, value, offset) {
143
+ return toBuffer(buffer).writeUInt32BE(value, offset)
144
+ }
145
+
146
+ function writeUInt32LE(buffer, value, offset) {
147
+ return toBuffer(buffer).writeUInt32LE(value, offset)
148
+ }
149
+
150
+ module.exports = {
151
+ isBuffer,
152
+ isEncoding,
153
+ alloc,
154
+ allocUnsafe,
155
+ allocUnsafeSlow,
156
+ byteLength,
157
+ compare,
158
+ concat,
159
+ copy,
160
+ equals,
161
+ fill,
162
+ from,
163
+ includes,
164
+ indexOf,
165
+ lastIndexOf,
166
+ swap16,
167
+ swap32,
168
+ swap64,
169
+ toBuffer,
170
+ toString,
171
+ write,
172
+ readDoubleBE,
173
+ readDoubleLE,
174
+ readFloatBE,
175
+ readFloatLE,
176
+ readInt32BE,
177
+ readInt32LE,
178
+ readUInt32BE,
179
+ readUInt32LE,
180
+ writeDoubleBE,
181
+ writeDoubleLE,
182
+ writeFloatBE,
183
+ writeFloatLE,
184
+ writeInt32BE,
185
+ writeInt32LE,
186
+ writeUInt32BE,
187
+ writeUInt32LE
188
+ }
node_modules/b4a/lib/ascii.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function byteLength(string) {
2
+ return string.length
3
+ }
4
+
5
+ function toString(buffer) {
6
+ const len = buffer.byteLength
7
+
8
+ let result = ''
9
+
10
+ for (let i = 0; i < len; i++) {
11
+ result += String.fromCharCode(buffer[i] & 0x7f)
12
+ }
13
+
14
+ return result
15
+ }
16
+
17
+ function write(buffer, string) {
18
+ const len = buffer.byteLength
19
+
20
+ for (let i = 0; i < len; i++) {
21
+ buffer[i] = string.charCodeAt(i)
22
+ }
23
+
24
+ return len
25
+ }
26
+
27
+ module.exports = {
28
+ byteLength,
29
+ toString,
30
+ write
31
+ }
node_modules/b4a/lib/base64.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
2
+
3
+ const codes = new Uint8Array(256)
4
+
5
+ for (let i = 0; i < alphabet.length; i++) {
6
+ codes[alphabet.charCodeAt(i)] = i
7
+ }
8
+
9
+ codes[/* - */ 0x2d] = 62
10
+ codes[/* _ */ 0x5f] = 63
11
+
12
+ function byteLength(string) {
13
+ let len = string.length
14
+
15
+ if (string.charCodeAt(len - 1) === 0x3d) len--
16
+ if (len > 1 && string.charCodeAt(len - 1) === 0x3d) len--
17
+
18
+ return (len * 3) >>> 2
19
+ }
20
+
21
+ function toString(buffer) {
22
+ const len = buffer.byteLength
23
+
24
+ let result = ''
25
+
26
+ for (let i = 0; i < len; i += 3) {
27
+ result +=
28
+ alphabet[buffer[i] >> 2] +
29
+ alphabet[((buffer[i] & 3) << 4) | (buffer[i + 1] >> 4)] +
30
+ alphabet[((buffer[i + 1] & 15) << 2) | (buffer[i + 2] >> 6)] +
31
+ alphabet[buffer[i + 2] & 63]
32
+ }
33
+
34
+ if (len % 3 === 2) {
35
+ result = result.substring(0, result.length - 1) + '='
36
+ } else if (len % 3 === 1) {
37
+ result = result.substring(0, result.length - 2) + '=='
38
+ }
39
+
40
+ return result
41
+ }
42
+
43
+ function write(buffer, string) {
44
+ const len = buffer.byteLength
45
+
46
+ for (let i = 0, j = 0; j < len; i += 4) {
47
+ const a = codes[string.charCodeAt(i)]
48
+ const b = codes[string.charCodeAt(i + 1)]
49
+ const c = codes[string.charCodeAt(i + 2)]
50
+ const d = codes[string.charCodeAt(i + 3)]
51
+
52
+ buffer[j++] = (a << 2) | (b >> 4)
53
+ buffer[j++] = ((b & 15) << 4) | (c >> 2)
54
+ buffer[j++] = ((c & 3) << 6) | (d & 63)
55
+ }
56
+
57
+ return len
58
+ }
59
+
60
+ module.exports = {
61
+ byteLength,
62
+ toString,
63
+ write
64
+ }
node_modules/b4a/lib/hex.js ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function byteLength(string) {
2
+ return string.length >>> 1
3
+ }
4
+
5
+ function toString(buffer) {
6
+ const len = buffer.byteLength
7
+
8
+ buffer = new DataView(buffer.buffer, buffer.byteOffset, len)
9
+
10
+ let result = ''
11
+ let i = 0
12
+
13
+ for (let n = len - (len % 4); i < n; i += 4) {
14
+ result += buffer.getUint32(i).toString(16).padStart(8, '0')
15
+ }
16
+
17
+ for (; i < len; i++) {
18
+ result += buffer.getUint8(i).toString(16).padStart(2, '0')
19
+ }
20
+
21
+ return result
22
+ }
23
+
24
+ function write(buffer, string) {
25
+ const len = buffer.byteLength
26
+
27
+ for (let i = 0; i < len; i++) {
28
+ const a = hexValue(string.charCodeAt(i * 2))
29
+ const b = hexValue(string.charCodeAt(i * 2 + 1))
30
+
31
+ if (a === undefined || b === undefined) {
32
+ return i
33
+ }
34
+
35
+ buffer[i] = (a << 4) | b
36
+ }
37
+
38
+ return len
39
+ }
40
+
41
+ module.exports = {
42
+ byteLength,
43
+ toString,
44
+ write
45
+ }
46
+
47
+ function hexValue(char) {
48
+ if (char >= 0x30 && char <= 0x39) return char - 0x30
49
+ if (char >= 0x41 && char <= 0x46) return char - 0x41 + 10
50
+ if (char >= 0x61 && char <= 0x66) return char - 0x61 + 10
51
+ }
node_modules/b4a/lib/latin1.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function byteLength(string) {
2
+ return string.length
3
+ }
4
+
5
+ function toString(buffer) {
6
+ const len = buffer.byteLength
7
+
8
+ let result = ''
9
+
10
+ for (let i = 0; i < len; i++) {
11
+ result += String.fromCharCode(buffer[i])
12
+ }
13
+
14
+ return result
15
+ }
16
+
17
+ function write(buffer, string) {
18
+ const len = buffer.byteLength
19
+
20
+ for (let i = 0; i < len; i++) {
21
+ buffer[i] = string.charCodeAt(i)
22
+ }
23
+
24
+ return len
25
+ }
26
+
27
+ module.exports = {
28
+ byteLength,
29
+ toString,
30
+ write
31
+ }
node_modules/b4a/lib/utf16le.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function byteLength(string) {
2
+ return string.length * 2
3
+ }
4
+
5
+ function toString(buffer) {
6
+ const len = buffer.byteLength
7
+
8
+ let result = ''
9
+
10
+ for (let i = 0; i < len - 1; i += 2) {
11
+ result += String.fromCharCode(buffer[i] + buffer[i + 1] * 256)
12
+ }
13
+
14
+ return result
15
+ }
16
+
17
+ function write(buffer, string) {
18
+ const len = buffer.byteLength
19
+
20
+ let units = len
21
+
22
+ for (let i = 0; i < string.length; ++i) {
23
+ if ((units -= 2) < 0) break
24
+
25
+ const c = string.charCodeAt(i)
26
+ const hi = c >> 8
27
+ const lo = c % 256
28
+
29
+ buffer[i * 2] = lo
30
+ buffer[i * 2 + 1] = hi
31
+ }
32
+
33
+ return len
34
+ }
35
+
36
+ module.exports = {
37
+ byteLength,
38
+ toString,
39
+ write
40
+ }
node_modules/b4a/lib/utf8.js ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function byteLength(string) {
2
+ let length = 0
3
+
4
+ for (let i = 0, n = string.length; i < n; i++) {
5
+ const code = string.charCodeAt(i)
6
+
7
+ if (code >= 0xd800 && code <= 0xdbff && i + 1 < n) {
8
+ const code = string.charCodeAt(i + 1)
9
+
10
+ if (code >= 0xdc00 && code <= 0xdfff) {
11
+ length += 4
12
+ i++
13
+ continue
14
+ }
15
+ }
16
+
17
+ if (code <= 0x7f) length += 1
18
+ else if (code <= 0x7ff) length += 2
19
+ else length += 3
20
+ }
21
+
22
+ return length
23
+ }
24
+
25
+ let toString
26
+
27
+ if (typeof TextDecoder !== 'undefined') {
28
+ const decoder = new TextDecoder()
29
+
30
+ toString = function toString(buffer) {
31
+ return decoder.decode(buffer)
32
+ }
33
+ } else {
34
+ toString = function toString(buffer) {
35
+ const len = buffer.byteLength
36
+
37
+ let output = ''
38
+ let i = 0
39
+
40
+ while (i < len) {
41
+ let byte = buffer[i]
42
+
43
+ if (byte <= 0x7f) {
44
+ output += String.fromCharCode(byte)
45
+ i++
46
+ continue
47
+ }
48
+
49
+ let bytesNeeded = 0
50
+ let codePoint = 0
51
+
52
+ if (byte <= 0xdf) {
53
+ bytesNeeded = 1
54
+ codePoint = byte & 0x1f
55
+ } else if (byte <= 0xef) {
56
+ bytesNeeded = 2
57
+ codePoint = byte & 0x0f
58
+ } else if (byte <= 0xf4) {
59
+ bytesNeeded = 3
60
+ codePoint = byte & 0x07
61
+ }
62
+
63
+ if (len - i - bytesNeeded > 0) {
64
+ let k = 0
65
+
66
+ while (k < bytesNeeded) {
67
+ byte = buffer[i + k + 1]
68
+ codePoint = (codePoint << 6) | (byte & 0x3f)
69
+ k += 1
70
+ }
71
+ } else {
72
+ codePoint = 0xfffd
73
+ bytesNeeded = len - i
74
+ }
75
+
76
+ output += String.fromCodePoint(codePoint)
77
+ i += bytesNeeded + 1
78
+ }
79
+
80
+ return output
81
+ }
82
+ }
83
+
84
+ let write
85
+
86
+ if (typeof TextEncoder !== 'undefined') {
87
+ const encoder = new TextEncoder()
88
+
89
+ write = function write(buffer, string) {
90
+ return encoder.encodeInto(string, buffer).written
91
+ }
92
+ } else {
93
+ write = function write(buffer, string) {
94
+ const len = buffer.byteLength
95
+
96
+ let i = 0
97
+ let j = 0
98
+
99
+ while (i < string.length) {
100
+ const code = string.codePointAt(i)
101
+
102
+ if (code <= 0x7f) {
103
+ if (j + 1 > len) break
104
+ buffer[j++] = code
105
+ i++
106
+ continue
107
+ }
108
+
109
+ let count = 0
110
+ let bits = 0
111
+
112
+ if (code <= 0x7ff) {
113
+ count = 6
114
+ bits = 0xc0
115
+ } else if (code <= 0xffff) {
116
+ count = 12
117
+ bits = 0xe0
118
+ } else if (code <= 0x1fffff) {
119
+ count = 18
120
+ bits = 0xf0
121
+ }
122
+
123
+ if (j + count / 6 + 1 > len) break
124
+
125
+ buffer[j++] = bits | (code >> count)
126
+ count -= 6
127
+
128
+ while (count >= 0) {
129
+ buffer[j++] = 0x80 | ((code >> count) & 0x3f)
130
+ count -= 6
131
+ }
132
+
133
+ i += code >= 0x10000 ? 2 : 1
134
+ }
135
+
136
+ return j
137
+ }
138
+ }
139
+
140
+ module.exports = {
141
+ byteLength,
142
+ toString,
143
+ write
144
+ }
node_modules/b4a/package.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "b4a",
3
+ "version": "1.8.1",
4
+ "description": "Bridging the gap between buffers and typed arrays",
5
+ "exports": {
6
+ "./package": "./package.json",
7
+ ".": {
8
+ "react-native": "./react-native.js",
9
+ "browser": "./browser.js",
10
+ "default": "./index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "browser.js",
15
+ "index.js",
16
+ "react-native.js",
17
+ "lib"
18
+ ],
19
+ "scripts": {
20
+ "format": "prettier --write . && lunte --fix",
21
+ "lint": "prettier --check . && lunte",
22
+ "test": "npm run test:bare && npm run test:node",
23
+ "test:bare": "brittle-bare --coverage test.mjs",
24
+ "test:node": "brittle-node --coverage test.mjs"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/holepunchto/b4a.git"
29
+ },
30
+ "author": "Holepunch",
31
+ "license": "Apache-2.0",
32
+ "bugs": {
33
+ "url": "https://github.com/holepunchto/b4a/issues"
34
+ },
35
+ "homepage": "https://github.com/holepunchto/b4a#readme",
36
+ "devDependencies": {
37
+ "brittle": "^3.5.2",
38
+ "lunte": "^1.7.0",
39
+ "nanobench": "^3.0.0",
40
+ "prettier": "^3.6.2",
41
+ "prettier-config-holepunch": "^2.0.0"
42
+ },
43
+ "peerDependencies": {
44
+ "react-native-b4a": "*"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "react-native-b4a": {
48
+ "optional": true
49
+ }
50
+ }
51
+ }
node_modules/b4a/react-native.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ try {
2
+ module.exports = require('react-native-b4a')
3
+ } catch {
4
+ module.exports = require('./browser')
5
+ }
node_modules/balanced-match/.github/FUNDING.yml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tidelift: "npm/balanced-match"
2
+ patreon: juliangruber
node_modules/balanced-match/LICENSE.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (MIT)
2
+
3
+ Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ 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/balanced-match/README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # balanced-match
2
+
3
+ Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
4
+
5
+ [![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
6
+ [![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
7
+
8
+ [![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
9
+
10
+ ## Example
11
+
12
+ Get the first matching pair of braces:
13
+
14
+ ```js
15
+ var balanced = require('balanced-match');
16
+
17
+ console.log(balanced('{', '}', 'pre{in{nested}}post'));
18
+ console.log(balanced('{', '}', 'pre{first}between{second}post'));
19
+ console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
20
+ ```
21
+
22
+ The matches are:
23
+
24
+ ```bash
25
+ $ node example.js
26
+ { start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
27
+ { start: 3,
28
+ end: 9,
29
+ pre: 'pre',
30
+ body: 'first',
31
+ post: 'between{second}post' }
32
+ { start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
33
+ ```
34
+
35
+ ## API
36
+
37
+ ### var m = balanced(a, b, str)
38
+
39
+ For the first non-nested matching pair of `a` and `b` in `str`, return an
40
+ object with those keys:
41
+
42
+ * **start** the index of the first match of `a`
43
+ * **end** the index of the matching `b`
44
+ * **pre** the preamble, `a` and `b` not included
45
+ * **body** the match, `a` and `b` not included
46
+ * **post** the postscript, `a` and `b` not included
47
+
48
+ If there's no match, `undefined` will be returned.
49
+
50
+ If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
51
+
52
+ ### var r = balanced.range(a, b, str)
53
+
54
+ For the first non-nested matching pair of `a` and `b` in `str`, return an
55
+ array with indexes: `[ <a index>, <b index> ]`.
56
+
57
+ If there's no match, `undefined` will be returned.
58
+
59
+ If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
60
+
61
+ ## Installation
62
+
63
+ With [npm](https://npmjs.org) do:
64
+
65
+ ```bash
66
+ npm install balanced-match
67
+ ```
68
+
69
+ ## Security contact information
70
+
71
+ To report a security vulnerability, please use the
72
+ [Tidelift security contact](https://tidelift.com/security).
73
+ Tidelift will coordinate the fix and disclosure.
74
+
75
+ ## License
76
+
77
+ (MIT)
78
+
79
+ Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
80
+
81
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
82
+ this software and associated documentation files (the "Software"), to deal in
83
+ the Software without restriction, including without limitation the rights to
84
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
85
+ of the Software, and to permit persons to whom the Software is furnished to do
86
+ so, subject to the following conditions:
87
+
88
+ The above copyright notice and this permission notice shall be included in all
89
+ copies or substantial portions of the Software.
90
+
91
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
92
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
93
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
94
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
95
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
96
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
97
+ SOFTWARE.
node_modules/balanced-match/index.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+ module.exports = balanced;
3
+ function balanced(a, b, str) {
4
+ if (a instanceof RegExp) a = maybeMatch(a, str);
5
+ if (b instanceof RegExp) b = maybeMatch(b, str);
6
+
7
+ var r = range(a, b, str);
8
+
9
+ return r && {
10
+ start: r[0],
11
+ end: r[1],
12
+ pre: str.slice(0, r[0]),
13
+ body: str.slice(r[0] + a.length, r[1]),
14
+ post: str.slice(r[1] + b.length)
15
+ };
16
+ }
17
+
18
+ function maybeMatch(reg, str) {
19
+ var m = str.match(reg);
20
+ return m ? m[0] : null;
21
+ }
22
+
23
+ balanced.range = range;
24
+ function range(a, b, str) {
25
+ var begs, beg, left, right, result;
26
+ var ai = str.indexOf(a);
27
+ var bi = str.indexOf(b, ai + 1);
28
+ var i = ai;
29
+
30
+ if (ai >= 0 && bi > 0) {
31
+ if(a===b) {
32
+ return [ai, bi];
33
+ }
34
+ begs = [];
35
+ left = str.length;
36
+
37
+ while (i >= 0 && !result) {
38
+ if (i == ai) {
39
+ begs.push(i);
40
+ ai = str.indexOf(a, i + 1);
41
+ } else if (begs.length == 1) {
42
+ result = [ begs.pop(), bi ];
43
+ } else {
44
+ beg = begs.pop();
45
+ if (beg < left) {
46
+ left = beg;
47
+ right = bi;
48
+ }
49
+
50
+ bi = str.indexOf(b, i + 1);
51
+ }
52
+
53
+ i = ai < bi && ai >= 0 ? ai : bi;
54
+ }
55
+
56
+ if (begs.length) {
57
+ result = [ left, right ];
58
+ }
59
+ }
60
+
61
+ return result;
62
+ }
node_modules/balanced-match/package.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "balanced-match",
3
+ "description": "Match balanced character pairs, like \"{\" and \"}\"",
4
+ "version": "1.0.2",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git://github.com/juliangruber/balanced-match.git"
8
+ },
9
+ "homepage": "https://github.com/juliangruber/balanced-match",
10
+ "main": "index.js",
11
+ "scripts": {
12
+ "test": "tape test/test.js",
13
+ "bench": "matcha test/bench.js"
14
+ },
15
+ "devDependencies": {
16
+ "matcha": "^0.7.0",
17
+ "tape": "^4.6.0"
18
+ },
19
+ "keywords": [
20
+ "match",
21
+ "regexp",
22
+ "test",
23
+ "balanced",
24
+ "parse"
25
+ ],
26
+ "author": {
27
+ "name": "Julian Gruber",
28
+ "email": "mail@juliangruber.com",
29
+ "url": "http://juliangruber.com"
30
+ },
31
+ "license": "MIT",
32
+ "testling": {
33
+ "files": "test/*.js",
34
+ "browsers": [
35
+ "ie/8..latest",
36
+ "firefox/20..latest",
37
+ "firefox/nightly",
38
+ "chrome/25..latest",
39
+ "chrome/canary",
40
+ "opera/12..latest",
41
+ "opera/next",
42
+ "safari/5.1..latest",
43
+ "ipad/6.0..latest",
44
+ "iphone/6.0..latest",
45
+ "android-browser/4.2..latest"
46
+ ]
47
+ }
48
+ }
node_modules/bare-events/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
node_modules/bare-events/README.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bare-events
2
+
3
+ Event emitters for JavaScript.
4
+
5
+ ```
6
+ npm install bare-events
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ ```js
12
+ const EventEmitter = require('bare-events')
13
+
14
+ const e = new EventEmitter()
15
+
16
+ e.on('hello', function (data) {
17
+ console.log(data)
18
+ })
19
+
20
+ e.emit('hello', 'world')
21
+ ```
22
+
23
+ ## License
24
+
25
+ Apache-2.0
node_modules/bare-events/global.d.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as events from './web'
2
+
3
+ type EventConstructor = typeof events.Event
4
+ type CustomEventConstructor = typeof events.CustomEvent
5
+ type EventTargetConstructor = typeof events.EventTarget
6
+
7
+ declare global {
8
+ type Event = events.Event
9
+ type CustomEvent<T = any> = events.CustomEvent<T>
10
+ type EventTarget = events.EventTarget
11
+
12
+ const Event: EventConstructor
13
+ const CustomEvent: CustomEventConstructor
14
+ const EventTarget: EventTargetConstructor
15
+ }
node_modules/bare-events/global.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ const events = require('./web')
2
+
3
+ global.Event = events.Event
4
+ global.CustomEvent = events.CustomEvent
5
+ global.EventTarget = events.EventTarget