You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

268 lines
12 KiB

4 years ago
  1. <h1 align="center">Neo-Async</h1>
  2. <p align="center">
  3. <img src="https://raw.githubusercontent.com/wiki/suguru03/neo-async/images/neo_async_v2.png" width="250px" />
  4. </p>
  5. <p align="center">
  6. <a href="https://www.npmjs.com/package/neo-async"><img alt="npm" src="https://img.shields.io/npm/v/neo-async.svg"></a>
  7. <a href="https://travis-ci.org/suguru03/neo-async"><img alt="Travis Status" src="https://img.shields.io/travis/suguru03/neo-async.svg"></a>
  8. <a href="https://codecov.io/gh/suguru03/neo-async"><img alt="Coverage Status" src="https://img.shields.io/codecov/c/github/suguru03/neo-async/master.svg"></a>
  9. <a href="https://www.npmjs.com/package/neo-async"><img alt="download" src="https://img.shields.io/npm/dm/neo-async.svg"></a>
  10. <a href="https://lgtm.com/projects/g/suguru03/neo-async/context:javascript"><img src="https://img.shields.io/lgtm/grade/javascript/g/suguru03/neo-async.svg?logo=lgtm&logoWidth=18" alt="Code Quality: Javascript" height="18"></a>
  11. <a href="https://lgtm.com/projects/g/suguru03/neo-async/alerts"><img src="https://img.shields.io/lgtm/alerts/g/suguru03/neo-async.svg?logo=lgtm&logoWidth=18" alt="Total Alerts" height="18"></a>
  12. </p>
  13. Neo-Async is thought to be used as a drop-in replacement for [Async](https://github.com/caolan/async), it almost fully covers its functionality and runs [faster](#benchmark).
  14. Benchmark is [here](#benchmark)!
  15. Bluebird's benchmark is [here](https://github.com/suguru03/bluebird/tree/aigle/benchmark)!
  16. ## Code Coverage
  17. ![coverage](https://raw.githubusercontent.com/wiki/suguru03/neo-async/images/coverage.png)
  18. ## Installation
  19. ### In a browser
  20. ```html
  21. <script src="async.min.js"></script>
  22. ```
  23. ### In an AMD loader
  24. ```js
  25. require(['async'], function(async) {});
  26. ```
  27. ### Promise and async/await
  28. I recommend to use [`Aigle`](https://github.com/suguru03/aigle).
  29. It is optimized for Promise handling and has almost the same functionality as `neo-async`.
  30. ### Node.js
  31. #### standard
  32. ```bash
  33. $ npm install neo-async
  34. ```
  35. ```js
  36. var async = require('neo-async');
  37. ```
  38. #### replacement
  39. ```bash
  40. $ npm install neo-async
  41. $ ln -s ./node_modules/neo-async ./node_modules/async
  42. ```
  43. ```js
  44. var async = require('async');
  45. ```
  46. ### Bower
  47. ```bash
  48. bower install neo-async
  49. ```
  50. ## Feature
  51. [JSDoc](http://suguru03.github.io/neo-async/doc/async.html)
  52. \* not in Async
  53. ### Collections
  54. - [`each`](http://suguru03.github.io/neo-async/doc/async.each.html)
  55. - [`eachSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html)
  56. - [`eachLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html)
  57. - [`forEach`](http://suguru03.github.io/neo-async/doc/async.each.html) -> [`each`](http://suguru03.github.io/neo-async/doc/async.each.html)
  58. - [`forEachSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html) -> [`eachSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html)
  59. - [`forEachLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html) -> [`eachLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html)
  60. - [`eachOf`](http://suguru03.github.io/neo-async/doc/async.each.html) -> [`each`](http://suguru03.github.io/neo-async/doc/async.each.html)
  61. - [`eachOfSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html) -> [`eachSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html)
  62. - [`eachOfLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html) -> [`eachLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html)
  63. - [`forEachOf`](http://suguru03.github.io/neo-async/doc/async.each.html) -> [`each`](http://suguru03.github.io/neo-async/doc/async.each.html)
  64. - [`forEachOfSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html) -> [`eachSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html)
  65. - [`eachOfLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html) -> [`forEachLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html)
  66. - [`map`](http://suguru03.github.io/neo-async/doc/async.map.html)
  67. - [`mapSeries`](http://suguru03.github.io/neo-async/doc/async.mapSeries.html)
  68. - [`mapLimit`](http://suguru03.github.io/neo-async/doc/async.mapLimit.html)
  69. - [`mapValues`](http://suguru03.github.io/neo-async/doc/async.mapValues.html)
  70. - [`mapValuesSeries`](http://suguru03.github.io/neo-async/doc/async.mapValuesSeries.html)
  71. - [`mapValuesLimit`](http://suguru03.github.io/neo-async/doc/async.mapValuesLimit.html)
  72. - [`filter`](http://suguru03.github.io/neo-async/doc/async.filter.html)
  73. - [`filterSeries`](http://suguru03.github.io/neo-async/doc/async.filterSeries.html)
  74. - [`filterLimit`](http://suguru03.github.io/neo-async/doc/async.filterLimit.html)
  75. - [`select`](http://suguru03.github.io/neo-async/doc/async.filter.html) -> [`filter`](http://suguru03.github.io/neo-async/doc/async.filter.html)
  76. - [`selectSeries`](http://suguru03.github.io/neo-async/doc/async.filterSeries.html) -> [`filterSeries`](http://suguru03.github.io/neo-async/doc/async.filterSeries.html)
  77. - [`selectLimit`](http://suguru03.github.io/neo-async/doc/async.filterLimit.html) -> [`filterLimit`](http://suguru03.github.io/neo-async/doc/async.filterLimit.html)
  78. - [`reject`](http://suguru03.github.io/neo-async/doc/async.reject.html)
  79. - [`rejectSeries`](http://suguru03.github.io/neo-async/doc/async.rejectSeries.html)
  80. - [`rejectLimit`](http://suguru03.github.io/neo-async/doc/async.rejectLimit.html)
  81. - [`detect`](http://suguru03.github.io/neo-async/doc/async.detect.html)
  82. - [`detectSeries`](http://suguru03.github.io/neo-async/doc/async.detectSeries.html)
  83. - [`detectLimit`](http://suguru03.github.io/neo-async/doc/async.detectLimit.html)
  84. - [`find`](http://suguru03.github.io/neo-async/doc/async.detect.html) -> [`detect`](http://suguru03.github.io/neo-async/doc/async.detect.html)
  85. - [`findSeries`](http://suguru03.github.io/neo-async/doc/async.detectSeries.html) -> [`detectSeries`](http://suguru03.github.io/neo-async/doc/async.detectSeries.html)
  86. - [`findLimit`](http://suguru03.github.io/neo-async/doc/async.detectLimit.html) -> [`detectLimit`](http://suguru03.github.io/neo-async/doc/async.detectLimit.html)
  87. - [`pick`](http://suguru03.github.io/neo-async/doc/async.pick.html) *
  88. - [`pickSeries`](http://suguru03.github.io/neo-async/doc/async.pickSeries.html) *
  89. - [`pickLimit`](http://suguru03.github.io/neo-async/doc/async.pickLimit.html) *
  90. - [`omit`](http://suguru03.github.io/neo-async/doc/async.omit.html) *
  91. - [`omitSeries`](http://suguru03.github.io/neo-async/doc/async.omitSeries.html) *
  92. - [`omitLimit`](http://suguru03.github.io/neo-async/doc/async.omitLimit.html) *
  93. - [`reduce`](http://suguru03.github.io/neo-async/doc/async.reduce.html)
  94. - [`inject`](http://suguru03.github.io/neo-async/doc/async.reduce.html) -> [`reduce`](http://suguru03.github.io/neo-async/doc/async.reduce.html)
  95. - [`foldl`](http://suguru03.github.io/neo-async/doc/async.reduce.html) -> [`reduce`](http://suguru03.github.io/neo-async/doc/async.reduce.html)
  96. - [`reduceRight`](http://suguru03.github.io/neo-async/doc/async.reduceRight.html)
  97. - [`foldr`](http://suguru03.github.io/neo-async/doc/async.reduceRight.html) -> [`reduceRight`](http://suguru03.github.io/neo-async/doc/async.reduceRight.html)
  98. - [`transform`](http://suguru03.github.io/neo-async/doc/async.transform.html)
  99. - [`transformSeries`](http://suguru03.github.io/neo-async/doc/async.transformSeries.html) *
  100. - [`transformLimit`](http://suguru03.github.io/neo-async/doc/async.transformLimit.html) *
  101. - [`sortBy`](http://suguru03.github.io/neo-async/doc/async.sortBy.html)
  102. - [`sortBySeries`](http://suguru03.github.io/neo-async/doc/async.sortBySeries.html) *
  103. - [`sortByLimit`](http://suguru03.github.io/neo-async/doc/async.sortByLimit.html) *
  104. - [`some`](http://suguru03.github.io/neo-async/doc/async.some.html)
  105. - [`someSeries`](http://suguru03.github.io/neo-async/doc/async.someSeries.html)
  106. - [`someLimit`](http://suguru03.github.io/neo-async/doc/async.someLimit.html)
  107. - [`any`](http://suguru03.github.io/neo-async/doc/async.some.html) -> [`some`](http://suguru03.github.io/neo-async/doc/async.some.html)
  108. - [`anySeries`](http://suguru03.github.io/neo-async/doc/async.someSeries.html) -> [`someSeries`](http://suguru03.github.io/neo-async/doc/async.someSeries.html)
  109. - [`anyLimit`](http://suguru03.github.io/neo-async/doc/async.someLimit.html) -> [`someLimit`](http://suguru03.github.io/neo-async/doc/async.someLimit.html)
  110. - [`every`](http://suguru03.github.io/neo-async/doc/async.every.html)
  111. - [`everySeries`](http://suguru03.github.io/neo-async/doc/async.everySeries.html)
  112. - [`everyLimit`](http://suguru03.github.io/neo-async/doc/async.everyLimit.html)
  113. - [`all`](http://suguru03.github.io/neo-async/doc/async.every.html) -> [`every`](http://suguru03.github.io/neo-async/doc/async.every.html)
  114. - [`allSeries`](http://suguru03.github.io/neo-async/doc/async.everySeries.html) -> [`every`](http://suguru03.github.io/neo-async/doc/async.everySeries.html)
  115. - [`allLimit`](http://suguru03.github.io/neo-async/doc/async.everyLimit.html) -> [`every`](http://suguru03.github.io/neo-async/doc/async.everyLimit.html)
  116. - [`concat`](http://suguru03.github.io/neo-async/doc/async.concat.html)
  117. - [`concatSeries`](http://suguru03.github.io/neo-async/doc/async.concatSeries.html)
  118. - [`concatLimit`](http://suguru03.github.io/neo-async/doc/async.concatLimit.html) *
  119. ### Control Flow
  120. - [`parallel`](http://suguru03.github.io/neo-async/doc/async.parallel.html)
  121. - [`series`](http://suguru03.github.io/neo-async/doc/async.series.html)
  122. - [`parallelLimit`](http://suguru03.github.io/neo-async/doc/async.series.html)
  123. - [`tryEach`](http://suguru03.github.io/neo-async/doc/async.tryEach.html)
  124. - [`waterfall`](http://suguru03.github.io/neo-async/doc/async.waterfall.html)
  125. - [`angelFall`](http://suguru03.github.io/neo-async/doc/async.angelFall.html) *
  126. - [`angelfall`](http://suguru03.github.io/neo-async/doc/async.angelFall.html) -> [`angelFall`](http://suguru03.github.io/neo-async/doc/async.angelFall.html) *
  127. - [`whilst`](#whilst)
  128. - [`doWhilst`](#doWhilst)
  129. - [`until`](#until)
  130. - [`doUntil`](#doUntil)
  131. - [`during`](#during)
  132. - [`doDuring`](#doDuring)
  133. - [`forever`](#forever)
  134. - [`compose`](#compose)
  135. - [`seq`](#seq)
  136. - [`applyEach`](#applyEach)
  137. - [`applyEachSeries`](#applyEachSeries)
  138. - [`queue`](#queue)
  139. - [`priorityQueue`](#priorityQueue)
  140. - [`cargo`](#cargo)
  141. - [`auto`](#auto)
  142. - [`autoInject`](#autoInject)
  143. - [`retry`](#retry)
  144. - [`retryable`](#retryable)
  145. - [`iterator`](#iterator)
  146. - [`times`](http://suguru03.github.io/neo-async/doc/async.times.html)
  147. - [`timesSeries`](http://suguru03.github.io/neo-async/doc/async.timesSeries.html)
  148. - [`timesLimit`](http://suguru03.github.io/neo-async/doc/async.timesLimit.html)
  149. - [`race`](#race)
  150. ### Utils
  151. - [`apply`](#apply)
  152. - [`setImmediate`](#setImmediate)
  153. - [`nextTick`](#nextTick)
  154. - [`memoize`](#memoize)
  155. - [`unmemoize`](#unmemoize)
  156. - [`ensureAsync`](#ensureAsync)
  157. - [`constant`](#constant)
  158. - [`asyncify`](#asyncify)
  159. - [`wrapSync`](#asyncify) -> [`asyncify`](#asyncify)
  160. - [`log`](#log)
  161. - [`dir`](#dir)
  162. - [`timeout`](http://suguru03.github.io/neo-async/doc/async.timeout.html)
  163. - [`reflect`](#reflect)
  164. - [`reflectAll`](#reflectAll)
  165. - [`createLogger`](#createLogger)
  166. ## Mode
  167. - [`safe`](#safe) *
  168. - [`fast`](#fast) *
  169. ## Benchmark
  170. [Benchmark: Async vs Neo-Async](http://suguru03.hatenablog.com/entry/2016/06/10/135559)
  171. ### How to check
  172. ```bash
  173. $ node perf
  174. ```
  175. ### Environment
  176. * Darwin 17.3.0 x64
  177. * Node.js v8.9.4
  178. * async v2.6.0
  179. * neo-async v2.5.0
  180. * benchmark v2.1.4
  181. ### Result
  182. The value is the ratio (Neo-Async/Async) of the average speed.
  183. #### Collections
  184. |function|benchmark|
  185. |---|--:|
  186. |each/forEach|2.43|
  187. |eachSeries/forEachSeries|1.75|
  188. |eachLimit/forEachLimit|1.68|
  189. |eachOf|3.29|
  190. |eachOfSeries|1.50|
  191. |eachOfLimit|1.59|
  192. |map|3.95|
  193. |mapSeries|1.81|
  194. |mapLimit|1.27|
  195. |mapValues|2.73|
  196. |mapValuesSeries|1.59|
  197. |mapValuesLimit|1.23|
  198. |filter|3.00|
  199. |filterSeries|1.74|
  200. |filterLimit|1.17|
  201. |reject|4.59|
  202. |rejectSeries|2.31|
  203. |rejectLimit|1.58|
  204. |detect|4.30|
  205. |detectSeries|1.86|
  206. |detectLimit|1.32|
  207. |reduce|1.82|
  208. |transform|2.46|
  209. |sortBy|4.08|
  210. |some|2.19|
  211. |someSeries|1.83|
  212. |someLimit|1.32|
  213. |every|2.09|
  214. |everySeries|1.84|
  215. |everyLimit|1.35|
  216. |concat|3.79|
  217. |concatSeries|4.45|
  218. #### Control Flow
  219. |funciton|benchmark|
  220. |---|--:|
  221. |parallel|2.93|
  222. |series|1.96|
  223. |waterfall|1.29|
  224. |whilst|1.00|
  225. |doWhilst|1.12|
  226. |until|1.12|
  227. |doUntil|1.12|
  228. |during|1.18|
  229. |doDuring|2.42|
  230. |times|4.25|
  231. |auto|1.97|