@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.
Files changed (124) hide show
  1. package/bin/VERSION +1 -1
  2. package/bin/linux/contrast-service +0 -0
  3. package/bin/mac/contrast-service +0 -0
  4. package/bin/windows/contrast-service.exe +0 -0
  5. package/lib/protect/rules/cmd-injection/cmdinjection-rule.js +1 -1
  6. package/node_modules/async/CHANGELOG.md +13 -0
  7. package/node_modules/async/all.js +74 -9
  8. package/node_modules/async/allLimit.js +3 -3
  9. package/node_modules/async/allSeries.js +3 -3
  10. package/node_modules/async/any.js +75 -9
  11. package/node_modules/async/anyLimit.js +3 -3
  12. package/node_modules/async/anySeries.js +3 -3
  13. package/node_modules/async/applyEach.js +2 -2
  14. package/node_modules/async/applyEachSeries.js +2 -2
  15. package/node_modules/async/asyncify.js +3 -3
  16. package/node_modules/async/auto.js +81 -15
  17. package/node_modules/async/autoInject.js +30 -4
  18. package/node_modules/async/cargo.js +1 -1
  19. package/node_modules/async/cargoQueue.js +1 -1
  20. package/node_modules/async/compose.js +1 -1
  21. package/node_modules/async/concat.js +72 -4
  22. package/node_modules/async/concatLimit.js +3 -3
  23. package/node_modules/async/concatSeries.js +2 -2
  24. package/node_modules/async/detect.js +43 -8
  25. package/node_modules/async/detectLimit.js +3 -3
  26. package/node_modules/async/detectSeries.js +3 -3
  27. package/node_modules/async/dir.js +1 -1
  28. package/node_modules/async/dist/async.js +1379 -168
  29. package/node_modules/async/dist/async.min.js +1 -1
  30. package/node_modules/async/dist/async.mjs +1372 -161
  31. package/node_modules/async/doDuring.js +3 -3
  32. package/node_modules/async/doUntil.js +2 -2
  33. package/node_modules/async/doWhilst.js +3 -3
  34. package/node_modules/async/during.js +3 -3
  35. package/node_modules/async/each.js +69 -28
  36. package/node_modules/async/eachLimit.js +4 -4
  37. package/node_modules/async/eachOf.js +85 -16
  38. package/node_modules/async/eachOfLimit.js +3 -3
  39. package/node_modules/async/eachOfSeries.js +2 -2
  40. package/node_modules/async/eachSeries.js +2 -2
  41. package/node_modules/async/ensureAsync.js +2 -2
  42. package/node_modules/async/every.js +74 -9
  43. package/node_modules/async/everyLimit.js +3 -3
  44. package/node_modules/async/everySeries.js +3 -3
  45. package/node_modules/async/filter.js +49 -9
  46. package/node_modules/async/filterLimit.js +3 -3
  47. package/node_modules/async/filterSeries.js +3 -3
  48. package/node_modules/async/find.js +43 -8
  49. package/node_modules/async/findLimit.js +3 -3
  50. package/node_modules/async/findSeries.js +3 -3
  51. package/node_modules/async/flatMap.js +72 -4
  52. package/node_modules/async/flatMapLimit.js +3 -3
  53. package/node_modules/async/flatMapSeries.js +2 -2
  54. package/node_modules/async/foldl.js +87 -11
  55. package/node_modules/async/foldr.js +2 -2
  56. package/node_modules/async/forEach.js +69 -28
  57. package/node_modules/async/forEachLimit.js +4 -4
  58. package/node_modules/async/forEachOf.js +85 -16
  59. package/node_modules/async/forEachOfLimit.js +3 -3
  60. package/node_modules/async/forEachOfSeries.js +2 -2
  61. package/node_modules/async/forEachSeries.js +2 -2
  62. package/node_modules/async/forever.js +4 -4
  63. package/node_modules/async/groupBy.js +62 -8
  64. package/node_modules/async/groupByLimit.js +3 -3
  65. package/node_modules/async/groupBySeries.js +2 -2
  66. package/node_modules/async/inject.js +87 -11
  67. package/node_modules/async/internal/applyEach.js +2 -2
  68. package/node_modules/async/internal/asyncEachOfLimit.js +1 -1
  69. package/node_modules/async/internal/consoleFunc.js +5 -1
  70. package/node_modules/async/internal/createTester.js +2 -2
  71. package/node_modules/async/internal/eachOfLimit.js +6 -6
  72. package/node_modules/async/internal/filter.js +2 -2
  73. package/node_modules/async/internal/iterator.js +5 -2
  74. package/node_modules/async/internal/map.js +1 -1
  75. package/node_modules/async/internal/parallel.js +3 -3
  76. package/node_modules/async/internal/queue.js +4 -4
  77. package/node_modules/async/internal/reject.js +2 -2
  78. package/node_modules/async/internal/setImmediate.js +6 -2
  79. package/node_modules/async/internal/wrapAsync.js +1 -1
  80. package/node_modules/async/log.js +1 -1
  81. package/node_modules/async/map.js +86 -6
  82. package/node_modules/async/mapLimit.js +3 -3
  83. package/node_modules/async/mapSeries.js +3 -3
  84. package/node_modules/async/mapValues.js +102 -12
  85. package/node_modules/async/mapValuesLimit.js +4 -4
  86. package/node_modules/async/mapValuesSeries.js +1 -1
  87. package/node_modules/async/memoize.js +3 -3
  88. package/node_modules/async/nextTick.js +3 -3
  89. package/node_modules/async/package.json +4 -6
  90. package/node_modules/async/parallel.js +96 -7
  91. package/node_modules/async/parallelLimit.js +2 -2
  92. package/node_modules/async/priorityQueue.js +11 -4
  93. package/node_modules/async/queue.js +4 -4
  94. package/node_modules/async/race.js +3 -3
  95. package/node_modules/async/reduce.js +87 -11
  96. package/node_modules/async/reduceRight.js +2 -2
  97. package/node_modules/async/reflect.js +2 -2
  98. package/node_modules/async/reflectAll.js +1 -1
  99. package/node_modules/async/reject.js +44 -10
  100. package/node_modules/async/rejectLimit.js +3 -3
  101. package/node_modules/async/rejectSeries.js +3 -3
  102. package/node_modules/async/retry.js +2 -2
  103. package/node_modules/async/retryable.js +4 -4
  104. package/node_modules/async/select.js +49 -9
  105. package/node_modules/async/selectLimit.js +3 -3
  106. package/node_modules/async/selectSeries.js +3 -3
  107. package/node_modules/async/seq.js +4 -4
  108. package/node_modules/async/series.js +112 -12
  109. package/node_modules/async/setImmediate.js +1 -1
  110. package/node_modules/async/some.js +75 -9
  111. package/node_modules/async/someLimit.js +3 -3
  112. package/node_modules/async/someSeries.js +3 -3
  113. package/node_modules/async/sortBy.js +121 -19
  114. package/node_modules/async/timeout.js +2 -2
  115. package/node_modules/async/times.js +1 -1
  116. package/node_modules/async/timesLimit.js +3 -3
  117. package/node_modules/async/timesSeries.js +1 -1
  118. package/node_modules/async/transform.js +111 -19
  119. package/node_modules/async/tryEach.js +3 -3
  120. package/node_modules/async/until.js +3 -3
  121. package/node_modules/async/waterfall.js +4 -4
  122. package/node_modules/async/whilst.js +3 -3
  123. package/node_modules/async/wrapSync.js +3 -3
  124. package/package.json +1 -1
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _filter2 = require('./internal/filter');
7
+ var _filter2 = require('./internal/filter.js');
8
8
 
9
9
  var _filter3 = _interopRequireDefault(_filter2);
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 _filter2 = require('./internal/filter');
7
+ var _filter2 = require('./internal/filter.js');
8
8
 
9
9
  var _filter3 = _interopRequireDefault(_filter2);
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 _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
 
@@ -46,13 +46,48 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
46
46
  * @returns A Promise, if no callback is passed
47
47
  * @example
48
48
  *
49
- * async.detect(['file1','file2','file3'], function(filePath, callback) {
50
- * fs.access(filePath, function(err) {
51
- * callback(null, !err)
52
- * });
53
- * }, function(err, result) {
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
54
73
  * // result now equals the first file in the list that exists
74
+ * }).catch(err => {
75
+ * console.log(err);
55
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
+ *
56
91
  */
57
92
  function detect(coll, iteratee, callback) {
58
93
  return (0, _createTester2.default)(bool => bool, (res, item) => item)(_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 _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,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _concatLimit = require('./concatLimit');
7
+ var _concatLimit = require('./concatLimit.js');
8
8
 
9
9
  var _concatLimit2 = _interopRequireDefault(_concatLimit);
10
10
 
11
- var _awaitify = require('./internal/awaitify');
11
+ var _awaitify = require('./internal/awaitify.js');
12
12
 
13
13
  var _awaitify2 = _interopRequireDefault(_awaitify);
14
14
 
@@ -36,9 +36,77 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
36
36
  * @returns A Promise, if no callback is passed
37
37
  * @example
38
38
  *
39
- * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
40
- * // files is now a list of filenames that exist in the 3 directories
39
+ * // dir1 is a directory that contains file1.txt, file2.txt
40
+ * // dir2 is a directory that contains file3.txt, file4.txt
41
+ * // dir3 is a directory that contains file5.txt
42
+ * // dir4 does not exist
43
+ *
44
+ * let directoryList = ['dir1','dir2','dir3'];
45
+ * let withMissingDirectoryList = ['dir1','dir2','dir3', 'dir4'];
46
+ *
47
+ * // Using callbacks
48
+ * async.concat(directoryList, fs.readdir, function(err, results) {
49
+ * if (err) {
50
+ * console.log(err);
51
+ * } else {
52
+ * console.log(results);
53
+ * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
54
+ * }
55
+ * });
56
+ *
57
+ * // Error Handling
58
+ * async.concat(withMissingDirectoryList, fs.readdir, function(err, results) {
59
+ * if (err) {
60
+ * console.log(err);
61
+ * // [ Error: ENOENT: no such file or directory ]
62
+ * // since dir4 does not exist
63
+ * } else {
64
+ * console.log(results);
65
+ * }
66
+ * });
67
+ *
68
+ * // Using Promises
69
+ * async.concat(directoryList, fs.readdir)
70
+ * .then(results => {
71
+ * console.log(results);
72
+ * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
73
+ * }).catch(err => {
74
+ * console.log(err);
41
75
  * });
76
+ *
77
+ * // Error Handling
78
+ * async.concat(withMissingDirectoryList, fs.readdir)
79
+ * .then(results => {
80
+ * console.log(results);
81
+ * }).catch(err => {
82
+ * console.log(err);
83
+ * // [ Error: ENOENT: no such file or directory ]
84
+ * // since dir4 does not exist
85
+ * });
86
+ *
87
+ * // Using async/await
88
+ * async () => {
89
+ * try {
90
+ * let results = await async.concat(directoryList, fs.readdir);
91
+ * console.log(results);
92
+ * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
93
+ * } catch (err) {
94
+ * console.log(err);
95
+ * }
96
+ * }
97
+ *
98
+ * // Error Handling
99
+ * async () => {
100
+ * try {
101
+ * let results = await async.concat(withMissingDirectoryList, fs.readdir);
102
+ * console.log(results);
103
+ * } catch (err) {
104
+ * console.log(err);
105
+ * // [ Error: ENOENT: no such file or directory ]
106
+ * // since dir4 does not exist
107
+ * }
108
+ * }
109
+ *
42
110
  */
43
111
  function concat(coll, iteratee, callback) {
44
112
  return (0, _concatLimit2.default)(coll, Infinity, iteratee, callback);
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _wrapAsync = require('./internal/wrapAsync');
7
+ var _wrapAsync = require('./internal/wrapAsync.js');
8
8
 
9
9
  var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
10
10
 
11
- var _mapLimit = require('./mapLimit');
11
+ var _mapLimit = require('./mapLimit.js');
12
12
 
13
13
  var _mapLimit2 = _interopRequireDefault(_mapLimit);
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,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _concatLimit = require('./concatLimit');
7
+ var _concatLimit = require('./concatLimit.js');
8
8
 
9
9
  var _concatLimit2 = _interopRequireDefault(_concatLimit);
10
10
 
11
- var _awaitify = require('./internal/awaitify');
11
+ var _awaitify = require('./internal/awaitify.js');
12
12
 
13
13
  var _awaitify2 = _interopRequireDefault(_awaitify);
14
14
 
@@ -4,19 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _eachOfSeries = require('./eachOfSeries');
7
+ var _eachOfSeries = require('./eachOfSeries.js');
8
8
 
9
9
  var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
10
10
 
11
- var _once = require('./internal/once');
11
+ var _once = require('./internal/once.js');
12
12
 
13
13
  var _once2 = _interopRequireDefault(_once);
14
14
 
15
- var _wrapAsync = require('./internal/wrapAsync');
15
+ var _wrapAsync = require('./internal/wrapAsync.js');
16
16
 
17
17
  var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18
18
 
19
- var _awaitify = require('./internal/awaitify');
19
+ var _awaitify = require('./internal/awaitify.js');
20
20
 
21
21
  var _awaitify2 = _interopRequireDefault(_awaitify);
22
22
 
@@ -45,7 +45,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
45
45
  * @param {AsyncFunction} iteratee - A function applied to each item in the
46
46
  * array to produce the next step in the reduction.
47
47
  * The `iteratee` should complete with the next state of the reduction.
48
- * If the iteratee complete with an error, the reduction is stopped and the
48
+ * If the iteratee completes with an error, the reduction is stopped and the
49
49
  * main `callback` is immediately called with the error.
50
50
  * Invoked with (memo, item, callback).
51
51
  * @param {Function} [callback] - A callback which is called after all the
@@ -54,14 +54,90 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
54
54
  * @returns {Promise} a promise, if no callback is passed
55
55
  * @example
56
56
  *
57
- * async.reduce([1,2,3], 0, function(memo, item, callback) {
58
- * // pointless async:
59
- * process.nextTick(function() {
60
- * callback(null, memo + item)
57
+ * // file1.txt is a file that is 1000 bytes in size
58
+ * // file2.txt is a file that is 2000 bytes in size
59
+ * // file3.txt is a file that is 3000 bytes in size
60
+ * // file4.txt does not exist
61
+ *
62
+ * const fileList = ['file1.txt','file2.txt','file3.txt'];
63
+ * const withMissingFileList = ['file1.txt','file2.txt','file3.txt', 'file4.txt'];
64
+ *
65
+ * // asynchronous function that computes the file size in bytes
66
+ * // file size is added to the memoized value, then returned
67
+ * function getFileSizeInBytes(memo, file, callback) {
68
+ * fs.stat(file, function(err, stat) {
69
+ * if (err) {
70
+ * return callback(err);
71
+ * }
72
+ * callback(null, memo + stat.size);
61
73
  * });
62
- * }, function(err, result) {
63
- * // result is now equal to the last value of memo, which is 6
74
+ * }
75
+ *
76
+ * // Using callbacks
77
+ * async.reduce(fileList, 0, getFileSizeInBytes, function(err, result) {
78
+ * if (err) {
79
+ * console.log(err);
80
+ * } else {
81
+ * console.log(result);
82
+ * // 6000
83
+ * // which is the sum of the file sizes of the three files
84
+ * }
85
+ * });
86
+ *
87
+ * // Error Handling
88
+ * async.reduce(withMissingFileList, 0, getFileSizeInBytes, function(err, result) {
89
+ * if (err) {
90
+ * console.log(err);
91
+ * // [ Error: ENOENT: no such file or directory ]
92
+ * } else {
93
+ * console.log(result);
94
+ * }
95
+ * });
96
+ *
97
+ * // Using Promises
98
+ * async.reduce(fileList, 0, getFileSizeInBytes)
99
+ * .then( result => {
100
+ * console.log(result);
101
+ * // 6000
102
+ * // which is the sum of the file sizes of the three files
103
+ * }).catch( err => {
104
+ * console.log(err);
105
+ * });
106
+ *
107
+ * // Error Handling
108
+ * async.reduce(withMissingFileList, 0, getFileSizeInBytes)
109
+ * .then( result => {
110
+ * console.log(result);
111
+ * }).catch( err => {
112
+ * console.log(err);
113
+ * // [ Error: ENOENT: no such file or directory ]
64
114
  * });
115
+ *
116
+ * // Using async/await
117
+ * async () => {
118
+ * try {
119
+ * let result = await async.reduce(fileList, 0, getFileSizeInBytes);
120
+ * console.log(result);
121
+ * // 6000
122
+ * // which is the sum of the file sizes of the three files
123
+ * }
124
+ * catch (err) {
125
+ * console.log(err);
126
+ * }
127
+ * }
128
+ *
129
+ * // Error Handling
130
+ * async () => {
131
+ * try {
132
+ * let result = await async.reduce(withMissingFileList, 0, getFileSizeInBytes);
133
+ * console.log(result);
134
+ * }
135
+ * catch (err) {
136
+ * console.log(err);
137
+ * // [ Error: ENOENT: no such file or directory ]
138
+ * }
139
+ * }
140
+ *
65
141
  */
66
142
  function reduce(coll, memo, iteratee, callback) {
67
143
  callback = (0, _once2.default)(callback);
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = reduceRight;
7
7
 
8
- var _reduce = require('./reduce');
8
+ var _reduce = require('./reduce.js');
9
9
 
10
10
  var _reduce2 = _interopRequireDefault(_reduce);
11
11
 
@@ -26,7 +26,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
26
26
  * @param {AsyncFunction} iteratee - A function applied to each item in the
27
27
  * array to produce the next step in the reduction.
28
28
  * The `iteratee` should complete with the next state of the reduction.
29
- * If the iteratee complete with an error, the reduction is stopped and the
29
+ * If the iteratee completes with an error, the reduction is stopped and the
30
30
  * main `callback` is immediately called with the error.
31
31
  * Invoked with (memo, item, callback).
32
32
  * @param {Function} [callback] - A callback which is called after all the
@@ -4,19 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _eachOf = require('./eachOf');
7
+ var _eachOf = require('./eachOf.js');
8
8
 
9
9
  var _eachOf2 = _interopRequireDefault(_eachOf);
10
10
 
11
- var _withoutIndex = require('./internal/withoutIndex');
11
+ var _withoutIndex = require('./internal/withoutIndex.js');
12
12
 
13
13
  var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
14
14
 
15
- var _wrapAsync = require('./internal/wrapAsync');
15
+ var _wrapAsync = require('./internal/wrapAsync.js');
16
16
 
17
17
  var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18
18
 
19
- var _awaitify = require('./internal/awaitify');
19
+ var _awaitify = require('./internal/awaitify.js');
20
20
 
21
21
  var _awaitify2 = _interopRequireDefault(_awaitify);
22
22
 
@@ -48,37 +48,78 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
48
48
  * @returns {Promise} a promise, if a callback is omitted
49
49
  * @example
50
50
  *
51
- * // assuming openFiles is an array of file names and saveFile is a function
52
- * // to save the modified contents of that file:
51
+ * // dir1 is a directory that contains file1.txt, file2.txt
52
+ * // dir2 is a directory that contains file3.txt, file4.txt
53
+ * // dir3 is a directory that contains file5.txt
54
+ * // dir4 does not exist
53
55
  *
54
- * async.each(openFiles, saveFile, function(err){
55
- * // if any of the saves produced an error, err would equal that error
56
- * });
57
- *
58
- * // assuming openFiles is an array of file names
59
- * async.each(openFiles, function(file, callback) {
56
+ * const fileList = [ 'dir1/file2.txt', 'dir2/file3.txt', 'dir/file5.txt'];
57
+ * const withMissingFileList = ['dir1/file1.txt', 'dir4/file2.txt'];
60
58
  *
61
- * // Perform operation on file here.
62
- * console.log('Processing file ' + file);
59
+ * // asynchronous function that deletes a file
60
+ * const deleteFile = function(file, callback) {
61
+ * fs.unlink(file, callback);
62
+ * };
63
63
  *
64
- * if( file.length > 32 ) {
65
- * console.log('This file name is too long');
66
- * callback('File name too long');
67
- * } else {
68
- * // Do work to process file here
69
- * console.log('File processed');
70
- * callback();
71
- * }
72
- * }, function(err) {
73
- * // if any of the file processing produced an error, err would equal that error
64
+ * // Using callbacks
65
+ * async.each(fileList, deleteFile, function(err) {
74
66
  * if( err ) {
75
- * // One of the iterations produced an error.
76
- * // All processing will now stop.
77
- * console.log('A file failed to process');
67
+ * console.log(err);
78
68
  * } else {
79
- * console.log('All files have been processed successfully');
69
+ * console.log('All files have been deleted successfully');
80
70
  * }
81
71
  * });
72
+ *
73
+ * // Error Handling
74
+ * async.each(withMissingFileList, deleteFile, function(err){
75
+ * console.log(err);
76
+ * // [ Error: ENOENT: no such file or directory ]
77
+ * // since dir4/file2.txt does not exist
78
+ * // dir1/file1.txt could have been deleted
79
+ * });
80
+ *
81
+ * // Using Promises
82
+ * async.each(fileList, deleteFile)
83
+ * .then( () => {
84
+ * console.log('All files have been deleted successfully');
85
+ * }).catch( err => {
86
+ * console.log(err);
87
+ * });
88
+ *
89
+ * // Error Handling
90
+ * async.each(fileList, deleteFile)
91
+ * .then( () => {
92
+ * console.log('All files have been deleted successfully');
93
+ * }).catch( err => {
94
+ * console.log(err);
95
+ * // [ Error: ENOENT: no such file or directory ]
96
+ * // since dir4/file2.txt does not exist
97
+ * // dir1/file1.txt could have been deleted
98
+ * });
99
+ *
100
+ * // Using async/await
101
+ * async () => {
102
+ * try {
103
+ * await async.each(files, deleteFile);
104
+ * }
105
+ * catch (err) {
106
+ * console.log(err);
107
+ * }
108
+ * }
109
+ *
110
+ * // Error Handling
111
+ * async () => {
112
+ * try {
113
+ * await async.each(withMissingFileList, deleteFile);
114
+ * }
115
+ * catch (err) {
116
+ * console.log(err);
117
+ * // [ Error: ENOENT: no such file or directory ]
118
+ * // since dir4/file2.txt does not exist
119
+ * // dir1/file1.txt could have been deleted
120
+ * }
121
+ * }
122
+ *
82
123
  */
83
124
  function eachLimit(coll, iteratee, callback) {
84
125
  return (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
@@ -4,19 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _eachOfLimit = require('./internal/eachOfLimit');
7
+ var _eachOfLimit = require('./internal/eachOfLimit.js');
8
8
 
9
9
  var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
10
10
 
11
- var _withoutIndex = require('./internal/withoutIndex');
11
+ var _withoutIndex = require('./internal/withoutIndex.js');
12
12
 
13
13
  var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
14
14
 
15
- var _wrapAsync = require('./internal/wrapAsync');
15
+ var _wrapAsync = require('./internal/wrapAsync.js');
16
16
 
17
17
  var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18
18
 
19
- var _awaitify = require('./internal/awaitify');
19
+ var _awaitify = require('./internal/awaitify.js');
20
20
 
21
21
  var _awaitify2 = _interopRequireDefault(_awaitify);
22
22