@contrast/agent 4.15.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 (431) hide show
  1. package/README.md +1 -1
  2. package/bin/VERSION +1 -1
  3. package/bin/linux/contrast-service +0 -0
  4. package/bin/mac/contrast-service +0 -0
  5. package/bin/windows/contrast-service.exe +0 -0
  6. package/lib/assess/sinks/dynamo.js +87 -76
  7. package/lib/protect/errors/handler-async-errors.js +1 -1
  8. package/lib/protect/rules/cmd-injection/cmdinjection-rule.js +1 -1
  9. package/lib/protect/service.js +1 -1
  10. package/node_modules/async/CHANGELOG.md +13 -0
  11. package/node_modules/async/all.js +74 -9
  12. package/node_modules/async/allLimit.js +3 -3
  13. package/node_modules/async/allSeries.js +3 -3
  14. package/node_modules/async/any.js +75 -9
  15. package/node_modules/async/anyLimit.js +3 -3
  16. package/node_modules/async/anySeries.js +3 -3
  17. package/node_modules/async/applyEach.js +2 -2
  18. package/node_modules/async/applyEachSeries.js +2 -2
  19. package/node_modules/async/asyncify.js +3 -3
  20. package/node_modules/async/auto.js +81 -15
  21. package/node_modules/async/autoInject.js +30 -4
  22. package/node_modules/async/cargo.js +1 -1
  23. package/node_modules/async/cargoQueue.js +1 -1
  24. package/node_modules/async/compose.js +1 -1
  25. package/node_modules/async/concat.js +72 -4
  26. package/node_modules/async/concatLimit.js +3 -3
  27. package/node_modules/async/concatSeries.js +2 -2
  28. package/node_modules/async/detect.js +43 -8
  29. package/node_modules/async/detectLimit.js +3 -3
  30. package/node_modules/async/detectSeries.js +3 -3
  31. package/node_modules/async/dir.js +1 -1
  32. package/node_modules/async/dist/async.js +1379 -168
  33. package/node_modules/async/dist/async.min.js +1 -1
  34. package/node_modules/async/dist/async.mjs +1372 -161
  35. package/node_modules/async/doDuring.js +3 -3
  36. package/node_modules/async/doUntil.js +2 -2
  37. package/node_modules/async/doWhilst.js +3 -3
  38. package/node_modules/async/during.js +3 -3
  39. package/node_modules/async/each.js +69 -28
  40. package/node_modules/async/eachLimit.js +4 -4
  41. package/node_modules/async/eachOf.js +85 -16
  42. package/node_modules/async/eachOfLimit.js +3 -3
  43. package/node_modules/async/eachOfSeries.js +2 -2
  44. package/node_modules/async/eachSeries.js +2 -2
  45. package/node_modules/async/ensureAsync.js +2 -2
  46. package/node_modules/async/every.js +74 -9
  47. package/node_modules/async/everyLimit.js +3 -3
  48. package/node_modules/async/everySeries.js +3 -3
  49. package/node_modules/async/filter.js +49 -9
  50. package/node_modules/async/filterLimit.js +3 -3
  51. package/node_modules/async/filterSeries.js +3 -3
  52. package/node_modules/async/find.js +43 -8
  53. package/node_modules/async/findLimit.js +3 -3
  54. package/node_modules/async/findSeries.js +3 -3
  55. package/node_modules/async/flatMap.js +72 -4
  56. package/node_modules/async/flatMapLimit.js +3 -3
  57. package/node_modules/async/flatMapSeries.js +2 -2
  58. package/node_modules/async/foldl.js +87 -11
  59. package/node_modules/async/foldr.js +2 -2
  60. package/node_modules/async/forEach.js +69 -28
  61. package/node_modules/async/forEachLimit.js +4 -4
  62. package/node_modules/async/forEachOf.js +85 -16
  63. package/node_modules/async/forEachOfLimit.js +3 -3
  64. package/node_modules/async/forEachOfSeries.js +2 -2
  65. package/node_modules/async/forEachSeries.js +2 -2
  66. package/node_modules/async/forever.js +4 -4
  67. package/node_modules/async/groupBy.js +62 -8
  68. package/node_modules/async/groupByLimit.js +3 -3
  69. package/node_modules/async/groupBySeries.js +2 -2
  70. package/node_modules/async/inject.js +87 -11
  71. package/node_modules/async/internal/applyEach.js +2 -2
  72. package/node_modules/async/internal/asyncEachOfLimit.js +1 -1
  73. package/node_modules/async/internal/consoleFunc.js +5 -1
  74. package/node_modules/async/internal/createTester.js +2 -2
  75. package/node_modules/async/internal/eachOfLimit.js +6 -6
  76. package/node_modules/async/internal/filter.js +2 -2
  77. package/node_modules/async/internal/iterator.js +5 -2
  78. package/node_modules/async/internal/map.js +1 -1
  79. package/node_modules/async/internal/parallel.js +3 -3
  80. package/node_modules/async/internal/queue.js +4 -4
  81. package/node_modules/async/internal/reject.js +2 -2
  82. package/node_modules/async/internal/setImmediate.js +6 -2
  83. package/node_modules/async/internal/wrapAsync.js +1 -1
  84. package/node_modules/async/log.js +1 -1
  85. package/node_modules/async/map.js +86 -6
  86. package/node_modules/async/mapLimit.js +3 -3
  87. package/node_modules/async/mapSeries.js +3 -3
  88. package/node_modules/async/mapValues.js +102 -12
  89. package/node_modules/async/mapValuesLimit.js +4 -4
  90. package/node_modules/async/mapValuesSeries.js +1 -1
  91. package/node_modules/async/memoize.js +3 -3
  92. package/node_modules/async/nextTick.js +3 -3
  93. package/node_modules/async/package.json +4 -6
  94. package/node_modules/async/parallel.js +96 -7
  95. package/node_modules/async/parallelLimit.js +2 -2
  96. package/node_modules/async/priorityQueue.js +11 -4
  97. package/node_modules/async/queue.js +4 -4
  98. package/node_modules/async/race.js +3 -3
  99. package/node_modules/async/reduce.js +87 -11
  100. package/node_modules/async/reduceRight.js +2 -2
  101. package/node_modules/async/reflect.js +2 -2
  102. package/node_modules/async/reflectAll.js +1 -1
  103. package/node_modules/async/reject.js +44 -10
  104. package/node_modules/async/rejectLimit.js +3 -3
  105. package/node_modules/async/rejectSeries.js +3 -3
  106. package/node_modules/async/retry.js +2 -2
  107. package/node_modules/async/retryable.js +4 -4
  108. package/node_modules/async/select.js +49 -9
  109. package/node_modules/async/selectLimit.js +3 -3
  110. package/node_modules/async/selectSeries.js +3 -3
  111. package/node_modules/async/seq.js +4 -4
  112. package/node_modules/async/series.js +112 -12
  113. package/node_modules/async/setImmediate.js +1 -1
  114. package/node_modules/async/some.js +75 -9
  115. package/node_modules/async/someLimit.js +3 -3
  116. package/node_modules/async/someSeries.js +3 -3
  117. package/node_modules/async/sortBy.js +121 -19
  118. package/node_modules/async/timeout.js +2 -2
  119. package/node_modules/async/times.js +1 -1
  120. package/node_modules/async/timesLimit.js +3 -3
  121. package/node_modules/async/timesSeries.js +1 -1
  122. package/node_modules/async/transform.js +111 -19
  123. package/node_modules/async/tryEach.js +3 -3
  124. package/node_modules/async/until.js +3 -3
  125. package/node_modules/async/waterfall.js +4 -4
  126. package/node_modules/async/whilst.js +3 -3
  127. package/node_modules/async/wrapSync.js +3 -3
  128. package/node_modules/moment/CHANGELOG.md +6 -0
  129. package/node_modules/moment/dist/locale/ar-kw.js +4 -3
  130. package/node_modules/moment/dist/locale/ar-ly.js +1 -1
  131. package/node_modules/moment/dist/locale/ar-ma.js +4 -3
  132. package/node_modules/moment/dist/locale/ar-sa.js +4 -3
  133. package/node_modules/moment/dist/locale/ar-tn.js +4 -3
  134. package/node_modules/moment/dist/locale/az.js +4 -3
  135. package/node_modules/moment/dist/locale/be.js +10 -9
  136. package/node_modules/moment/dist/locale/bn-bd.js +4 -3
  137. package/node_modules/moment/dist/locale/bn.js +4 -3
  138. package/node_modules/moment/dist/locale/bo.js +8 -6
  139. package/node_modules/moment/dist/locale/br.js +6 -3
  140. package/node_modules/moment/dist/locale/bs.js +4 -3
  141. package/node_modules/moment/dist/locale/ca.js +12 -9
  142. package/node_modules/moment/dist/locale/cs.js +15 -6
  143. package/node_modules/moment/dist/locale/cv.js +4 -3
  144. package/node_modules/moment/dist/locale/cy.js +4 -3
  145. package/node_modules/moment/dist/locale/de-at.js +6 -6
  146. package/node_modules/moment/dist/locale/de-ch.js +6 -6
  147. package/node_modules/moment/dist/locale/de.js +6 -6
  148. package/node_modules/moment/dist/locale/el.js +8 -6
  149. package/node_modules/moment/dist/locale/es-do.js +10 -6
  150. package/node_modules/moment/dist/locale/es-mx.js +10 -6
  151. package/node_modules/moment/dist/locale/es-us.js +10 -6
  152. package/node_modules/moment/dist/locale/es.js +10 -6
  153. package/node_modules/moment/dist/locale/et.js +6 -6
  154. package/node_modules/moment/dist/locale/eu.js +8 -6
  155. package/node_modules/moment/dist/locale/fa.js +12 -9
  156. package/node_modules/moment/dist/locale/fi.js +12 -9
  157. package/node_modules/moment/dist/locale/fo.js +4 -3
  158. package/node_modules/moment/dist/locale/fr-ca.js +4 -3
  159. package/node_modules/moment/dist/locale/fr-ch.js +4 -3
  160. package/node_modules/moment/dist/locale/fr.js +10 -6
  161. package/node_modules/moment/dist/locale/fy.js +4 -6
  162. package/node_modules/moment/dist/locale/gl.js +4 -3
  163. package/node_modules/moment/dist/locale/gom-deva.js +8 -6
  164. package/node_modules/moment/dist/locale/gom-latn.js +6 -6
  165. package/node_modules/moment/dist/locale/gu.js +4 -3
  166. package/node_modules/moment/dist/locale/he.js +4 -4
  167. package/node_modules/moment/dist/locale/hi.js +14 -10
  168. package/node_modules/moment/dist/locale/hr.js +7 -5
  169. package/node_modules/moment/dist/locale/hu.js +6 -6
  170. package/node_modules/moment/dist/locale/hy-am.js +8 -6
  171. package/node_modules/moment/dist/locale/is.js +4 -3
  172. package/node_modules/moment/dist/locale/ka.js +10 -10
  173. package/node_modules/moment/dist/locale/km.js +4 -3
  174. package/node_modules/moment/dist/locale/kn.js +4 -3
  175. package/node_modules/moment/dist/locale/ku.js +6 -6
  176. package/node_modules/moment/dist/locale/lb.js +8 -6
  177. package/node_modules/moment/dist/locale/lo.js +4 -3
  178. package/node_modules/moment/dist/locale/lt.js +8 -6
  179. package/node_modules/moment/dist/locale/lv.js +4 -3
  180. package/node_modules/moment/dist/locale/me.js +2 -3
  181. package/node_modules/moment/dist/locale/mi.js +4 -3
  182. package/node_modules/moment/dist/locale/ml.js +8 -6
  183. package/node_modules/moment/dist/locale/mn.js +4 -3
  184. package/node_modules/moment/dist/locale/mr.js +4 -3
  185. package/node_modules/moment/dist/locale/mt.js +4 -3
  186. package/node_modules/moment/dist/locale/nb.js +2 -3
  187. package/node_modules/moment/dist/locale/ne.js +4 -3
  188. package/node_modules/moment/dist/locale/nl-be.js +12 -12
  189. package/node_modules/moment/dist/locale/nl.js +12 -12
  190. package/node_modules/moment/dist/locale/nn.js +2 -3
  191. package/node_modules/moment/dist/locale/oc-lnc.js +8 -6
  192. package/node_modules/moment/dist/locale/pa-in.js +4 -3
  193. package/node_modules/moment/dist/locale/pl.js +10 -9
  194. package/node_modules/moment/dist/locale/pt-br.js +4 -3
  195. package/node_modules/moment/dist/locale/pt.js +4 -3
  196. package/node_modules/moment/dist/locale/ro.js +4 -3
  197. package/node_modules/moment/dist/locale/ru.js +20 -13
  198. package/node_modules/moment/dist/locale/se.js +6 -6
  199. package/node_modules/moment/dist/locale/si.js +4 -3
  200. package/node_modules/moment/dist/locale/sk.js +4 -3
  201. package/node_modules/moment/dist/locale/sl.js +4 -3
  202. package/node_modules/moment/dist/locale/sr-cyrl.js +32 -22
  203. package/node_modules/moment/dist/locale/sr.js +32 -22
  204. package/node_modules/moment/dist/locale/ss.js +4 -3
  205. package/node_modules/moment/dist/locale/sw.js +4 -3
  206. package/node_modules/moment/dist/locale/ta.js +8 -6
  207. package/node_modules/moment/dist/locale/te.js +8 -6
  208. package/node_modules/moment/dist/locale/tg.js +4 -3
  209. package/node_modules/moment/dist/locale/th.js +4 -3
  210. package/node_modules/moment/dist/locale/tlh.js +8 -9
  211. package/node_modules/moment/dist/locale/tr.js +1 -1
  212. package/node_modules/moment/dist/locale/tzm-latn.js +4 -3
  213. package/node_modules/moment/dist/locale/tzm.js +4 -3
  214. package/node_modules/moment/dist/locale/ug-cn.js +4 -3
  215. package/node_modules/moment/dist/locale/uk.js +16 -12
  216. package/node_modules/moment/dist/locale/uz-latn.js +4 -3
  217. package/node_modules/moment/dist/locale/vi.js +4 -3
  218. package/node_modules/moment/dist/locale/x-pseudo.js +8 -6
  219. package/node_modules/moment/dist/moment.js +95 -80
  220. package/node_modules/moment/locale/ar-kw.js +4 -3
  221. package/node_modules/moment/locale/ar-ly.js +1 -1
  222. package/node_modules/moment/locale/ar-ma.js +4 -3
  223. package/node_modules/moment/locale/ar-sa.js +4 -3
  224. package/node_modules/moment/locale/ar-tn.js +4 -3
  225. package/node_modules/moment/locale/az.js +4 -3
  226. package/node_modules/moment/locale/be.js +10 -9
  227. package/node_modules/moment/locale/bn-bd.js +4 -3
  228. package/node_modules/moment/locale/bn.js +4 -3
  229. package/node_modules/moment/locale/bo.js +8 -6
  230. package/node_modules/moment/locale/br.js +6 -3
  231. package/node_modules/moment/locale/bs.js +4 -3
  232. package/node_modules/moment/locale/ca.js +12 -9
  233. package/node_modules/moment/locale/cs.js +15 -6
  234. package/node_modules/moment/locale/cv.js +4 -3
  235. package/node_modules/moment/locale/cy.js +4 -3
  236. package/node_modules/moment/locale/de-at.js +6 -6
  237. package/node_modules/moment/locale/de-ch.js +6 -6
  238. package/node_modules/moment/locale/de.js +6 -6
  239. package/node_modules/moment/locale/el.js +8 -6
  240. package/node_modules/moment/locale/es-do.js +10 -6
  241. package/node_modules/moment/locale/es-mx.js +10 -6
  242. package/node_modules/moment/locale/es-us.js +10 -6
  243. package/node_modules/moment/locale/es.js +10 -6
  244. package/node_modules/moment/locale/et.js +6 -6
  245. package/node_modules/moment/locale/eu.js +8 -6
  246. package/node_modules/moment/locale/fa.js +12 -9
  247. package/node_modules/moment/locale/fi.js +12 -9
  248. package/node_modules/moment/locale/fo.js +4 -3
  249. package/node_modules/moment/locale/fr-ca.js +4 -3
  250. package/node_modules/moment/locale/fr-ch.js +4 -3
  251. package/node_modules/moment/locale/fr.js +10 -6
  252. package/node_modules/moment/locale/fy.js +4 -6
  253. package/node_modules/moment/locale/gl.js +4 -3
  254. package/node_modules/moment/locale/gom-deva.js +8 -6
  255. package/node_modules/moment/locale/gom-latn.js +6 -6
  256. package/node_modules/moment/locale/gu.js +4 -3
  257. package/node_modules/moment/locale/he.js +4 -4
  258. package/node_modules/moment/locale/hi.js +14 -10
  259. package/node_modules/moment/locale/hr.js +7 -5
  260. package/node_modules/moment/locale/hu.js +6 -6
  261. package/node_modules/moment/locale/hy-am.js +8 -6
  262. package/node_modules/moment/locale/is.js +4 -3
  263. package/node_modules/moment/locale/ka.js +10 -10
  264. package/node_modules/moment/locale/km.js +4 -3
  265. package/node_modules/moment/locale/kn.js +4 -3
  266. package/node_modules/moment/locale/ku.js +6 -6
  267. package/node_modules/moment/locale/lb.js +8 -6
  268. package/node_modules/moment/locale/lo.js +4 -3
  269. package/node_modules/moment/locale/lt.js +8 -6
  270. package/node_modules/moment/locale/lv.js +4 -3
  271. package/node_modules/moment/locale/me.js +2 -3
  272. package/node_modules/moment/locale/mi.js +4 -3
  273. package/node_modules/moment/locale/ml.js +8 -6
  274. package/node_modules/moment/locale/mn.js +4 -3
  275. package/node_modules/moment/locale/mr.js +4 -3
  276. package/node_modules/moment/locale/mt.js +4 -3
  277. package/node_modules/moment/locale/nb.js +2 -3
  278. package/node_modules/moment/locale/ne.js +4 -3
  279. package/node_modules/moment/locale/nl-be.js +12 -12
  280. package/node_modules/moment/locale/nl.js +12 -12
  281. package/node_modules/moment/locale/nn.js +2 -3
  282. package/node_modules/moment/locale/oc-lnc.js +8 -6
  283. package/node_modules/moment/locale/pa-in.js +4 -3
  284. package/node_modules/moment/locale/pl.js +10 -9
  285. package/node_modules/moment/locale/pt-br.js +4 -3
  286. package/node_modules/moment/locale/pt.js +4 -3
  287. package/node_modules/moment/locale/ro.js +4 -3
  288. package/node_modules/moment/locale/ru.js +20 -13
  289. package/node_modules/moment/locale/se.js +6 -6
  290. package/node_modules/moment/locale/si.js +4 -3
  291. package/node_modules/moment/locale/sk.js +4 -3
  292. package/node_modules/moment/locale/sl.js +4 -3
  293. package/node_modules/moment/locale/sr-cyrl.js +32 -22
  294. package/node_modules/moment/locale/sr.js +32 -22
  295. package/node_modules/moment/locale/ss.js +4 -3
  296. package/node_modules/moment/locale/sw.js +4 -3
  297. package/node_modules/moment/locale/ta.js +8 -6
  298. package/node_modules/moment/locale/te.js +8 -6
  299. package/node_modules/moment/locale/tg.js +4 -3
  300. package/node_modules/moment/locale/th.js +4 -3
  301. package/node_modules/moment/locale/tlh.js +8 -9
  302. package/node_modules/moment/locale/tr.js +1 -1
  303. package/node_modules/moment/locale/tzm-latn.js +4 -3
  304. package/node_modules/moment/locale/tzm.js +4 -3
  305. package/node_modules/moment/locale/ug-cn.js +4 -3
  306. package/node_modules/moment/locale/uk.js +16 -12
  307. package/node_modules/moment/locale/uz-latn.js +4 -3
  308. package/node_modules/moment/locale/vi.js +4 -3
  309. package/node_modules/moment/locale/x-pseudo.js +8 -6
  310. package/node_modules/moment/min/locales.js +613 -474
  311. package/node_modules/moment/min/locales.min.js +1 -1
  312. package/node_modules/moment/min/locales.min.js.map +1 -1
  313. package/node_modules/moment/min/moment-with-locales.js +707 -553
  314. package/node_modules/moment/min/moment-with-locales.min.js +1 -1
  315. package/node_modules/moment/min/moment-with-locales.min.js.map +1 -1
  316. package/node_modules/moment/min/moment.min.js +1 -1
  317. package/node_modules/moment/min/moment.min.js.map +1 -1
  318. package/node_modules/moment/moment.js +95 -80
  319. package/node_modules/moment/package.json +4 -4
  320. package/node_modules/moment/src/lib/create/from-string-and-array.js +4 -3
  321. package/node_modules/moment/src/lib/create/from-string-and-format.js +4 -3
  322. package/node_modules/moment/src/lib/create/from-string.js +11 -7
  323. package/node_modules/moment/src/lib/duration/create.js +2 -1
  324. package/node_modules/moment/src/lib/duration/valid.js +3 -2
  325. package/node_modules/moment/src/lib/format/format.js +2 -1
  326. package/node_modules/moment/src/lib/locale/locales.js +7 -1
  327. package/node_modules/moment/src/lib/moment/constructor.js +6 -3
  328. package/node_modules/moment/src/lib/moment/get-set.js +3 -2
  329. package/node_modules/moment/src/lib/parse/regex.js +8 -10
  330. package/node_modules/moment/src/lib/parse/token.js +4 -2
  331. package/node_modules/moment/src/lib/units/day-of-week.js +2 -3
  332. package/node_modules/moment/src/lib/units/era.js +10 -12
  333. package/node_modules/moment/src/lib/units/month.js +6 -6
  334. package/node_modules/moment/src/lib/units/week-year.js +6 -8
  335. package/node_modules/moment/src/lib/units/week.js +6 -8
  336. package/node_modules/moment/src/lib/utils/deprecate.js +3 -2
  337. package/node_modules/moment/src/lib/utils/is-moment-input.js +3 -2
  338. package/node_modules/moment/src/lib/utils/map.js +3 -2
  339. package/node_modules/moment/src/locale/ar-kw.js +4 -3
  340. package/node_modules/moment/src/locale/ar-ly.js +1 -1
  341. package/node_modules/moment/src/locale/ar-ma.js +4 -3
  342. package/node_modules/moment/src/locale/ar-sa.js +4 -3
  343. package/node_modules/moment/src/locale/ar-tn.js +4 -3
  344. package/node_modules/moment/src/locale/az.js +4 -3
  345. package/node_modules/moment/src/locale/be.js +10 -9
  346. package/node_modules/moment/src/locale/bn-bd.js +4 -3
  347. package/node_modules/moment/src/locale/bn.js +4 -3
  348. package/node_modules/moment/src/locale/bo.js +8 -6
  349. package/node_modules/moment/src/locale/br.js +6 -3
  350. package/node_modules/moment/src/locale/bs.js +4 -3
  351. package/node_modules/moment/src/locale/ca.js +12 -9
  352. package/node_modules/moment/src/locale/cs.js +15 -6
  353. package/node_modules/moment/src/locale/cv.js +4 -3
  354. package/node_modules/moment/src/locale/cy.js +4 -3
  355. package/node_modules/moment/src/locale/de-at.js +6 -6
  356. package/node_modules/moment/src/locale/de-ch.js +6 -6
  357. package/node_modules/moment/src/locale/de.js +6 -6
  358. package/node_modules/moment/src/locale/el.js +8 -6
  359. package/node_modules/moment/src/locale/es-do.js +10 -6
  360. package/node_modules/moment/src/locale/es-mx.js +10 -6
  361. package/node_modules/moment/src/locale/es-us.js +10 -6
  362. package/node_modules/moment/src/locale/es.js +10 -6
  363. package/node_modules/moment/src/locale/et.js +6 -6
  364. package/node_modules/moment/src/locale/eu.js +8 -6
  365. package/node_modules/moment/src/locale/fa.js +12 -9
  366. package/node_modules/moment/src/locale/fi.js +12 -9
  367. package/node_modules/moment/src/locale/fo.js +4 -3
  368. package/node_modules/moment/src/locale/fr-ca.js +4 -3
  369. package/node_modules/moment/src/locale/fr-ch.js +4 -3
  370. package/node_modules/moment/src/locale/fr.js +10 -6
  371. package/node_modules/moment/src/locale/fy.js +4 -6
  372. package/node_modules/moment/src/locale/gl.js +4 -3
  373. package/node_modules/moment/src/locale/gom-deva.js +8 -6
  374. package/node_modules/moment/src/locale/gom-latn.js +6 -6
  375. package/node_modules/moment/src/locale/gu.js +4 -3
  376. package/node_modules/moment/src/locale/he.js +4 -4
  377. package/node_modules/moment/src/locale/hi.js +14 -10
  378. package/node_modules/moment/src/locale/hr.js +7 -5
  379. package/node_modules/moment/src/locale/hu.js +6 -6
  380. package/node_modules/moment/src/locale/hy-am.js +8 -6
  381. package/node_modules/moment/src/locale/is.js +4 -3
  382. package/node_modules/moment/src/locale/ka.js +10 -10
  383. package/node_modules/moment/src/locale/km.js +4 -3
  384. package/node_modules/moment/src/locale/kn.js +4 -3
  385. package/node_modules/moment/src/locale/ku.js +6 -6
  386. package/node_modules/moment/src/locale/lb.js +8 -6
  387. package/node_modules/moment/src/locale/lo.js +4 -3
  388. package/node_modules/moment/src/locale/lt.js +8 -6
  389. package/node_modules/moment/src/locale/lv.js +4 -3
  390. package/node_modules/moment/src/locale/me.js +2 -3
  391. package/node_modules/moment/src/locale/mi.js +4 -3
  392. package/node_modules/moment/src/locale/ml.js +8 -6
  393. package/node_modules/moment/src/locale/mn.js +4 -3
  394. package/node_modules/moment/src/locale/mr.js +4 -3
  395. package/node_modules/moment/src/locale/mt.js +4 -3
  396. package/node_modules/moment/src/locale/nb.js +2 -3
  397. package/node_modules/moment/src/locale/ne.js +4 -3
  398. package/node_modules/moment/src/locale/nl-be.js +12 -12
  399. package/node_modules/moment/src/locale/nl.js +12 -12
  400. package/node_modules/moment/src/locale/nn.js +2 -3
  401. package/node_modules/moment/src/locale/oc-lnc.js +8 -6
  402. package/node_modules/moment/src/locale/pa-in.js +4 -3
  403. package/node_modules/moment/src/locale/pl.js +10 -9
  404. package/node_modules/moment/src/locale/pt-br.js +4 -3
  405. package/node_modules/moment/src/locale/pt.js +4 -3
  406. package/node_modules/moment/src/locale/ro.js +4 -3
  407. package/node_modules/moment/src/locale/ru.js +20 -13
  408. package/node_modules/moment/src/locale/se.js +6 -6
  409. package/node_modules/moment/src/locale/si.js +4 -3
  410. package/node_modules/moment/src/locale/sk.js +4 -3
  411. package/node_modules/moment/src/locale/sl.js +4 -3
  412. package/node_modules/moment/src/locale/sr-cyrl.js +32 -22
  413. package/node_modules/moment/src/locale/sr.js +32 -22
  414. package/node_modules/moment/src/locale/ss.js +4 -3
  415. package/node_modules/moment/src/locale/sw.js +4 -3
  416. package/node_modules/moment/src/locale/ta.js +8 -6
  417. package/node_modules/moment/src/locale/te.js +8 -6
  418. package/node_modules/moment/src/locale/tg.js +4 -3
  419. package/node_modules/moment/src/locale/th.js +4 -3
  420. package/node_modules/moment/src/locale/tlh.js +8 -9
  421. package/node_modules/moment/src/locale/tr.js +1 -1
  422. package/node_modules/moment/src/locale/tzm-latn.js +4 -3
  423. package/node_modules/moment/src/locale/tzm.js +4 -3
  424. package/node_modules/moment/src/locale/ug-cn.js +4 -3
  425. package/node_modules/moment/src/locale/uk.js +16 -12
  426. package/node_modules/moment/src/locale/uz-latn.js +4 -3
  427. package/node_modules/moment/src/locale/vi.js +4 -3
  428. package/node_modules/moment/src/locale/x-pseudo.js +8 -6
  429. package/node_modules/moment/src/moment.js +2 -2
  430. package/node_modules/moment/ts3.1-typings/moment.d.ts +1 -1
  431. package/package.json +2 -2
@@ -62,6 +62,7 @@
62
62
 
63
63
  /* istanbul ignore file */
64
64
 
65
+ var hasQueueMicrotask = typeof queueMicrotask === 'function' && queueMicrotask;
65
66
  var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
66
67
  var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
67
68
 
@@ -75,7 +76,9 @@
75
76
 
76
77
  var _defer;
77
78
 
78
- if (hasSetImmediate) {
79
+ if (hasQueueMicrotask) {
80
+ _defer = queueMicrotask;
81
+ } else if (hasSetImmediate) {
79
82
  _defer = setImmediate;
80
83
  } else if (hasNextTick) {
81
84
  _defer = process.nextTick;
@@ -300,6 +303,9 @@
300
303
  var len = okeys.length;
301
304
  return function next() {
302
305
  var key = okeys[++i];
306
+ if (key === '__proto__') {
307
+ return next();
308
+ }
303
309
  return i < len ? {value: obj[key], key} : null;
304
310
  };
305
311
  }
@@ -527,12 +533,19 @@
527
533
  * @returns {Promise} a promise, if a callback is omitted
528
534
  * @example
529
535
  *
530
- * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
531
- * var configs = {};
536
+ * // dev.json is a file containing a valid json object config for dev environment
537
+ * // dev.json is a file containing a valid json object config for test environment
538
+ * // prod.json is a file containing a valid json object config for prod environment
539
+ * // invalid.json is a file with a malformed json object
532
540
  *
533
- * async.forEachOf(obj, function (value, key, callback) {
534
- * fs.readFile(__dirname + value, "utf8", function (err, data) {
535
- * if (err) return callback(err);
541
+ * let configs = {}; //global variable
542
+ * let validConfigFileMap = {dev: 'dev.json', test: 'test.json', prod: 'prod.json'};
543
+ * let invalidConfigFileMap = {dev: 'dev.json', test: 'test.json', invalid: 'invalid.json'};
544
+ *
545
+ * // asynchronous function that reads a json file and parses the contents as json object
546
+ * function parseFile(file, key, callback) {
547
+ * fs.readFile(file, "utf8", function(err, data) {
548
+ * if (err) return calback(err);
536
549
  * try {
537
550
  * configs[key] = JSON.parse(data);
538
551
  * } catch (e) {
@@ -540,11 +553,73 @@
540
553
  * }
541
554
  * callback();
542
555
  * });
543
- * }, function (err) {
544
- * if (err) console.error(err.message);
545
- * // configs is now a map of JSON data
546
- * doSomethingWith(configs);
556
+ * }
557
+ *
558
+ * // Using callbacks
559
+ * async.forEachOf(validConfigFileMap, parseFile, function (err) {
560
+ * if (err) {
561
+ * console.error(err);
562
+ * } else {
563
+ * console.log(configs);
564
+ * // configs is now a map of JSON data, e.g.
565
+ * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
566
+ * }
547
567
  * });
568
+ *
569
+ * //Error handing
570
+ * async.forEachOf(invalidConfigFileMap, parseFile, function (err) {
571
+ * if (err) {
572
+ * console.error(err);
573
+ * // JSON parse error exception
574
+ * } else {
575
+ * console.log(configs);
576
+ * }
577
+ * });
578
+ *
579
+ * // Using Promises
580
+ * async.forEachOf(validConfigFileMap, parseFile)
581
+ * .then( () => {
582
+ * console.log(configs);
583
+ * // configs is now a map of JSON data, e.g.
584
+ * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
585
+ * }).catch( err => {
586
+ * console.error(err);
587
+ * });
588
+ *
589
+ * //Error handing
590
+ * async.forEachOf(invalidConfigFileMap, parseFile)
591
+ * .then( () => {
592
+ * console.log(configs);
593
+ * }).catch( err => {
594
+ * console.error(err);
595
+ * // JSON parse error exception
596
+ * });
597
+ *
598
+ * // Using async/await
599
+ * async () => {
600
+ * try {
601
+ * let result = await async.forEachOf(validConfigFileMap, parseFile);
602
+ * console.log(configs);
603
+ * // configs is now a map of JSON data, e.g.
604
+ * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
605
+ * }
606
+ * catch (err) {
607
+ * console.log(err);
608
+ * }
609
+ * }
610
+ *
611
+ * //Error handing
612
+ * async () => {
613
+ * try {
614
+ * let result = await async.forEachOf(invalidConfigFileMap, parseFile);
615
+ * console.log(configs);
616
+ * }
617
+ * catch (err) {
618
+ * console.log(err);
619
+ * // JSON parse error exception
620
+ * }
621
+ * }
622
+ *
548
623
  */
549
624
  function eachOf(coll, iteratee, callback) {
550
625
  var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric;
@@ -556,7 +631,7 @@
556
631
  /**
557
632
  * Produces a new collection of values by mapping each value in `coll` through
558
633
  * the `iteratee` function. The `iteratee` is called with an item from `coll`
559
- * and a callback for when it has finished processing. Each of these callback
634
+ * and a callback for when it has finished processing. Each of these callbacks
560
635
  * takes 2 arguments: an `error`, and the transformed item from `coll`. If
561
636
  * `iteratee` passes an error to its callback, the main `callback` (for the
562
637
  * `map` function) is immediately called with the error.
@@ -586,9 +661,89 @@
586
661
  * @returns {Promise} a promise, if no callback is passed
587
662
  * @example
588
663
  *
589
- * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
590
- * // results is now an array of stats for each file
664
+ * // file1.txt is a file that is 1000 bytes in size
665
+ * // file2.txt is a file that is 2000 bytes in size
666
+ * // file3.txt is a file that is 3000 bytes in size
667
+ * // file4.txt does not exist
668
+ *
669
+ * const fileList = ['file1.txt','file2.txt','file3.txt'];
670
+ * const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
671
+ *
672
+ * // asynchronous function that returns the file size in bytes
673
+ * function getFileSizeInBytes(file, callback) {
674
+ * fs.stat(file, function(err, stat) {
675
+ * if (err) {
676
+ * return callback(err);
677
+ * }
678
+ * callback(null, stat.size);
679
+ * });
680
+ * }
681
+ *
682
+ * // Using callbacks
683
+ * async.map(fileList, getFileSizeInBytes, function(err, results) {
684
+ * if (err) {
685
+ * console.log(err);
686
+ * } else {
687
+ * console.log(results);
688
+ * // results is now an array of the file size in bytes for each file, e.g.
689
+ * // [ 1000, 2000, 3000]
690
+ * }
691
+ * });
692
+ *
693
+ * // Error Handling
694
+ * async.map(withMissingFileList, getFileSizeInBytes, function(err, results) {
695
+ * if (err) {
696
+ * console.log(err);
697
+ * // [ Error: ENOENT: no such file or directory ]
698
+ * } else {
699
+ * console.log(results);
700
+ * }
701
+ * });
702
+ *
703
+ * // Using Promises
704
+ * async.map(fileList, getFileSizeInBytes)
705
+ * .then( results => {
706
+ * console.log(results);
707
+ * // results is now an array of the file size in bytes for each file, e.g.
708
+ * // [ 1000, 2000, 3000]
709
+ * }).catch( err => {
710
+ * console.log(err);
591
711
  * });
712
+ *
713
+ * // Error Handling
714
+ * async.map(withMissingFileList, getFileSizeInBytes)
715
+ * .then( results => {
716
+ * console.log(results);
717
+ * }).catch( err => {
718
+ * console.log(err);
719
+ * // [ Error: ENOENT: no such file or directory ]
720
+ * });
721
+ *
722
+ * // Using async/await
723
+ * async () => {
724
+ * try {
725
+ * let results = await async.map(fileList, getFileSizeInBytes);
726
+ * console.log(results);
727
+ * // results is now an array of the file size in bytes for each file, e.g.
728
+ * // [ 1000, 2000, 3000]
729
+ * }
730
+ * catch (err) {
731
+ * console.log(err);
732
+ * }
733
+ * }
734
+ *
735
+ * // Error Handling
736
+ * async () => {
737
+ * try {
738
+ * let results = await async.map(withMissingFileList, getFileSizeInBytes);
739
+ * console.log(results);
740
+ * }
741
+ * catch (err) {
742
+ * console.log(err);
743
+ * // [ Error: ENOENT: no such file or directory ]
744
+ * }
745
+ * }
746
+ *
592
747
  */
593
748
  function map (coll, iteratee, callback) {
594
749
  return _asyncMap(eachOf$1, coll, iteratee, callback)
@@ -762,15 +917,40 @@
762
917
  * @returns {Promise} a promise, if a callback is not passed
763
918
  * @example
764
919
  *
920
+ * //Using Callbacks
765
921
  * async.auto({
766
- * // this function will just be passed a callback
767
- * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
768
- * showData: ['readData', function(results, cb) {
769
- * // results.readData is the file's contents
770
- * // ...
922
+ * get_data: function(callback) {
923
+ * // async code to get some data
924
+ * callback(null, 'data', 'converted to array');
925
+ * },
926
+ * make_folder: function(callback) {
927
+ * // async code to create a directory to store a file in
928
+ * // this is run at the same time as getting the data
929
+ * callback(null, 'folder');
930
+ * },
931
+ * write_file: ['get_data', 'make_folder', function(results, callback) {
932
+ * // once there is some data and the directory exists,
933
+ * // write the data to a file in the directory
934
+ * callback(null, 'filename');
935
+ * }],
936
+ * email_link: ['write_file', function(results, callback) {
937
+ * // once the file is written let's email a link to it...
938
+ * callback(null, {'file':results.write_file, 'email':'user@example.com'});
771
939
  * }]
772
- * }, callback);
940
+ * }, function(err, results) {
941
+ * if (err) {
942
+ * console.log('err = ', err);
943
+ * }
944
+ * console.log('results = ', results);
945
+ * // results = {
946
+ * // get_data: ['data', 'converted to array']
947
+ * // make_folder; 'folder',
948
+ * // write_file: 'filename'
949
+ * // email_link: { file: 'filename', email: 'user@example.com' }
950
+ * // }
951
+ * });
773
952
  *
953
+ * //Using Promises
774
954
  * async.auto({
775
955
  * get_data: function(callback) {
776
956
  * console.log('in get_data');
@@ -784,21 +964,62 @@
784
964
  * callback(null, 'folder');
785
965
  * },
786
966
  * write_file: ['get_data', 'make_folder', function(results, callback) {
787
- * console.log('in write_file', JSON.stringify(results));
788
967
  * // once there is some data and the directory exists,
789
968
  * // write the data to a file in the directory
790
969
  * callback(null, 'filename');
791
970
  * }],
792
971
  * email_link: ['write_file', function(results, callback) {
793
- * console.log('in email_link', JSON.stringify(results));
794
972
  * // once the file is written let's email a link to it...
795
- * // results.write_file contains the filename returned by write_file.
796
973
  * callback(null, {'file':results.write_file, 'email':'user@example.com'});
797
974
  * }]
798
- * }, function(err, results) {
799
- * console.log('err = ', err);
975
+ * }).then(results => {
800
976
  * console.log('results = ', results);
977
+ * // results = {
978
+ * // get_data: ['data', 'converted to array']
979
+ * // make_folder; 'folder',
980
+ * // write_file: 'filename'
981
+ * // email_link: { file: 'filename', email: 'user@example.com' }
982
+ * // }
983
+ * }).catch(err => {
984
+ * console.log('err = ', err);
801
985
  * });
986
+ *
987
+ * //Using async/await
988
+ * async () => {
989
+ * try {
990
+ * let results = await async.auto({
991
+ * get_data: function(callback) {
992
+ * // async code to get some data
993
+ * callback(null, 'data', 'converted to array');
994
+ * },
995
+ * make_folder: function(callback) {
996
+ * // async code to create a directory to store a file in
997
+ * // this is run at the same time as getting the data
998
+ * callback(null, 'folder');
999
+ * },
1000
+ * write_file: ['get_data', 'make_folder', function(results, callback) {
1001
+ * // once there is some data and the directory exists,
1002
+ * // write the data to a file in the directory
1003
+ * callback(null, 'filename');
1004
+ * }],
1005
+ * email_link: ['write_file', function(results, callback) {
1006
+ * // once the file is written let's email a link to it...
1007
+ * callback(null, {'file':results.write_file, 'email':'user@example.com'});
1008
+ * }]
1009
+ * });
1010
+ * console.log('results = ', results);
1011
+ * // results = {
1012
+ * // get_data: ['data', 'converted to array']
1013
+ * // make_folder; 'folder',
1014
+ * // write_file: 'filename'
1015
+ * // email_link: { file: 'filename', email: 'user@example.com' }
1016
+ * // }
1017
+ * }
1018
+ * catch (err) {
1019
+ * console.log(err);
1020
+ * }
1021
+ * }
1022
+ *
802
1023
  */
803
1024
  function auto(tasks, concurrency, callback) {
804
1025
  if (typeof concurrency !== 'number') {
@@ -976,10 +1197,36 @@
976
1197
  var ARROW_FN_ARGS = /^(?:async\s+)?\(?\s*([^)=]+)\s*\)?(?:\s*=>)/;
977
1198
  var FN_ARG_SPLIT = /,/;
978
1199
  var FN_ARG = /(=.+)?(\s*)$/;
979
- var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
1200
+
1201
+ function stripComments(string) {
1202
+ let stripped = '';
1203
+ let index = 0;
1204
+ let endBlockComment = string.indexOf('*/');
1205
+ while (index < string.length) {
1206
+ if (string[index] === '/' && string[index+1] === '/') {
1207
+ // inline comment
1208
+ let endIndex = string.indexOf('\n', index);
1209
+ index = (endIndex === -1) ? string.length : endIndex;
1210
+ } else if ((endBlockComment !== -1) && (string[index] === '/') && (string[index+1] === '*')) {
1211
+ // block comment
1212
+ let endIndex = string.indexOf('*/', index);
1213
+ if (endIndex !== -1) {
1214
+ index = endIndex + 2;
1215
+ endBlockComment = string.indexOf('*/', index);
1216
+ } else {
1217
+ stripped += string[index];
1218
+ index++;
1219
+ }
1220
+ } else {
1221
+ stripped += string[index];
1222
+ index++;
1223
+ }
1224
+ }
1225
+ return stripped;
1226
+ }
980
1227
 
981
1228
  function parseParams(func) {
982
- const src = func.toString().replace(STRIP_COMMENTS, '');
1229
+ const src = stripComments(func.toString());
983
1230
  let match = src.match(FN_ARGS);
984
1231
  if (!match) {
985
1232
  match = src.match(ARROW_FN_ARGS);
@@ -1606,7 +1853,7 @@
1606
1853
  * @param {AsyncFunction} iteratee - A function applied to each item in the
1607
1854
  * array to produce the next step in the reduction.
1608
1855
  * The `iteratee` should complete with the next state of the reduction.
1609
- * If the iteratee complete with an error, the reduction is stopped and the
1856
+ * If the iteratee completes with an error, the reduction is stopped and the
1610
1857
  * main `callback` is immediately called with the error.
1611
1858
  * Invoked with (memo, item, callback).
1612
1859
  * @param {Function} [callback] - A callback which is called after all the
@@ -1615,14 +1862,90 @@
1615
1862
  * @returns {Promise} a promise, if no callback is passed
1616
1863
  * @example
1617
1864
  *
1618
- * async.reduce([1,2,3], 0, function(memo, item, callback) {
1619
- * // pointless async:
1620
- * process.nextTick(function() {
1621
- * callback(null, memo + item)
1865
+ * // file1.txt is a file that is 1000 bytes in size
1866
+ * // file2.txt is a file that is 2000 bytes in size
1867
+ * // file3.txt is a file that is 3000 bytes in size
1868
+ * // file4.txt does not exist
1869
+ *
1870
+ * const fileList = ['file1.txt','file2.txt','file3.txt'];
1871
+ * const withMissingFileList = ['file1.txt','file2.txt','file3.txt', 'file4.txt'];
1872
+ *
1873
+ * // asynchronous function that computes the file size in bytes
1874
+ * // file size is added to the memoized value, then returned
1875
+ * function getFileSizeInBytes(memo, file, callback) {
1876
+ * fs.stat(file, function(err, stat) {
1877
+ * if (err) {
1878
+ * return callback(err);
1879
+ * }
1880
+ * callback(null, memo + stat.size);
1622
1881
  * });
1623
- * }, function(err, result) {
1624
- * // result is now equal to the last value of memo, which is 6
1882
+ * }
1883
+ *
1884
+ * // Using callbacks
1885
+ * async.reduce(fileList, 0, getFileSizeInBytes, function(err, result) {
1886
+ * if (err) {
1887
+ * console.log(err);
1888
+ * } else {
1889
+ * console.log(result);
1890
+ * // 6000
1891
+ * // which is the sum of the file sizes of the three files
1892
+ * }
1893
+ * });
1894
+ *
1895
+ * // Error Handling
1896
+ * async.reduce(withMissingFileList, 0, getFileSizeInBytes, function(err, result) {
1897
+ * if (err) {
1898
+ * console.log(err);
1899
+ * // [ Error: ENOENT: no such file or directory ]
1900
+ * } else {
1901
+ * console.log(result);
1902
+ * }
1903
+ * });
1904
+ *
1905
+ * // Using Promises
1906
+ * async.reduce(fileList, 0, getFileSizeInBytes)
1907
+ * .then( result => {
1908
+ * console.log(result);
1909
+ * // 6000
1910
+ * // which is the sum of the file sizes of the three files
1911
+ * }).catch( err => {
1912
+ * console.log(err);
1625
1913
  * });
1914
+ *
1915
+ * // Error Handling
1916
+ * async.reduce(withMissingFileList, 0, getFileSizeInBytes)
1917
+ * .then( result => {
1918
+ * console.log(result);
1919
+ * }).catch( err => {
1920
+ * console.log(err);
1921
+ * // [ Error: ENOENT: no such file or directory ]
1922
+ * });
1923
+ *
1924
+ * // Using async/await
1925
+ * async () => {
1926
+ * try {
1927
+ * let result = await async.reduce(fileList, 0, getFileSizeInBytes);
1928
+ * console.log(result);
1929
+ * // 6000
1930
+ * // which is the sum of the file sizes of the three files
1931
+ * }
1932
+ * catch (err) {
1933
+ * console.log(err);
1934
+ * }
1935
+ * }
1936
+ *
1937
+ * // Error Handling
1938
+ * async () => {
1939
+ * try {
1940
+ * let result = await async.reduce(withMissingFileList, 0, getFileSizeInBytes);
1941
+ * console.log(result);
1942
+ * }
1943
+ * catch (err) {
1944
+ * console.log(err);
1945
+ * // [ Error: ENOENT: no such file or directory ]
1946
+ * }
1947
+ * }
1948
+ *
1626
1949
  */
1627
1950
  function reduce(coll, memo, iteratee, callback) {
1628
1951
  callback = once(callback);
@@ -1660,7 +1983,7 @@
1660
1983
  * app.get('/cats', function(request, response) {
1661
1984
  * var User = request.models.User;
1662
1985
  * async.seq(
1663
- * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
1986
+ * User.get.bind(User), // 'User.get' has signature (id, callback(err, data))
1664
1987
  * function(user, fn) {
1665
1988
  * user.getCats(fn); // 'getCats' has signature (callback(err, data))
1666
1989
  * }
@@ -1826,9 +2149,77 @@
1826
2149
  * @returns A Promise, if no callback is passed
1827
2150
  * @example
1828
2151
  *
1829
- * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
1830
- * // files is now a list of filenames that exist in the 3 directories
2152
+ * // dir1 is a directory that contains file1.txt, file2.txt
2153
+ * // dir2 is a directory that contains file3.txt, file4.txt
2154
+ * // dir3 is a directory that contains file5.txt
2155
+ * // dir4 does not exist
2156
+ *
2157
+ * let directoryList = ['dir1','dir2','dir3'];
2158
+ * let withMissingDirectoryList = ['dir1','dir2','dir3', 'dir4'];
2159
+ *
2160
+ * // Using callbacks
2161
+ * async.concat(directoryList, fs.readdir, function(err, results) {
2162
+ * if (err) {
2163
+ * console.log(err);
2164
+ * } else {
2165
+ * console.log(results);
2166
+ * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
2167
+ * }
2168
+ * });
2169
+ *
2170
+ * // Error Handling
2171
+ * async.concat(withMissingDirectoryList, fs.readdir, function(err, results) {
2172
+ * if (err) {
2173
+ * console.log(err);
2174
+ * // [ Error: ENOENT: no such file or directory ]
2175
+ * // since dir4 does not exist
2176
+ * } else {
2177
+ * console.log(results);
2178
+ * }
2179
+ * });
2180
+ *
2181
+ * // Using Promises
2182
+ * async.concat(directoryList, fs.readdir)
2183
+ * .then(results => {
2184
+ * console.log(results);
2185
+ * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
2186
+ * }).catch(err => {
2187
+ * console.log(err);
2188
+ * });
2189
+ *
2190
+ * // Error Handling
2191
+ * async.concat(withMissingDirectoryList, fs.readdir)
2192
+ * .then(results => {
2193
+ * console.log(results);
2194
+ * }).catch(err => {
2195
+ * console.log(err);
2196
+ * // [ Error: ENOENT: no such file or directory ]
2197
+ * // since dir4 does not exist
1831
2198
  * });
2199
+ *
2200
+ * // Using async/await
2201
+ * async () => {
2202
+ * try {
2203
+ * let results = await async.concat(directoryList, fs.readdir);
2204
+ * console.log(results);
2205
+ * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
2206
+ * } catch (err) {
2207
+ * console.log(err);
2208
+ * }
2209
+ * }
2210
+ *
2211
+ * // Error Handling
2212
+ * async () => {
2213
+ * try {
2214
+ * let results = await async.concat(withMissingDirectoryList, fs.readdir);
2215
+ * console.log(results);
2216
+ * } catch (err) {
2217
+ * console.log(err);
2218
+ * // [ Error: ENOENT: no such file or directory ]
2219
+ * // since dir4 does not exist
2220
+ * }
2221
+ * }
2222
+ *
1832
2223
  */
1833
2224
  function concat(coll, iteratee, callback) {
1834
2225
  return concatLimit$1(coll, Infinity, iteratee, callback)
@@ -1960,13 +2351,48 @@
1960
2351
  * @returns A Promise, if no callback is passed
1961
2352
  * @example
1962
2353
  *
1963
- * async.detect(['file1','file2','file3'], function(filePath, callback) {
1964
- * fs.access(filePath, function(err) {
1965
- * callback(null, !err)
1966
- * });
1967
- * }, function(err, result) {
2354
+ * // dir1 is a directory that contains file1.txt, file2.txt
2355
+ * // dir2 is a directory that contains file3.txt, file4.txt
2356
+ * // dir3 is a directory that contains file5.txt
2357
+ *
2358
+ * // asynchronous function that checks if a file exists
2359
+ * function fileExists(file, callback) {
2360
+ * fs.access(file, fs.constants.F_OK, (err) => {
2361
+ * callback(null, !err);
2362
+ * });
2363
+ * }
2364
+ *
2365
+ * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists,
2366
+ * function(err, result) {
2367
+ * console.log(result);
2368
+ * // dir1/file1.txt
2369
+ * // result now equals the first file in the list that exists
2370
+ * }
2371
+ *);
2372
+ *
2373
+ * // Using Promises
2374
+ * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists)
2375
+ * .then(result => {
2376
+ * console.log(result);
2377
+ * // dir1/file1.txt
1968
2378
  * // result now equals the first file in the list that exists
2379
+ * }).catch(err => {
2380
+ * console.log(err);
1969
2381
  * });
2382
+ *
2383
+ * // Using async/await
2384
+ * async () => {
2385
+ * try {
2386
+ * let result = await async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists);
2387
+ * console.log(result);
2388
+ * // dir1/file1.txt
2389
+ * // result now equals the file in the list that exists
2390
+ * }
2391
+ * catch (err) {
2392
+ * console.log(err);
2393
+ * }
2394
+ * }
2395
+ *
1970
2396
  */
1971
2397
  function detect(coll, iteratee, callback) {
1972
2398
  return _createTester(bool => bool, (res, item) => item)(eachOf$1, coll, iteratee, callback)
@@ -2030,12 +2456,15 @@
2030
2456
 
2031
2457
  function consoleFunc(name) {
2032
2458
  return (fn, ...args) => wrapAsync(fn)(...args, (err, ...resultArgs) => {
2459
+ /* istanbul ignore else */
2033
2460
  if (typeof console === 'object') {
2461
+ /* istanbul ignore else */
2034
2462
  if (err) {
2463
+ /* istanbul ignore else */
2035
2464
  if (console.error) {
2036
2465
  console.error(err);
2037
2466
  }
2038
- } else if (console[name]) {
2467
+ } else if (console[name]) { /* istanbul ignore else */
2039
2468
  resultArgs.forEach(x => console[name](x));
2040
2469
  }
2041
2470
  }
@@ -2180,37 +2609,78 @@
2180
2609
  * @returns {Promise} a promise, if a callback is omitted
2181
2610
  * @example
2182
2611
  *
2183
- * // assuming openFiles is an array of file names and saveFile is a function
2184
- * // to save the modified contents of that file:
2185
- *
2186
- * async.each(openFiles, saveFile, function(err){
2187
- * // if any of the saves produced an error, err would equal that error
2188
- * });
2612
+ * // dir1 is a directory that contains file1.txt, file2.txt
2613
+ * // dir2 is a directory that contains file3.txt, file4.txt
2614
+ * // dir3 is a directory that contains file5.txt
2615
+ * // dir4 does not exist
2189
2616
  *
2190
- * // assuming openFiles is an array of file names
2191
- * async.each(openFiles, function(file, callback) {
2617
+ * const fileList = [ 'dir1/file2.txt', 'dir2/file3.txt', 'dir/file5.txt'];
2618
+ * const withMissingFileList = ['dir1/file1.txt', 'dir4/file2.txt'];
2192
2619
  *
2193
- * // Perform operation on file here.
2194
- * console.log('Processing file ' + file);
2620
+ * // asynchronous function that deletes a file
2621
+ * const deleteFile = function(file, callback) {
2622
+ * fs.unlink(file, callback);
2623
+ * };
2195
2624
  *
2196
- * if( file.length > 32 ) {
2197
- * console.log('This file name is too long');
2198
- * callback('File name too long');
2199
- * } else {
2200
- * // Do work to process file here
2201
- * console.log('File processed');
2202
- * callback();
2203
- * }
2204
- * }, function(err) {
2205
- * // if any of the file processing produced an error, err would equal that error
2625
+ * // Using callbacks
2626
+ * async.each(fileList, deleteFile, function(err) {
2206
2627
  * if( err ) {
2207
- * // One of the iterations produced an error.
2208
- * // All processing will now stop.
2209
- * console.log('A file failed to process');
2628
+ * console.log(err);
2210
2629
  * } else {
2211
- * console.log('All files have been processed successfully');
2630
+ * console.log('All files have been deleted successfully');
2212
2631
  * }
2213
2632
  * });
2633
+ *
2634
+ * // Error Handling
2635
+ * async.each(withMissingFileList, deleteFile, function(err){
2636
+ * console.log(err);
2637
+ * // [ Error: ENOENT: no such file or directory ]
2638
+ * // since dir4/file2.txt does not exist
2639
+ * // dir1/file1.txt could have been deleted
2640
+ * });
2641
+ *
2642
+ * // Using Promises
2643
+ * async.each(fileList, deleteFile)
2644
+ * .then( () => {
2645
+ * console.log('All files have been deleted successfully');
2646
+ * }).catch( err => {
2647
+ * console.log(err);
2648
+ * });
2649
+ *
2650
+ * // Error Handling
2651
+ * async.each(fileList, deleteFile)
2652
+ * .then( () => {
2653
+ * console.log('All files have been deleted successfully');
2654
+ * }).catch( err => {
2655
+ * console.log(err);
2656
+ * // [ Error: ENOENT: no such file or directory ]
2657
+ * // since dir4/file2.txt does not exist
2658
+ * // dir1/file1.txt could have been deleted
2659
+ * });
2660
+ *
2661
+ * // Using async/await
2662
+ * async () => {
2663
+ * try {
2664
+ * await async.each(files, deleteFile);
2665
+ * }
2666
+ * catch (err) {
2667
+ * console.log(err);
2668
+ * }
2669
+ * }
2670
+ *
2671
+ * // Error Handling
2672
+ * async () => {
2673
+ * try {
2674
+ * await async.each(withMissingFileList, deleteFile);
2675
+ * }
2676
+ * catch (err) {
2677
+ * console.log(err);
2678
+ * // [ Error: ENOENT: no such file or directory ]
2679
+ * // since dir4/file2.txt does not exist
2680
+ * // dir1/file1.txt could have been deleted
2681
+ * }
2682
+ * }
2683
+ *
2214
2684
  */
2215
2685
  function eachLimit(coll, iteratee, callback) {
2216
2686
  return eachOf$1(coll, _withoutIndex(wrapAsync(iteratee)), callback);
@@ -2345,13 +2815,78 @@
2345
2815
  * @returns {Promise} a promise, if no callback provided
2346
2816
  * @example
2347
2817
  *
2348
- * async.every(['file1','file2','file3'], function(filePath, callback) {
2349
- * fs.access(filePath, function(err) {
2350
- * callback(null, !err)
2351
- * });
2352
- * }, function(err, result) {
2353
- * // if result is true then every file exists
2818
+ * // dir1 is a directory that contains file1.txt, file2.txt
2819
+ * // dir2 is a directory that contains file3.txt, file4.txt
2820
+ * // dir3 is a directory that contains file5.txt
2821
+ * // dir4 does not exist
2822
+ *
2823
+ * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file5.txt'];
2824
+ * const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
2825
+ *
2826
+ * // asynchronous function that checks if a file exists
2827
+ * function fileExists(file, callback) {
2828
+ * fs.access(file, fs.constants.F_OK, (err) => {
2829
+ * callback(null, !err);
2830
+ * });
2831
+ * }
2832
+ *
2833
+ * // Using callbacks
2834
+ * async.every(fileList, fileExists, function(err, result) {
2835
+ * console.log(result);
2836
+ * // true
2837
+ * // result is true since every file exists
2838
+ * });
2839
+ *
2840
+ * async.every(withMissingFileList, fileExists, function(err, result) {
2841
+ * console.log(result);
2842
+ * // false
2843
+ * // result is false since NOT every file exists
2354
2844
  * });
2845
+ *
2846
+ * // Using Promises
2847
+ * async.every(fileList, fileExists)
2848
+ * .then( result => {
2849
+ * console.log(result);
2850
+ * // true
2851
+ * // result is true since every file exists
2852
+ * }).catch( err => {
2853
+ * console.log(err);
2854
+ * });
2855
+ *
2856
+ * async.every(withMissingFileList, fileExists)
2857
+ * .then( result => {
2858
+ * console.log(result);
2859
+ * // false
2860
+ * // result is false since NOT every file exists
2861
+ * }).catch( err => {
2862
+ * console.log(err);
2863
+ * });
2864
+ *
2865
+ * // Using async/await
2866
+ * async () => {
2867
+ * try {
2868
+ * let result = await async.every(fileList, fileExists);
2869
+ * console.log(result);
2870
+ * // true
2871
+ * // result is true since every file exists
2872
+ * }
2873
+ * catch (err) {
2874
+ * console.log(err);
2875
+ * }
2876
+ * }
2877
+ *
2878
+ * async () => {
2879
+ * try {
2880
+ * let result = await async.every(withMissingFileList, fileExists);
2881
+ * console.log(result);
2882
+ * // false
2883
+ * // result is false since NOT every file exists
2884
+ * }
2885
+ * catch (err) {
2886
+ * console.log(err);
2887
+ * }
2888
+ * }
2889
+ *
2355
2890
  */
2356
2891
  function every(coll, iteratee, callback) {
2357
2892
  return _createTester(bool => !bool, res => !res)(eachOf$1, coll, iteratee, callback)
@@ -2469,13 +3004,53 @@
2469
3004
  * @returns {Promise} a promise, if no callback provided
2470
3005
  * @example
2471
3006
  *
2472
- * async.filter(['file1','file2','file3'], function(filePath, callback) {
2473
- * fs.access(filePath, function(err) {
2474
- * callback(null, !err)
2475
- * });
2476
- * }, function(err, results) {
2477
- * // results now equals an array of the existing files
3007
+ * // dir1 is a directory that contains file1.txt, file2.txt
3008
+ * // dir2 is a directory that contains file3.txt, file4.txt
3009
+ * // dir3 is a directory that contains file5.txt
3010
+ *
3011
+ * const files = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
3012
+ *
3013
+ * // asynchronous function that checks if a file exists
3014
+ * function fileExists(file, callback) {
3015
+ * fs.access(file, fs.constants.F_OK, (err) => {
3016
+ * callback(null, !err);
3017
+ * });
3018
+ * }
3019
+ *
3020
+ * // Using callbacks
3021
+ * async.filter(files, fileExists, function(err, results) {
3022
+ * if(err) {
3023
+ * console.log(err);
3024
+ * } else {
3025
+ * console.log(results);
3026
+ * // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
3027
+ * // results is now an array of the existing files
3028
+ * }
3029
+ * });
3030
+ *
3031
+ * // Using Promises
3032
+ * async.filter(files, fileExists)
3033
+ * .then(results => {
3034
+ * console.log(results);
3035
+ * // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
3036
+ * // results is now an array of the existing files
3037
+ * }).catch(err => {
3038
+ * console.log(err);
2478
3039
  * });
3040
+ *
3041
+ * // Using async/await
3042
+ * async () => {
3043
+ * try {
3044
+ * let results = await async.filter(files, fileExists);
3045
+ * console.log(results);
3046
+ * // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
3047
+ * // results is now an array of the existing files
3048
+ * }
3049
+ * catch (err) {
3050
+ * console.log(err);
3051
+ * }
3052
+ * }
3053
+ *
2479
3054
  */
2480
3055
  function filter (coll, iteratee, callback) {
2481
3056
  return _filter(eachOf$1, coll, iteratee, callback)
@@ -2652,15 +3227,69 @@
2652
3227
  * @returns {Promise} a promise, if no callback is passed
2653
3228
  * @example
2654
3229
  *
2655
- * async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) {
2656
- * db.findById(userId, function(err, user) {
2657
- * if (err) return callback(err);
2658
- * return callback(null, user.age);
3230
+ * // dir1 is a directory that contains file1.txt, file2.txt
3231
+ * // dir2 is a directory that contains file3.txt, file4.txt
3232
+ * // dir3 is a directory that contains file5.txt
3233
+ * // dir4 does not exist
3234
+ *
3235
+ * const files = ['dir1/file1.txt','dir2','dir4']
3236
+ *
3237
+ * // asynchronous function that detects file type as none, file, or directory
3238
+ * function detectFile(file, callback) {
3239
+ * fs.stat(file, function(err, stat) {
3240
+ * if (err) {
3241
+ * return callback(null, 'none');
3242
+ * }
3243
+ * callback(null, stat.isDirectory() ? 'directory' : 'file');
2659
3244
  * });
2660
- * }, function(err, result) {
2661
- * // result is object containing the userIds grouped by age
2662
- * // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']};
3245
+ * }
3246
+ *
3247
+ * //Using callbacks
3248
+ * async.groupBy(files, detectFile, function(err, result) {
3249
+ * if(err) {
3250
+ * console.log(err);
3251
+ * } else {
3252
+ * console.log(result);
3253
+ * // {
3254
+ * // file: [ 'dir1/file1.txt' ],
3255
+ * // none: [ 'dir4' ],
3256
+ * // directory: [ 'dir2']
3257
+ * // }
3258
+ * // result is object containing the files grouped by type
3259
+ * }
2663
3260
  * });
3261
+ *
3262
+ * // Using Promises
3263
+ * async.groupBy(files, detectFile)
3264
+ * .then( result => {
3265
+ * console.log(result);
3266
+ * // {
3267
+ * // file: [ 'dir1/file1.txt' ],
3268
+ * // none: [ 'dir4' ],
3269
+ * // directory: [ 'dir2']
3270
+ * // }
3271
+ * // result is object containing the files grouped by type
3272
+ * }).catch( err => {
3273
+ * console.log(err);
3274
+ * });
3275
+ *
3276
+ * // Using async/await
3277
+ * async () => {
3278
+ * try {
3279
+ * let result = await async.groupBy(files, detectFile);
3280
+ * console.log(result);
3281
+ * // {
3282
+ * // file: [ 'dir1/file1.txt' ],
3283
+ * // none: [ 'dir4' ],
3284
+ * // directory: [ 'dir2']
3285
+ * // }
3286
+ * // result is object containing the files grouped by type
3287
+ * }
3288
+ * catch (err) {
3289
+ * console.log(err);
3290
+ * }
3291
+ * }
3292
+ *
2664
3293
  */
2665
3294
  function groupBy (coll, iteratee, callback) {
2666
3295
  return groupByLimit$1(coll, Infinity, iteratee, callback)
@@ -2681,7 +3310,7 @@
2681
3310
  * The iteratee should complete with a `key` to group the value under.
2682
3311
  * Invoked with (value, callback).
2683
3312
  * @param {Function} [callback] - A callback which is called when all `iteratee`
2684
- * functions have finished, or an error occurs. Result is an `Object` whoses
3313
+ * functions have finished, or an error occurs. Result is an `Object` whose
2685
3314
  * properties are arrays of values which returned the corresponding key.
2686
3315
  * @returns {Promise} a promise, if no callback is passed
2687
3316
  */
@@ -2785,20 +3414,110 @@
2785
3414
  * @returns {Promise} a promise, if no callback is passed
2786
3415
  * @example
2787
3416
  *
2788
- * async.mapValues({
2789
- * f1: 'file1',
2790
- * f2: 'file2',
2791
- * f3: 'file3'
2792
- * }, function (file, key, callback) {
2793
- * fs.stat(file, callback);
2794
- * }, function(err, result) {
2795
- * // result is now a map of stats for each file, e.g.
3417
+ * // file1.txt is a file that is 1000 bytes in size
3418
+ * // file2.txt is a file that is 2000 bytes in size
3419
+ * // file3.txt is a file that is 3000 bytes in size
3420
+ * // file4.txt does not exist
3421
+ *
3422
+ * const fileMap = {
3423
+ * f1: 'file1.txt',
3424
+ * f2: 'file2.txt',
3425
+ * f3: 'file3.txt'
3426
+ * };
3427
+ *
3428
+ * const withMissingFileMap = {
3429
+ * f1: 'file1.txt',
3430
+ * f2: 'file2.txt',
3431
+ * f3: 'file4.txt'
3432
+ * };
3433
+ *
3434
+ * // asynchronous function that returns the file size in bytes
3435
+ * function getFileSizeInBytes(file, key, callback) {
3436
+ * fs.stat(file, function(err, stat) {
3437
+ * if (err) {
3438
+ * return callback(err);
3439
+ * }
3440
+ * callback(null, stat.size);
3441
+ * });
3442
+ * }
3443
+ *
3444
+ * // Using callbacks
3445
+ * async.mapValues(fileMap, getFileSizeInBytes, function(err, result) {
3446
+ * if (err) {
3447
+ * console.log(err);
3448
+ * } else {
3449
+ * console.log(result);
3450
+ * // result is now a map of file size in bytes for each file, e.g.
3451
+ * // {
3452
+ * // f1: 1000,
3453
+ * // f2: 2000,
3454
+ * // f3: 3000
3455
+ * // }
3456
+ * }
3457
+ * });
3458
+ *
3459
+ * // Error handling
3460
+ * async.mapValues(withMissingFileMap, getFileSizeInBytes, function(err, result) {
3461
+ * if (err) {
3462
+ * console.log(err);
3463
+ * // [ Error: ENOENT: no such file or directory ]
3464
+ * } else {
3465
+ * console.log(result);
3466
+ * }
3467
+ * });
3468
+ *
3469
+ * // Using Promises
3470
+ * async.mapValues(fileMap, getFileSizeInBytes)
3471
+ * .then( result => {
3472
+ * console.log(result);
3473
+ * // result is now a map of file size in bytes for each file, e.g.
2796
3474
  * // {
2797
- * // f1: [stats for file1],
2798
- * // f2: [stats for file2],
2799
- * // f3: [stats for file3]
3475
+ * // f1: 1000,
3476
+ * // f2: 2000,
3477
+ * // f3: 3000
2800
3478
  * // }
3479
+ * }).catch (err => {
3480
+ * console.log(err);
2801
3481
  * });
3482
+ *
3483
+ * // Error Handling
3484
+ * async.mapValues(withMissingFileMap, getFileSizeInBytes)
3485
+ * .then( result => {
3486
+ * console.log(result);
3487
+ * }).catch (err => {
3488
+ * console.log(err);
3489
+ * // [ Error: ENOENT: no such file or directory ]
3490
+ * });
3491
+ *
3492
+ * // Using async/await
3493
+ * async () => {
3494
+ * try {
3495
+ * let result = await async.mapValues(fileMap, getFileSizeInBytes);
3496
+ * console.log(result);
3497
+ * // result is now a map of file size in bytes for each file, e.g.
3498
+ * // {
3499
+ * // f1: 1000,
3500
+ * // f2: 2000,
3501
+ * // f3: 3000
3502
+ * // }
3503
+ * }
3504
+ * catch (err) {
3505
+ * console.log(err);
3506
+ * }
3507
+ * }
3508
+ *
3509
+ * // Error Handling
3510
+ * async () => {
3511
+ * try {
3512
+ * let result = await async.mapValues(withMissingFileMap, getFileSizeInBytes);
3513
+ * console.log(result);
3514
+ * }
3515
+ * catch (err) {
3516
+ * console.log(err);
3517
+ * // [ Error: ENOENT: no such file or directory ]
3518
+ * }
3519
+ * }
3520
+ *
2802
3521
  */
2803
3522
  function mapValues(obj, iteratee, callback) {
2804
3523
  return mapValuesLimit$1(obj, Infinity, iteratee, callback)
@@ -2898,6 +3617,8 @@
2898
3617
  return memoized;
2899
3618
  }
2900
3619
 
3620
+ /* istanbul ignore file */
3621
+
2901
3622
  /**
2902
3623
  * Calls `callback` on a later loop around the event loop. In Node.js this just
2903
3624
  * calls `process.nextTick`. In the browser it will use `setImmediate` if
@@ -2941,7 +3662,7 @@
2941
3662
 
2942
3663
  var nextTick = wrap(_defer$1);
2943
3664
 
2944
- var parallel = awaitify((eachfn, tasks, callback) => {
3665
+ var _parallel = awaitify((eachfn, tasks, callback) => {
2945
3666
  var results = isArrayLike(tasks) ? [] : {};
2946
3667
 
2947
3668
  eachfn(tasks, (task, key, taskCb) => {
@@ -2991,6 +3712,8 @@
2991
3712
  * @returns {Promise} a promise, if a callback is not passed
2992
3713
  *
2993
3714
  * @example
3715
+ *
3716
+ * //Using Callbacks
2994
3717
  * async.parallel([
2995
3718
  * function(callback) {
2996
3719
  * setTimeout(function() {
@@ -3002,10 +3725,9 @@
3002
3725
  * callback(null, 'two');
3003
3726
  * }, 100);
3004
3727
  * }
3005
- * ],
3006
- * // optional callback
3007
- * function(err, results) {
3008
- * // the results array will equal ['one','two'] even though
3728
+ * ], function(err, results) {
3729
+ * console.log(results);
3730
+ * // results is equal to ['one','two'] even though
3009
3731
  * // the second function had a shorter timeout.
3010
3732
  * });
3011
3733
  *
@@ -3022,11 +3744,99 @@
3022
3744
  * }, 100);
3023
3745
  * }
3024
3746
  * }, function(err, results) {
3025
- * // results is now equals to: {one: 1, two: 2}
3747
+ * console.log(results);
3748
+ * // results is equal to: { one: 1, two: 2 }
3026
3749
  * });
3750
+ *
3751
+ * //Using Promises
3752
+ * async.parallel([
3753
+ * function(callback) {
3754
+ * setTimeout(function() {
3755
+ * callback(null, 'one');
3756
+ * }, 200);
3757
+ * },
3758
+ * function(callback) {
3759
+ * setTimeout(function() {
3760
+ * callback(null, 'two');
3761
+ * }, 100);
3762
+ * }
3763
+ * ]).then(results => {
3764
+ * console.log(results);
3765
+ * // results is equal to ['one','two'] even though
3766
+ * // the second function had a shorter timeout.
3767
+ * }).catch(err => {
3768
+ * console.log(err);
3769
+ * });
3770
+ *
3771
+ * // an example using an object instead of an array
3772
+ * async.parallel({
3773
+ * one: function(callback) {
3774
+ * setTimeout(function() {
3775
+ * callback(null, 1);
3776
+ * }, 200);
3777
+ * },
3778
+ * two: function(callback) {
3779
+ * setTimeout(function() {
3780
+ * callback(null, 2);
3781
+ * }, 100);
3782
+ * }
3783
+ * }).then(results => {
3784
+ * console.log(results);
3785
+ * // results is equal to: { one: 1, two: 2 }
3786
+ * }).catch(err => {
3787
+ * console.log(err);
3788
+ * });
3789
+ *
3790
+ * //Using async/await
3791
+ * async () => {
3792
+ * try {
3793
+ * let results = await async.parallel([
3794
+ * function(callback) {
3795
+ * setTimeout(function() {
3796
+ * callback(null, 'one');
3797
+ * }, 200);
3798
+ * },
3799
+ * function(callback) {
3800
+ * setTimeout(function() {
3801
+ * callback(null, 'two');
3802
+ * }, 100);
3803
+ * }
3804
+ * ]);
3805
+ * console.log(results);
3806
+ * // results is equal to ['one','two'] even though
3807
+ * // the second function had a shorter timeout.
3808
+ * }
3809
+ * catch (err) {
3810
+ * console.log(err);
3811
+ * }
3812
+ * }
3813
+ *
3814
+ * // an example using an object instead of an array
3815
+ * async () => {
3816
+ * try {
3817
+ * let results = await async.parallel({
3818
+ * one: function(callback) {
3819
+ * setTimeout(function() {
3820
+ * callback(null, 1);
3821
+ * }, 200);
3822
+ * },
3823
+ * two: function(callback) {
3824
+ * setTimeout(function() {
3825
+ * callback(null, 2);
3826
+ * }, 100);
3827
+ * }
3828
+ * });
3829
+ * console.log(results);
3830
+ * // results is equal to: { one: 1, two: 2 }
3831
+ * }
3832
+ * catch (err) {
3833
+ * console.log(err);
3834
+ * }
3835
+ * }
3836
+ *
3027
3837
  */
3028
- function parallel$1(tasks, callback) {
3029
- return parallel(eachOf$1, tasks, callback);
3838
+ function parallel(tasks, callback) {
3839
+ return _parallel(eachOf$1, tasks, callback);
3030
3840
  }
3031
3841
 
3032
3842
  /**
@@ -3050,7 +3860,7 @@
3050
3860
  * @returns {Promise} a promise, if a callback is not passed
3051
3861
  */
3052
3862
  function parallelLimit(tasks, limit, callback) {
3053
- return parallel(eachOfLimit(limit), tasks, callback);
3863
+ return _parallel(eachOfLimit(limit), tasks, callback);
3054
3864
  }
3055
3865
 
3056
3866
  /**
@@ -3081,7 +3891,7 @@
3081
3891
  * Invoke with `queue.unshift(task, [callback])`.
3082
3892
  * @property {AsyncFunction} pushAsync - the same as `q.push`, except this returns
3083
3893
  * a promise that rejects if an error occurs.
3084
- * @property {AsyncFunction} unshirtAsync - the same as `q.unshift`, except this returns
3894
+ * @property {AsyncFunction} unshiftAsync - the same as `q.unshift`, except this returns
3085
3895
  * a promise that rejects if an error occurs.
3086
3896
  * @property {Function} remove - remove items from the queue that match a test
3087
3897
  * function. The test function will be passed an object with a `data` property,
@@ -3120,7 +3930,7 @@
3120
3930
  * should be pushed to the queue after calling this function. Invoke with `queue.kill()`.
3121
3931
  *
3122
3932
  * @example
3123
- * const q = aync.queue(worker, 2)
3933
+ * const q = async.queue(worker, 2)
3124
3934
  * q.push(item1)
3125
3935
  * q.push(item2)
3126
3936
  * q.push(item3)
@@ -3343,6 +4153,7 @@
3343
4153
  function priorityQueue(worker, concurrency) {
3344
4154
  // Start with a normal queue
3345
4155
  var q = queue$1(worker, concurrency);
4156
+ var processingScheduled = false;
3346
4157
 
3347
4158
  q._tasks = new Heap();
3348
4159
 
@@ -3370,7 +4181,13 @@
3370
4181
  q._tasks.push(item);
3371
4182
  }
3372
4183
 
3373
- setImmediate$1(q.process);
4184
+ if (!processingScheduled) {
4185
+ processingScheduled = true;
4186
+ setImmediate$1(() => {
4187
+ processingScheduled = false;
4188
+ q.process();
4189
+ });
4190
+ }
3374
4191
  };
3375
4192
 
3376
4193
  // Remove unshift function
@@ -3441,7 +4258,7 @@
3441
4258
  * @param {AsyncFunction} iteratee - A function applied to each item in the
3442
4259
  * array to produce the next step in the reduction.
3443
4260
  * The `iteratee` should complete with the next state of the reduction.
3444
- * If the iteratee complete with an error, the reduction is stopped and the
4261
+ * If the iteratee completes with an error, the reduction is stopped and the
3445
4262
  * main `callback` is immediately called with the error.
3446
4263
  * Invoked with (memo, item, callback).
3447
4264
  * @param {Function} [callback] - A callback which is called after all the
@@ -3623,14 +4440,48 @@
3623
4440
  * @returns {Promise} a promise, if no callback is passed
3624
4441
  * @example
3625
4442
  *
3626
- * async.reject(['file1','file2','file3'], function(filePath, callback) {
3627
- * fs.access(filePath, function(err) {
3628
- * callback(null, !err)
3629
- * });
3630
- * }, function(err, results) {
3631
- * // results now equals an array of missing files
3632
- * createFiles(results);
4443
+ * // dir1 is a directory that contains file1.txt, file2.txt
4444
+ * // dir2 is a directory that contains file3.txt, file4.txt
4445
+ * // dir3 is a directory that contains file5.txt
4446
+ *
4447
+ * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
4448
+ *
4449
+ * // asynchronous function that checks if a file exists
4450
+ * function fileExists(file, callback) {
4451
+ * fs.access(file, fs.constants.F_OK, (err) => {
4452
+ * callback(null, !err);
4453
+ * });
4454
+ * }
4455
+ *
4456
+ * // Using callbacks
4457
+ * async.reject(fileList, fileExists, function(err, results) {
4458
+ * // [ 'dir3/file6.txt' ]
4459
+ * // results now equals an array of the non-existing files
3633
4460
  * });
4461
+ *
4462
+ * // Using Promises
4463
+ * async.reject(fileList, fileExists)
4464
+ * .then( results => {
4465
+ * console.log(results);
4466
+ * // [ 'dir3/file6.txt' ]
4467
+ * // results now equals an array of the non-existing files
4468
+ * }).catch( err => {
4469
+ * console.log(err);
4470
+ * });
4471
+ *
4472
+ * // Using async/await
4473
+ * async () => {
4474
+ * try {
4475
+ * let results = await async.reject(fileList, fileExists);
4476
+ * console.log(results);
4477
+ * // [ 'dir3/file6.txt' ]
4478
+ * // results now equals an array of the non-existing files
4479
+ * }
4480
+ * catch (err) {
4481
+ * console.log(err);
4482
+ * }
4483
+ * }
4484
+ *
3634
4485
  */
3635
4486
  function reject$1 (coll, iteratee, callback) {
3636
4487
  return reject(eachOf$1, coll, iteratee, callback)
@@ -3923,38 +4774,138 @@
3923
4774
  * with (err, result).
3924
4775
  * @return {Promise} a promise, if no callback is passed
3925
4776
  * @example
4777
+ *
4778
+ * //Using Callbacks
3926
4779
  * async.series([
3927
4780
  * function(callback) {
3928
- * // do some stuff ...
3929
- * callback(null, 'one');
4781
+ * setTimeout(function() {
4782
+ * // do some async task
4783
+ * callback(null, 'one');
4784
+ * }, 200);
3930
4785
  * },
3931
4786
  * function(callback) {
3932
- * // do some more stuff ...
3933
- * callback(null, 'two');
4787
+ * setTimeout(function() {
4788
+ * // then do another async task
4789
+ * callback(null, 'two');
4790
+ * }, 100);
3934
4791
  * }
3935
- * ],
3936
- * // optional callback
3937
- * function(err, results) {
3938
- * // results is now equal to ['one', 'two']
4792
+ * ], function(err, results) {
4793
+ * console.log(results);
4794
+ * // results is equal to ['one','two']
3939
4795
  * });
3940
4796
  *
4797
+ * // an example using objects instead of arrays
3941
4798
  * async.series({
3942
4799
  * one: function(callback) {
3943
4800
  * setTimeout(function() {
4801
+ * // do some async task
3944
4802
  * callback(null, 1);
3945
4803
  * }, 200);
3946
4804
  * },
3947
- * two: function(callback){
4805
+ * two: function(callback) {
3948
4806
  * setTimeout(function() {
4807
+ * // then do another async task
3949
4808
  * callback(null, 2);
3950
4809
  * }, 100);
3951
4810
  * }
3952
4811
  * }, function(err, results) {
3953
- * // results is now equal to: {one: 1, two: 2}
4812
+ * console.log(results);
4813
+ * // results is equal to: { one: 1, two: 2 }
4814
+ * });
4815
+ *
4816
+ * //Using Promises
4817
+ * async.series([
4818
+ * function(callback) {
4819
+ * setTimeout(function() {
4820
+ * callback(null, 'one');
4821
+ * }, 200);
4822
+ * },
4823
+ * function(callback) {
4824
+ * setTimeout(function() {
4825
+ * callback(null, 'two');
4826
+ * }, 100);
4827
+ * }
4828
+ * ]).then(results => {
4829
+ * console.log(results);
4830
+ * // results is equal to ['one','two']
4831
+ * }).catch(err => {
4832
+ * console.log(err);
3954
4833
  * });
4834
+ *
4835
+ * // an example using an object instead of an array
4836
+ * async.series({
4837
+ * one: function(callback) {
4838
+ * setTimeout(function() {
4839
+ * // do some async task
4840
+ * callback(null, 1);
4841
+ * }, 200);
4842
+ * },
4843
+ * two: function(callback) {
4844
+ * setTimeout(function() {
4845
+ * // then do another async task
4846
+ * callback(null, 2);
4847
+ * }, 100);
4848
+ * }
4849
+ * }).then(results => {
4850
+ * console.log(results);
4851
+ * // results is equal to: { one: 1, two: 2 }
4852
+ * }).catch(err => {
4853
+ * console.log(err);
4854
+ * });
4855
+ *
4856
+ * //Using async/await
4857
+ * async () => {
4858
+ * try {
4859
+ * let results = await async.series([
4860
+ * function(callback) {
4861
+ * setTimeout(function() {
4862
+ * // do some async task
4863
+ * callback(null, 'one');
4864
+ * }, 200);
4865
+ * },
4866
+ * function(callback) {
4867
+ * setTimeout(function() {
4868
+ * // then do another async task
4869
+ * callback(null, 'two');
4870
+ * }, 100);
4871
+ * }
4872
+ * ]);
4873
+ * console.log(results);
4874
+ * // results is equal to ['one','two']
4875
+ * }
4876
+ * catch (err) {
4877
+ * console.log(err);
4878
+ * }
4879
+ * }
4880
+ *
4881
+ * // an example using an object instead of an array
4882
+ * async () => {
4883
+ * try {
4884
+ * let results = await async.parallel({
4885
+ * one: function(callback) {
4886
+ * setTimeout(function() {
4887
+ * // do some async task
4888
+ * callback(null, 1);
4889
+ * }, 200);
4890
+ * },
4891
+ * two: function(callback) {
4892
+ * setTimeout(function() {
4893
+ * // then do another async task
4894
+ * callback(null, 2);
4895
+ * }, 100);
4896
+ * }
4897
+ * });
4898
+ * console.log(results);
4899
+ * // results is equal to: { one: 1, two: 2 }
4900
+ * }
4901
+ * catch (err) {
4902
+ * console.log(err);
4903
+ * }
4904
+ * }
4905
+ *
3955
4906
  */
3956
4907
  function series(tasks, callback) {
3957
- return parallel(eachOfSeries$1, tasks, callback);
4908
+ return _parallel(eachOfSeries$1, tasks, callback);
3958
4909
  }
3959
4910
 
3960
4911
  /**
@@ -3980,13 +4931,79 @@
3980
4931
  * @returns {Promise} a promise, if no callback provided
3981
4932
  * @example
3982
4933
  *
3983
- * async.some(['file1','file2','file3'], function(filePath, callback) {
3984
- * fs.access(filePath, function(err) {
3985
- * callback(null, !err)
3986
- * });
3987
- * }, function(err, result) {
3988
- * // if result is true then at least one of the files exists
4934
+ * // dir1 is a directory that contains file1.txt, file2.txt
4935
+ * // dir2 is a directory that contains file3.txt, file4.txt
4936
+ * // dir3 is a directory that contains file5.txt
4937
+ * // dir4 does not exist
4938
+ *
4939
+ * // asynchronous function that checks if a file exists
4940
+ * function fileExists(file, callback) {
4941
+ * fs.access(file, fs.constants.F_OK, (err) => {
4942
+ * callback(null, !err);
4943
+ * });
4944
+ * }
4945
+ *
4946
+ * // Using callbacks
4947
+ * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists,
4948
+ * function(err, result) {
4949
+ * console.log(result);
4950
+ * // true
4951
+ * // result is true since some file in the list exists
4952
+ * }
4953
+ *);
4954
+ *
4955
+ * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists,
4956
+ * function(err, result) {
4957
+ * console.log(result);
4958
+ * // false
4959
+ * // result is false since none of the files exists
4960
+ * }
4961
+ *);
4962
+ *
4963
+ * // Using Promises
4964
+ * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists)
4965
+ * .then( result => {
4966
+ * console.log(result);
4967
+ * // true
4968
+ * // result is true since some file in the list exists
4969
+ * }).catch( err => {
4970
+ * console.log(err);
3989
4971
  * });
4972
+ *
4973
+ * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists)
4974
+ * .then( result => {
4975
+ * console.log(result);
4976
+ * // false
4977
+ * // result is false since none of the files exists
4978
+ * }).catch( err => {
4979
+ * console.log(err);
4980
+ * });
4981
+ *
4982
+ * // Using async/await
4983
+ * async () => {
4984
+ * try {
4985
+ * let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists);
4986
+ * console.log(result);
4987
+ * // true
4988
+ * // result is true since some file in the list exists
4989
+ * }
4990
+ * catch (err) {
4991
+ * console.log(err);
4992
+ * }
4993
+ * }
4994
+ *
4995
+ * async () => {
4996
+ * try {
4997
+ * let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists);
4998
+ * console.log(result);
4999
+ * // false
5000
+ * // result is false since none of the files exists
5001
+ * }
5002
+ * catch (err) {
5003
+ * console.log(err);
5004
+ * }
5005
+ * }
5006
+ *
3990
5007
  */
3991
5008
  function some(coll, iteratee, callback) {
3992
5009
  return _createTester(Boolean, res => res)(eachOf$1, coll, iteratee, callback)
@@ -4068,31 +5085,133 @@
4068
5085
  * @returns {Promise} a promise, if no callback passed
4069
5086
  * @example
4070
5087
  *
4071
- * async.sortBy(['file1','file2','file3'], function(file, callback) {
4072
- * fs.stat(file, function(err, stats) {
4073
- * callback(err, stats.mtime);
5088
+ * // bigfile.txt is a file that is 251100 bytes in size
5089
+ * // mediumfile.txt is a file that is 11000 bytes in size
5090
+ * // smallfile.txt is a file that is 121 bytes in size
5091
+ *
5092
+ * // asynchronous function that returns the file size in bytes
5093
+ * function getFileSizeInBytes(file, callback) {
5094
+ * fs.stat(file, function(err, stat) {
5095
+ * if (err) {
5096
+ * return callback(err);
5097
+ * }
5098
+ * callback(null, stat.size);
4074
5099
  * });
4075
- * }, function(err, results) {
4076
- * // results is now the original array of files sorted by
4077
- * // modified date
4078
- * });
5100
+ * }
5101
+ *
5102
+ * // Using callbacks
5103
+ * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes,
5104
+ * function(err, results) {
5105
+ * if (err) {
5106
+ * console.log(err);
5107
+ * } else {
5108
+ * console.log(results);
5109
+ * // results is now the original array of files sorted by
5110
+ * // file size (ascending by default), e.g.
5111
+ * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
5112
+ * }
5113
+ * }
5114
+ * );
4079
5115
  *
4080
5116
  * // By modifying the callback parameter the
4081
5117
  * // sorting order can be influenced:
4082
5118
  *
4083
5119
  * // ascending order
4084
- * async.sortBy([1,9,3,5], function(x, callback) {
4085
- * callback(null, x);
4086
- * }, function(err,result) {
4087
- * // result callback
4088
- * });
5120
+ * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], function(file, callback) {
5121
+ * getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
5122
+ * if (getFileSizeErr) return callback(getFileSizeErr);
5123
+ * callback(null, fileSize);
5124
+ * });
5125
+ * }, function(err, results) {
5126
+ * if (err) {
5127
+ * console.log(err);
5128
+ * } else {
5129
+ * console.log(results);
5130
+ * // results is now the original array of files sorted by
5131
+ * // file size (ascending by default), e.g.
5132
+ * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
5133
+ * }
5134
+ * }
5135
+ * );
4089
5136
  *
4090
5137
  * // descending order
4091
- * async.sortBy([1,9,3,5], function(x, callback) {
4092
- * callback(null, x*-1); //<- x*-1 instead of x, turns the order around
4093
- * }, function(err,result) {
4094
- * // result callback
5138
+ * async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], function(file, callback) {
5139
+ * getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
5140
+ * if (getFileSizeErr) {
5141
+ * return callback(getFileSizeErr);
5142
+ * }
5143
+ * callback(null, fileSize * -1);
5144
+ * });
5145
+ * }, function(err, results) {
5146
+ * if (err) {
5147
+ * console.log(err);
5148
+ * } else {
5149
+ * console.log(results);
5150
+ * // results is now the original array of files sorted by
5151
+ * // file size (ascending by default), e.g.
5152
+ * // [ 'bigfile.txt', 'mediumfile.txt', 'smallfile.txt']
5153
+ * }
5154
+ * }
5155
+ * );
5156
+ *
5157
+ * // Error handling
5158
+ * async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes,
5159
+ * function(err, results) {
5160
+ * if (err) {
5161
+ * console.log(err);
5162
+ * // [ Error: ENOENT: no such file or directory ]
5163
+ * } else {
5164
+ * console.log(results);
5165
+ * }
5166
+ * }
5167
+ * );
5168
+ *
5169
+ * // Using Promises
5170
+ * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes)
5171
+ * .then( results => {
5172
+ * console.log(results);
5173
+ * // results is now the original array of files sorted by
5174
+ * // file size (ascending by default), e.g.
5175
+ * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
5176
+ * }).catch( err => {
5177
+ * console.log(err);
5178
+ * });
5179
+ *
5180
+ * // Error handling
5181
+ * async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes)
5182
+ * .then( results => {
5183
+ * console.log(results);
5184
+ * }).catch( err => {
5185
+ * console.log(err);
5186
+ * // [ Error: ENOENT: no such file or directory ]
4095
5187
  * });
5188
+ *
5189
+ * // Using async/await
5190
+ * (async () => {
5191
+ * try {
5192
+ * let results = await async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes);
5193
+ * console.log(results);
5194
+ * // results is now the original array of files sorted by
5195
+ * // file size (ascending by default), e.g.
5196
+ * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
5197
+ * }
5198
+ * catch (err) {
5199
+ * console.log(err);
5200
+ * }
5201
+ * })();
5202
+ *
5203
+ * // Error handling
5204
+ * async () => {
5205
+ * try {
5206
+ * let results = await async.sortBy(['missingfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes);
5207
+ * console.log(results);
5208
+ * }
5209
+ * catch (err) {
5210
+ * console.log(err);
5211
+ * // [ Error: ENOENT: no such file or directory ]
5212
+ * }
5213
+ * }
5214
+ *
4096
5215
  */
4097
5216
  function sortBy (coll, iteratee, callback) {
4098
5217
  var _iteratee = wrapAsync(iteratee);
@@ -4293,26 +5412,118 @@
4293
5412
  * @returns {Promise} a promise, if no callback provided
4294
5413
  * @example
4295
5414
  *
4296
- * async.transform([1,2,3], function(acc, item, index, callback) {
4297
- * // pointless async:
4298
- * process.nextTick(function() {
4299
- * acc[index] = item * 2
4300
- * callback(null)
5415
+ * // file1.txt is a file that is 1000 bytes in size
5416
+ * // file2.txt is a file that is 2000 bytes in size
5417
+ * // file3.txt is a file that is 3000 bytes in size
5418
+ *
5419
+ * // helper function that returns human-readable size format from bytes
5420
+ * function formatBytes(bytes, decimals = 2) {
5421
+ * // implementation not included for brevity
5422
+ * return humanReadbleFilesize;
5423
+ * }
5424
+ *
5425
+ * const fileList = ['file1.txt','file2.txt','file3.txt'];
5426
+ *
5427
+ * // asynchronous function that returns the file size, transformed to human-readable format
5428
+ * // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc.
5429
+ * function transformFileSize(acc, value, key, callback) {
5430
+ * fs.stat(value, function(err, stat) {
5431
+ * if (err) {
5432
+ * return callback(err);
5433
+ * }
5434
+ * acc[key] = formatBytes(stat.size);
5435
+ * callback(null);
4301
5436
  * });
4302
- * }, function(err, result) {
4303
- * // result is now equal to [2, 4, 6]
5437
+ * }
5438
+ *
5439
+ * // Using callbacks
5440
+ * async.transform(fileList, transformFileSize, function(err, result) {
5441
+ * if(err) {
5442
+ * console.log(err);
5443
+ * } else {
5444
+ * console.log(result);
5445
+ * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
5446
+ * }
5447
+ * });
5448
+ *
5449
+ * // Using Promises
5450
+ * async.transform(fileList, transformFileSize)
5451
+ * .then(result => {
5452
+ * console.log(result);
5453
+ * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
5454
+ * }).catch(err => {
5455
+ * console.log(err);
4304
5456
  * });
4305
5457
  *
5458
+ * // Using async/await
5459
+ * (async () => {
5460
+ * try {
5461
+ * let result = await async.transform(fileList, transformFileSize);
5462
+ * console.log(result);
5463
+ * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
5464
+ * }
5465
+ * catch (err) {
5466
+ * console.log(err);
5467
+ * }
5468
+ * })();
5469
+ *
4306
5470
  * @example
4307
5471
  *
4308
- * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
4309
- * setImmediate(function () {
4310
- * obj[key] = val * 2;
4311
- * callback();
4312
- * })
4313
- * }, function (err, result) {
4314
- * // result is equal to {a: 2, b: 4, c: 6}
4315
- * })
5472
+ * // file1.txt is a file that is 1000 bytes in size
5473
+ * // file2.txt is a file that is 2000 bytes in size
5474
+ * // file3.txt is a file that is 3000 bytes in size
5475
+ *
5476
+ * // helper function that returns human-readable size format from bytes
5477
+ * function formatBytes(bytes, decimals = 2) {
5478
+ * // implementation not included for brevity
5479
+ * return humanReadbleFilesize;
5480
+ * }
5481
+ *
5482
+ * const fileMap = { f1: 'file1.txt', f2: 'file2.txt', f3: 'file3.txt' };
5483
+ *
5484
+ * // asynchronous function that returns the file size, transformed to human-readable format
5485
+ * // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc.
5486
+ * function transformFileSize(acc, value, key, callback) {
5487
+ * fs.stat(value, function(err, stat) {
5488
+ * if (err) {
5489
+ * return callback(err);
5490
+ * }
5491
+ * acc[key] = formatBytes(stat.size);
5492
+ * callback(null);
5493
+ * });
5494
+ * }
5495
+ *
5496
+ * // Using callbacks
5497
+ * async.transform(fileMap, transformFileSize, function(err, result) {
5498
+ * if(err) {
5499
+ * console.log(err);
5500
+ * } else {
5501
+ * console.log(result);
5502
+ * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
5503
+ * }
5504
+ * });
5505
+ *
5506
+ * // Using Promises
5507
+ * async.transform(fileMap, transformFileSize)
5508
+ * .then(result => {
5509
+ * console.log(result);
5510
+ * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
5511
+ * }).catch(err => {
5512
+ * console.log(err);
5513
+ * });
5514
+ *
5515
+ * // Using async/await
5516
+ * async () => {
5517
+ * try {
5518
+ * let result = await async.transform(fileMap, transformFileSize);
5519
+ * console.log(result);
5520
+ * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
5521
+ * }
5522
+ * catch (err) {
5523
+ * console.log(err);
5524
+ * }
5525
+ * }
5526
+ *
4316
5527
  */
4317
5528
  function transform (coll, accumulator, iteratee, callback) {
4318
5529
  if (arguments.length <= 3 && typeof accumulator === 'function') {
@@ -4490,7 +5701,7 @@
4490
5701
  * @example
4491
5702
  * const results = []
4492
5703
  * let finished = false
4493
- * async.until(function test(page, cb) {
5704
+ * async.until(function test(cb) {
4494
5705
  * cb(null, finished)
4495
5706
  * }, function iter(next) {
4496
5707
  * fetchPage(url, (err, body) => {
@@ -4674,7 +5885,7 @@
4674
5885
  mapValuesSeries,
4675
5886
  memoize,
4676
5887
  nextTick,
4677
- parallel: parallel$1,
5888
+ parallel,
4678
5889
  parallelLimit,
4679
5890
  priorityQueue,
4680
5891
  queue: queue$1,
@@ -4782,7 +5993,7 @@
4782
5993
  exports.mapValuesSeries = mapValuesSeries;
4783
5994
  exports.memoize = memoize;
4784
5995
  exports.nextTick = nextTick;
4785
- exports.parallel = parallel$1;
5996
+ exports.parallel = parallel;
4786
5997
  exports.parallelLimit = parallelLimit;
4787
5998
  exports.priorityQueue = priorityQueue;
4788
5999
  exports.queue = queue$1;