@nocobase/plugin-backup-restore 1.6.20 → 1.6.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/d0c15e9119b8e3d3.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +5 -5
- package/dist/node_modules/@hapi/topo/package.json +1 -1
- package/dist/node_modules/archiver/index.js +2 -2
- package/dist/node_modules/archiver/node_modules/async/all.js +119 -0
- package/dist/node_modules/archiver/node_modules/async/allLimit.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/allSeries.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/any.js +122 -0
- package/dist/node_modules/archiver/node_modules/async/anyLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/anySeries.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/apply.js +11 -0
- package/dist/node_modules/archiver/node_modules/async/applyEach.js +57 -0
- package/dist/node_modules/archiver/node_modules/async/applyEachSeries.js +37 -0
- package/dist/node_modules/archiver/node_modules/async/asyncify.js +118 -0
- package/dist/node_modules/archiver/node_modules/async/auto.js +333 -0
- package/dist/node_modules/archiver/node_modules/async/autoInject.js +182 -0
- package/dist/node_modules/archiver/node_modules/async/bower.json +17 -0
- package/dist/node_modules/archiver/node_modules/async/cargo.js +63 -0
- package/dist/node_modules/archiver/node_modules/async/cargoQueue.js +71 -0
- package/dist/node_modules/archiver/node_modules/async/compose.js +55 -0
- package/dist/node_modules/archiver/node_modules/async/concat.js +115 -0
- package/dist/node_modules/archiver/node_modules/async/concatLimit.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/concatSeries.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/constant.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/detect.js +96 -0
- package/dist/node_modules/archiver/node_modules/async/detectLimit.js +48 -0
- package/dist/node_modules/archiver/node_modules/async/detectSeries.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/dir.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/dist/async.js +6062 -0
- package/dist/node_modules/archiver/node_modules/async/dist/async.min.js +1 -0
- package/dist/node_modules/archiver/node_modules/async/doDuring.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/doUntil.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/doWhilst.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/during.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/each.js +129 -0
- package/dist/node_modules/archiver/node_modules/async/eachLimit.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/eachOf.js +185 -0
- package/dist/node_modules/archiver/node_modules/async/eachOfLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/eachOfSeries.js +39 -0
- package/dist/node_modules/archiver/node_modules/async/eachSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/ensureAsync.js +67 -0
- package/dist/node_modules/archiver/node_modules/async/every.js +119 -0
- package/dist/node_modules/archiver/node_modules/async/everyLimit.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/everySeries.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/filter.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/filterLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/filterSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/find.js +96 -0
- package/dist/node_modules/archiver/node_modules/async/findLimit.js +48 -0
- package/dist/node_modules/archiver/node_modules/async/findSeries.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/flatMap.js +115 -0
- package/dist/node_modules/archiver/node_modules/async/flatMapLimit.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/flatMapSeries.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/foldl.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/foldr.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/forEach.js +129 -0
- package/dist/node_modules/archiver/node_modules/async/forEachLimit.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOf.js +185 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOfLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOfSeries.js +39 -0
- package/dist/node_modules/archiver/node_modules/async/forEachSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/forever.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/groupBy.js +108 -0
- package/dist/node_modules/archiver/node_modules/async/groupByLimit.js +71 -0
- package/dist/node_modules/archiver/node_modules/async/groupBySeries.js +36 -0
- package/dist/node_modules/archiver/node_modules/async/index.js +588 -0
- package/dist/node_modules/archiver/node_modules/async/inject.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/internal/DoublyLinkedList.js +92 -0
- package/dist/node_modules/archiver/node_modules/async/internal/Heap.js +120 -0
- package/dist/node_modules/archiver/node_modules/async/internal/applyEach.js +29 -0
- package/dist/node_modules/archiver/node_modules/async/internal/asyncEachOfLimit.js +75 -0
- package/dist/node_modules/archiver/node_modules/async/internal/awaitify.js +28 -0
- package/dist/node_modules/archiver/node_modules/async/internal/breakLoop.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/consoleFunc.js +31 -0
- package/dist/node_modules/archiver/node_modules/async/internal/createTester.js +40 -0
- package/dist/node_modules/archiver/node_modules/async/internal/eachOfLimit.js +90 -0
- package/dist/node_modules/archiver/node_modules/async/internal/filter.js +55 -0
- package/dist/node_modules/archiver/node_modules/async/internal/getIterator.js +11 -0
- package/dist/node_modules/archiver/node_modules/async/internal/initialParams.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/internal/isArrayLike.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/iterator.js +57 -0
- package/dist/node_modules/archiver/node_modules/async/internal/map.js +30 -0
- package/dist/node_modules/archiver/node_modules/async/internal/once.js +17 -0
- package/dist/node_modules/archiver/node_modules/async/internal/onlyOnce.js +15 -0
- package/dist/node_modules/archiver/node_modules/async/internal/parallel.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/internal/promiseCallback.js +23 -0
- package/dist/node_modules/archiver/node_modules/async/internal/queue.js +294 -0
- package/dist/node_modules/archiver/node_modules/async/internal/range.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/internal/reject.js +26 -0
- package/dist/node_modules/archiver/node_modules/async/internal/setImmediate.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/internal/withoutIndex.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/wrapAsync.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/log.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/map.js +142 -0
- package/dist/node_modules/archiver/node_modules/async/mapLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/mapSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/mapValues.js +152 -0
- package/dist/node_modules/archiver/node_modules/async/mapValuesLimit.js +61 -0
- package/dist/node_modules/archiver/node_modules/async/mapValuesSeries.js +37 -0
- package/dist/node_modules/archiver/node_modules/async/memoize.js +91 -0
- package/dist/node_modules/archiver/node_modules/async/nextTick.js +52 -0
- package/dist/node_modules/archiver/node_modules/async/package.json +75 -0
- package/dist/node_modules/archiver/node_modules/async/parallel.js +180 -0
- package/dist/node_modules/archiver/node_modules/async/parallelLimit.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/priorityQueue.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/queue.js +24 -0
- package/dist/node_modules/archiver/node_modules/async/race.js +67 -0
- package/dist/node_modules/archiver/node_modules/async/reduce.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/reduceRight.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/reflect.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/reflectAll.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/reject.js +87 -0
- package/dist/node_modules/archiver/node_modules/async/rejectLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/rejectSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/retry.js +159 -0
- package/dist/node_modules/archiver/node_modules/async/retryable.js +77 -0
- package/dist/node_modules/archiver/node_modules/async/select.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/selectLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/selectSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/seq.js +79 -0
- package/dist/node_modules/archiver/node_modules/async/series.js +186 -0
- package/dist/node_modules/archiver/node_modules/async/setImmediate.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/some.js +122 -0
- package/dist/node_modules/archiver/node_modules/async/someLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/someSeries.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/sortBy.js +190 -0
- package/dist/node_modules/archiver/node_modules/async/timeout.js +89 -0
- package/dist/node_modules/archiver/node_modules/async/times.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/timesLimit.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/timesSeries.js +32 -0
- package/dist/node_modules/archiver/node_modules/async/transform.js +173 -0
- package/dist/node_modules/archiver/node_modules/async/tryEach.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/unmemoize.js +25 -0
- package/dist/node_modules/archiver/node_modules/async/until.js +61 -0
- package/dist/node_modules/archiver/node_modules/async/waterfall.js +105 -0
- package/dist/node_modules/archiver/node_modules/async/whilst.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/wrapSync.js +118 -0
- package/dist/node_modules/archiver/package.json +1 -1
- package/dist/node_modules/decompress/package.json +1 -1
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/moment/package.json +1 -1
- package/dist/node_modules/semver/bin/semver.js +7 -15
- package/dist/node_modules/semver/classes/range.js +28 -13
- package/dist/node_modules/semver/classes/semver.js +23 -7
- package/dist/node_modules/semver/functions/diff.js +5 -12
- package/dist/node_modules/semver/index.js +1 -1
- package/dist/node_modules/semver/internal/lrucache.js +40 -0
- package/dist/node_modules/semver/internal/re.js +2 -0
- package/dist/node_modules/semver/package.json +1 -1
- package/package.json +3 -3
- package/dist/client/04e68bac2ed0170d.js +0 -10
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _eachOfSeries = require('./eachOfSeries.js');
|
|
8
|
+
|
|
9
|
+
var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
|
|
10
|
+
|
|
11
|
+
var _once = require('./internal/once.js');
|
|
12
|
+
|
|
13
|
+
var _once2 = _interopRequireDefault(_once);
|
|
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
|
+
* Reduces `coll` into a single value using an async `iteratee` to return each
|
|
27
|
+
* successive step. `memo` is the initial state of the reduction. This function
|
|
28
|
+
* only operates in series.
|
|
29
|
+
*
|
|
30
|
+
* For performance reasons, it may make sense to split a call to this function
|
|
31
|
+
* into a parallel map, and then use the normal `Array.prototype.reduce` on the
|
|
32
|
+
* results. This function is for situations where each step in the reduction
|
|
33
|
+
* needs to be async; if you can get the data before reducing it, then it's
|
|
34
|
+
* probably a good idea to do so.
|
|
35
|
+
*
|
|
36
|
+
* @name reduce
|
|
37
|
+
* @static
|
|
38
|
+
* @memberOf module:Collections
|
|
39
|
+
* @method
|
|
40
|
+
* @alias inject
|
|
41
|
+
* @alias foldl
|
|
42
|
+
* @category Collection
|
|
43
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
44
|
+
* @param {*} memo - The initial state of the reduction.
|
|
45
|
+
* @param {AsyncFunction} iteratee - A function applied to each item in the
|
|
46
|
+
* array to produce the next step in the reduction.
|
|
47
|
+
* The `iteratee` should complete with the next state of the reduction.
|
|
48
|
+
* If the iteratee completes with an error, the reduction is stopped and the
|
|
49
|
+
* main `callback` is immediately called with the error.
|
|
50
|
+
* Invoked with (memo, item, callback).
|
|
51
|
+
* @param {Function} [callback] - A callback which is called after all the
|
|
52
|
+
* `iteratee` functions have finished. Result is the reduced value. Invoked with
|
|
53
|
+
* (err, result).
|
|
54
|
+
* @returns {Promise} a promise, if no callback is passed
|
|
55
|
+
* @example
|
|
56
|
+
*
|
|
57
|
+
* // file1.txt is a file that is 1000 bytes in size
|
|
58
|
+
* // file2.txt is a file that is 2000 bytes in size
|
|
59
|
+
* // file3.txt is a file that is 3000 bytes in size
|
|
60
|
+
* // file4.txt does not exist
|
|
61
|
+
*
|
|
62
|
+
* const fileList = ['file1.txt','file2.txt','file3.txt'];
|
|
63
|
+
* const withMissingFileList = ['file1.txt','file2.txt','file3.txt', 'file4.txt'];
|
|
64
|
+
*
|
|
65
|
+
* // asynchronous function that computes the file size in bytes
|
|
66
|
+
* // file size is added to the memoized value, then returned
|
|
67
|
+
* function getFileSizeInBytes(memo, file, callback) {
|
|
68
|
+
* fs.stat(file, function(err, stat) {
|
|
69
|
+
* if (err) {
|
|
70
|
+
* return callback(err);
|
|
71
|
+
* }
|
|
72
|
+
* callback(null, memo + stat.size);
|
|
73
|
+
* });
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* // Using callbacks
|
|
77
|
+
* async.reduce(fileList, 0, getFileSizeInBytes, function(err, result) {
|
|
78
|
+
* if (err) {
|
|
79
|
+
* console.log(err);
|
|
80
|
+
* } else {
|
|
81
|
+
* console.log(result);
|
|
82
|
+
* // 6000
|
|
83
|
+
* // which is the sum of the file sizes of the three files
|
|
84
|
+
* }
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* // Error Handling
|
|
88
|
+
* async.reduce(withMissingFileList, 0, getFileSizeInBytes, function(err, result) {
|
|
89
|
+
* if (err) {
|
|
90
|
+
* console.log(err);
|
|
91
|
+
* // [ Error: ENOENT: no such file or directory ]
|
|
92
|
+
* } else {
|
|
93
|
+
* console.log(result);
|
|
94
|
+
* }
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* // Using Promises
|
|
98
|
+
* async.reduce(fileList, 0, getFileSizeInBytes)
|
|
99
|
+
* .then( result => {
|
|
100
|
+
* console.log(result);
|
|
101
|
+
* // 6000
|
|
102
|
+
* // which is the sum of the file sizes of the three files
|
|
103
|
+
* }).catch( err => {
|
|
104
|
+
* console.log(err);
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* // Error Handling
|
|
108
|
+
* async.reduce(withMissingFileList, 0, getFileSizeInBytes)
|
|
109
|
+
* .then( result => {
|
|
110
|
+
* console.log(result);
|
|
111
|
+
* }).catch( err => {
|
|
112
|
+
* console.log(err);
|
|
113
|
+
* // [ Error: ENOENT: no such file or directory ]
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* // Using async/await
|
|
117
|
+
* async () => {
|
|
118
|
+
* try {
|
|
119
|
+
* let result = await async.reduce(fileList, 0, getFileSizeInBytes);
|
|
120
|
+
* console.log(result);
|
|
121
|
+
* // 6000
|
|
122
|
+
* // which is the sum of the file sizes of the three files
|
|
123
|
+
* }
|
|
124
|
+
* catch (err) {
|
|
125
|
+
* console.log(err);
|
|
126
|
+
* }
|
|
127
|
+
* }
|
|
128
|
+
*
|
|
129
|
+
* // Error Handling
|
|
130
|
+
* async () => {
|
|
131
|
+
* try {
|
|
132
|
+
* let result = await async.reduce(withMissingFileList, 0, getFileSizeInBytes);
|
|
133
|
+
* console.log(result);
|
|
134
|
+
* }
|
|
135
|
+
* catch (err) {
|
|
136
|
+
* console.log(err);
|
|
137
|
+
* // [ Error: ENOENT: no such file or directory ]
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
*
|
|
141
|
+
*/
|
|
142
|
+
function reduce(coll, memo, iteratee, callback) {
|
|
143
|
+
callback = (0, _once2.default)(callback);
|
|
144
|
+
var _iteratee = (0, _wrapAsync2.default)(iteratee);
|
|
145
|
+
return (0, _eachOfSeries2.default)(coll, (x, i, iterCb) => {
|
|
146
|
+
_iteratee(memo, x, (err, v) => {
|
|
147
|
+
memo = v;
|
|
148
|
+
iterCb(err);
|
|
149
|
+
});
|
|
150
|
+
}, err => callback(err, memo));
|
|
151
|
+
}
|
|
152
|
+
exports.default = (0, _awaitify2.default)(reduce, 4);
|
|
153
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation
|
|
7
|
+
// used for queues. This implementation assumes that the node provided by the user can be modified
|
|
8
|
+
// to adjust the next and last properties. We implement only the minimal functionality
|
|
9
|
+
// for queue support.
|
|
10
|
+
class DLL {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.head = this.tail = null;
|
|
13
|
+
this.length = 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
removeLink(node) {
|
|
17
|
+
if (node.prev) node.prev.next = node.next;else this.head = node.next;
|
|
18
|
+
if (node.next) node.next.prev = node.prev;else this.tail = node.prev;
|
|
19
|
+
|
|
20
|
+
node.prev = node.next = null;
|
|
21
|
+
this.length -= 1;
|
|
22
|
+
return node;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
empty() {
|
|
26
|
+
while (this.head) this.shift();
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
insertAfter(node, newNode) {
|
|
31
|
+
newNode.prev = node;
|
|
32
|
+
newNode.next = node.next;
|
|
33
|
+
if (node.next) node.next.prev = newNode;else this.tail = newNode;
|
|
34
|
+
node.next = newNode;
|
|
35
|
+
this.length += 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
insertBefore(node, newNode) {
|
|
39
|
+
newNode.prev = node.prev;
|
|
40
|
+
newNode.next = node;
|
|
41
|
+
if (node.prev) node.prev.next = newNode;else this.head = newNode;
|
|
42
|
+
node.prev = newNode;
|
|
43
|
+
this.length += 1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
unshift(node) {
|
|
47
|
+
if (this.head) this.insertBefore(this.head, node);else setInitial(this, node);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
push(node) {
|
|
51
|
+
if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
shift() {
|
|
55
|
+
return this.head && this.removeLink(this.head);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
pop() {
|
|
59
|
+
return this.tail && this.removeLink(this.tail);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
toArray() {
|
|
63
|
+
return [...this];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
*[Symbol.iterator]() {
|
|
67
|
+
var cur = this.head;
|
|
68
|
+
while (cur) {
|
|
69
|
+
yield cur.data;
|
|
70
|
+
cur = cur.next;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
remove(testFn) {
|
|
75
|
+
var curr = this.head;
|
|
76
|
+
while (curr) {
|
|
77
|
+
var { next } = curr;
|
|
78
|
+
if (testFn(curr)) {
|
|
79
|
+
this.removeLink(curr);
|
|
80
|
+
}
|
|
81
|
+
curr = next;
|
|
82
|
+
}
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
exports.default = DLL;
|
|
88
|
+
function setInitial(dll, node) {
|
|
89
|
+
dll.length = 1;
|
|
90
|
+
dll.head = dll.tail = node;
|
|
91
|
+
}
|
|
92
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
// Binary min-heap implementation used for priority queue.
|
|
7
|
+
// Implementation is stable, i.e. push time is considered for equal priorities
|
|
8
|
+
class Heap {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.heap = [];
|
|
11
|
+
this.pushCount = Number.MIN_SAFE_INTEGER;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get length() {
|
|
15
|
+
return this.heap.length;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
empty() {
|
|
19
|
+
this.heap = [];
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
percUp(index) {
|
|
24
|
+
let p;
|
|
25
|
+
|
|
26
|
+
while (index > 0 && smaller(this.heap[index], this.heap[p = parent(index)])) {
|
|
27
|
+
let t = this.heap[index];
|
|
28
|
+
this.heap[index] = this.heap[p];
|
|
29
|
+
this.heap[p] = t;
|
|
30
|
+
|
|
31
|
+
index = p;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
percDown(index) {
|
|
36
|
+
let l;
|
|
37
|
+
|
|
38
|
+
while ((l = leftChi(index)) < this.heap.length) {
|
|
39
|
+
if (l + 1 < this.heap.length && smaller(this.heap[l + 1], this.heap[l])) {
|
|
40
|
+
l = l + 1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (smaller(this.heap[index], this.heap[l])) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let t = this.heap[index];
|
|
48
|
+
this.heap[index] = this.heap[l];
|
|
49
|
+
this.heap[l] = t;
|
|
50
|
+
|
|
51
|
+
index = l;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
push(node) {
|
|
56
|
+
node.pushCount = ++this.pushCount;
|
|
57
|
+
this.heap.push(node);
|
|
58
|
+
this.percUp(this.heap.length - 1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
unshift(node) {
|
|
62
|
+
return this.heap.push(node);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
shift() {
|
|
66
|
+
let [top] = this.heap;
|
|
67
|
+
|
|
68
|
+
this.heap[0] = this.heap[this.heap.length - 1];
|
|
69
|
+
this.heap.pop();
|
|
70
|
+
this.percDown(0);
|
|
71
|
+
|
|
72
|
+
return top;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
toArray() {
|
|
76
|
+
return [...this];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
*[Symbol.iterator]() {
|
|
80
|
+
for (let i = 0; i < this.heap.length; i++) {
|
|
81
|
+
yield this.heap[i].data;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
remove(testFn) {
|
|
86
|
+
let j = 0;
|
|
87
|
+
for (let i = 0; i < this.heap.length; i++) {
|
|
88
|
+
if (!testFn(this.heap[i])) {
|
|
89
|
+
this.heap[j] = this.heap[i];
|
|
90
|
+
j++;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.heap.splice(j);
|
|
95
|
+
|
|
96
|
+
for (let i = parent(this.heap.length - 1); i >= 0; i--) {
|
|
97
|
+
this.percDown(i);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
exports.default = Heap;
|
|
105
|
+
function leftChi(i) {
|
|
106
|
+
return (i << 1) + 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function parent(i) {
|
|
110
|
+
return (i + 1 >> 1) - 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function smaller(x, y) {
|
|
114
|
+
if (x.priority !== y.priority) {
|
|
115
|
+
return x.priority < y.priority;
|
|
116
|
+
} else {
|
|
117
|
+
return x.pushCount < y.pushCount;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
exports.default = function (eachfn) {
|
|
8
|
+
return function applyEach(fns, ...callArgs) {
|
|
9
|
+
const go = (0, _awaitify2.default)(function (callback) {
|
|
10
|
+
var that = this;
|
|
11
|
+
return eachfn(fns, (fn, cb) => {
|
|
12
|
+
(0, _wrapAsync2.default)(fn).apply(that, callArgs.concat(cb));
|
|
13
|
+
}, callback);
|
|
14
|
+
});
|
|
15
|
+
return go;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
var _wrapAsync = require('./wrapAsync.js');
|
|
20
|
+
|
|
21
|
+
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
22
|
+
|
|
23
|
+
var _awaitify = require('./awaitify.js');
|
|
24
|
+
|
|
25
|
+
var _awaitify2 = _interopRequireDefault(_awaitify);
|
|
26
|
+
|
|
27
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
+
|
|
29
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = asyncEachOfLimit;
|
|
7
|
+
|
|
8
|
+
var _breakLoop = require('./breakLoop.js');
|
|
9
|
+
|
|
10
|
+
var _breakLoop2 = _interopRequireDefault(_breakLoop);
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
// for async generators
|
|
15
|
+
function asyncEachOfLimit(generator, limit, iteratee, callback) {
|
|
16
|
+
let done = false;
|
|
17
|
+
let canceled = false;
|
|
18
|
+
let awaiting = false;
|
|
19
|
+
let running = 0;
|
|
20
|
+
let idx = 0;
|
|
21
|
+
|
|
22
|
+
function replenish() {
|
|
23
|
+
//console.log('replenish')
|
|
24
|
+
if (running >= limit || awaiting || done) return;
|
|
25
|
+
//console.log('replenish awaiting')
|
|
26
|
+
awaiting = true;
|
|
27
|
+
generator.next().then(({ value, done: iterDone }) => {
|
|
28
|
+
//console.log('got value', value)
|
|
29
|
+
if (canceled || done) return;
|
|
30
|
+
awaiting = false;
|
|
31
|
+
if (iterDone) {
|
|
32
|
+
done = true;
|
|
33
|
+
if (running <= 0) {
|
|
34
|
+
//console.log('done nextCb')
|
|
35
|
+
callback(null);
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
running++;
|
|
40
|
+
iteratee(value, idx, iterateeCallback);
|
|
41
|
+
idx++;
|
|
42
|
+
replenish();
|
|
43
|
+
}).catch(handleError);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function iterateeCallback(err, result) {
|
|
47
|
+
//console.log('iterateeCallback')
|
|
48
|
+
running -= 1;
|
|
49
|
+
if (canceled) return;
|
|
50
|
+
if (err) return handleError(err);
|
|
51
|
+
|
|
52
|
+
if (err === false) {
|
|
53
|
+
done = true;
|
|
54
|
+
canceled = true;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (result === _breakLoop2.default || done && running <= 0) {
|
|
59
|
+
done = true;
|
|
60
|
+
//console.log('done iterCb')
|
|
61
|
+
return callback(null);
|
|
62
|
+
}
|
|
63
|
+
replenish();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function handleError(err) {
|
|
67
|
+
if (canceled) return;
|
|
68
|
+
awaiting = false;
|
|
69
|
+
done = true;
|
|
70
|
+
callback(err);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
replenish();
|
|
74
|
+
}
|
|
75
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = awaitify;
|
|
7
|
+
// conditionally promisify a function.
|
|
8
|
+
// only return a promise if a callback is omitted
|
|
9
|
+
function awaitify(asyncFn, arity) {
|
|
10
|
+
if (!arity) arity = asyncFn.length;
|
|
11
|
+
if (!arity) throw new Error('arity is undefined');
|
|
12
|
+
function awaitable(...args) {
|
|
13
|
+
if (typeof args[arity - 1] === 'function') {
|
|
14
|
+
return asyncFn.apply(this, args);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
args[arity - 1] = (err, ...cbArgs) => {
|
|
19
|
+
if (err) return reject(err);
|
|
20
|
+
resolve(cbArgs.length > 1 ? cbArgs : cbArgs[0]);
|
|
21
|
+
};
|
|
22
|
+
asyncFn.apply(this, args);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return awaitable;
|
|
27
|
+
}
|
|
28
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
// A temporary value used to identify if the loop should be broken.
|
|
7
|
+
// See #1064, #1293
|
|
8
|
+
const breakLoop = {};
|
|
9
|
+
exports.default = breakLoop;
|
|
10
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = consoleFunc;
|
|
7
|
+
|
|
8
|
+
var _wrapAsync = require('./wrapAsync.js');
|
|
9
|
+
|
|
10
|
+
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function consoleFunc(name) {
|
|
15
|
+
return (fn, ...args) => (0, _wrapAsync2.default)(fn)(...args, (err, ...resultArgs) => {
|
|
16
|
+
/* istanbul ignore else */
|
|
17
|
+
if (typeof console === 'object') {
|
|
18
|
+
/* istanbul ignore else */
|
|
19
|
+
if (err) {
|
|
20
|
+
/* istanbul ignore else */
|
|
21
|
+
if (console.error) {
|
|
22
|
+
console.error(err);
|
|
23
|
+
}
|
|
24
|
+
} else if (console[name]) {
|
|
25
|
+
/* istanbul ignore else */
|
|
26
|
+
resultArgs.forEach(x => console[name](x));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = _createTester;
|
|
7
|
+
|
|
8
|
+
var _breakLoop = require('./breakLoop.js');
|
|
9
|
+
|
|
10
|
+
var _breakLoop2 = _interopRequireDefault(_breakLoop);
|
|
11
|
+
|
|
12
|
+
var _wrapAsync = require('./wrapAsync.js');
|
|
13
|
+
|
|
14
|
+
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _createTester(check, getResult) {
|
|
19
|
+
return (eachfn, arr, _iteratee, cb) => {
|
|
20
|
+
var testPassed = false;
|
|
21
|
+
var testResult;
|
|
22
|
+
const iteratee = (0, _wrapAsync2.default)(_iteratee);
|
|
23
|
+
eachfn(arr, (value, _, callback) => {
|
|
24
|
+
iteratee(value, (err, result) => {
|
|
25
|
+
if (err || err === false) return callback(err);
|
|
26
|
+
|
|
27
|
+
if (check(result) && !testResult) {
|
|
28
|
+
testPassed = true;
|
|
29
|
+
testResult = getResult(true, value);
|
|
30
|
+
return callback(null, _breakLoop2.default);
|
|
31
|
+
}
|
|
32
|
+
callback();
|
|
33
|
+
});
|
|
34
|
+
}, err => {
|
|
35
|
+
if (err) return cb(err);
|
|
36
|
+
cb(null, testPassed ? testResult : getResult(false));
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _once = require('./once.js');
|
|
8
|
+
|
|
9
|
+
var _once2 = _interopRequireDefault(_once);
|
|
10
|
+
|
|
11
|
+
var _iterator = require('./iterator.js');
|
|
12
|
+
|
|
13
|
+
var _iterator2 = _interopRequireDefault(_iterator);
|
|
14
|
+
|
|
15
|
+
var _onlyOnce = require('./onlyOnce.js');
|
|
16
|
+
|
|
17
|
+
var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
|
|
18
|
+
|
|
19
|
+
var _wrapAsync = require('./wrapAsync.js');
|
|
20
|
+
|
|
21
|
+
var _asyncEachOfLimit = require('./asyncEachOfLimit.js');
|
|
22
|
+
|
|
23
|
+
var _asyncEachOfLimit2 = _interopRequireDefault(_asyncEachOfLimit);
|
|
24
|
+
|
|
25
|
+
var _breakLoop = require('./breakLoop.js');
|
|
26
|
+
|
|
27
|
+
var _breakLoop2 = _interopRequireDefault(_breakLoop);
|
|
28
|
+
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
+
|
|
31
|
+
exports.default = limit => {
|
|
32
|
+
return (obj, iteratee, callback) => {
|
|
33
|
+
callback = (0, _once2.default)(callback);
|
|
34
|
+
if (limit <= 0) {
|
|
35
|
+
throw new RangeError('concurrency limit cannot be less than 1');
|
|
36
|
+
}
|
|
37
|
+
if (!obj) {
|
|
38
|
+
return callback(null);
|
|
39
|
+
}
|
|
40
|
+
if ((0, _wrapAsync.isAsyncGenerator)(obj)) {
|
|
41
|
+
return (0, _asyncEachOfLimit2.default)(obj, limit, iteratee, callback);
|
|
42
|
+
}
|
|
43
|
+
if ((0, _wrapAsync.isAsyncIterable)(obj)) {
|
|
44
|
+
return (0, _asyncEachOfLimit2.default)(obj[Symbol.asyncIterator](), limit, iteratee, callback);
|
|
45
|
+
}
|
|
46
|
+
var nextElem = (0, _iterator2.default)(obj);
|
|
47
|
+
var done = false;
|
|
48
|
+
var canceled = false;
|
|
49
|
+
var running = 0;
|
|
50
|
+
var looping = false;
|
|
51
|
+
|
|
52
|
+
function iterateeCallback(err, value) {
|
|
53
|
+
if (canceled) return;
|
|
54
|
+
running -= 1;
|
|
55
|
+
if (err) {
|
|
56
|
+
done = true;
|
|
57
|
+
callback(err);
|
|
58
|
+
} else if (err === false) {
|
|
59
|
+
done = true;
|
|
60
|
+
canceled = true;
|
|
61
|
+
} else if (value === _breakLoop2.default || done && running <= 0) {
|
|
62
|
+
done = true;
|
|
63
|
+
return callback(null);
|
|
64
|
+
} else if (!looping) {
|
|
65
|
+
replenish();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function replenish() {
|
|
70
|
+
looping = true;
|
|
71
|
+
while (running < limit && !done) {
|
|
72
|
+
var elem = nextElem();
|
|
73
|
+
if (elem === null) {
|
|
74
|
+
done = true;
|
|
75
|
+
if (running <= 0) {
|
|
76
|
+
callback(null);
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
running += 1;
|
|
81
|
+
iteratee(elem.value, elem.key, (0, _onlyOnce2.default)(iterateeCallback));
|
|
82
|
+
}
|
|
83
|
+
looping = false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
replenish();
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
module.exports = exports.default;
|