@contrast/agent 4.16.1 → 4.17.1

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 (267) 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/esm.mjs +21 -11
  6. package/lib/assess/policy/propagators.json +4 -0
  7. package/lib/assess/policy/signatures.json +5 -0
  8. package/lib/assess/propagators/fastify-static/allowed-path.js +85 -0
  9. package/lib/cli-rewriter/index.js +1 -1
  10. package/lib/contrast.js +1 -1
  11. package/lib/core/rewrite/index.js +2 -2
  12. package/lib/protect/rules/cmd-injection/cmdinjection-rule.js +1 -1
  13. package/lib/protect/service.js +2 -0
  14. package/lib/util/trace-util.js +5 -4
  15. package/node_modules/@colors/colors/LICENSE +26 -0
  16. package/node_modules/@colors/colors/README.md +219 -0
  17. package/node_modules/@colors/colors/examples/normal-usage.js +83 -0
  18. package/node_modules/@colors/colors/examples/safe-string.js +80 -0
  19. package/node_modules/@colors/colors/index.d.ts +136 -0
  20. package/node_modules/@colors/colors/lib/colors.js +211 -0
  21. package/node_modules/@colors/colors/lib/custom/trap.js +46 -0
  22. package/node_modules/@colors/colors/lib/custom/zalgo.js +110 -0
  23. package/node_modules/@colors/colors/lib/extendStringPrototype.js +110 -0
  24. package/node_modules/@colors/colors/lib/index.js +13 -0
  25. package/node_modules/@colors/colors/lib/maps/america.js +10 -0
  26. package/node_modules/@colors/colors/lib/maps/rainbow.js +12 -0
  27. package/node_modules/@colors/colors/lib/maps/random.js +11 -0
  28. package/node_modules/@colors/colors/lib/maps/zebra.js +5 -0
  29. package/node_modules/@colors/colors/lib/styles.js +95 -0
  30. package/node_modules/@colors/colors/lib/system/has-flag.js +35 -0
  31. package/node_modules/@colors/colors/lib/system/supports-colors.js +151 -0
  32. package/node_modules/@colors/colors/package.json +49 -0
  33. package/node_modules/@colors/colors/safe.d.ts +48 -0
  34. package/node_modules/@colors/colors/safe.js +10 -0
  35. package/node_modules/@colors/colors/themes/generic-logging.js +12 -0
  36. package/node_modules/@dabh/diagnostics/README.md +16 -16
  37. package/node_modules/@dabh/diagnostics/package.json +9 -9
  38. package/node_modules/async/CHANGELOG.md +13 -0
  39. package/node_modules/async/all.js +74 -9
  40. package/node_modules/async/allLimit.js +3 -3
  41. package/node_modules/async/allSeries.js +3 -3
  42. package/node_modules/async/any.js +75 -9
  43. package/node_modules/async/anyLimit.js +3 -3
  44. package/node_modules/async/anySeries.js +3 -3
  45. package/node_modules/async/applyEach.js +2 -2
  46. package/node_modules/async/applyEachSeries.js +2 -2
  47. package/node_modules/async/asyncify.js +3 -3
  48. package/node_modules/async/auto.js +81 -15
  49. package/node_modules/async/autoInject.js +30 -4
  50. package/node_modules/async/cargo.js +1 -1
  51. package/node_modules/async/cargoQueue.js +1 -1
  52. package/node_modules/async/compose.js +1 -1
  53. package/node_modules/async/concat.js +72 -4
  54. package/node_modules/async/concatLimit.js +3 -3
  55. package/node_modules/async/concatSeries.js +2 -2
  56. package/node_modules/async/detect.js +43 -8
  57. package/node_modules/async/detectLimit.js +3 -3
  58. package/node_modules/async/detectSeries.js +3 -3
  59. package/node_modules/async/dir.js +1 -1
  60. package/node_modules/async/dist/async.js +1379 -168
  61. package/node_modules/async/dist/async.min.js +1 -1
  62. package/node_modules/async/dist/async.mjs +1372 -161
  63. package/node_modules/async/doDuring.js +3 -3
  64. package/node_modules/async/doUntil.js +2 -2
  65. package/node_modules/async/doWhilst.js +3 -3
  66. package/node_modules/async/during.js +3 -3
  67. package/node_modules/async/each.js +69 -28
  68. package/node_modules/async/eachLimit.js +4 -4
  69. package/node_modules/async/eachOf.js +85 -16
  70. package/node_modules/async/eachOfLimit.js +3 -3
  71. package/node_modules/async/eachOfSeries.js +2 -2
  72. package/node_modules/async/eachSeries.js +2 -2
  73. package/node_modules/async/ensureAsync.js +2 -2
  74. package/node_modules/async/every.js +74 -9
  75. package/node_modules/async/everyLimit.js +3 -3
  76. package/node_modules/async/everySeries.js +3 -3
  77. package/node_modules/async/filter.js +49 -9
  78. package/node_modules/async/filterLimit.js +3 -3
  79. package/node_modules/async/filterSeries.js +3 -3
  80. package/node_modules/async/find.js +43 -8
  81. package/node_modules/async/findLimit.js +3 -3
  82. package/node_modules/async/findSeries.js +3 -3
  83. package/node_modules/async/flatMap.js +72 -4
  84. package/node_modules/async/flatMapLimit.js +3 -3
  85. package/node_modules/async/flatMapSeries.js +2 -2
  86. package/node_modules/async/foldl.js +87 -11
  87. package/node_modules/async/foldr.js +2 -2
  88. package/node_modules/async/forEach.js +69 -28
  89. package/node_modules/async/forEachLimit.js +4 -4
  90. package/node_modules/async/forEachOf.js +85 -16
  91. package/node_modules/async/forEachOfLimit.js +3 -3
  92. package/node_modules/async/forEachOfSeries.js +2 -2
  93. package/node_modules/async/forEachSeries.js +2 -2
  94. package/node_modules/async/forever.js +4 -4
  95. package/node_modules/async/groupBy.js +62 -8
  96. package/node_modules/async/groupByLimit.js +3 -3
  97. package/node_modules/async/groupBySeries.js +2 -2
  98. package/node_modules/async/inject.js +87 -11
  99. package/node_modules/async/internal/applyEach.js +2 -2
  100. package/node_modules/async/internal/asyncEachOfLimit.js +1 -1
  101. package/node_modules/async/internal/consoleFunc.js +5 -1
  102. package/node_modules/async/internal/createTester.js +2 -2
  103. package/node_modules/async/internal/eachOfLimit.js +6 -6
  104. package/node_modules/async/internal/filter.js +2 -2
  105. package/node_modules/async/internal/iterator.js +5 -2
  106. package/node_modules/async/internal/map.js +1 -1
  107. package/node_modules/async/internal/parallel.js +3 -3
  108. package/node_modules/async/internal/queue.js +4 -4
  109. package/node_modules/async/internal/reject.js +2 -2
  110. package/node_modules/async/internal/setImmediate.js +6 -2
  111. package/node_modules/async/internal/wrapAsync.js +1 -1
  112. package/node_modules/async/log.js +1 -1
  113. package/node_modules/async/map.js +86 -6
  114. package/node_modules/async/mapLimit.js +3 -3
  115. package/node_modules/async/mapSeries.js +3 -3
  116. package/node_modules/async/mapValues.js +102 -12
  117. package/node_modules/async/mapValuesLimit.js +4 -4
  118. package/node_modules/async/mapValuesSeries.js +1 -1
  119. package/node_modules/async/memoize.js +3 -3
  120. package/node_modules/async/nextTick.js +3 -3
  121. package/node_modules/async/package.json +4 -6
  122. package/node_modules/async/parallel.js +96 -7
  123. package/node_modules/async/parallelLimit.js +2 -2
  124. package/node_modules/async/priorityQueue.js +11 -4
  125. package/node_modules/async/queue.js +4 -4
  126. package/node_modules/async/race.js +3 -3
  127. package/node_modules/async/reduce.js +87 -11
  128. package/node_modules/async/reduceRight.js +2 -2
  129. package/node_modules/async/reflect.js +2 -2
  130. package/node_modules/async/reflectAll.js +1 -1
  131. package/node_modules/async/reject.js +44 -10
  132. package/node_modules/async/rejectLimit.js +3 -3
  133. package/node_modules/async/rejectSeries.js +3 -3
  134. package/node_modules/async/retry.js +2 -2
  135. package/node_modules/async/retryable.js +4 -4
  136. package/node_modules/async/select.js +49 -9
  137. package/node_modules/async/selectLimit.js +3 -3
  138. package/node_modules/async/selectSeries.js +3 -3
  139. package/node_modules/async/seq.js +4 -4
  140. package/node_modules/async/series.js +112 -12
  141. package/node_modules/async/setImmediate.js +1 -1
  142. package/node_modules/async/some.js +75 -9
  143. package/node_modules/async/someLimit.js +3 -3
  144. package/node_modules/async/someSeries.js +3 -3
  145. package/node_modules/async/sortBy.js +121 -19
  146. package/node_modules/async/timeout.js +2 -2
  147. package/node_modules/async/times.js +1 -1
  148. package/node_modules/async/timesLimit.js +3 -3
  149. package/node_modules/async/timesSeries.js +1 -1
  150. package/node_modules/async/transform.js +111 -19
  151. package/node_modules/async/tryEach.js +3 -3
  152. package/node_modules/async/until.js +3 -3
  153. package/node_modules/async/waterfall.js +4 -4
  154. package/node_modules/async/whilst.js +3 -3
  155. package/node_modules/async/wrapSync.js +3 -3
  156. package/node_modules/color/README.md +9 -0
  157. package/node_modules/color/index.js +4 -1
  158. package/node_modules/color/package.json +8 -8
  159. package/node_modules/color-string/README.md +6 -2
  160. package/node_modules/color-string/index.js +21 -13
  161. package/node_modules/color-string/package.json +4 -4
  162. package/node_modules/colorspace/package.json +5 -5
  163. package/node_modules/fecha/dist/fecha.min.js +1 -1
  164. package/node_modules/fecha/dist/fecha.min.js.map +1 -0
  165. package/node_modules/fecha/lib/fecha.d.ts +2 -2
  166. package/node_modules/fecha/lib/fecha.js +35 -18
  167. package/node_modules/fecha/lib/fecha.js.map +1 -0
  168. package/node_modules/fecha/lib/fecha.umd.js +35 -18
  169. package/node_modules/fecha/lib/fecha.umd.js.map +1 -0
  170. package/node_modules/fecha/package.json +9 -10
  171. package/node_modules/fecha/src/fecha.ts +524 -0
  172. package/node_modules/logform/.eslintrc +1 -1
  173. package/node_modules/logform/CHANGELOG.md +24 -0
  174. package/node_modules/logform/README.md +15 -17
  175. package/node_modules/logform/browser.js +3 -1
  176. package/node_modules/logform/cli.js +1 -1
  177. package/node_modules/logform/colorize.js +2 -2
  178. package/node_modules/logform/dist/browser.js +8 -2
  179. package/node_modules/logform/dist/cli.js +2 -2
  180. package/node_modules/logform/dist/colorize.js +5 -5
  181. package/node_modules/logform/dist/errors.js +1 -1
  182. package/node_modules/logform/dist/format.js +9 -5
  183. package/node_modules/logform/dist/index.js +53 -20
  184. package/node_modules/logform/dist/json.js +7 -6
  185. package/node_modules/logform/dist/logstash.js +1 -1
  186. package/node_modules/logform/dist/pad-levels.js +4 -4
  187. package/node_modules/logform/dist/printf.js +1 -1
  188. package/node_modules/logform/dist/simple.js +1 -1
  189. package/node_modules/logform/dist/splat.js +2 -2
  190. package/node_modules/logform/dist/uncolorize.js +1 -1
  191. package/node_modules/logform/errors.js +1 -1
  192. package/node_modules/logform/index.d.ts +36 -0
  193. package/node_modules/logform/index.js +19 -20
  194. package/node_modules/logform/json.js +7 -7
  195. package/node_modules/logform/logstash.js +1 -1
  196. package/node_modules/logform/package.json +10 -9
  197. package/node_modules/logform/simple.js +1 -1
  198. package/node_modules/logform/uncolorize.js +1 -1
  199. package/node_modules/safe-stable-stringify/CHANGELOG.md +75 -0
  200. package/node_modules/safe-stable-stringify/LICENSE +21 -0
  201. package/node_modules/safe-stable-stringify/esm/package.json +4 -0
  202. package/node_modules/safe-stable-stringify/esm/wrapper.js +6 -0
  203. package/node_modules/safe-stable-stringify/index.d.ts +18 -0
  204. package/node_modules/safe-stable-stringify/index.js +618 -0
  205. package/node_modules/safe-stable-stringify/package.json +69 -0
  206. package/node_modules/safe-stable-stringify/readme.md +170 -0
  207. package/node_modules/safe-stable-stringify/tsconfig.json +22 -0
  208. package/node_modules/winston/LICENSE +18 -18
  209. package/node_modules/winston/README.md +1231 -1230
  210. package/node_modules/winston/dist/winston/common.js +10 -10
  211. package/node_modules/winston/dist/winston/config/index.js +17 -17
  212. package/node_modules/winston/dist/winston/container.js +46 -46
  213. package/node_modules/winston/dist/winston/create-logger.js +28 -24
  214. package/node_modules/winston/dist/winston/exception-handler.js +49 -49
  215. package/node_modules/winston/dist/winston/exception-stream.js +27 -27
  216. package/node_modules/winston/dist/winston/logger.js +152 -138
  217. package/node_modules/winston/dist/winston/profiler.js +22 -22
  218. package/node_modules/winston/dist/winston/rejection-handler.js +54 -54
  219. package/node_modules/winston/dist/winston/tail-file.js +14 -14
  220. package/node_modules/winston/dist/winston/transports/console.js +31 -31
  221. package/node_modules/winston/dist/winston/transports/file.js +101 -101
  222. package/node_modules/winston/dist/winston/transports/http.js +119 -41
  223. package/node_modules/winston/dist/winston/transports/index.js +17 -17
  224. package/node_modules/winston/dist/winston/transports/stream.js +24 -24
  225. package/node_modules/winston/dist/winston.js +91 -97
  226. package/node_modules/winston/index.d.ts +213 -193
  227. package/node_modules/winston/lib/winston/common.js +61 -61
  228. package/node_modules/winston/lib/winston/config/index.d.ts +99 -98
  229. package/node_modules/winston/lib/winston/config/index.js +35 -35
  230. package/node_modules/winston/lib/winston/container.js +114 -114
  231. package/node_modules/winston/lib/winston/create-logger.js +104 -104
  232. package/node_modules/winston/lib/winston/exception-handler.js +245 -245
  233. package/node_modules/winston/lib/winston/exception-stream.js +54 -54
  234. package/node_modules/winston/lib/winston/logger.js +676 -667
  235. package/node_modules/winston/lib/winston/profiler.js +51 -51
  236. package/node_modules/winston/lib/winston/rejection-handler.js +251 -251
  237. package/node_modules/winston/lib/winston/tail-file.js +124 -124
  238. package/node_modules/winston/lib/winston/transports/console.js +117 -117
  239. package/node_modules/winston/lib/winston/transports/file.js +695 -695
  240. package/node_modules/winston/lib/winston/transports/http.js +267 -202
  241. package/node_modules/winston/lib/winston/transports/index.d.ts +103 -100
  242. package/node_modules/winston/lib/winston/transports/index.js +56 -56
  243. package/node_modules/winston/lib/winston/transports/stream.js +63 -63
  244. package/node_modules/winston/lib/winston.js +176 -182
  245. package/node_modules/winston/node_modules/winston-transport/.babelrc +3 -0
  246. package/node_modules/winston/node_modules/winston-transport/.eslintrc +7 -0
  247. package/node_modules/winston/node_modules/winston-transport/.gitattributes +1 -0
  248. package/node_modules/winston/node_modules/winston-transport/.nyc_output/c3d7ddb9-cc26-466b-a4f6-993ad69e86f6.json +1 -0
  249. package/node_modules/winston/node_modules/winston-transport/.nyc_output/processinfo/c3d7ddb9-cc26-466b-a4f6-993ad69e86f6.json +1 -0
  250. package/node_modules/winston/node_modules/winston-transport/.nyc_output/processinfo/index.json +1 -0
  251. package/node_modules/winston/node_modules/winston-transport/CHANGELOG.md +126 -0
  252. package/node_modules/winston/node_modules/winston-transport/LICENSE +22 -0
  253. package/node_modules/winston/node_modules/winston-transport/README.md +50 -0
  254. package/node_modules/winston/node_modules/winston-transport/dist/index.js +215 -0
  255. package/node_modules/winston/node_modules/winston-transport/dist/legacy.js +116 -0
  256. package/node_modules/winston/node_modules/winston-transport/index.d.ts +39 -0
  257. package/node_modules/winston/node_modules/winston-transport/index.js +215 -0
  258. package/node_modules/winston/node_modules/winston-transport/legacy.js +119 -0
  259. package/node_modules/winston/node_modules/winston-transport/package.json +56 -0
  260. package/node_modules/winston/package.json +76 -75
  261. package/package.json +8 -6
  262. package/node_modules/@dabh/diagnostics/example.png +0 -0
  263. package/node_modules/color-string/CHANGELOG.md +0 -18
  264. package/node_modules/colorspace/test.js +0 -14
  265. package/node_modules/fecha/CHANGELOG.md +0 -67
  266. package/node_modules/logform/.travis.yml +0 -17
  267. package/node_modules/winston/CHANGELOG.md +0 -560
@@ -11,11 +11,11 @@ exports.default = function (worker, concurrency) {
11
11
  }, concurrency, 1);
12
12
  };
13
13
 
14
- var _queue = require('./internal/queue');
14
+ var _queue = require('./internal/queue.js');
15
15
 
16
16
  var _queue2 = _interopRequireDefault(_queue);
17
17
 
18
- var _wrapAsync = require('./internal/wrapAsync');
18
+ var _wrapAsync = require('./internal/wrapAsync.js');
19
19
 
20
20
  var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
21
21
 
@@ -51,7 +51,7 @@ module.exports = exports['default'];
51
51
  * Invoke with `queue.unshift(task, [callback])`.
52
52
  * @property {AsyncFunction} pushAsync - the same as `q.push`, except this returns
53
53
  * a promise that rejects if an error occurs.
54
- * @property {AsyncFunction} unshirtAsync - the same as `q.unshift`, except this returns
54
+ * @property {AsyncFunction} unshiftAsync - the same as `q.unshift`, except this returns
55
55
  * a promise that rejects if an error occurs.
56
56
  * @property {Function} remove - remove items from the queue that match a test
57
57
  * function. The test function will be passed an object with a `data` property,
@@ -90,7 +90,7 @@ module.exports = exports['default'];
90
90
  * should be pushed to the queue after calling this function. Invoke with `queue.kill()`.
91
91
  *
92
92
  * @example
93
- * const q = aync.queue(worker, 2)
93
+ * const q = async.queue(worker, 2)
94
94
  * q.push(item1)
95
95
  * q.push(item2)
96
96
  * q.push(item3)
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _once = require('./internal/once');
7
+ var _once = require('./internal/once.js');
8
8
 
9
9
  var _once2 = _interopRequireDefault(_once);
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
 
@@ -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
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = reflect;
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,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = reflectAll;
7
7
 
8
- var _reflect = require('./reflect');
8
+ var _reflect = require('./reflect.js');
9
9
 
10
10
  var _reflect2 = _interopRequireDefault(_reflect);
11
11
 
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _reject2 = require('./internal/reject');
7
+ var _reject2 = require('./internal/reject.js');
8
8
 
9
9
  var _reject3 = _interopRequireDefault(_reject2);
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
 
@@ -37,14 +37,48 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
37
37
  * @returns {Promise} a promise, if no callback is passed
38
38
  * @example
39
39
  *
40
- * async.reject(['file1','file2','file3'], function(filePath, callback) {
41
- * fs.access(filePath, function(err) {
42
- * callback(null, !err)
43
- * });
44
- * }, function(err, results) {
45
- * // results now equals an array of missing files
46
- * createFiles(results);
40
+ * // dir1 is a directory that contains file1.txt, file2.txt
41
+ * // dir2 is a directory that contains file3.txt, file4.txt
42
+ * // dir3 is a directory that contains file5.txt
43
+ *
44
+ * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
45
+ *
46
+ * // asynchronous function that checks if a file exists
47
+ * function fileExists(file, callback) {
48
+ * fs.access(file, fs.constants.F_OK, (err) => {
49
+ * callback(null, !err);
50
+ * });
51
+ * }
52
+ *
53
+ * // Using callbacks
54
+ * async.reject(fileList, fileExists, function(err, results) {
55
+ * // [ 'dir3/file6.txt' ]
56
+ * // results now equals an array of the non-existing files
47
57
  * });
58
+ *
59
+ * // Using Promises
60
+ * async.reject(fileList, fileExists)
61
+ * .then( results => {
62
+ * console.log(results);
63
+ * // [ 'dir3/file6.txt' ]
64
+ * // results now equals an array of the non-existing files
65
+ * }).catch( err => {
66
+ * console.log(err);
67
+ * });
68
+ *
69
+ * // Using async/await
70
+ * async () => {
71
+ * try {
72
+ * let results = await async.reject(fileList, fileExists);
73
+ * console.log(results);
74
+ * // [ 'dir3/file6.txt' ]
75
+ * // results now equals an array of the non-existing files
76
+ * }
77
+ * catch (err) {
78
+ * console.log(err);
79
+ * }
80
+ * }
81
+ *
48
82
  */
49
83
  function reject(coll, iteratee, callback) {
50
84
  return (0, _reject3.default)(_eachOf2.default, coll, iteratee, callback);
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _reject2 = require('./internal/reject');
7
+ var _reject2 = require('./internal/reject.js');
8
8
 
9
9
  var _reject3 = _interopRequireDefault(_reject2);
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 _reject2 = require('./internal/reject');
7
+ var _reject2 = require('./internal/reject.js');
8
8
 
9
9
  var _reject3 = _interopRequireDefault(_reject2);
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
 
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = retry;
7
7
 
8
- var _wrapAsync = require('./internal/wrapAsync');
8
+ var _wrapAsync = require('./internal/wrapAsync.js');
9
9
 
10
10
  var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
11
11
 
12
- var _promiseCallback = require('./internal/promiseCallback');
12
+ var _promiseCallback = require('./internal/promiseCallback.js');
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
@@ -5,19 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = retryable;
7
7
 
8
- var _retry = require('./retry');
8
+ var _retry = require('./retry.js');
9
9
 
10
10
  var _retry2 = _interopRequireDefault(_retry);
11
11
 
12
- var _initialParams = require('./internal/initialParams');
12
+ var _initialParams = require('./internal/initialParams.js');
13
13
 
14
14
  var _initialParams2 = _interopRequireDefault(_initialParams);
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
 
20
- var _promiseCallback = require('./internal/promiseCallback');
20
+ var _promiseCallback = require('./internal/promiseCallback.js');
21
21
 
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
23
 
@@ -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 _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
 
@@ -38,13 +38,53 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
38
38
  * @returns {Promise} a promise, if no callback provided
39
39
  * @example
40
40
  *
41
- * async.filter(['file1','file2','file3'], function(filePath, callback) {
42
- * fs.access(filePath, function(err) {
43
- * callback(null, !err)
44
- * });
45
- * }, function(err, results) {
46
- * // results now equals an array of the existing files
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
+ * }
47
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
+ *
48
88
  */
49
89
  function filter(coll, iteratee, callback) {
50
90
  return (0, _filter3.default)(_eachOf2.default, coll, iteratee, callback);
@@ -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
 
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = seq;
7
7
 
8
- var _reduce = require('./reduce');
8
+ var _reduce = require('./reduce.js');
9
9
 
10
10
  var _reduce2 = _interopRequireDefault(_reduce);
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
 
16
- var _promiseCallback = require('./internal/promiseCallback');
16
+ var _promiseCallback = require('./internal/promiseCallback.js');
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
@@ -41,7 +41,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
41
41
  * app.get('/cats', function(request, response) {
42
42
  * var User = request.models.User;
43
43
  * async.seq(
44
- * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
44
+ * User.get.bind(User), // 'User.get' has signature (id, callback(err, data))
45
45
  * function(user, fn) {
46
46
  * user.getCats(fn); // 'getCats' has signature (callback(err, data))
47
47
  * }