1 | # Neo-Async v1.7.4
|
2 |
|
3 | [![npm](https://img.shields.io/npm/v/neo-async.svg)](https://www.npmjs.com/package/neo-async)
|
4 | [![Travis](https://img.shields.io/travis/suguru03/neo-async.svg)](https://travis-ci.org/suguru03/neo-async)
|
5 | [![Codecov](https://img.shields.io/codecov/c/github/suguru03/neo-async.svg)](https://codecov.io/github/suguru03/neo-async?branch=master)
|
6 | [![Dependency Status](https://gemnasium.com/suguru03/neo-async.svg)](https://gemnasium.com/suguru03/neo-async)
|
7 | [![npm](https://img.shields.io/npm/dm/neo-async.svg)](https://www.npmjs.com/package/neo-async)
|
8 |
|
9 | 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](#speed-comparison).
|
10 |
|
11 | [Async](https://github.com/caolan/async) allows double callbacks in `waterfall`, but Neo-Async does not allow. ([test](https://github.com/suguru03/async/tree/neo-async/test))
|
12 | PR is welcome ! Especially improvement for English documents :)
|
13 |
|
14 | ![Neo-Async](https://raw.githubusercontent.com/wiki/suguru03/neo-async/images/neo_async.png)
|
15 |
|
16 | ![nodei](https://nodei.co/npm/neo-async.png?downloads=true&downloadRank=true)
|
17 |
|
18 | ## Installation
|
19 |
|
20 | ### In a browser
|
21 | ```html
|
22 | <script src="async.min.js"></script>
|
23 | ```
|
24 |
|
25 | ### In an AMD loader
|
26 | ```js
|
27 | require(['async'], function(async) {});
|
28 | ```
|
29 |
|
30 | ### Node.js
|
31 |
|
32 | #### standard
|
33 |
|
34 | ```bash
|
35 | $ npm install neo-async
|
36 | ```
|
37 | ```js
|
38 | var async = require('neo-async');
|
39 |
|
40 | // safe mode
|
41 | var async = require('neo-async').safe; // avoid stack overflow if iterator is called on sync.
|
42 | ```
|
43 |
|
44 | #### replacement
|
45 | ```bash
|
46 | $ npm install neo-async
|
47 | $ ln -s ./node_modules/neo-async ./node_modules/async
|
48 | ```
|
49 | ```js
|
50 | var async = require('async');
|
51 | ```
|
52 |
|
53 | ### Bower
|
54 |
|
55 | ```bash
|
56 | bower install neo-async
|
57 | ```
|
58 |
|
59 | ## Feature
|
60 |
|
61 | [JSDoc](http://suguru03.github.io/neo-async/doc/async.html)
|
62 |
|
63 | \* not in Async
|
64 |
|
65 | ### Collections
|
66 |
|
67 | - [`each`](http://suguru03.github.io/neo-async/doc/async.each.html)
|
68 | - [`eachSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html)
|
69 | - [`eachLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html)
|
70 | - [`forEach`](http://suguru03.github.io/neo-async/doc/async.each.html) -> [`each`](http://suguru03.github.io/neo-async/doc/async.each.html)
|
71 | - [`forEachSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html) -> [`eachSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html)
|
72 | - [`forEachLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html) -> [`eachLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html)
|
73 | - [`eachOf`](http://suguru03.github.io/neo-async/doc/async.each.html) -> [`each`](http://suguru03.github.io/neo-async/doc/async.each.html)
|
74 | - [`eachOfSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html) -> [`eachSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html)
|
75 | - [`eachOfLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html) -> [`eachLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html)
|
76 | - [`forEachOf`](http://suguru03.github.io/neo-async/doc/async.each.html) -> [`each`](http://suguru03.github.io/neo-async/doc/async.each.html)
|
77 | - [`forEachOfSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html) -> [`eachSeries`](http://suguru03.github.io/neo-async/doc/async.eachSeries.html)
|
78 | - [`eachOfLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html) -> [`forEachLimit`](http://suguru03.github.io/neo-async/doc/async.eachLimit.html)
|
79 | - [`map`](http://suguru03.github.io/neo-async/doc/async.map.html)
|
80 | - [`mapSeries`](http://suguru03.github.io/neo-async/doc/async.mapSeries.html)
|
81 | - [`mapLimit`](http://suguru03.github.io/neo-async/doc/async.mapLimit.html)
|
82 | - [`mapValues`](http://suguru03.github.io/neo-async/doc/async.mapValues.html) *
|
83 | - [`mapValuesSeries`](http://suguru03.github.io/neo-async/doc/async.mapValuesSeries.html) *
|
84 | - [`mapValuesLimit`](http://suguru03.github.io/neo-async/doc/async.mapValuesLimit.html) *
|
85 | - [`filter`](http://suguru03.github.io/neo-async/doc/async.filter.html)
|
86 | - [`filterSeries`](http://suguru03.github.io/neo-async/doc/async.filterSeries.html)
|
87 | - [`filterLimit`](http://suguru03.github.io/neo-async/doc/async.filterLimit.html)
|
88 | - [`select`](http://suguru03.github.io/neo-async/doc/async.filter.html) -> [`filter`](http://suguru03.github.io/neo-async/doc/async.filter.html)
|
89 | - [`selectSeries`](http://suguru03.github.io/neo-async/doc/async.filterSeries.html) -> [`filterSeries`](http://suguru03.github.io/neo-async/doc/async.filterSeries.html)
|
90 | - [`selectLimit`](http://suguru03.github.io/neo-async/doc/async.filterLimit.html) -> [`filterLimit`](http://suguru03.github.io/neo-async/doc/async.filterLimit.html)
|
91 | - [`reject`](http://suguru03.github.io/neo-async/doc/async.reject.html)
|
92 | - [`rejectSeries`](http://suguru03.github.io/neo-async/doc/async.rejectSeries.html)
|
93 | - [`rejectLimit`](http://suguru03.github.io/neo-async/doc/async.rejectLimit.html)
|
94 | - [`detect`](http://suguru03.github.io/neo-async/doc/async.detect.html)
|
95 | - [`detectSeries`](http://suguru03.github.io/neo-async/doc/async.detectSeries.html)
|
96 | - [`detectLimit`](http://suguru03.github.io/neo-async/doc/async.detectLimit.html)
|
97 | - [`pick`](http://suguru03.github.io/neo-async/doc/async.pick.html) *
|
98 | - [`pickSeries`](http://suguru03.github.io/neo-async/doc/async.pickSeries.html) *
|
99 | - [`pickLimit`](http://suguru03.github.io/neo-async/doc/async.pickLimit.html) *
|
100 | - [`omit`](http://suguru03.github.io/neo-async/doc/async.omit.html) *
|
101 | - [`omitSeries`](http://suguru03.github.io/neo-async/doc/async.omitSeries.html) *
|
102 | - [`omitLimit`](http://suguru03.github.io/neo-async/doc/async.omitLimit.html) *
|
103 | - [`reduce`](http://suguru03.github.io/neo-async/doc/async.reduce.html)
|
104 | - [`inject`](http://suguru03.github.io/neo-async/doc/async.reduce.html) -> [`reduce`](http://suguru03.github.io/neo-async/doc/async.reduce.html)
|
105 | - [`foldl`](http://suguru03.github.io/neo-async/doc/async.reduce.html) -> [`reduce`](http://suguru03.github.io/neo-async/doc/async.reduce.html)
|
106 | - [`reduceRight`](http://suguru03.github.io/neo-async/doc/async.reduceRight.html)
|
107 | - [`foldr`](http://suguru03.github.io/neo-async/doc/async.reduceRight.html) -> [`reduceRight`](http://suguru03.github.io/neo-async/doc/async.reduceRight.html)
|
108 | - [`transform`](http://suguru03.github.io/neo-async/doc/async.transform.html) *
|
109 | - [`transformSeries`](http://suguru03.github.io/neo-async/doc/async.transformSeries.html) *
|
110 | - [`transformLimit`](http://suguru03.github.io/neo-async/doc/async.transformLimit.html) *
|
111 | - [`sortBy`](http://suguru03.github.io/neo-async/doc/async.sortBy.html)
|
112 | - [`sortBySeries`](http://suguru03.github.io/neo-async/doc/async.sortBySeries.html)
|
113 | - [`sortByLimit`](http://suguru03.github.io/neo-async/doc/async.sortByLimit.html) *
|
114 | - [`some`](http://suguru03.github.io/neo-async/doc/async.some.html)
|
115 | - [`someSeries`](http://suguru03.github.io/neo-async/doc/async.someSeries.html)
|
116 | - [`someLimit`](http://suguru03.github.io/neo-async/doc/async.someLimit.html)
|
117 | - [`any`](http://suguru03.github.io/neo-async/doc/async.some.html) -> [`some`](http://suguru03.github.io/neo-async/doc/async.some.html)
|
118 | - [`every`](http://suguru03.github.io/neo-async/doc/async.every.html)
|
119 | - [`everySeries`](http://suguru03.github.io/neo-async/doc/async.everySeries.html) *
|
120 | - [`everyLimit`](http://suguru03.github.io/neo-async/doc/async.everyLimit.html)
|
121 | - [`all`](http://suguru03.github.io/neo-async/doc/async.every.html) -> [`every`](http://suguru03.github.io/neo-async/doc/async.every.html)
|
122 | - [`concat`](http://suguru03.github.io/neo-async/doc/async.concat.html)
|
123 | - [`concatSeries`](http://suguru03.github.io/neo-async/doc/async.concatSeries.html)
|
124 | - [`concatLimit`](http://suguru03.github.io/neo-async/doc/async.concatLimit.html) *
|
125 |
|
126 | ### Control Flow
|
127 |
|
128 | - [`parallel`](http://suguru03.github.io/neo-async/doc/async.parallel.html)
|
129 | - [`series`](http://suguru03.github.io/neo-async/doc/async.series.html)
|
130 | - [`parallelLimit`](http://suguru03.github.io/neo-async/doc/async.series.html)
|
131 | - [`waterfall`](http://suguru03.github.io/neo-async/doc/async.waterfall.html)
|
132 | - [`angelFall`](http://suguru03.github.io/neo-async/doc/async.angelFall.html) *
|
133 | - [`angelfall`](http://suguru03.github.io/neo-async/doc/async.angelFall.html) -> [`angelFall`](http://suguru03.github.io/neo-async/doc/async.angelFall.html) *
|
134 | - [`whilst`](#whilst)
|
135 | - [`doWhilst`](#doWhilst)
|
136 | - [`until`](#until)
|
137 | - [`forever`](#forever)
|
138 | - [`compose`](#compose)
|
139 | - [`seq`](#seq)
|
140 | - [`applyEach`](#applyEach)
|
141 | - [`applyEachSeries`](#applyEachSeries)
|
142 | - [`queue`](#queue)
|
143 | - [`priorityQueue`](#priorityQueue)
|
144 | - [`cargo`](#cargo)
|
145 | - [`auto`](#auto)
|
146 | - [`retry`](#retry)
|
147 | - [`iterator`](#iterator)
|
148 | - [`times`](http://suguru03.github.io/neo-async/doc/async.times.html)
|
149 | - [`timesSeries`](http://suguru03.github.io/neo-async/doc/async.timesSeries.html)
|
150 | - [`timesLimit`](http://suguru03.github.io/neo-async/doc/async.timesLimit.html)
|
151 |
|
152 | ### Utils
|
153 | - [`apply`](#apply)
|
154 | - [`nextTick`](#nextTick)
|
155 | - [`setImmediate`](#setImmediate)
|
156 | - [`safeNextTick`](#safeNextTick) *
|
157 | - [`asyncify`](#asyncify)
|
158 | - [`wrapSync`](#asyncify) -> [`asyncify`](#asyncify)
|
159 | - [`constant`](#constant)
|
160 | - [`ensureAsync`](#ensureAsync)
|
161 | - [`memoize`](#memoize)
|
162 | - [`unmemoize`](#unmemoize)
|
163 | - [`log`](#log)
|
164 | - [`dir`](#dir)
|
165 | - [`createLogger`](#createLogger)
|
166 | - [`noConflict`](#noConflict)
|
167 | - [`eventEmitter`](#eventEmitter) *
|
168 | - [`EventEmitter`](#EventEmitter) *
|
169 | - [`safe`](#safe) *
|
170 |
|
171 | ### Safe
|
172 |
|
173 | ```js
|
174 | var async = require('neo-async').safe;
|
175 | // or
|
176 | var async = require('neo-async');
|
177 | async.safe.each(collection, iterator, callback);
|
178 | ```
|
179 |
|
180 | ## Speed Comparison
|
181 |
|
182 | * async v1.3.0
|
183 | * neo-async v1.3.0
|
184 |
|
185 | ### Server-side
|
186 |
|
187 | Speed comparison of server-side measured by [func-comparator](https://github.com/suguru03/func-comparator).
|
188 |
|
189 | Specifications are as follows.
|
190 |
|
191 | * n times trials
|
192 | * Random execution order
|
193 | * Measure the average speed[μs] of n times
|
194 |
|
195 | __execute__
|
196 |
|
197 | * 100 times trials
|
198 | * 500000 tasks
|
199 |
|
200 | Execution environment are as follows.
|
201 |
|
202 | * node v0.10.40
|
203 | * node v0.12.7
|
204 | * iojs v2.3.4
|
205 |
|
206 | ```bash
|
207 | $ node perf/func-comparator
|
208 | ```
|
209 | __result__
|
210 |
|
211 | The value is the ratio (Neo-Async/Async) of the average speed per n times.
|
212 |
|
213 | ##### collections
|
214 |
|
215 | |function|node v0.10.40|node v0.12.7|iojs v2.3.4|
|
216 | |---|---|---|---|
|
217 | |each|2.01|1.95|2.19|
|
218 | |eachSeries|2.28|2.62|2.28|
|
219 | |eachLimit|2.33|3.32|2.81|
|
220 | |eachOf|1.93|1.92|2.12|
|
221 | |eachOfSeries|2.17|2.79|2.98|
|
222 | |eachOfLimit|2.03|1.54|2.57|
|
223 | |map|3.10|3.11|3.38|
|
224 | |mapSeries|2.36|1.98|2.32|
|
225 | |mapLimit|1.76|1.84|2.06|
|
226 | |filter|2.33|3.70|6.59|
|
227 | |filterSeries|2.11|2.71|3.68|
|
228 | |reject|2.71|4.38|7.33|
|
229 | |rejectSeries|2.31|3.09|3.86|
|
230 | |detect|2.31|2.69|2.92|
|
231 | |detectSeries|2.13|1.96|2.71|
|
232 | |reduce|2.09|1.94|2.26|
|
233 | |reduceRight|2.19|1.93|2.51|
|
234 | |sortBy|1.41|1.66|1.52|
|
235 | |some|2.23|2.29|2.50|
|
236 | |every|2.22|2.25|2.93|
|
237 | |concat|12.0|7.23|10.0|
|
238 | |concatSeries|8.37|5.15|8.05|
|
239 |
|
240 | ##### control flow
|
241 |
|
242 | |function|node v0.10.40|node v0.12.7|iojs v2.3.4|
|
243 | |---|---|---|---|
|
244 | |parallel|4.13|5.00|3.37|
|
245 | |series|3.13|2.70|3.03|
|
246 | |parallelLimit|2.69|2.96|2.49|
|
247 | |waterfall|3.45|7.24|7.59|
|
248 | |whilst|1.02|1.09|1.14|
|
249 | |doWhilst|1.26|1.36|1.28|
|
250 | |until|1.02|1.08|1.13|
|
251 | |doUntil|1.25|1.31|1.34|
|
252 | |during|2.15|2.08|2.08|
|
253 | |doDuring|5.08|5.77|5.39|
|
254 | |times|4.07|3.16|3.44|
|
255 | |timesSeries|2.82|2.58|2.71|
|
256 | |timesLimit|2.23|2.05|1.93|
|