Comparing version 2.0.0 to 2.1.0
10
index.js
@@ -50,10 +50,14 @@ import isAsyncIterable from "is-async-iterable"; | ||
} | ||
const generator = data[Symbol.asyncIterator] || data[Symbol.iterator]; | ||
const iterator = generator.call(data); | ||
for await (const item of data) { | ||
let it = await iterator.next(); | ||
while (!it.done) { | ||
if (accumulator === Unspecified) { | ||
accumulator = item; | ||
accumulator = it.value; | ||
} else { | ||
accumulator = await reducer(accumulator, item, index, data); | ||
accumulator = await reducer(accumulator, await it.value, index, data); | ||
} | ||
index++; | ||
it = await iterator.next(); | ||
} | ||
@@ -60,0 +64,0 @@ |
{ | ||
"name": "ai-reduce", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Reduce for async iterables.", | ||
@@ -13,7 +13,7 @@ "repository": "parro-it/ai-reduce", | ||
"scripts": { | ||
"test": "node --harmony_async_iteration -r @std/esm test.js | tap-colorize - && linterjs .", | ||
"test": "node -r @std/esm test.js | tap-colorize - && linterjs .", | ||
"doc": "documentation readme index.js --section=API" | ||
}, | ||
"engines": { | ||
"node": ">9" | ||
"node": ">7" | ||
}, | ||
@@ -20,0 +20,0 @@ "keywords": [ |
8132
73