promise_array_parallel
v0.0.1-alpha.6
Published
Manage arrays of Promise
Downloads
1
Maintainers
Readme
promise_array_parallel
- Manage
Promise[]
.- Parallel execution of async function
- Semaphore
There are no dependent packages, so it can be used in both Deno & npm environments.
Example
See ./src/promise_array_parallel.test.ts
Node
npm install promise_array_parallel
make example.js
const PromiseArray = require('promise_array_parallel').PromiseArray
const sleep = (ms = 0) =>
new Promise((res) => setTimeout(res, ms));
PromiseArray
.from([...new Array(40)].map((_, i) => i < 20 ? 20 - i : i - 20))
.parallelWork(async({idx, value}) => {
await sleep(value * 10)
console.log(idx)
})
.parallelWork(async({idx}) => {
console.log(" " + idx)
}, { priority: "INDEX" })
node ./example.js
Deno
import {PromiseArray} from 'https://deno.land/x/promise_array_parallel/mod.ts'
const sleep = (ms = 0) =>
new Promise((res) => setTimeout(res, ms));
PromiseArray
.from([...new Array(40)].map((_, i) => i < 20 ? 20 - i : i - 20))
.parallelWork(async({idx, value}) => {
await sleep(value * 10)
console.log(idx)
})
.parallelWork(async({idx}) => {
console.log(" " + idx)
}, { priority: "INDEX" })
Develop This package
This package is developed in Deno; it is recommended to install Deno.
Lint / Format / test
deno task test
Generate NPM Package & Publish
deno task dnt
Automatically published when you push the tagged main branch