it-parallel-batch
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -6,3 +6,5 @@ 'use strict' | ||
async function * parallelBatch (source, size) { | ||
if (isNaN(size)) { | ||
size = parseInt(size) | ||
if (isNaN(size) || size < 1) { | ||
size = 1 | ||
@@ -9,0 +11,0 @@ } |
{ | ||
"name": "it-parallel-batch", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input", | ||
"main": "index.js", | ||
"repository": "github:achingbrain/it", | ||
"homepage": "https://github.com/achingbrain/it#readme", | ||
"bugs": "https://github.com/achingbrain/it/issues", | ||
"scripts": { | ||
"test": "nyc --check-coverage --lines 100 --reporter html --reporter lcov ava", | ||
"test": "ava", | ||
"lint": "standard", | ||
"coveralls": "npm test && cat ./coverage/lcov.info | coveralls" | ||
"coverage": "nyc --reporter html --reporter lcov ava", | ||
"clean": "rm -rf .nyc_output coverage" | ||
}, | ||
"author": "Alex Potsides <alex@achingbrain.net>", | ||
"license": "ISC", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/achingbrain/it-parallel-batch.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/achingbrain/it-parallel-batch/issues" | ||
}, | ||
"homepage": "https://github.com/achingbrain/it-parallel-batch#readme", | ||
"devDependencies": { | ||
"ava": "^2.4.0", | ||
"coveralls": "^3.0.2", | ||
"delay": "^4.3.0", | ||
"it-all": "1.0.0", | ||
"it-all": "^1.0.1", | ||
"nyc": "^14.0.0", | ||
@@ -31,3 +26,4 @@ "standard": "^14.3.1" | ||
"it-batch": "0.0.1" | ||
} | ||
}, | ||
"gitHead": "92319e3234c9361cee162c3e4ff5648770028f2a" | ||
} |
# it-parallel-batch | ||
[](https://travis-ci.org/achingbrain/it-parallel-batch?branch=master) [](https://coveralls.io/github/achingbrain/it-parallel-batch?branch=master) [](https://david-dm.org/achingbrain/it-parallel-batch) | ||
[](https://travis-ci.org/achingbrain/it?branch=master) [](https://coveralls.io/github/achingbrain/it?branch=master) [](https://david-dm.org/achingbrain/it) | ||
@@ -5,0 +5,0 @@ > Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results as they become available but in the same order as the input |
76
test.js
@@ -135,1 +135,77 @@ 'use strict' | ||
}) | ||
test('Should batch up entries with negative batch size', async (t) => { | ||
const input = [ | ||
async () => { | ||
await delay(200) | ||
return 1 | ||
}, | ||
async () => { | ||
await delay(100) | ||
return 2 | ||
} | ||
] | ||
const batchSize = -1 | ||
const res = await all(parallelBatch(input, batchSize)) | ||
t.deepEqual(res, [1, 2]) | ||
}) | ||
test('Should batch up entries with zero batch size', async (t) => { | ||
const input = [ | ||
async () => { | ||
await delay(200) | ||
return 1 | ||
}, | ||
async () => { | ||
await delay(100) | ||
return 2 | ||
} | ||
] | ||
const batchSize = 0 | ||
const res = await all(parallelBatch(input, batchSize)) | ||
t.deepEqual(res, [1, 2]) | ||
}) | ||
test('Should batch up entries with string batch size', async (t) => { | ||
const input = [ | ||
async () => { | ||
await delay(200) | ||
return 1 | ||
}, | ||
async () => { | ||
await delay(100) | ||
return 2 | ||
} | ||
] | ||
const batchSize = '2' | ||
const res = await all(parallelBatch(input, batchSize)) | ||
t.deepEqual(res, [1, 2]) | ||
}) | ||
test('Should batch up entries with non-integer batch size', async (t) => { | ||
const input = [ | ||
async () => { | ||
await delay(200) | ||
return 1 | ||
}, | ||
async () => { | ||
await delay(100) | ||
return 2 | ||
} | ||
] | ||
const batchSize = 2.5 | ||
const res = await all(parallelBatch(input, batchSize)) | ||
t.deepEqual(res, [1, 2]) | ||
}) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
104788
5
26
1228
1
1
1