@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,190 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _map = require('./map.js');
|
|
8
|
+
|
|
9
|
+
var _map2 = _interopRequireDefault(_map);
|
|
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
|
+
* Sorts a list by the results of running each `coll` value through an async
|
|
23
|
+
* `iteratee`.
|
|
24
|
+
*
|
|
25
|
+
* @name sortBy
|
|
26
|
+
* @static
|
|
27
|
+
* @memberOf module:Collections
|
|
28
|
+
* @method
|
|
29
|
+
* @category Collection
|
|
30
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
31
|
+
* @param {AsyncFunction} iteratee - An async function to apply to each item in
|
|
32
|
+
* `coll`.
|
|
33
|
+
* The iteratee should complete with a value to use as the sort criteria as
|
|
34
|
+
* its `result`.
|
|
35
|
+
* Invoked with (item, callback).
|
|
36
|
+
* @param {Function} callback - A callback which is called after all the
|
|
37
|
+
* `iteratee` functions have finished, or an error occurs. Results is the items
|
|
38
|
+
* from the original `coll` sorted by the values returned by the `iteratee`
|
|
39
|
+
* calls. Invoked with (err, results).
|
|
40
|
+
* @returns {Promise} a promise, if no callback passed
|
|
41
|
+
* @example
|
|
42
|
+
*
|
|
43
|
+
* // bigfile.txt is a file that is 251100 bytes in size
|
|
44
|
+
* // mediumfile.txt is a file that is 11000 bytes in size
|
|
45
|
+
* // smallfile.txt is a file that is 121 bytes in size
|
|
46
|
+
*
|
|
47
|
+
* // asynchronous function that returns the file size in bytes
|
|
48
|
+
* function getFileSizeInBytes(file, callback) {
|
|
49
|
+
* fs.stat(file, function(err, stat) {
|
|
50
|
+
* if (err) {
|
|
51
|
+
* return callback(err);
|
|
52
|
+
* }
|
|
53
|
+
* callback(null, stat.size);
|
|
54
|
+
* });
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* // Using callbacks
|
|
58
|
+
* async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes,
|
|
59
|
+
* function(err, results) {
|
|
60
|
+
* if (err) {
|
|
61
|
+
* console.log(err);
|
|
62
|
+
* } else {
|
|
63
|
+
* console.log(results);
|
|
64
|
+
* // results is now the original array of files sorted by
|
|
65
|
+
* // file size (ascending by default), e.g.
|
|
66
|
+
* // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
* );
|
|
70
|
+
*
|
|
71
|
+
* // By modifying the callback parameter the
|
|
72
|
+
* // sorting order can be influenced:
|
|
73
|
+
*
|
|
74
|
+
* // ascending order
|
|
75
|
+
* async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], function(file, callback) {
|
|
76
|
+
* getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
|
|
77
|
+
* if (getFileSizeErr) return callback(getFileSizeErr);
|
|
78
|
+
* callback(null, fileSize);
|
|
79
|
+
* });
|
|
80
|
+
* }, function(err, results) {
|
|
81
|
+
* if (err) {
|
|
82
|
+
* console.log(err);
|
|
83
|
+
* } else {
|
|
84
|
+
* console.log(results);
|
|
85
|
+
* // results is now the original array of files sorted by
|
|
86
|
+
* // file size (ascending by default), e.g.
|
|
87
|
+
* // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
* );
|
|
91
|
+
*
|
|
92
|
+
* // descending order
|
|
93
|
+
* async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], function(file, callback) {
|
|
94
|
+
* getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
|
|
95
|
+
* if (getFileSizeErr) {
|
|
96
|
+
* return callback(getFileSizeErr);
|
|
97
|
+
* }
|
|
98
|
+
* callback(null, fileSize * -1);
|
|
99
|
+
* });
|
|
100
|
+
* }, function(err, results) {
|
|
101
|
+
* if (err) {
|
|
102
|
+
* console.log(err);
|
|
103
|
+
* } else {
|
|
104
|
+
* console.log(results);
|
|
105
|
+
* // results is now the original array of files sorted by
|
|
106
|
+
* // file size (ascending by default), e.g.
|
|
107
|
+
* // [ 'bigfile.txt', 'mediumfile.txt', 'smallfile.txt']
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
* );
|
|
111
|
+
*
|
|
112
|
+
* // Error handling
|
|
113
|
+
* async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes,
|
|
114
|
+
* function(err, results) {
|
|
115
|
+
* if (err) {
|
|
116
|
+
* console.log(err);
|
|
117
|
+
* // [ Error: ENOENT: no such file or directory ]
|
|
118
|
+
* } else {
|
|
119
|
+
* console.log(results);
|
|
120
|
+
* }
|
|
121
|
+
* }
|
|
122
|
+
* );
|
|
123
|
+
*
|
|
124
|
+
* // Using Promises
|
|
125
|
+
* async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes)
|
|
126
|
+
* .then( results => {
|
|
127
|
+
* console.log(results);
|
|
128
|
+
* // results is now the original array of files sorted by
|
|
129
|
+
* // file size (ascending by default), e.g.
|
|
130
|
+
* // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
|
|
131
|
+
* }).catch( err => {
|
|
132
|
+
* console.log(err);
|
|
133
|
+
* });
|
|
134
|
+
*
|
|
135
|
+
* // Error handling
|
|
136
|
+
* async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes)
|
|
137
|
+
* .then( results => {
|
|
138
|
+
* console.log(results);
|
|
139
|
+
* }).catch( err => {
|
|
140
|
+
* console.log(err);
|
|
141
|
+
* // [ Error: ENOENT: no such file or directory ]
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* // Using async/await
|
|
145
|
+
* (async () => {
|
|
146
|
+
* try {
|
|
147
|
+
* let results = await async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes);
|
|
148
|
+
* console.log(results);
|
|
149
|
+
* // results is now the original array of files sorted by
|
|
150
|
+
* // file size (ascending by default), e.g.
|
|
151
|
+
* // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
|
|
152
|
+
* }
|
|
153
|
+
* catch (err) {
|
|
154
|
+
* console.log(err);
|
|
155
|
+
* }
|
|
156
|
+
* })();
|
|
157
|
+
*
|
|
158
|
+
* // Error handling
|
|
159
|
+
* async () => {
|
|
160
|
+
* try {
|
|
161
|
+
* let results = await async.sortBy(['missingfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes);
|
|
162
|
+
* console.log(results);
|
|
163
|
+
* }
|
|
164
|
+
* catch (err) {
|
|
165
|
+
* console.log(err);
|
|
166
|
+
* // [ Error: ENOENT: no such file or directory ]
|
|
167
|
+
* }
|
|
168
|
+
* }
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
function sortBy(coll, iteratee, callback) {
|
|
172
|
+
var _iteratee = (0, _wrapAsync2.default)(iteratee);
|
|
173
|
+
return (0, _map2.default)(coll, (x, iterCb) => {
|
|
174
|
+
_iteratee(x, (err, criteria) => {
|
|
175
|
+
if (err) return iterCb(err);
|
|
176
|
+
iterCb(err, { value: x, criteria });
|
|
177
|
+
});
|
|
178
|
+
}, (err, results) => {
|
|
179
|
+
if (err) return callback(err);
|
|
180
|
+
callback(null, results.sort(comparator).map(v => v.value));
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
function comparator(left, right) {
|
|
184
|
+
var a = left.criteria,
|
|
185
|
+
b = right.criteria;
|
|
186
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.default = (0, _awaitify2.default)(sortBy, 3);
|
|
190
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = timeout;
|
|
7
|
+
|
|
8
|
+
var _initialParams = require('./internal/initialParams.js');
|
|
9
|
+
|
|
10
|
+
var _initialParams2 = _interopRequireDefault(_initialParams);
|
|
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
|
+
* Sets a time limit on an asynchronous function. If the function does not call
|
|
20
|
+
* its callback within the specified milliseconds, it will be called with a
|
|
21
|
+
* timeout error. The code property for the error object will be `'ETIMEDOUT'`.
|
|
22
|
+
*
|
|
23
|
+
* @name timeout
|
|
24
|
+
* @static
|
|
25
|
+
* @memberOf module:Utils
|
|
26
|
+
* @method
|
|
27
|
+
* @category Util
|
|
28
|
+
* @param {AsyncFunction} asyncFn - The async function to limit in time.
|
|
29
|
+
* @param {number} milliseconds - The specified time limit.
|
|
30
|
+
* @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
|
|
31
|
+
* to timeout Error for more information..
|
|
32
|
+
* @returns {AsyncFunction} Returns a wrapped function that can be used with any
|
|
33
|
+
* of the control flow functions.
|
|
34
|
+
* Invoke this function with the same parameters as you would `asyncFunc`.
|
|
35
|
+
* @example
|
|
36
|
+
*
|
|
37
|
+
* function myFunction(foo, callback) {
|
|
38
|
+
* doAsyncTask(foo, function(err, data) {
|
|
39
|
+
* // handle errors
|
|
40
|
+
* if (err) return callback(err);
|
|
41
|
+
*
|
|
42
|
+
* // do some stuff ...
|
|
43
|
+
*
|
|
44
|
+
* // return processed data
|
|
45
|
+
* return callback(null, data);
|
|
46
|
+
* });
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* var wrapped = async.timeout(myFunction, 1000);
|
|
50
|
+
*
|
|
51
|
+
* // call `wrapped` as you would `myFunction`
|
|
52
|
+
* wrapped({ bar: 'bar' }, function(err, data) {
|
|
53
|
+
* // if `myFunction` takes < 1000 ms to execute, `err`
|
|
54
|
+
* // and `data` will have their expected values
|
|
55
|
+
*
|
|
56
|
+
* // else `err` will be an Error with the code 'ETIMEDOUT'
|
|
57
|
+
* });
|
|
58
|
+
*/
|
|
59
|
+
function timeout(asyncFn, milliseconds, info) {
|
|
60
|
+
var fn = (0, _wrapAsync2.default)(asyncFn);
|
|
61
|
+
|
|
62
|
+
return (0, _initialParams2.default)((args, callback) => {
|
|
63
|
+
var timedOut = false;
|
|
64
|
+
var timer;
|
|
65
|
+
|
|
66
|
+
function timeoutCallback() {
|
|
67
|
+
var name = asyncFn.name || 'anonymous';
|
|
68
|
+
var error = new Error('Callback function "' + name + '" timed out.');
|
|
69
|
+
error.code = 'ETIMEDOUT';
|
|
70
|
+
if (info) {
|
|
71
|
+
error.info = info;
|
|
72
|
+
}
|
|
73
|
+
timedOut = true;
|
|
74
|
+
callback(error);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
args.push((...cbArgs) => {
|
|
78
|
+
if (!timedOut) {
|
|
79
|
+
callback(...cbArgs);
|
|
80
|
+
clearTimeout(timer);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// setup timer and call original function
|
|
85
|
+
timer = setTimeout(timeoutCallback, milliseconds);
|
|
86
|
+
fn(...args);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = times;
|
|
7
|
+
|
|
8
|
+
var _timesLimit = require('./timesLimit.js');
|
|
9
|
+
|
|
10
|
+
var _timesLimit2 = _interopRequireDefault(_timesLimit);
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Calls the `iteratee` function `n` times, and accumulates results in the same
|
|
16
|
+
* manner you would use with [map]{@link module:Collections.map}.
|
|
17
|
+
*
|
|
18
|
+
* @name times
|
|
19
|
+
* @static
|
|
20
|
+
* @memberOf module:ControlFlow
|
|
21
|
+
* @method
|
|
22
|
+
* @see [async.map]{@link module:Collections.map}
|
|
23
|
+
* @category Control Flow
|
|
24
|
+
* @param {number} n - The number of times to run the function.
|
|
25
|
+
* @param {AsyncFunction} iteratee - The async function to call `n` times.
|
|
26
|
+
* Invoked with the iteration index and a callback: (n, next).
|
|
27
|
+
* @param {Function} callback - see {@link module:Collections.map}.
|
|
28
|
+
* @returns {Promise} a promise, if no callback is provided
|
|
29
|
+
* @example
|
|
30
|
+
*
|
|
31
|
+
* // Pretend this is some complicated async factory
|
|
32
|
+
* var createUser = function(id, callback) {
|
|
33
|
+
* callback(null, {
|
|
34
|
+
* id: 'user' + id
|
|
35
|
+
* });
|
|
36
|
+
* };
|
|
37
|
+
*
|
|
38
|
+
* // generate 5 users
|
|
39
|
+
* async.times(5, function(n, next) {
|
|
40
|
+
* createUser(n, function(err, user) {
|
|
41
|
+
* next(err, user);
|
|
42
|
+
* });
|
|
43
|
+
* }, function(err, users) {
|
|
44
|
+
* // we should now have 5 users
|
|
45
|
+
* });
|
|
46
|
+
*/
|
|
47
|
+
function times(n, iteratee, callback) {
|
|
48
|
+
return (0, _timesLimit2.default)(n, Infinity, iteratee, callback);
|
|
49
|
+
}
|
|
50
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = timesLimit;
|
|
7
|
+
|
|
8
|
+
var _mapLimit = require('./mapLimit.js');
|
|
9
|
+
|
|
10
|
+
var _mapLimit2 = _interopRequireDefault(_mapLimit);
|
|
11
|
+
|
|
12
|
+
var _range = require('./internal/range.js');
|
|
13
|
+
|
|
14
|
+
var _range2 = _interopRequireDefault(_range);
|
|
15
|
+
|
|
16
|
+
var _wrapAsync = require('./internal/wrapAsync.js');
|
|
17
|
+
|
|
18
|
+
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
|
|
24
|
+
* time.
|
|
25
|
+
*
|
|
26
|
+
* @name timesLimit
|
|
27
|
+
* @static
|
|
28
|
+
* @memberOf module:ControlFlow
|
|
29
|
+
* @method
|
|
30
|
+
* @see [async.times]{@link module:ControlFlow.times}
|
|
31
|
+
* @category Control Flow
|
|
32
|
+
* @param {number} count - The number of times to run the function.
|
|
33
|
+
* @param {number} limit - The maximum number of async operations at a time.
|
|
34
|
+
* @param {AsyncFunction} iteratee - The async function to call `n` times.
|
|
35
|
+
* Invoked with the iteration index and a callback: (n, next).
|
|
36
|
+
* @param {Function} callback - see [async.map]{@link module:Collections.map}.
|
|
37
|
+
* @returns {Promise} a promise, if no callback is provided
|
|
38
|
+
*/
|
|
39
|
+
function timesLimit(count, limit, iteratee, callback) {
|
|
40
|
+
var _iteratee = (0, _wrapAsync2.default)(iteratee);
|
|
41
|
+
return (0, _mapLimit2.default)((0, _range2.default)(count), limit, _iteratee, callback);
|
|
42
|
+
}
|
|
43
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = timesSeries;
|
|
7
|
+
|
|
8
|
+
var _timesLimit = require('./timesLimit.js');
|
|
9
|
+
|
|
10
|
+
var _timesLimit2 = _interopRequireDefault(_timesLimit);
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
|
|
16
|
+
*
|
|
17
|
+
* @name timesSeries
|
|
18
|
+
* @static
|
|
19
|
+
* @memberOf module:ControlFlow
|
|
20
|
+
* @method
|
|
21
|
+
* @see [async.times]{@link module:ControlFlow.times}
|
|
22
|
+
* @category Control Flow
|
|
23
|
+
* @param {number} n - The number of times to run the function.
|
|
24
|
+
* @param {AsyncFunction} iteratee - The async function to call `n` times.
|
|
25
|
+
* Invoked with the iteration index and a callback: (n, next).
|
|
26
|
+
* @param {Function} callback - see {@link module:Collections.map}.
|
|
27
|
+
* @returns {Promise} a promise, if no callback is provided
|
|
28
|
+
*/
|
|
29
|
+
function timesSeries(n, iteratee, callback) {
|
|
30
|
+
return (0, _timesLimit2.default)(n, 1, iteratee, callback);
|
|
31
|
+
}
|
|
32
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transform;
|
|
7
|
+
|
|
8
|
+
var _eachOf = require('./eachOf.js');
|
|
9
|
+
|
|
10
|
+
var _eachOf2 = _interopRequireDefault(_eachOf);
|
|
11
|
+
|
|
12
|
+
var _once = require('./internal/once.js');
|
|
13
|
+
|
|
14
|
+
var _once2 = _interopRequireDefault(_once);
|
|
15
|
+
|
|
16
|
+
var _wrapAsync = require('./internal/wrapAsync.js');
|
|
17
|
+
|
|
18
|
+
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
19
|
+
|
|
20
|
+
var _promiseCallback = require('./internal/promiseCallback.js');
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A relative of `reduce`. Takes an Object or Array, and iterates over each
|
|
26
|
+
* element in parallel, each step potentially mutating an `accumulator` value.
|
|
27
|
+
* The type of the accumulator defaults to the type of collection passed in.
|
|
28
|
+
*
|
|
29
|
+
* @name transform
|
|
30
|
+
* @static
|
|
31
|
+
* @memberOf module:Collections
|
|
32
|
+
* @method
|
|
33
|
+
* @category Collection
|
|
34
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
35
|
+
* @param {*} [accumulator] - The initial state of the transform. If omitted,
|
|
36
|
+
* it will default to an empty Object or Array, depending on the type of `coll`
|
|
37
|
+
* @param {AsyncFunction} iteratee - A function applied to each item in the
|
|
38
|
+
* collection that potentially modifies the accumulator.
|
|
39
|
+
* Invoked with (accumulator, item, key, callback).
|
|
40
|
+
* @param {Function} [callback] - A callback which is called after all the
|
|
41
|
+
* `iteratee` functions have finished. Result is the transformed accumulator.
|
|
42
|
+
* Invoked with (err, result).
|
|
43
|
+
* @returns {Promise} a promise, if no callback provided
|
|
44
|
+
* @example
|
|
45
|
+
*
|
|
46
|
+
* // file1.txt is a file that is 1000 bytes in size
|
|
47
|
+
* // file2.txt is a file that is 2000 bytes in size
|
|
48
|
+
* // file3.txt is a file that is 3000 bytes in size
|
|
49
|
+
*
|
|
50
|
+
* // helper function that returns human-readable size format from bytes
|
|
51
|
+
* function formatBytes(bytes, decimals = 2) {
|
|
52
|
+
* // implementation not included for brevity
|
|
53
|
+
* return humanReadbleFilesize;
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* const fileList = ['file1.txt','file2.txt','file3.txt'];
|
|
57
|
+
*
|
|
58
|
+
* // asynchronous function that returns the file size, transformed to human-readable format
|
|
59
|
+
* // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc.
|
|
60
|
+
* function transformFileSize(acc, value, key, callback) {
|
|
61
|
+
* fs.stat(value, function(err, stat) {
|
|
62
|
+
* if (err) {
|
|
63
|
+
* return callback(err);
|
|
64
|
+
* }
|
|
65
|
+
* acc[key] = formatBytes(stat.size);
|
|
66
|
+
* callback(null);
|
|
67
|
+
* });
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* // Using callbacks
|
|
71
|
+
* async.transform(fileList, transformFileSize, function(err, result) {
|
|
72
|
+
* if(err) {
|
|
73
|
+
* console.log(err);
|
|
74
|
+
* } else {
|
|
75
|
+
* console.log(result);
|
|
76
|
+
* // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
|
|
77
|
+
* }
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Using Promises
|
|
81
|
+
* async.transform(fileList, transformFileSize)
|
|
82
|
+
* .then(result => {
|
|
83
|
+
* console.log(result);
|
|
84
|
+
* // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
|
|
85
|
+
* }).catch(err => {
|
|
86
|
+
* console.log(err);
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* // Using async/await
|
|
90
|
+
* (async () => {
|
|
91
|
+
* try {
|
|
92
|
+
* let result = await async.transform(fileList, transformFileSize);
|
|
93
|
+
* console.log(result);
|
|
94
|
+
* // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
|
|
95
|
+
* }
|
|
96
|
+
* catch (err) {
|
|
97
|
+
* console.log(err);
|
|
98
|
+
* }
|
|
99
|
+
* })();
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
*
|
|
103
|
+
* // file1.txt is a file that is 1000 bytes in size
|
|
104
|
+
* // file2.txt is a file that is 2000 bytes in size
|
|
105
|
+
* // file3.txt is a file that is 3000 bytes in size
|
|
106
|
+
*
|
|
107
|
+
* // helper function that returns human-readable size format from bytes
|
|
108
|
+
* function formatBytes(bytes, decimals = 2) {
|
|
109
|
+
* // implementation not included for brevity
|
|
110
|
+
* return humanReadbleFilesize;
|
|
111
|
+
* }
|
|
112
|
+
*
|
|
113
|
+
* const fileMap = { f1: 'file1.txt', f2: 'file2.txt', f3: 'file3.txt' };
|
|
114
|
+
*
|
|
115
|
+
* // asynchronous function that returns the file size, transformed to human-readable format
|
|
116
|
+
* // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc.
|
|
117
|
+
* function transformFileSize(acc, value, key, callback) {
|
|
118
|
+
* fs.stat(value, function(err, stat) {
|
|
119
|
+
* if (err) {
|
|
120
|
+
* return callback(err);
|
|
121
|
+
* }
|
|
122
|
+
* acc[key] = formatBytes(stat.size);
|
|
123
|
+
* callback(null);
|
|
124
|
+
* });
|
|
125
|
+
* }
|
|
126
|
+
*
|
|
127
|
+
* // Using callbacks
|
|
128
|
+
* async.transform(fileMap, transformFileSize, function(err, result) {
|
|
129
|
+
* if(err) {
|
|
130
|
+
* console.log(err);
|
|
131
|
+
* } else {
|
|
132
|
+
* console.log(result);
|
|
133
|
+
* // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
|
|
134
|
+
* }
|
|
135
|
+
* });
|
|
136
|
+
*
|
|
137
|
+
* // Using Promises
|
|
138
|
+
* async.transform(fileMap, transformFileSize)
|
|
139
|
+
* .then(result => {
|
|
140
|
+
* console.log(result);
|
|
141
|
+
* // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
|
|
142
|
+
* }).catch(err => {
|
|
143
|
+
* console.log(err);
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* // Using async/await
|
|
147
|
+
* async () => {
|
|
148
|
+
* try {
|
|
149
|
+
* let result = await async.transform(fileMap, transformFileSize);
|
|
150
|
+
* console.log(result);
|
|
151
|
+
* // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
|
|
152
|
+
* }
|
|
153
|
+
* catch (err) {
|
|
154
|
+
* console.log(err);
|
|
155
|
+
* }
|
|
156
|
+
* }
|
|
157
|
+
*
|
|
158
|
+
*/
|
|
159
|
+
function transform(coll, accumulator, iteratee, callback) {
|
|
160
|
+
if (arguments.length <= 3 && typeof accumulator === 'function') {
|
|
161
|
+
callback = iteratee;
|
|
162
|
+
iteratee = accumulator;
|
|
163
|
+
accumulator = Array.isArray(coll) ? [] : {};
|
|
164
|
+
}
|
|
165
|
+
callback = (0, _once2.default)(callback || (0, _promiseCallback.promiseCallback)());
|
|
166
|
+
var _iteratee = (0, _wrapAsync2.default)(iteratee);
|
|
167
|
+
|
|
168
|
+
(0, _eachOf2.default)(coll, (v, k, cb) => {
|
|
169
|
+
_iteratee(accumulator, v, k, cb);
|
|
170
|
+
}, err => callback(err, accumulator));
|
|
171
|
+
return callback[_promiseCallback.PROMISE_SYMBOL];
|
|
172
|
+
}
|
|
173
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _eachSeries = require('./eachSeries.js');
|
|
8
|
+
|
|
9
|
+
var _eachSeries2 = _interopRequireDefault(_eachSeries);
|
|
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
|
+
* It runs each task in series but stops whenever any of the functions were
|
|
23
|
+
* successful. If one of the tasks were successful, the `callback` will be
|
|
24
|
+
* passed the result of the successful task. If all tasks fail, the callback
|
|
25
|
+
* will be passed the error and result (if any) of the final attempt.
|
|
26
|
+
*
|
|
27
|
+
* @name tryEach
|
|
28
|
+
* @static
|
|
29
|
+
* @memberOf module:ControlFlow
|
|
30
|
+
* @method
|
|
31
|
+
* @category Control Flow
|
|
32
|
+
* @param {Array|Iterable|AsyncIterable|Object} tasks - A collection containing functions to
|
|
33
|
+
* run, each function is passed a `callback(err, result)` it must call on
|
|
34
|
+
* completion with an error `err` (which can be `null`) and an optional `result`
|
|
35
|
+
* value.
|
|
36
|
+
* @param {Function} [callback] - An optional callback which is called when one
|
|
37
|
+
* of the tasks has succeeded, or all have failed. It receives the `err` and
|
|
38
|
+
* `result` arguments of the last attempt at completing the `task`. Invoked with
|
|
39
|
+
* (err, results).
|
|
40
|
+
* @returns {Promise} a promise, if no callback is passed
|
|
41
|
+
* @example
|
|
42
|
+
* async.tryEach([
|
|
43
|
+
* function getDataFromFirstWebsite(callback) {
|
|
44
|
+
* // Try getting the data from the first website
|
|
45
|
+
* callback(err, data);
|
|
46
|
+
* },
|
|
47
|
+
* function getDataFromSecondWebsite(callback) {
|
|
48
|
+
* // First website failed,
|
|
49
|
+
* // Try getting the data from the backup website
|
|
50
|
+
* callback(err, data);
|
|
51
|
+
* }
|
|
52
|
+
* ],
|
|
53
|
+
* // optional callback
|
|
54
|
+
* function(err, results) {
|
|
55
|
+
* Now do something with the data.
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
function tryEach(tasks, callback) {
|
|
60
|
+
var error = null;
|
|
61
|
+
var result;
|
|
62
|
+
return (0, _eachSeries2.default)(tasks, (task, taskCb) => {
|
|
63
|
+
(0, _wrapAsync2.default)(task)((err, ...args) => {
|
|
64
|
+
if (err === false) return taskCb(err);
|
|
65
|
+
|
|
66
|
+
if (args.length < 2) {
|
|
67
|
+
[result] = args;
|
|
68
|
+
} else {
|
|
69
|
+
result = args;
|
|
70
|
+
}
|
|
71
|
+
error = err;
|
|
72
|
+
taskCb(err ? null : {});
|
|
73
|
+
});
|
|
74
|
+
}, () => callback(error, result));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
exports.default = (0, _awaitify2.default)(tryEach);
|
|
78
|
+
module.exports = exports.default;
|
|
@@ -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;
|