@contrast/agent 4.16.1 → 4.16.2
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/bin/VERSION +1 -1
- package/bin/linux/contrast-service +0 -0
- package/bin/mac/contrast-service +0 -0
- package/bin/windows/contrast-service.exe +0 -0
- package/lib/protect/rules/cmd-injection/cmdinjection-rule.js +1 -1
- package/node_modules/async/CHANGELOG.md +13 -0
- package/node_modules/async/all.js +74 -9
- package/node_modules/async/allLimit.js +3 -3
- package/node_modules/async/allSeries.js +3 -3
- package/node_modules/async/any.js +75 -9
- package/node_modules/async/anyLimit.js +3 -3
- package/node_modules/async/anySeries.js +3 -3
- package/node_modules/async/applyEach.js +2 -2
- package/node_modules/async/applyEachSeries.js +2 -2
- package/node_modules/async/asyncify.js +3 -3
- package/node_modules/async/auto.js +81 -15
- package/node_modules/async/autoInject.js +30 -4
- package/node_modules/async/cargo.js +1 -1
- package/node_modules/async/cargoQueue.js +1 -1
- package/node_modules/async/compose.js +1 -1
- package/node_modules/async/concat.js +72 -4
- package/node_modules/async/concatLimit.js +3 -3
- package/node_modules/async/concatSeries.js +2 -2
- package/node_modules/async/detect.js +43 -8
- package/node_modules/async/detectLimit.js +3 -3
- package/node_modules/async/detectSeries.js +3 -3
- package/node_modules/async/dir.js +1 -1
- package/node_modules/async/dist/async.js +1379 -168
- package/node_modules/async/dist/async.min.js +1 -1
- package/node_modules/async/dist/async.mjs +1372 -161
- package/node_modules/async/doDuring.js +3 -3
- package/node_modules/async/doUntil.js +2 -2
- package/node_modules/async/doWhilst.js +3 -3
- package/node_modules/async/during.js +3 -3
- package/node_modules/async/each.js +69 -28
- package/node_modules/async/eachLimit.js +4 -4
- package/node_modules/async/eachOf.js +85 -16
- package/node_modules/async/eachOfLimit.js +3 -3
- package/node_modules/async/eachOfSeries.js +2 -2
- package/node_modules/async/eachSeries.js +2 -2
- package/node_modules/async/ensureAsync.js +2 -2
- package/node_modules/async/every.js +74 -9
- package/node_modules/async/everyLimit.js +3 -3
- package/node_modules/async/everySeries.js +3 -3
- package/node_modules/async/filter.js +49 -9
- package/node_modules/async/filterLimit.js +3 -3
- package/node_modules/async/filterSeries.js +3 -3
- package/node_modules/async/find.js +43 -8
- package/node_modules/async/findLimit.js +3 -3
- package/node_modules/async/findSeries.js +3 -3
- package/node_modules/async/flatMap.js +72 -4
- package/node_modules/async/flatMapLimit.js +3 -3
- package/node_modules/async/flatMapSeries.js +2 -2
- package/node_modules/async/foldl.js +87 -11
- package/node_modules/async/foldr.js +2 -2
- package/node_modules/async/forEach.js +69 -28
- package/node_modules/async/forEachLimit.js +4 -4
- package/node_modules/async/forEachOf.js +85 -16
- package/node_modules/async/forEachOfLimit.js +3 -3
- package/node_modules/async/forEachOfSeries.js +2 -2
- package/node_modules/async/forEachSeries.js +2 -2
- package/node_modules/async/forever.js +4 -4
- package/node_modules/async/groupBy.js +62 -8
- package/node_modules/async/groupByLimit.js +3 -3
- package/node_modules/async/groupBySeries.js +2 -2
- package/node_modules/async/inject.js +87 -11
- package/node_modules/async/internal/applyEach.js +2 -2
- package/node_modules/async/internal/asyncEachOfLimit.js +1 -1
- package/node_modules/async/internal/consoleFunc.js +5 -1
- package/node_modules/async/internal/createTester.js +2 -2
- package/node_modules/async/internal/eachOfLimit.js +6 -6
- package/node_modules/async/internal/filter.js +2 -2
- package/node_modules/async/internal/iterator.js +5 -2
- package/node_modules/async/internal/map.js +1 -1
- package/node_modules/async/internal/parallel.js +3 -3
- package/node_modules/async/internal/queue.js +4 -4
- package/node_modules/async/internal/reject.js +2 -2
- package/node_modules/async/internal/setImmediate.js +6 -2
- package/node_modules/async/internal/wrapAsync.js +1 -1
- package/node_modules/async/log.js +1 -1
- package/node_modules/async/map.js +86 -6
- package/node_modules/async/mapLimit.js +3 -3
- package/node_modules/async/mapSeries.js +3 -3
- package/node_modules/async/mapValues.js +102 -12
- package/node_modules/async/mapValuesLimit.js +4 -4
- package/node_modules/async/mapValuesSeries.js +1 -1
- package/node_modules/async/memoize.js +3 -3
- package/node_modules/async/nextTick.js +3 -3
- package/node_modules/async/package.json +4 -6
- package/node_modules/async/parallel.js +96 -7
- package/node_modules/async/parallelLimit.js +2 -2
- package/node_modules/async/priorityQueue.js +11 -4
- package/node_modules/async/queue.js +4 -4
- package/node_modules/async/race.js +3 -3
- package/node_modules/async/reduce.js +87 -11
- package/node_modules/async/reduceRight.js +2 -2
- package/node_modules/async/reflect.js +2 -2
- package/node_modules/async/reflectAll.js +1 -1
- package/node_modules/async/reject.js +44 -10
- package/node_modules/async/rejectLimit.js +3 -3
- package/node_modules/async/rejectSeries.js +3 -3
- package/node_modules/async/retry.js +2 -2
- package/node_modules/async/retryable.js +4 -4
- package/node_modules/async/select.js +49 -9
- package/node_modules/async/selectLimit.js +3 -3
- package/node_modules/async/selectSeries.js +3 -3
- package/node_modules/async/seq.js +4 -4
- package/node_modules/async/series.js +112 -12
- package/node_modules/async/setImmediate.js +1 -1
- package/node_modules/async/some.js +75 -9
- package/node_modules/async/someLimit.js +3 -3
- package/node_modules/async/someSeries.js +3 -3
- package/node_modules/async/sortBy.js +121 -19
- package/node_modules/async/timeout.js +2 -2
- package/node_modules/async/times.js +1 -1
- package/node_modules/async/timesLimit.js +3 -3
- package/node_modules/async/timesSeries.js +1 -1
- package/node_modules/async/transform.js +111 -19
- package/node_modules/async/tryEach.js +3 -3
- package/node_modules/async/until.js +3 -3
- package/node_modules/async/waterfall.js +4 -4
- package/node_modules/async/whilst.js +3 -3
- package/node_modules/async/wrapSync.js +3 -3
- package/package.json +1 -1
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = series;
|
|
7
7
|
|
|
8
|
-
var _parallel2 = require('./internal/parallel');
|
|
8
|
+
var _parallel2 = require('./internal/parallel.js');
|
|
9
9
|
|
|
10
10
|
var _parallel3 = _interopRequireDefault(_parallel2);
|
|
11
11
|
|
|
12
|
-
var _eachOfSeries = require('./eachOfSeries');
|
|
12
|
+
var _eachOfSeries = require('./eachOfSeries.js');
|
|
13
13
|
|
|
14
14
|
var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
|
|
15
15
|
|
|
@@ -50,35 +50,135 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
50
50
|
* with (err, result).
|
|
51
51
|
* @return {Promise} a promise, if no callback is passed
|
|
52
52
|
* @example
|
|
53
|
+
*
|
|
54
|
+
* //Using Callbacks
|
|
53
55
|
* async.series([
|
|
54
56
|
* function(callback) {
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
+
* setTimeout(function() {
|
|
58
|
+
* // do some async task
|
|
59
|
+
* callback(null, 'one');
|
|
60
|
+
* }, 200);
|
|
57
61
|
* },
|
|
58
62
|
* function(callback) {
|
|
59
|
-
*
|
|
60
|
-
*
|
|
63
|
+
* setTimeout(function() {
|
|
64
|
+
* // then do another async task
|
|
65
|
+
* callback(null, 'two');
|
|
66
|
+
* }, 100);
|
|
61
67
|
* }
|
|
62
|
-
* ],
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* // results is now equal to ['one', 'two']
|
|
68
|
+
* ], function(err, results) {
|
|
69
|
+
* console.log(results);
|
|
70
|
+
* // results is equal to ['one','two']
|
|
66
71
|
* });
|
|
67
72
|
*
|
|
73
|
+
* // an example using objects instead of arrays
|
|
68
74
|
* async.series({
|
|
69
75
|
* one: function(callback) {
|
|
70
76
|
* setTimeout(function() {
|
|
77
|
+
* // do some async task
|
|
71
78
|
* callback(null, 1);
|
|
72
79
|
* }, 200);
|
|
73
80
|
* },
|
|
74
|
-
* two: function(callback){
|
|
81
|
+
* two: function(callback) {
|
|
75
82
|
* setTimeout(function() {
|
|
83
|
+
* // then do another async task
|
|
76
84
|
* callback(null, 2);
|
|
77
85
|
* }, 100);
|
|
78
86
|
* }
|
|
79
87
|
* }, function(err, results) {
|
|
80
|
-
*
|
|
88
|
+
* console.log(results);
|
|
89
|
+
* // results is equal to: { one: 1, two: 2 }
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* //Using Promises
|
|
93
|
+
* async.series([
|
|
94
|
+
* function(callback) {
|
|
95
|
+
* setTimeout(function() {
|
|
96
|
+
* callback(null, 'one');
|
|
97
|
+
* }, 200);
|
|
98
|
+
* },
|
|
99
|
+
* function(callback) {
|
|
100
|
+
* setTimeout(function() {
|
|
101
|
+
* callback(null, 'two');
|
|
102
|
+
* }, 100);
|
|
103
|
+
* }
|
|
104
|
+
* ]).then(results => {
|
|
105
|
+
* console.log(results);
|
|
106
|
+
* // results is equal to ['one','two']
|
|
107
|
+
* }).catch(err => {
|
|
108
|
+
* console.log(err);
|
|
81
109
|
* });
|
|
110
|
+
*
|
|
111
|
+
* // an example using an object instead of an array
|
|
112
|
+
* async.series({
|
|
113
|
+
* one: function(callback) {
|
|
114
|
+
* setTimeout(function() {
|
|
115
|
+
* // do some async task
|
|
116
|
+
* callback(null, 1);
|
|
117
|
+
* }, 200);
|
|
118
|
+
* },
|
|
119
|
+
* two: function(callback) {
|
|
120
|
+
* setTimeout(function() {
|
|
121
|
+
* // then do another async task
|
|
122
|
+
* callback(null, 2);
|
|
123
|
+
* }, 100);
|
|
124
|
+
* }
|
|
125
|
+
* }).then(results => {
|
|
126
|
+
* console.log(results);
|
|
127
|
+
* // results is equal to: { one: 1, two: 2 }
|
|
128
|
+
* }).catch(err => {
|
|
129
|
+
* console.log(err);
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* //Using async/await
|
|
133
|
+
* async () => {
|
|
134
|
+
* try {
|
|
135
|
+
* let results = await async.series([
|
|
136
|
+
* function(callback) {
|
|
137
|
+
* setTimeout(function() {
|
|
138
|
+
* // do some async task
|
|
139
|
+
* callback(null, 'one');
|
|
140
|
+
* }, 200);
|
|
141
|
+
* },
|
|
142
|
+
* function(callback) {
|
|
143
|
+
* setTimeout(function() {
|
|
144
|
+
* // then do another async task
|
|
145
|
+
* callback(null, 'two');
|
|
146
|
+
* }, 100);
|
|
147
|
+
* }
|
|
148
|
+
* ]);
|
|
149
|
+
* console.log(results);
|
|
150
|
+
* // results is equal to ['one','two']
|
|
151
|
+
* }
|
|
152
|
+
* catch (err) {
|
|
153
|
+
* console.log(err);
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
156
|
+
*
|
|
157
|
+
* // an example using an object instead of an array
|
|
158
|
+
* async () => {
|
|
159
|
+
* try {
|
|
160
|
+
* let results = await async.parallel({
|
|
161
|
+
* one: function(callback) {
|
|
162
|
+
* setTimeout(function() {
|
|
163
|
+
* // do some async task
|
|
164
|
+
* callback(null, 1);
|
|
165
|
+
* }, 200);
|
|
166
|
+
* },
|
|
167
|
+
* two: function(callback) {
|
|
168
|
+
* setTimeout(function() {
|
|
169
|
+
* // then do another async task
|
|
170
|
+
* callback(null, 2);
|
|
171
|
+
* }, 100);
|
|
172
|
+
* }
|
|
173
|
+
* });
|
|
174
|
+
* console.log(results);
|
|
175
|
+
* // results is equal to: { one: 1, two: 2 }
|
|
176
|
+
* }
|
|
177
|
+
* catch (err) {
|
|
178
|
+
* console.log(err);
|
|
179
|
+
* }
|
|
180
|
+
* }
|
|
181
|
+
*
|
|
82
182
|
*/
|
|
83
183
|
function series(tasks, callback) {
|
|
84
184
|
return (0, _parallel3.default)(_eachOfSeries2.default, tasks, callback);
|
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _createTester = require('./internal/createTester');
|
|
7
|
+
var _createTester = require('./internal/createTester.js');
|
|
8
8
|
|
|
9
9
|
var _createTester2 = _interopRequireDefault(_createTester);
|
|
10
10
|
|
|
11
|
-
var _eachOf = require('./eachOf');
|
|
11
|
+
var _eachOf = require('./eachOf.js');
|
|
12
12
|
|
|
13
13
|
var _eachOf2 = _interopRequireDefault(_eachOf);
|
|
14
14
|
|
|
15
|
-
var _awaitify = require('./internal/awaitify');
|
|
15
|
+
var _awaitify = require('./internal/awaitify.js');
|
|
16
16
|
|
|
17
17
|
var _awaitify2 = _interopRequireDefault(_awaitify);
|
|
18
18
|
|
|
@@ -41,13 +41,79 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
41
41
|
* @returns {Promise} a promise, if no callback provided
|
|
42
42
|
* @example
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
44
|
+
* // dir1 is a directory that contains file1.txt, file2.txt
|
|
45
|
+
* // dir2 is a directory that contains file3.txt, file4.txt
|
|
46
|
+
* // dir3 is a directory that contains file5.txt
|
|
47
|
+
* // dir4 does not exist
|
|
48
|
+
*
|
|
49
|
+
* // asynchronous function that checks if a file exists
|
|
50
|
+
* function fileExists(file, callback) {
|
|
51
|
+
* fs.access(file, fs.constants.F_OK, (err) => {
|
|
52
|
+
* callback(null, !err);
|
|
53
|
+
* });
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* // Using callbacks
|
|
57
|
+
* async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists,
|
|
58
|
+
* function(err, result) {
|
|
59
|
+
* console.log(result);
|
|
60
|
+
* // true
|
|
61
|
+
* // result is true since some file in the list exists
|
|
62
|
+
* }
|
|
63
|
+
*);
|
|
64
|
+
*
|
|
65
|
+
* async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists,
|
|
66
|
+
* function(err, result) {
|
|
67
|
+
* console.log(result);
|
|
68
|
+
* // false
|
|
69
|
+
* // result is false since none of the files exists
|
|
70
|
+
* }
|
|
71
|
+
*);
|
|
72
|
+
*
|
|
73
|
+
* // Using Promises
|
|
74
|
+
* async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists)
|
|
75
|
+
* .then( result => {
|
|
76
|
+
* console.log(result);
|
|
77
|
+
* // true
|
|
78
|
+
* // result is true since some file in the list exists
|
|
79
|
+
* }).catch( err => {
|
|
80
|
+
* console.log(err);
|
|
50
81
|
* });
|
|
82
|
+
*
|
|
83
|
+
* async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists)
|
|
84
|
+
* .then( result => {
|
|
85
|
+
* console.log(result);
|
|
86
|
+
* // false
|
|
87
|
+
* // result is false since none of the files exists
|
|
88
|
+
* }).catch( err => {
|
|
89
|
+
* console.log(err);
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* // Using async/await
|
|
93
|
+
* async () => {
|
|
94
|
+
* try {
|
|
95
|
+
* let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists);
|
|
96
|
+
* console.log(result);
|
|
97
|
+
* // true
|
|
98
|
+
* // result is true since some file in the list exists
|
|
99
|
+
* }
|
|
100
|
+
* catch (err) {
|
|
101
|
+
* console.log(err);
|
|
102
|
+
* }
|
|
103
|
+
* }
|
|
104
|
+
*
|
|
105
|
+
* async () => {
|
|
106
|
+
* try {
|
|
107
|
+
* let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists);
|
|
108
|
+
* console.log(result);
|
|
109
|
+
* // false
|
|
110
|
+
* // result is false since none of the files exists
|
|
111
|
+
* }
|
|
112
|
+
* catch (err) {
|
|
113
|
+
* console.log(err);
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
*
|
|
51
117
|
*/
|
|
52
118
|
function some(coll, iteratee, callback) {
|
|
53
119
|
return (0, _createTester2.default)(Boolean, res => res)(_eachOf2.default, coll, iteratee, callback);
|
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _createTester = require('./internal/createTester');
|
|
7
|
+
var _createTester = require('./internal/createTester.js');
|
|
8
8
|
|
|
9
9
|
var _createTester2 = _interopRequireDefault(_createTester);
|
|
10
10
|
|
|
11
|
-
var _eachOfLimit = require('./internal/eachOfLimit');
|
|
11
|
+
var _eachOfLimit = require('./internal/eachOfLimit.js');
|
|
12
12
|
|
|
13
13
|
var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
|
|
14
14
|
|
|
15
|
-
var _awaitify = require('./internal/awaitify');
|
|
15
|
+
var _awaitify = require('./internal/awaitify.js');
|
|
16
16
|
|
|
17
17
|
var _awaitify2 = _interopRequireDefault(_awaitify);
|
|
18
18
|
|
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _createTester = require('./internal/createTester');
|
|
7
|
+
var _createTester = require('./internal/createTester.js');
|
|
8
8
|
|
|
9
9
|
var _createTester2 = _interopRequireDefault(_createTester);
|
|
10
10
|
|
|
11
|
-
var _eachOfSeries = require('./eachOfSeries');
|
|
11
|
+
var _eachOfSeries = require('./eachOfSeries.js');
|
|
12
12
|
|
|
13
13
|
var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
|
|
14
14
|
|
|
15
|
-
var _awaitify = require('./internal/awaitify');
|
|
15
|
+
var _awaitify = require('./internal/awaitify.js');
|
|
16
16
|
|
|
17
17
|
var _awaitify2 = _interopRequireDefault(_awaitify);
|
|
18
18
|
|
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _map = require('./map');
|
|
7
|
+
var _map = require('./map.js');
|
|
8
8
|
|
|
9
9
|
var _map2 = _interopRequireDefault(_map);
|
|
10
10
|
|
|
11
|
-
var _wrapAsync = require('./internal/wrapAsync');
|
|
11
|
+
var _wrapAsync = require('./internal/wrapAsync.js');
|
|
12
12
|
|
|
13
13
|
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
14
14
|
|
|
15
|
-
var _awaitify = require('./internal/awaitify');
|
|
15
|
+
var _awaitify = require('./internal/awaitify.js');
|
|
16
16
|
|
|
17
17
|
var _awaitify2 = _interopRequireDefault(_awaitify);
|
|
18
18
|
|
|
@@ -40,31 +40,133 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
40
40
|
* @returns {Promise} a promise, if no callback passed
|
|
41
41
|
* @example
|
|
42
42
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
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);
|
|
46
54
|
* });
|
|
47
|
-
* }
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
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
|
+
* );
|
|
51
70
|
*
|
|
52
71
|
* // By modifying the callback parameter the
|
|
53
72
|
* // sorting order can be influenced:
|
|
54
73
|
*
|
|
55
74
|
* // ascending order
|
|
56
|
-
* async.sortBy([
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
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
|
+
* );
|
|
61
91
|
*
|
|
62
92
|
* // descending order
|
|
63
|
-
* async.sortBy([
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
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);
|
|
67
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
|
+
*
|
|
68
170
|
*/
|
|
69
171
|
function sortBy(coll, iteratee, callback) {
|
|
70
172
|
var _iteratee = (0, _wrapAsync2.default)(iteratee);
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = timeout;
|
|
7
7
|
|
|
8
|
-
var _initialParams = require('./internal/initialParams');
|
|
8
|
+
var _initialParams = require('./internal/initialParams.js');
|
|
9
9
|
|
|
10
10
|
var _initialParams2 = _interopRequireDefault(_initialParams);
|
|
11
11
|
|
|
12
|
-
var _wrapAsync = require('./internal/wrapAsync');
|
|
12
|
+
var _wrapAsync = require('./internal/wrapAsync.js');
|
|
13
13
|
|
|
14
14
|
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
15
15
|
|
|
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = timesLimit;
|
|
7
7
|
|
|
8
|
-
var _mapLimit = require('./mapLimit');
|
|
8
|
+
var _mapLimit = require('./mapLimit.js');
|
|
9
9
|
|
|
10
10
|
var _mapLimit2 = _interopRequireDefault(_mapLimit);
|
|
11
11
|
|
|
12
|
-
var _range = require('./internal/range');
|
|
12
|
+
var _range = require('./internal/range.js');
|
|
13
13
|
|
|
14
14
|
var _range2 = _interopRequireDefault(_range);
|
|
15
15
|
|
|
16
|
-
var _wrapAsync = require('./internal/wrapAsync');
|
|
16
|
+
var _wrapAsync = require('./internal/wrapAsync.js');
|
|
17
17
|
|
|
18
18
|
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
19
19
|
|