@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,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _eachOfLimit2 = require('./internal/eachOfLimit.js');
|
|
8
|
+
|
|
9
|
+
var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
|
|
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
|
+
* The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
|
|
23
|
+
* time.
|
|
24
|
+
*
|
|
25
|
+
* @name eachOfLimit
|
|
26
|
+
* @static
|
|
27
|
+
* @memberOf module:Collections
|
|
28
|
+
* @method
|
|
29
|
+
* @see [async.eachOf]{@link module:Collections.eachOf}
|
|
30
|
+
* @alias forEachOfLimit
|
|
31
|
+
* @category Collection
|
|
32
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
33
|
+
* @param {number} limit - The maximum number of async operations at a time.
|
|
34
|
+
* @param {AsyncFunction} iteratee - An async function to apply to each
|
|
35
|
+
* item in `coll`. The `key` is the item's key, or index in the case of an
|
|
36
|
+
* array.
|
|
37
|
+
* Invoked with (item, key, callback).
|
|
38
|
+
* @param {Function} [callback] - A callback which is called when all
|
|
39
|
+
* `iteratee` functions have finished, or an error occurs. Invoked with (err).
|
|
40
|
+
* @returns {Promise} a promise, if a callback is omitted
|
|
41
|
+
*/
|
|
42
|
+
function eachOfLimit(coll, limit, iteratee, callback) {
|
|
43
|
+
return (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.default = (0, _awaitify2.default)(eachOfLimit, 4);
|
|
47
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _eachOfLimit = require('./eachOfLimit.js');
|
|
8
|
+
|
|
9
|
+
var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
|
|
10
|
+
|
|
11
|
+
var _awaitify = require('./internal/awaitify.js');
|
|
12
|
+
|
|
13
|
+
var _awaitify2 = _interopRequireDefault(_awaitify);
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
|
|
19
|
+
*
|
|
20
|
+
* @name eachOfSeries
|
|
21
|
+
* @static
|
|
22
|
+
* @memberOf module:Collections
|
|
23
|
+
* @method
|
|
24
|
+
* @see [async.eachOf]{@link module:Collections.eachOf}
|
|
25
|
+
* @alias forEachOfSeries
|
|
26
|
+
* @category Collection
|
|
27
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
28
|
+
* @param {AsyncFunction} iteratee - An async function to apply to each item in
|
|
29
|
+
* `coll`.
|
|
30
|
+
* Invoked with (item, key, callback).
|
|
31
|
+
* @param {Function} [callback] - A callback which is called when all `iteratee`
|
|
32
|
+
* functions have finished, or an error occurs. Invoked with (err).
|
|
33
|
+
* @returns {Promise} a promise, if a callback is omitted
|
|
34
|
+
*/
|
|
35
|
+
function eachOfSeries(coll, iteratee, callback) {
|
|
36
|
+
return (0, _eachOfLimit2.default)(coll, 1, iteratee, callback);
|
|
37
|
+
}
|
|
38
|
+
exports.default = (0, _awaitify2.default)(eachOfSeries, 3);
|
|
39
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _eachLimit = require('./eachLimit.js');
|
|
8
|
+
|
|
9
|
+
var _eachLimit2 = _interopRequireDefault(_eachLimit);
|
|
10
|
+
|
|
11
|
+
var _awaitify = require('./internal/awaitify.js');
|
|
12
|
+
|
|
13
|
+
var _awaitify2 = _interopRequireDefault(_awaitify);
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
|
|
19
|
+
*
|
|
20
|
+
* Note, that unlike [`each`]{@link module:Collections.each}, this function applies iteratee to each item
|
|
21
|
+
* in series and therefore the iteratee functions will complete in order.
|
|
22
|
+
|
|
23
|
+
* @name eachSeries
|
|
24
|
+
* @static
|
|
25
|
+
* @memberOf module:Collections
|
|
26
|
+
* @method
|
|
27
|
+
* @see [async.each]{@link module:Collections.each}
|
|
28
|
+
* @alias forEachSeries
|
|
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
|
|
32
|
+
* item in `coll`.
|
|
33
|
+
* The array index is not passed to the iteratee.
|
|
34
|
+
* If you need the index, use `eachOfSeries`.
|
|
35
|
+
* Invoked with (item, callback).
|
|
36
|
+
* @param {Function} [callback] - A callback which is called when all
|
|
37
|
+
* `iteratee` functions have finished, or an error occurs. Invoked with (err).
|
|
38
|
+
* @returns {Promise} a promise, if a callback is omitted
|
|
39
|
+
*/
|
|
40
|
+
function eachSeries(coll, iteratee, callback) {
|
|
41
|
+
return (0, _eachLimit2.default)(coll, 1, iteratee, callback);
|
|
42
|
+
}
|
|
43
|
+
exports.default = (0, _awaitify2.default)(eachSeries, 3);
|
|
44
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ensureAsync;
|
|
7
|
+
|
|
8
|
+
var _setImmediate = require('./internal/setImmediate.js');
|
|
9
|
+
|
|
10
|
+
var _setImmediate2 = _interopRequireDefault(_setImmediate);
|
|
11
|
+
|
|
12
|
+
var _wrapAsync = require('./internal/wrapAsync.js');
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Wrap an async function and ensure it calls its callback on a later tick of
|
|
18
|
+
* the event loop. If the function already calls its callback on a next tick,
|
|
19
|
+
* no extra deferral is added. This is useful for preventing stack overflows
|
|
20
|
+
* (`RangeError: Maximum call stack size exceeded`) and generally keeping
|
|
21
|
+
* [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
|
|
22
|
+
* contained. ES2017 `async` functions are returned as-is -- they are immune
|
|
23
|
+
* to Zalgo's corrupting influences, as they always resolve on a later tick.
|
|
24
|
+
*
|
|
25
|
+
* @name ensureAsync
|
|
26
|
+
* @static
|
|
27
|
+
* @memberOf module:Utils
|
|
28
|
+
* @method
|
|
29
|
+
* @category Util
|
|
30
|
+
* @param {AsyncFunction} fn - an async function, one that expects a node-style
|
|
31
|
+
* callback as its last argument.
|
|
32
|
+
* @returns {AsyncFunction} Returns a wrapped function with the exact same call
|
|
33
|
+
* signature as the function passed in.
|
|
34
|
+
* @example
|
|
35
|
+
*
|
|
36
|
+
* function sometimesAsync(arg, callback) {
|
|
37
|
+
* if (cache[arg]) {
|
|
38
|
+
* return callback(null, cache[arg]); // this would be synchronous!!
|
|
39
|
+
* } else {
|
|
40
|
+
* doSomeIO(arg, callback); // this IO would be asynchronous
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* // this has a risk of stack overflows if many results are cached in a row
|
|
45
|
+
* async.mapSeries(args, sometimesAsync, done);
|
|
46
|
+
*
|
|
47
|
+
* // this will defer sometimesAsync's callback if necessary,
|
|
48
|
+
* // preventing stack overflows
|
|
49
|
+
* async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
|
|
50
|
+
*/
|
|
51
|
+
function ensureAsync(fn) {
|
|
52
|
+
if ((0, _wrapAsync.isAsync)(fn)) return fn;
|
|
53
|
+
return function (...args /*, callback*/) {
|
|
54
|
+
var callback = args.pop();
|
|
55
|
+
var sync = true;
|
|
56
|
+
args.push((...innerArgs) => {
|
|
57
|
+
if (sync) {
|
|
58
|
+
(0, _setImmediate2.default)(() => callback(...innerArgs));
|
|
59
|
+
} else {
|
|
60
|
+
callback(...innerArgs);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
fn.apply(this, args);
|
|
64
|
+
sync = false;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _createTester = require('./internal/createTester.js');
|
|
8
|
+
|
|
9
|
+
var _createTester2 = _interopRequireDefault(_createTester);
|
|
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 `true` if every element in `coll` satisfies an async test. If any
|
|
23
|
+
* iteratee call returns `false`, the main `callback` is immediately called.
|
|
24
|
+
*
|
|
25
|
+
* @name every
|
|
26
|
+
* @static
|
|
27
|
+
* @memberOf module:Collections
|
|
28
|
+
* @method
|
|
29
|
+
* @alias all
|
|
30
|
+
* @category Collection
|
|
31
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
32
|
+
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
|
|
33
|
+
* in the collection in parallel.
|
|
34
|
+
* The iteratee must complete with a boolean result value.
|
|
35
|
+
* Invoked with (item, callback).
|
|
36
|
+
* @param {Function} [callback] - A callback which is called after all the
|
|
37
|
+
* `iteratee` functions have finished. Result will be either `true` or `false`
|
|
38
|
+
* depending on the values of the async tests. Invoked with (err, result).
|
|
39
|
+
* @returns {Promise} a promise, if no callback provided
|
|
40
|
+
* @example
|
|
41
|
+
*
|
|
42
|
+
* // dir1 is a directory that contains file1.txt, file2.txt
|
|
43
|
+
* // dir2 is a directory that contains file3.txt, file4.txt
|
|
44
|
+
* // dir3 is a directory that contains file5.txt
|
|
45
|
+
* // dir4 does not exist
|
|
46
|
+
*
|
|
47
|
+
* const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file5.txt'];
|
|
48
|
+
* const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
|
|
49
|
+
*
|
|
50
|
+
* // asynchronous function that checks if a file exists
|
|
51
|
+
* function fileExists(file, callback) {
|
|
52
|
+
* fs.access(file, fs.constants.F_OK, (err) => {
|
|
53
|
+
* callback(null, !err);
|
|
54
|
+
* });
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* // Using callbacks
|
|
58
|
+
* async.every(fileList, fileExists, function(err, result) {
|
|
59
|
+
* console.log(result);
|
|
60
|
+
* // true
|
|
61
|
+
* // result is true since every file exists
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* async.every(withMissingFileList, fileExists, function(err, result) {
|
|
65
|
+
* console.log(result);
|
|
66
|
+
* // false
|
|
67
|
+
* // result is false since NOT every file exists
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Using Promises
|
|
71
|
+
* async.every(fileList, fileExists)
|
|
72
|
+
* .then( result => {
|
|
73
|
+
* console.log(result);
|
|
74
|
+
* // true
|
|
75
|
+
* // result is true since every file exists
|
|
76
|
+
* }).catch( err => {
|
|
77
|
+
* console.log(err);
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* async.every(withMissingFileList, fileExists)
|
|
81
|
+
* .then( result => {
|
|
82
|
+
* console.log(result);
|
|
83
|
+
* // false
|
|
84
|
+
* // result is false since NOT every file exists
|
|
85
|
+
* }).catch( err => {
|
|
86
|
+
* console.log(err);
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* // Using async/await
|
|
90
|
+
* async () => {
|
|
91
|
+
* try {
|
|
92
|
+
* let result = await async.every(fileList, fileExists);
|
|
93
|
+
* console.log(result);
|
|
94
|
+
* // true
|
|
95
|
+
* // result is true since every file exists
|
|
96
|
+
* }
|
|
97
|
+
* catch (err) {
|
|
98
|
+
* console.log(err);
|
|
99
|
+
* }
|
|
100
|
+
* }
|
|
101
|
+
*
|
|
102
|
+
* async () => {
|
|
103
|
+
* try {
|
|
104
|
+
* let result = await async.every(withMissingFileList, fileExists);
|
|
105
|
+
* console.log(result);
|
|
106
|
+
* // false
|
|
107
|
+
* // result is false since NOT every file exists
|
|
108
|
+
* }
|
|
109
|
+
* catch (err) {
|
|
110
|
+
* console.log(err);
|
|
111
|
+
* }
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
function every(coll, iteratee, callback) {
|
|
116
|
+
return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOf2.default, coll, iteratee, callback);
|
|
117
|
+
}
|
|
118
|
+
exports.default = (0, _awaitify2.default)(every, 3);
|
|
119
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _createTester = require('./internal/createTester.js');
|
|
8
|
+
|
|
9
|
+
var _createTester2 = _interopRequireDefault(_createTester);
|
|
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 [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
|
|
23
|
+
*
|
|
24
|
+
* @name everyLimit
|
|
25
|
+
* @static
|
|
26
|
+
* @memberOf module:Collections
|
|
27
|
+
* @method
|
|
28
|
+
* @see [async.every]{@link module:Collections.every}
|
|
29
|
+
* @alias allLimit
|
|
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 {AsyncFunction} iteratee - An async truth test to apply to each item
|
|
34
|
+
* in the collection in parallel.
|
|
35
|
+
* The iteratee must complete with a boolean result value.
|
|
36
|
+
* Invoked with (item, callback).
|
|
37
|
+
* @param {Function} [callback] - A callback which is called after all the
|
|
38
|
+
* `iteratee` functions have finished. Result will be either `true` or `false`
|
|
39
|
+
* depending on the values of the async tests. Invoked with (err, result).
|
|
40
|
+
* @returns {Promise} a promise, if no callback provided
|
|
41
|
+
*/
|
|
42
|
+
function everyLimit(coll, limit, iteratee, callback) {
|
|
43
|
+
return (0, _createTester2.default)(bool => !bool, res => !res)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
|
|
44
|
+
}
|
|
45
|
+
exports.default = (0, _awaitify2.default)(everyLimit, 4);
|
|
46
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _createTester = require('./internal/createTester.js');
|
|
8
|
+
|
|
9
|
+
var _createTester2 = _interopRequireDefault(_createTester);
|
|
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 [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
|
|
23
|
+
*
|
|
24
|
+
* @name everySeries
|
|
25
|
+
* @static
|
|
26
|
+
* @memberOf module:Collections
|
|
27
|
+
* @method
|
|
28
|
+
* @see [async.every]{@link module:Collections.every}
|
|
29
|
+
* @alias allSeries
|
|
30
|
+
* @category Collection
|
|
31
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
32
|
+
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
|
|
33
|
+
* in the collection in series.
|
|
34
|
+
* The iteratee must complete with a boolean result value.
|
|
35
|
+
* Invoked with (item, callback).
|
|
36
|
+
* @param {Function} [callback] - A callback which is called after all the
|
|
37
|
+
* `iteratee` functions have finished. Result will be either `true` or `false`
|
|
38
|
+
* depending on the values of the async tests. Invoked with (err, result).
|
|
39
|
+
* @returns {Promise} a promise, if no callback provided
|
|
40
|
+
*/
|
|
41
|
+
function everySeries(coll, iteratee, callback) {
|
|
42
|
+
return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOfSeries2.default, coll, iteratee, callback);
|
|
43
|
+
}
|
|
44
|
+
exports.default = (0, _awaitify2.default)(everySeries, 3);
|
|
45
|
+
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;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 _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 [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
|
|
23
|
+
* time.
|
|
24
|
+
*
|
|
25
|
+
* @name filterLimit
|
|
26
|
+
* @static
|
|
27
|
+
* @memberOf module:Collections
|
|
28
|
+
* @method
|
|
29
|
+
* @see [async.filter]{@link module:Collections.filter}
|
|
30
|
+
* @alias selectLimit
|
|
31
|
+
* @category Collection
|
|
32
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
33
|
+
* @param {number} limit - The maximum number of async operations at a time.
|
|
34
|
+
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
|
|
35
|
+
* The `iteratee` is passed a `callback(err, truthValue)`, which must be called
|
|
36
|
+
* with a boolean argument once it has completed. 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 provided
|
|
40
|
+
*/
|
|
41
|
+
function filterLimit(coll, limit, iteratee, callback) {
|
|
42
|
+
return (0, _filter3.default)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
|
|
43
|
+
}
|
|
44
|
+
exports.default = (0, _awaitify2.default)(filterLimit, 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 _filter2 = require('./internal/filter.js');
|
|
8
|
+
|
|
9
|
+
var _filter3 = _interopRequireDefault(_filter2);
|
|
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 [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
|
|
23
|
+
*
|
|
24
|
+
* @name filterSeries
|
|
25
|
+
* @static
|
|
26
|
+
* @memberOf module:Collections
|
|
27
|
+
* @method
|
|
28
|
+
* @see [async.filter]{@link module:Collections.filter}
|
|
29
|
+
* @alias selectSeries
|
|
30
|
+
* @category Collection
|
|
31
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
32
|
+
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
|
|
33
|
+
* The `iteratee` is passed a `callback(err, truthValue)`, which must be called
|
|
34
|
+
* with a boolean argument once it has completed. 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 provided
|
|
38
|
+
*/
|
|
39
|
+
function filterSeries(coll, iteratee, callback) {
|
|
40
|
+
return (0, _filter3.default)(_eachOfSeries2.default, coll, iteratee, callback);
|
|
41
|
+
}
|
|
42
|
+
exports.default = (0, _awaitify2.default)(filterSeries, 3);
|
|
43
|
+
module.exports = exports.default;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _createTester = require('./internal/createTester.js');
|
|
8
|
+
|
|
9
|
+
var _createTester2 = _interopRequireDefault(_createTester);
|
|
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 the first value in `coll` that passes an async truth test. The
|
|
23
|
+
* `iteratee` is applied in parallel, meaning the first iteratee to return
|
|
24
|
+
* `true` will fire the detect `callback` with that result. That means the
|
|
25
|
+
* result might not be the first item in the original `coll` (in terms of order)
|
|
26
|
+
* that passes the test.
|
|
27
|
+
|
|
28
|
+
* If order within the original `coll` is important, then look at
|
|
29
|
+
* [`detectSeries`]{@link module:Collections.detectSeries}.
|
|
30
|
+
*
|
|
31
|
+
* @name detect
|
|
32
|
+
* @static
|
|
33
|
+
* @memberOf module:Collections
|
|
34
|
+
* @method
|
|
35
|
+
* @alias find
|
|
36
|
+
* @category Collections
|
|
37
|
+
* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
|
|
38
|
+
* @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
|
|
39
|
+
* The iteratee must complete with a boolean value as its result.
|
|
40
|
+
* Invoked with (item, callback).
|
|
41
|
+
* @param {Function} [callback] - A callback which is called as soon as any
|
|
42
|
+
* iteratee returns `true`, or after all the `iteratee` functions have finished.
|
|
43
|
+
* Result will be the first item in the array that passes the truth test
|
|
44
|
+
* (iteratee) or the value `undefined` if none passed. Invoked with
|
|
45
|
+
* (err, result).
|
|
46
|
+
* @returns {Promise} a promise, if a callback is omitted
|
|
47
|
+
* @example
|
|
48
|
+
*
|
|
49
|
+
* // dir1 is a directory that contains file1.txt, file2.txt
|
|
50
|
+
* // dir2 is a directory that contains file3.txt, file4.txt
|
|
51
|
+
* // dir3 is a directory that contains file5.txt
|
|
52
|
+
*
|
|
53
|
+
* // asynchronous function that checks if a file exists
|
|
54
|
+
* function fileExists(file, callback) {
|
|
55
|
+
* fs.access(file, fs.constants.F_OK, (err) => {
|
|
56
|
+
* callback(null, !err);
|
|
57
|
+
* });
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists,
|
|
61
|
+
* function(err, result) {
|
|
62
|
+
* console.log(result);
|
|
63
|
+
* // dir1/file1.txt
|
|
64
|
+
* // result now equals the first file in the list that exists
|
|
65
|
+
* }
|
|
66
|
+
*);
|
|
67
|
+
*
|
|
68
|
+
* // Using Promises
|
|
69
|
+
* async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists)
|
|
70
|
+
* .then(result => {
|
|
71
|
+
* console.log(result);
|
|
72
|
+
* // dir1/file1.txt
|
|
73
|
+
* // result now equals the first file in the list that exists
|
|
74
|
+
* }).catch(err => {
|
|
75
|
+
* console.log(err);
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Using async/await
|
|
79
|
+
* async () => {
|
|
80
|
+
* try {
|
|
81
|
+
* let result = await async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists);
|
|
82
|
+
* console.log(result);
|
|
83
|
+
* // dir1/file1.txt
|
|
84
|
+
* // result now equals the file in the list that exists
|
|
85
|
+
* }
|
|
86
|
+
* catch (err) {
|
|
87
|
+
* console.log(err);
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
*
|
|
91
|
+
*/
|
|
92
|
+
function detect(coll, iteratee, callback) {
|
|
93
|
+
return (0, _createTester2.default)(bool => bool, (res, item) => item)(_eachOf2.default, coll, iteratee, callback);
|
|
94
|
+
}
|
|
95
|
+
exports.default = (0, _awaitify2.default)(detect, 3);
|
|
96
|
+
module.exports = exports.default;
|