@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,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = reflect;
|
|
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
|
+
* Wraps the async function in another function that always completes with a
|
|
20
|
+
* result object, even when it errors.
|
|
21
|
+
*
|
|
22
|
+
* The result object has either the property `error` or `value`.
|
|
23
|
+
*
|
|
24
|
+
* @name reflect
|
|
25
|
+
* @static
|
|
26
|
+
* @memberOf module:Utils
|
|
27
|
+
* @method
|
|
28
|
+
* @category Util
|
|
29
|
+
* @param {AsyncFunction} fn - The async function you want to wrap
|
|
30
|
+
* @returns {Function} - A function that always passes null to it's callback as
|
|
31
|
+
* the error. The second argument to the callback will be an `object` with
|
|
32
|
+
* either an `error` or a `value` property.
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
35
|
+
* async.parallel([
|
|
36
|
+
* async.reflect(function(callback) {
|
|
37
|
+
* // do some stuff ...
|
|
38
|
+
* callback(null, 'one');
|
|
39
|
+
* }),
|
|
40
|
+
* async.reflect(function(callback) {
|
|
41
|
+
* // do some more stuff but error ...
|
|
42
|
+
* callback('bad stuff happened');
|
|
43
|
+
* }),
|
|
44
|
+
* async.reflect(function(callback) {
|
|
45
|
+
* // do some more stuff ...
|
|
46
|
+
* callback(null, 'two');
|
|
47
|
+
* })
|
|
48
|
+
* ],
|
|
49
|
+
* // optional callback
|
|
50
|
+
* function(err, results) {
|
|
51
|
+
* // values
|
|
52
|
+
* // results[0].value = 'one'
|
|
53
|
+
* // results[1].error = 'bad stuff happened'
|
|
54
|
+
* // results[2].value = 'two'
|
|
55
|
+
* });
|
|
56
|
+
*/
|
|
57
|
+
function reflect(fn) {
|
|
58
|
+
var _fn = (0, _wrapAsync2.default)(fn);
|
|
59
|
+
return (0, _initialParams2.default)(function reflectOn(args, reflectCallback) {
|
|
60
|
+
args.push((error, ...cbArgs) => {
|
|
61
|
+
let retVal = {};
|
|
62
|
+
if (error) {
|
|
63
|
+
retVal.error = error;
|
|
64
|
+
}
|
|
65
|
+
if (cbArgs.length > 0) {
|
|
66
|
+
var value = cbArgs;
|
|
67
|
+
if (cbArgs.length <= 1) {
|
|
68
|
+
[value] = cbArgs;
|
|
69
|
+
}
|
|
70
|
+
retVal.value = value;
|
|
71
|
+
}
|
|
72
|
+
reflectCallback(null, retVal);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return _fn.apply(this, args);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = reflectAll;
|
|
7
|
+
|
|
8
|
+
var _reflect = require('./reflect.js');
|
|
9
|
+
|
|
10
|
+
var _reflect2 = _interopRequireDefault(_reflect);
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A helper function that wraps an array or an object of functions with `reflect`.
|
|
16
|
+
*
|
|
17
|
+
* @name reflectAll
|
|
18
|
+
* @static
|
|
19
|
+
* @memberOf module:Utils
|
|
20
|
+
* @method
|
|
21
|
+
* @see [async.reflect]{@link module:Utils.reflect}
|
|
22
|
+
* @category Util
|
|
23
|
+
* @param {Array|Object|Iterable} tasks - The collection of
|
|
24
|
+
* [async functions]{@link AsyncFunction} to wrap in `async.reflect`.
|
|
25
|
+
* @returns {Array} Returns an array of async functions, each wrapped in
|
|
26
|
+
* `async.reflect`
|
|
27
|
+
* @example
|
|
28
|
+
*
|
|
29
|
+
* let tasks = [
|
|
30
|
+
* function(callback) {
|
|
31
|
+
* setTimeout(function() {
|
|
32
|
+
* callback(null, 'one');
|
|
33
|
+
* }, 200);
|
|
34
|
+
* },
|
|
35
|
+
* function(callback) {
|
|
36
|
+
* // do some more stuff but error ...
|
|
37
|
+
* callback(new Error('bad stuff happened'));
|
|
38
|
+
* },
|
|
39
|
+
* function(callback) {
|
|
40
|
+
* setTimeout(function() {
|
|
41
|
+
* callback(null, 'two');
|
|
42
|
+
* }, 100);
|
|
43
|
+
* }
|
|
44
|
+
* ];
|
|
45
|
+
*
|
|
46
|
+
* async.parallel(async.reflectAll(tasks),
|
|
47
|
+
* // optional callback
|
|
48
|
+
* function(err, results) {
|
|
49
|
+
* // values
|
|
50
|
+
* // results[0].value = 'one'
|
|
51
|
+
* // results[1].error = Error('bad stuff happened')
|
|
52
|
+
* // results[2].value = 'two'
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // an example using an object instead of an array
|
|
56
|
+
* let tasks = {
|
|
57
|
+
* one: function(callback) {
|
|
58
|
+
* setTimeout(function() {
|
|
59
|
+
* callback(null, 'one');
|
|
60
|
+
* }, 200);
|
|
61
|
+
* },
|
|
62
|
+
* two: function(callback) {
|
|
63
|
+
* callback('two');
|
|
64
|
+
* },
|
|
65
|
+
* three: function(callback) {
|
|
66
|
+
* setTimeout(function() {
|
|
67
|
+
* callback(null, 'three');
|
|
68
|
+
* }, 100);
|
|
69
|
+
* }
|
|
70
|
+
* };
|
|
71
|
+
*
|
|
72
|
+
* async.parallel(async.reflectAll(tasks),
|
|
73
|
+
* // optional callback
|
|
74
|
+
* function(err, results) {
|
|
75
|
+
* // values
|
|
76
|
+
* // results.one.value = 'one'
|
|
77
|
+
* // results.two.error = 'two'
|
|
78
|
+
* // results.three.value = 'three'
|
|
79
|
+
* });
|
|
80
|
+
*/
|
|
81
|
+
function reflectAll(tasks) {
|
|
82
|
+
var results;
|
|
83
|
+
if (Array.isArray(tasks)) {
|
|
84
|
+
results = tasks.map(_reflect2.default);
|
|
85
|
+
} else {
|
|
86
|
+
results = {};
|
|
87
|
+
Object.keys(tasks).forEach(key => {
|
|
88
|
+
results[key] = _reflect2.default.call(this, tasks[key]);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return results;
|
|
92
|
+
}
|
|
93
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _reject2 = require('./internal/reject.js');
|
|
8
|
+
|
|
9
|
+
var _reject3 = _interopRequireDefault(_reject2);
|
|
10
|
+
|
|
11
|
+
var _eachOf = require('./eachOf.js');
|
|
12
|
+
|
|
13
|
+
var _eachOf2 = _interopRequireDefault(_eachOf);
|
|
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
|
+
* The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
|
|
23
|
+
*
|
|
24
|
+
* @name reject
|
|
25
|
+
* @static
|
|
26
|
+
* @memberOf module:Collections
|
|
27
|
+
* @method
|
|
28
|
+
* @see [async.filter]{@link module:Collections.filter}
|
|
29
|
+
* @category Collection
|
|
30
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
31
|
+
* @param {Function} iteratee - An async truth test to apply to each item in
|
|
32
|
+
* `coll`.
|
|
33
|
+
* The should complete with a boolean value as its `result`.
|
|
34
|
+
* Invoked with (item, callback).
|
|
35
|
+
* @param {Function} [callback] - A callback which is called after all the
|
|
36
|
+
* `iteratee` functions have finished. Invoked with (err, results).
|
|
37
|
+
* @returns {Promise} a promise, if no callback is passed
|
|
38
|
+
* @example
|
|
39
|
+
*
|
|
40
|
+
* // dir1 is a directory that contains file1.txt, file2.txt
|
|
41
|
+
* // dir2 is a directory that contains file3.txt, file4.txt
|
|
42
|
+
* // dir3 is a directory that contains file5.txt
|
|
43
|
+
*
|
|
44
|
+
* const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
|
|
45
|
+
*
|
|
46
|
+
* // asynchronous function that checks if a file exists
|
|
47
|
+
* function fileExists(file, callback) {
|
|
48
|
+
* fs.access(file, fs.constants.F_OK, (err) => {
|
|
49
|
+
* callback(null, !err);
|
|
50
|
+
* });
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* // Using callbacks
|
|
54
|
+
* async.reject(fileList, fileExists, function(err, results) {
|
|
55
|
+
* // [ 'dir3/file6.txt' ]
|
|
56
|
+
* // results now equals an array of the non-existing files
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // Using Promises
|
|
60
|
+
* async.reject(fileList, fileExists)
|
|
61
|
+
* .then( results => {
|
|
62
|
+
* console.log(results);
|
|
63
|
+
* // [ 'dir3/file6.txt' ]
|
|
64
|
+
* // results now equals an array of the non-existing files
|
|
65
|
+
* }).catch( err => {
|
|
66
|
+
* console.log(err);
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* // Using async/await
|
|
70
|
+
* async () => {
|
|
71
|
+
* try {
|
|
72
|
+
* let results = await async.reject(fileList, fileExists);
|
|
73
|
+
* console.log(results);
|
|
74
|
+
* // [ 'dir3/file6.txt' ]
|
|
75
|
+
* // results now equals an array of the non-existing files
|
|
76
|
+
* }
|
|
77
|
+
* catch (err) {
|
|
78
|
+
* console.log(err);
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
function reject(coll, iteratee, callback) {
|
|
84
|
+
return (0, _reject3.default)(_eachOf2.default, coll, iteratee, callback);
|
|
85
|
+
}
|
|
86
|
+
exports.default = (0, _awaitify2.default)(reject, 3);
|
|
87
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _reject2 = require('./internal/reject.js');
|
|
8
|
+
|
|
9
|
+
var _reject3 = _interopRequireDefault(_reject2);
|
|
10
|
+
|
|
11
|
+
var _eachOfLimit = require('./internal/eachOfLimit.js');
|
|
12
|
+
|
|
13
|
+
var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
|
|
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
|
+
* The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
|
|
23
|
+
* time.
|
|
24
|
+
*
|
|
25
|
+
* @name rejectLimit
|
|
26
|
+
* @static
|
|
27
|
+
* @memberOf module:Collections
|
|
28
|
+
* @method
|
|
29
|
+
* @see [async.reject]{@link module:Collections.reject}
|
|
30
|
+
* @category Collection
|
|
31
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
32
|
+
* @param {number} limit - The maximum number of async operations at a time.
|
|
33
|
+
* @param {Function} iteratee - An async truth test to apply to each item in
|
|
34
|
+
* `coll`.
|
|
35
|
+
* The should complete with a boolean value as its `result`.
|
|
36
|
+
* Invoked with (item, callback).
|
|
37
|
+
* @param {Function} [callback] - A callback which is called after all the
|
|
38
|
+
* `iteratee` functions have finished. Invoked with (err, results).
|
|
39
|
+
* @returns {Promise} a promise, if no callback is passed
|
|
40
|
+
*/
|
|
41
|
+
function rejectLimit(coll, limit, iteratee, callback) {
|
|
42
|
+
return (0, _reject3.default)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
|
|
43
|
+
}
|
|
44
|
+
exports.default = (0, _awaitify2.default)(rejectLimit, 4);
|
|
45
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _reject2 = require('./internal/reject.js');
|
|
8
|
+
|
|
9
|
+
var _reject3 = _interopRequireDefault(_reject2);
|
|
10
|
+
|
|
11
|
+
var _eachOfSeries = require('./eachOfSeries.js');
|
|
12
|
+
|
|
13
|
+
var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
|
|
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
|
+
* The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
|
|
23
|
+
*
|
|
24
|
+
* @name rejectSeries
|
|
25
|
+
* @static
|
|
26
|
+
* @memberOf module:Collections
|
|
27
|
+
* @method
|
|
28
|
+
* @see [async.reject]{@link module:Collections.reject}
|
|
29
|
+
* @category Collection
|
|
30
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
31
|
+
* @param {Function} iteratee - An async truth test to apply to each item in
|
|
32
|
+
* `coll`.
|
|
33
|
+
* The should complete with a boolean value as its `result`.
|
|
34
|
+
* Invoked with (item, callback).
|
|
35
|
+
* @param {Function} [callback] - A callback which is called after all the
|
|
36
|
+
* `iteratee` functions have finished. Invoked with (err, results).
|
|
37
|
+
* @returns {Promise} a promise, if no callback is passed
|
|
38
|
+
*/
|
|
39
|
+
function rejectSeries(coll, iteratee, callback) {
|
|
40
|
+
return (0, _reject3.default)(_eachOfSeries2.default, coll, iteratee, callback);
|
|
41
|
+
}
|
|
42
|
+
exports.default = (0, _awaitify2.default)(rejectSeries, 3);
|
|
43
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = retry;
|
|
7
|
+
|
|
8
|
+
var _wrapAsync = require('./internal/wrapAsync.js');
|
|
9
|
+
|
|
10
|
+
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
11
|
+
|
|
12
|
+
var _promiseCallback = require('./internal/promiseCallback.js');
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function constant(value) {
|
|
17
|
+
return function () {
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Attempts to get a successful response from `task` no more than `times` times
|
|
24
|
+
* before returning an error. If the task is successful, the `callback` will be
|
|
25
|
+
* passed the result of the successful task. If all attempts fail, the callback
|
|
26
|
+
* will be passed the error and result (if any) of the final attempt.
|
|
27
|
+
*
|
|
28
|
+
* @name retry
|
|
29
|
+
* @static
|
|
30
|
+
* @memberOf module:ControlFlow
|
|
31
|
+
* @method
|
|
32
|
+
* @category Control Flow
|
|
33
|
+
* @see [async.retryable]{@link module:ControlFlow.retryable}
|
|
34
|
+
* @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
|
|
35
|
+
* object with `times` and `interval` or a number.
|
|
36
|
+
* * `times` - The number of attempts to make before giving up. The default
|
|
37
|
+
* is `5`.
|
|
38
|
+
* * `interval` - The time to wait between retries, in milliseconds. The
|
|
39
|
+
* default is `0`. The interval may also be specified as a function of the
|
|
40
|
+
* retry count (see example).
|
|
41
|
+
* * `errorFilter` - An optional synchronous function that is invoked on
|
|
42
|
+
* erroneous result. If it returns `true` the retry attempts will continue;
|
|
43
|
+
* if the function returns `false` the retry flow is aborted with the current
|
|
44
|
+
* attempt's error and result being returned to the final callback.
|
|
45
|
+
* Invoked with (err).
|
|
46
|
+
* * If `opts` is a number, the number specifies the number of times to retry,
|
|
47
|
+
* with the default interval of `0`.
|
|
48
|
+
* @param {AsyncFunction} task - An async function to retry.
|
|
49
|
+
* Invoked with (callback).
|
|
50
|
+
* @param {Function} [callback] - An optional callback which is called when the
|
|
51
|
+
* task has succeeded, or after the final failed attempt. It receives the `err`
|
|
52
|
+
* and `result` arguments of the last attempt at completing the `task`. Invoked
|
|
53
|
+
* with (err, results).
|
|
54
|
+
* @returns {Promise} a promise if no callback provided
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
*
|
|
58
|
+
* // The `retry` function can be used as a stand-alone control flow by passing
|
|
59
|
+
* // a callback, as shown below:
|
|
60
|
+
*
|
|
61
|
+
* // try calling apiMethod 3 times
|
|
62
|
+
* async.retry(3, apiMethod, function(err, result) {
|
|
63
|
+
* // do something with the result
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* // try calling apiMethod 3 times, waiting 200 ms between each retry
|
|
67
|
+
* async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
|
|
68
|
+
* // do something with the result
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* // try calling apiMethod 10 times with exponential backoff
|
|
72
|
+
* // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
|
|
73
|
+
* async.retry({
|
|
74
|
+
* times: 10,
|
|
75
|
+
* interval: function(retryCount) {
|
|
76
|
+
* return 50 * Math.pow(2, retryCount);
|
|
77
|
+
* }
|
|
78
|
+
* }, apiMethod, function(err, result) {
|
|
79
|
+
* // do something with the result
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* // try calling apiMethod the default 5 times no delay between each retry
|
|
83
|
+
* async.retry(apiMethod, function(err, result) {
|
|
84
|
+
* // do something with the result
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* // try calling apiMethod only when error condition satisfies, all other
|
|
88
|
+
* // errors will abort the retry control flow and return to final callback
|
|
89
|
+
* async.retry({
|
|
90
|
+
* errorFilter: function(err) {
|
|
91
|
+
* return err.message === 'Temporary error'; // only retry on a specific error
|
|
92
|
+
* }
|
|
93
|
+
* }, apiMethod, function(err, result) {
|
|
94
|
+
* // do something with the result
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* // to retry individual methods that are not as reliable within other
|
|
98
|
+
* // control flow functions, use the `retryable` wrapper:
|
|
99
|
+
* async.auto({
|
|
100
|
+
* users: api.getUsers.bind(api),
|
|
101
|
+
* payments: async.retryable(3, api.getPayments.bind(api))
|
|
102
|
+
* }, function(err, results) {
|
|
103
|
+
* // do something with the results
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
*/
|
|
107
|
+
const DEFAULT_TIMES = 5;
|
|
108
|
+
const DEFAULT_INTERVAL = 0;
|
|
109
|
+
|
|
110
|
+
function retry(opts, task, callback) {
|
|
111
|
+
var options = {
|
|
112
|
+
times: DEFAULT_TIMES,
|
|
113
|
+
intervalFunc: constant(DEFAULT_INTERVAL)
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (arguments.length < 3 && typeof opts === 'function') {
|
|
117
|
+
callback = task || (0, _promiseCallback.promiseCallback)();
|
|
118
|
+
task = opts;
|
|
119
|
+
} else {
|
|
120
|
+
parseTimes(options, opts);
|
|
121
|
+
callback = callback || (0, _promiseCallback.promiseCallback)();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (typeof task !== 'function') {
|
|
125
|
+
throw new Error("Invalid arguments for async.retry");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
var _task = (0, _wrapAsync2.default)(task);
|
|
129
|
+
|
|
130
|
+
var attempt = 1;
|
|
131
|
+
function retryAttempt() {
|
|
132
|
+
_task((err, ...args) => {
|
|
133
|
+
if (err === false) return;
|
|
134
|
+
if (err && attempt++ < options.times && (typeof options.errorFilter != 'function' || options.errorFilter(err))) {
|
|
135
|
+
setTimeout(retryAttempt, options.intervalFunc(attempt - 1));
|
|
136
|
+
} else {
|
|
137
|
+
callback(err, ...args);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
retryAttempt();
|
|
143
|
+
return callback[_promiseCallback.PROMISE_SYMBOL];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function parseTimes(acc, t) {
|
|
147
|
+
if (typeof t === 'object') {
|
|
148
|
+
acc.times = +t.times || DEFAULT_TIMES;
|
|
149
|
+
|
|
150
|
+
acc.intervalFunc = typeof t.interval === 'function' ? t.interval : constant(+t.interval || DEFAULT_INTERVAL);
|
|
151
|
+
|
|
152
|
+
acc.errorFilter = t.errorFilter;
|
|
153
|
+
} else if (typeof t === 'number' || typeof t === 'string') {
|
|
154
|
+
acc.times = +t || DEFAULT_TIMES;
|
|
155
|
+
} else {
|
|
156
|
+
throw new Error("Invalid arguments for async.retry");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = retryable;
|
|
7
|
+
|
|
8
|
+
var _retry = require('./retry.js');
|
|
9
|
+
|
|
10
|
+
var _retry2 = _interopRequireDefault(_retry);
|
|
11
|
+
|
|
12
|
+
var _initialParams = require('./internal/initialParams.js');
|
|
13
|
+
|
|
14
|
+
var _initialParams2 = _interopRequireDefault(_initialParams);
|
|
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 close relative of [`retry`]{@link module:ControlFlow.retry}. This method
|
|
26
|
+
* wraps a task and makes it retryable, rather than immediately calling it
|
|
27
|
+
* with retries.
|
|
28
|
+
*
|
|
29
|
+
* @name retryable
|
|
30
|
+
* @static
|
|
31
|
+
* @memberOf module:ControlFlow
|
|
32
|
+
* @method
|
|
33
|
+
* @see [async.retry]{@link module:ControlFlow.retry}
|
|
34
|
+
* @category Control Flow
|
|
35
|
+
* @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
|
|
36
|
+
* options, exactly the same as from `retry`, except for a `opts.arity` that
|
|
37
|
+
* is the arity of the `task` function, defaulting to `task.length`
|
|
38
|
+
* @param {AsyncFunction} task - the asynchronous function to wrap.
|
|
39
|
+
* This function will be passed any arguments passed to the returned wrapper.
|
|
40
|
+
* Invoked with (...args, callback).
|
|
41
|
+
* @returns {AsyncFunction} The wrapped function, which when invoked, will
|
|
42
|
+
* retry on an error, based on the parameters specified in `opts`.
|
|
43
|
+
* This function will accept the same parameters as `task`.
|
|
44
|
+
* @example
|
|
45
|
+
*
|
|
46
|
+
* async.auto({
|
|
47
|
+
* dep1: async.retryable(3, getFromFlakyService),
|
|
48
|
+
* process: ["dep1", async.retryable(3, function (results, cb) {
|
|
49
|
+
* maybeProcessData(results.dep1, cb);
|
|
50
|
+
* })]
|
|
51
|
+
* }, callback);
|
|
52
|
+
*/
|
|
53
|
+
function retryable(opts, task) {
|
|
54
|
+
if (!task) {
|
|
55
|
+
task = opts;
|
|
56
|
+
opts = null;
|
|
57
|
+
}
|
|
58
|
+
let arity = opts && opts.arity || task.length;
|
|
59
|
+
if ((0, _wrapAsync.isAsync)(task)) {
|
|
60
|
+
arity += 1;
|
|
61
|
+
}
|
|
62
|
+
var _task = (0, _wrapAsync2.default)(task);
|
|
63
|
+
return (0, _initialParams2.default)((args, callback) => {
|
|
64
|
+
if (args.length < arity - 1 || callback == null) {
|
|
65
|
+
args.push(callback);
|
|
66
|
+
callback = (0, _promiseCallback.promiseCallback)();
|
|
67
|
+
}
|
|
68
|
+
function taskFn(cb) {
|
|
69
|
+
_task(...args, cb);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (opts) (0, _retry2.default)(opts, taskFn, callback);else (0, _retry2.default)(taskFn, callback);
|
|
73
|
+
|
|
74
|
+
return callback[_promiseCallback.PROMISE_SYMBOL];
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _filter2 = require('./internal/filter.js');
|
|
8
|
+
|
|
9
|
+
var _filter3 = _interopRequireDefault(_filter2);
|
|
10
|
+
|
|
11
|
+
var _eachOf = require('./eachOf.js');
|
|
12
|
+
|
|
13
|
+
var _eachOf2 = _interopRequireDefault(_eachOf);
|
|
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
|
+
* Returns a new array of all the values in `coll` which pass an async truth
|
|
23
|
+
* test. This operation is performed in parallel, but the results array will be
|
|
24
|
+
* in the same order as the original.
|
|
25
|
+
*
|
|
26
|
+
* @name filter
|
|
27
|
+
* @static
|
|
28
|
+
* @memberOf module:Collections
|
|
29
|
+
* @method
|
|
30
|
+
* @alias select
|
|
31
|
+
* @category Collection
|
|
32
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
33
|
+
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
|
|
34
|
+
* The `iteratee` is passed a `callback(err, truthValue)`, which must be called
|
|
35
|
+
* with a boolean argument once it has completed. Invoked with (item, callback).
|
|
36
|
+
* @param {Function} [callback] - A callback which is called after all the
|
|
37
|
+
* `iteratee` functions have finished. Invoked with (err, results).
|
|
38
|
+
* @returns {Promise} a promise, if no callback provided
|
|
39
|
+
* @example
|
|
40
|
+
*
|
|
41
|
+
* // dir1 is a directory that contains file1.txt, file2.txt
|
|
42
|
+
* // dir2 is a directory that contains file3.txt, file4.txt
|
|
43
|
+
* // dir3 is a directory that contains file5.txt
|
|
44
|
+
*
|
|
45
|
+
* const files = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
|
|
46
|
+
*
|
|
47
|
+
* // asynchronous function that checks if a file exists
|
|
48
|
+
* function fileExists(file, callback) {
|
|
49
|
+
* fs.access(file, fs.constants.F_OK, (err) => {
|
|
50
|
+
* callback(null, !err);
|
|
51
|
+
* });
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* // Using callbacks
|
|
55
|
+
* async.filter(files, fileExists, function(err, results) {
|
|
56
|
+
* if(err) {
|
|
57
|
+
* console.log(err);
|
|
58
|
+
* } else {
|
|
59
|
+
* console.log(results);
|
|
60
|
+
* // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
|
|
61
|
+
* // results is now an array of the existing files
|
|
62
|
+
* }
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* // Using Promises
|
|
66
|
+
* async.filter(files, fileExists)
|
|
67
|
+
* .then(results => {
|
|
68
|
+
* console.log(results);
|
|
69
|
+
* // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
|
|
70
|
+
* // results is now an array of the existing files
|
|
71
|
+
* }).catch(err => {
|
|
72
|
+
* console.log(err);
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* // Using async/await
|
|
76
|
+
* async () => {
|
|
77
|
+
* try {
|
|
78
|
+
* let results = await async.filter(files, fileExists);
|
|
79
|
+
* console.log(results);
|
|
80
|
+
* // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
|
|
81
|
+
* // results is now an array of the existing files
|
|
82
|
+
* }
|
|
83
|
+
* catch (err) {
|
|
84
|
+
* console.log(err);
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
function filter(coll, iteratee, callback) {
|
|
90
|
+
return (0, _filter3.default)(_eachOf2.default, coll, iteratee, callback);
|
|
91
|
+
}
|
|
92
|
+
exports.default = (0, _awaitify2.default)(filter, 3);
|
|
93
|
+
module.exports = exports.default;
|