0.0.1-alpha.6 • Published 3 years ago
promise_array_parallel v0.0.1-alpha.6
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_parallelmake 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.jsDeno
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 testGenerate NPM Package & Publish
deno task dntAutomatically published when you push the tagged main branch