Skip to content

Commit

Permalink
readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Nov 26, 2019
1 parent 7d488da commit 3f7d4ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
7 changes: 3 additions & 4 deletions README.md
Expand Up @@ -17,11 +17,10 @@ $ npm install --save it-all
```javascript
const all = require('it-all')

async function * iterator (values) {
yield * values
}
// This can also be an iterator, async iterator, generator, etc
const values = [0, 1, 2, 3, 4]

const arr = await all(iterator([0, 1, 2, 3, 4]))
const arr = await all(values)

console.info(arr) // 0, 1, 2, 3, 4
```
12 changes: 4 additions & 8 deletions test.js
@@ -1,14 +1,10 @@
import toArray from './'
import all from './'
import test from 'ava'

test('Should collect all entries of an async iterator as an array', async (t) => {
async function * iterator (values) {
yield * values
}
const values = [0, 1, 2, 3, 4]

const vals = [0, 1, 2, 3, 4]
const res = await all(values)

const arr = await toArray(iterator(vals))

t.deepEqual(arr, vals)
t.deepEqual(res, values)
})

0 comments on commit 3f7d4ce

Please sign in to comment.