Skip to content

Commit 68ea25d

Browse files
committed
Add support for iterable objects
PR-URL: #415
1 parent 0d770c0 commit 68ea25d

File tree

3 files changed

+202
-370
lines changed

3 files changed

+202
-370
lines changed

README.md

+27-22
Original file line numberDiff line numberDiff line change
@@ -100,31 +100,31 @@ Convert sync function to Promise object
100100

101101
### map(items, fn, done)
102102

103-
- `items`: [`<Array>`][array] incoming
103+
- `items`: [`<Iterable>`][iterable] incoming
104104
- `fn`: [`<Function>`][function] to be executed for each value in the array
105105
- `current`: `<any>` current element being processed in the array
106106
- `callback`: [`<Function>`][function]
107107
- `err`: [`<Error>`][error]|[`<null>`][null]
108108
- `value`: `<any>`
109109
- `done`: [`<Function>`][function] on done
110110
- `err`: [`<Error>`][error]|[`<null>`][null]
111-
- `result`: [`<Array>`][array]
111+
- `result`: [`<Iterable>`][iterable]
112112

113113
Asynchronous map (iterate parallel)
114114

115115
### filter(items, fn, done)
116116

117-
- `items`: [`<Array>`][array] incoming
117+
- `items`: [`<Iterable>`][iterable] incoming
118118
- `fn`: [`<Function>`][function] to be executed for each value in the array
119119
- `value`: `<any>` item from items array
120120
- `callback`: [`<Function>`][function]
121121
- `err`: [`<Error>`][error]|[`<null>`][null]
122122
- `accepted`: [`<boolean>`][boolean]
123123
- `done`: [`<Function>`][function] on done
124124
- `err`: [`<Error>`][error]|[`<null>`][null]
125-
- `result`: [`<Array>`][array]
125+
- `result`: [`<Iterable>`][iterable]
126126

127-
Asynchrous filter (iterate parallel)
127+
Asynchronous filter (iterate parallel)
128128

129129
_Example:_
130130

@@ -138,7 +138,7 @@ metasync.filter(
138138

139139
### reduce(items, fn, done\[, initial\])
140140

141-
- `items`: [`<Array>`][array] incoming
141+
- `items`: [`<Iterable>`][iterable] incoming
142142
- `fn`: [`<Function>`][function] to be executed for each value in array
143143
- `previous`: `<any>` value previously returned in the last iteration
144144
- `current`: `<any>` current element being processed in the array
@@ -148,18 +148,18 @@ metasync.filter(
148148
- `data`: `<any>` resulting value
149149
- `counter`: [`<number>`][number] index of the current element being processed
150150
in array
151-
- `items`: [`<Array>`][array] the array reduce was called upon
152-
- `done`: [`<Function>`][function] on done
151+
- `items`: [`<Iterable>`][iterable] the array reduce was called upon
152+
- `done`: [`<Function>`][function] on done, optional
153153
- `err`: [`<Error>`][error]|[`<null>`][null]
154-
- `result`: [`<Array>`][array]
154+
- `result`: [`<Iterable>`][iterable]
155155
- `initial`: `<any>` optional value to be used as first argument in first
156156
iteration
157157

158158
Asynchronous reduce
159159

160160
### reduceRight(items, fn, done\[, initial\])
161161

162-
- `items`: [`<Array>`][array] incoming
162+
- `items`: [`<Iterable>`][iterable] incoming
163163
- `fn`: [`<Function>`][function] to be executed for each value in array
164164
- `previous`: `<any>` value previously returned in the last iteration
165165
- `current`: `<any>` current element being processed in the array
@@ -169,25 +169,25 @@ Asynchronous reduce
169169
- `data`: `<any>` resulting value
170170
- `counter`: [`<number>`][number] index of the current element being processed
171171
in array
172-
- `items`: [`<Array>`][array] the array reduce was called upon
173-
- `done`: [`<Function>`][function] on done
172+
- `items`: [`<Iterable>`][iterable] the array reduce was called upon
173+
- `done`: [`<Function>`][function] on done, optional
174174
- `err`: [`<Error>`][error]|[`<null>`][null]
175-
- `result`: [`<Array>`][array]
175+
- `result`: [`<Iterable>`][iterable]
176176
- `initial`: `<any>` optional value to be used as first argument in first
177177
iteration
178178

179179
Asynchronous reduceRight
180180

181181
### each(items, fn, done)
182182

183-
- `items`: [`<Array>`][array] incoming
183+
- `items`: [`<Iterable>`][iterable] incoming
184184
- `fn`: [`<Function>`][function]
185185
- `value`: `<any>` item from items array
186186
- `callback`: [`<Function>`][function]
187187
- `err`: [`<Error>`][error]|[`<null>`][null]
188188
- `done`: [`<Function>`][function] on done
189189
- `err`: [`<Error>`][error]|[`<null>`][null]
190-
- `items`: [`<Array>`][array]
190+
- `items`: [`<Iterable>`][iterable]
191191

192192
Asynchronous each (iterate in parallel)
193193

@@ -206,14 +206,14 @@ metasync.each(
206206

207207
### series(items, fn, done)
208208

209-
- `items`: [`<Array>`][array] incoming
209+
- `items`: [`<Iterable>`][iterable] incoming
210210
- `fn`: [`<Function>`][function]
211211
- `value`: `<any>` item from items array
212212
- `callback`: [`<Function>`][function]
213213
- `err`: [`<Error>`][error]|[`<null>`][null]
214214
- `done`: [`<Function>`][function] on done
215215
- `err`: [`<Error>`][error]|[`<null>`][null]
216-
- `items`: [`<Array>`][array]
216+
- `items`: [`<Iterable>`][iterable]
217217

218218
Asynchronous series
219219

@@ -234,7 +234,7 @@ metasync.series(
234234

235235
### find(items, fn, done)
236236

237-
- `items`: [`<Array>`][array] incoming
237+
- `items`: [`<Iterable>`][iterable] incoming
238238
- `fn`: [`<Function>`][function]
239239
- `value`: `<any>` item from items array
240240
- `callback`: [`<Function>`][function]
@@ -260,7 +260,7 @@ metasync.find(
260260

261261
### every(items, fn, done)
262262

263-
- `items`: [`<Array>`][array] incoming
263+
- `items`: [`<Iterable>`][iterable] incoming
264264
- `fn`: [`<Function>`][function]
265265
- `value`: `<any>` item from items array
266266
- `callback`: [`<Function>`][function]
@@ -274,7 +274,7 @@ Asynchronous every
274274

275275
### some(items, fn, done)
276276

277-
- `items`: [`<Array>`][array] incoming
277+
- `items`: [`<Iterable>`][iterable] incoming
278278
- `fn`: [`<Function>`][function]
279279
- `value`: `<any>` item from items array
280280
- `callback`: [`<Function>`][function]
@@ -288,7 +288,7 @@ Asynchronous some (iterate in series)
288288

289289
### asyncMap(items, fn\[, options\]\[, done\])
290290

291-
- `items`: [`<Array>`][array] incoming dataset
291+
- `items`: [`<Iterable>`][iterable] incoming dataset
292292
- `fn`: [`<Function>`][function]
293293
- `item`: `<any>`
294294
- `index`: [`<number>`][number]
@@ -297,7 +297,7 @@ Asynchronous some (iterate in series)
297297
- `percent`: [`<number>`][number] ratio of map time to all time
298298
- `done`: [`<Function>`][function] call on done, optional
299299
- `err`: [`<Error>`][error]|[`<null>`][null]
300-
- `result`: [`<Array>`][array]
300+
- `result`: [`<Iterable>`][iterable]
301301

302302
Non-blocking synchronous map
303303

@@ -332,6 +332,8 @@ Create an AsyncIterator instance
332332

333333
#### async AsyncIterator.prototype.reduce(reducer, initialValue)
334334

335+
#### async AsyncIterator.prototype.reduceRight(reducer, initialValue)
336+
335337
#### async AsyncIterator.prototype.some(predicate, thisArg)
336338

337339
#### async AsyncIterator.prototype.someCount(predicate, count, thisArg)
@@ -366,6 +368,8 @@ Create an AsyncIterator instance
366368

367369
#### AsyncIterator.prototype.enumerate()
368370

371+
#### AsyncIterator.prototype.reverse()
372+
369373
### collect(expected)
370374

371375
- `expected`: [`<number>`][number]|[`<string[]>`][string]
@@ -867,6 +871,7 @@ Set timeout for asynchronous function execution
867871
- Timur Shemsedinov (marcusaurelius)
868872
- See github for full [contributors list](https://github.com/metarhia/metasync/graphs/contributors)
869873

874+
[iterable]: https://tc39.es/ecma262/#sec-iterable-interface
870875
[asynciterable]: https://tc39.github.io/ecma262/#sec-asynciterable-interface
871876
[asynciterator]: #class-asynciterator
872877
[collector]: #class-collector

0 commit comments

Comments
 (0)