Skip to content

Commit

Permalink
Add support for iterable objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Yehor Khilchenko authored and o-rumiantsev committed Jul 1, 2019
1 parent 0d770c0 commit ee7985b
Show file tree
Hide file tree
Showing 17 changed files with 455 additions and 476 deletions.
1 change: 1 addition & 0 deletions .metadocrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"lib/throttle.js"
],
"customLinks": {
"Iterable": "https://tc39.es/ecma262/#sec-iterable-interface",
"AsyncIterable": "https://tc39.github.io/ecma262/#sec-asynciterable-interface",
"AsyncIterator": "#class-asynciterator",
"ArrayChain": "#class-arraychain",
Expand Down
49 changes: 27 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,31 +100,31 @@ Convert sync function to Promise object

### map(items, fn, done)

- `items`: [`<Array>`][array] incoming
- `items`: [`<Iterable>`][iterable] incoming
- `fn`: [`<Function>`][function] to be executed for each value in the array
- `current`: `<any>` current element being processed in the array
- `callback`: [`<Function>`][function]
- `err`: [`<Error>`][error]|[`<null>`][null]
- `value`: `<any>`
- `done`: [`<Function>`][function] on done
- `err`: [`<Error>`][error]|[`<null>`][null]
- `result`: [`<Array>`][array]
- `result`: [`<Iterable>`][iterable]

Asynchronous map (iterate parallel)

### filter(items, fn, done)

- `items`: [`<Array>`][array] incoming
- `items`: [`<Iterable>`][iterable] incoming
- `fn`: [`<Function>`][function] to be executed for each value in the array
- `value`: `<any>` item from items array
- `callback`: [`<Function>`][function]
- `err`: [`<Error>`][error]|[`<null>`][null]
- `accepted`: [`<boolean>`][boolean]
- `done`: [`<Function>`][function] on done
- `err`: [`<Error>`][error]|[`<null>`][null]
- `result`: [`<Array>`][array]
- `result`: [`<Iterable>`][iterable]

Asynchrous filter (iterate parallel)
Asynchronous filter (iterate parallel)

_Example:_

Expand All @@ -138,7 +138,7 @@ metasync.filter(

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

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

Asynchronous reduce

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

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

Asynchronous reduceRight

### each(items, fn, done)

- `items`: [`<Array>`][array] incoming
- `items`: [`<Iterable>`][iterable] incoming
- `fn`: [`<Function>`][function]
- `value`: `<any>` item from items array
- `callback`: [`<Function>`][function]
- `err`: [`<Error>`][error]|[`<null>`][null]
- `done`: [`<Function>`][function] on done
- `err`: [`<Error>`][error]|[`<null>`][null]
- `items`: [`<Array>`][array]
- `items`: [`<Iterable>`][iterable]

Asynchronous each (iterate in parallel)

Expand All @@ -206,14 +206,14 @@ metasync.each(

### series(items, fn, done)

- `items`: [`<Array>`][array] incoming
- `items`: [`<Iterable>`][iterable] incoming
- `fn`: [`<Function>`][function]
- `value`: `<any>` item from items array
- `callback`: [`<Function>`][function]
- `err`: [`<Error>`][error]|[`<null>`][null]
- `done`: [`<Function>`][function] on done
- `err`: [`<Error>`][error]|[`<null>`][null]
- `items`: [`<Array>`][array]
- `items`: [`<Iterable>`][iterable]

Asynchronous series

Expand All @@ -234,7 +234,7 @@ metasync.series(

### find(items, fn, done)

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

### every(items, fn, done)

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

### some(items, fn, done)

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

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

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

Non-blocking synchronous map

Expand Down Expand Up @@ -332,6 +332,8 @@ Create an AsyncIterator instance

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

#### async AsyncIterator.prototype.reduceRight(reducer, initialValue)

#### async AsyncIterator.prototype.some(predicate, thisArg)

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

#### AsyncIterator.prototype.enumerate()

#### AsyncIterator.prototype.reverse()

### collect(expected)

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

[iterable]: https://tc39.es/ecma262/#sec-iterable-interface
[asynciterable]: https://tc39.github.io/ecma262/#sec-asynciterable-interface
[asynciterator]: #class-asynciterator
[collector]: #class-collector
Expand Down

0 comments on commit ee7985b

Please sign in to comment.