Gathering detailed insights and metrics for @tunnckocore/p-all
Gathering detailed insights and metrics for @tunnckocore/p-all
Gathering detailed insights and metrics for @tunnckocore/p-all
Gathering detailed insights and metrics for @tunnckocore/p-all
Delivering delightful digital solutions. Monorepo of monorepos of Open Source packages with combined ~100M/month downloads, semantically versioned following @conventional-commits. Fully powered ES Modules, @Airbnb @ESLint + @Prettier, independent & fixed versioning. Quality with @Actions, CodeQL, & Dependabot.
npm install @tunnckocore/p-all
Typescript
Module System
Min. Node Version
Node Version
NPM Version
67.8
Supply Chain
98.6
Quality
75.4
Maintenance
100
Vulnerability
100
License
parse-function@5.6.10
Updated on Mar 28, 2020
to-file-path@2.0.4
Updated on Mar 28, 2020
@tunnckocore/package-json@2.0.4
Updated on Mar 28, 2020
@tunnckocore/jest-runner-eslint@1.2.9
Updated on Mar 28, 2020
stringify-github-short-url@3.3.8
Updated on Mar 28, 2020
prettier-plugin-pkgjson@0.2.8
Updated on Mar 28, 2020
JavaScript (85.76%)
TypeScript (14.24%)
Total Downloads
1,922
Last Day
10
Last Week
21
Last Month
70
Last Year
623
484 Stars
601 Commits
18 Forks
10 Watchers
44 Branches
20 Contributors
Updated on Aug 27, 2025
Latest Version
0.2.0
Package Id
@tunnckocore/p-all@0.2.0
Unpacked Size
17.93 kB
Size
6.22 kB
File Count
4
NPM Version
8.12.1
Node Version
18.3.0
Cumulative downloads
Total Downloads
Last Day
400%
10
Compared to previous day
Last Week
90.9%
21
Compared to previous week
Last Month
11.1%
70
Compared to previous month
Last Year
52%
623
Compared to previous year
Map or loop through promises, promise-returning or async functions, serially or in parallel, based on Promise.all! Has a hooks system: start, beforeEach, afterEach, finish.
For usage, check the tests for now. Coverage is 100%, as always in the past 10 years.
It's similar to Promise.all
, or Promise.allSettled
more specifically, but
enhanced with a hooks system and ability to pass custom mapping function. It
works for promises and async functions.
1import { strict as assert } from 'node:assert'; 2import test from 'asia'; 3import { each, parallel, serial } from '@tunnckocore/p-all'; 4 5const delay = async (ms) => new Promise((resolve) => setTimeout(resolve, ms)); 6 7test('parallel - correct results and order', async () => { 8 const order = []; 9 const results = await parallel([ 10 () => delay(3000).then((x) => order.push('a')), // 8 11 () => delay(300).then((x) => order.push('b')), // 2 12 () => delay(1000).then((x) => order.push('c')), // 5 13 () => delay(100).then((x) => order.push('d')), // 1 14 () => 15 delay(2000).then((x) => { 16 order.push('e'); 17 throw new Error('the "e" error'); 18 }), // 6 19 () => delay(1500).then((x) => order.push('f')), // 7 20 () => delay(560).then((x) => order.push('g')), // 3 21 () => delay(880).then((x) => order.push('h')), // 4 22 ]); 23 24 assert.deepEqual(results, [ 25 { status: 'fulfilled', value: 8, index: 0 }, 26 { status: 'fulfilled', value: 2, index: 1 }, 27 { status: 'fulfilled', value: 5, index: 2 }, 28 { status: 'fulfilled', value: 1, index: 3 }, 29 { 30 status: 'rejected', 31 reason: results[4].reason, // well.. lol 32 index: 4, 33 }, 34 { status: 'fulfilled', value: 6, index: 5 }, 35 { status: 'fulfilled', value: 3, index: 6 }, 36 { status: 'fulfilled', value: 4, index: 7 }, 37 ]); 38 assert.deepEqual(order, ['d', 'b', 'g', 'h', 'c', 'f', 'e', 'a']); 39}); 40 41test('serial - force run in series', async () => { 42 const fixture = [ 43 () => delay(3000).then((x) => 'a'), // 8 44 () => delay(300).then((x) => 'b'), // 2 45 () => delay(1000).then((x) => 'c'), // 5 46 () => delay(100).then((x) => 'd'), // 1 47 () => 48 delay(2000).then((x) => { 49 throw new Error('the "e" error'); 50 }), // 6 51 () => delay(1500).then((x) => 'f'), // 7 52 () => delay(560).then((x) => 'g'), // 3 53 () => delay(880).then((x) => 'h'), // 4 54 ]; 55 56 const results = await each(fixture, { serial: true }); 57 58 assert.deepEqual( 59 results.map((x) => x.value), 60 ['a', 'b', 'c', 'd', undefined, 'f', 'g', 'h'], 61 ); 62 63 const serialResults = await serial(fixture); 64 assert.deepEqual( 65 serialResults.map((x) => x.value), 66 ['a', 'b', 'c', 'd', undefined, 'f', 'g', 'h'], 67 ); 68}); 69 70test('custom mapper() function', async () => { 71 const res = []; 72 const results = await serial( 73 [() => 3, 2, () => 5, () => 1, () => 4], 74 function mapper(item, index) { 75 res.push(item); 76 return index > 2 ? item : undefined; 77 }, 78 ); 79 80 assert.deepEqual(results, res); 81});
If mapper
is object, it's assumed options
.
Passing options.serial
is the same as serial
.
You can also pass options.args
- custom arguments passed to each function.
A hooks system:
If mapper
is object, it's assumed options
.
If mapper
is object, it's assumed options
.
Apache-2.0, 2022
No vulnerabilities found.