Gathering detailed insights and metrics for p-iteration-with-concurrency
Gathering detailed insights and metrics for p-iteration-with-concurrency
Gathering detailed insights and metrics for p-iteration-with-concurrency
Gathering detailed insights and metrics for p-iteration-with-concurrency
Utilities that make array iteration easy when using async/await or Promises
npm install p-iteration-with-concurrency
Typescript
Module System
Min. Node Version
Node Version
NPM Version
72.2
Supply Chain
98.9
Quality
74.3
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
836
Last Day
1
Last Week
5
Last Month
11
Last Year
93
77 Commits
1 Watchers
5 Branches
1 Contributors
Updated on Sep 14, 2018
Minified
Minified + Gzipped
Latest Version
1.1.7
Package Id
p-iteration-with-concurrency@1.1.7
Unpacked Size
344.07 kB
Size
59.74 kB
File Count
19
NPM Version
5.6.0
Node Version
8.11.4
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
25%
5
Compared to previous week
Last Month
120%
11
Compared to previous month
Last Year
69.1%
93
Compared to previous year
1
6
Make array iteration easy when using async/await and promises
Promise
, making them awaitable and thenable$ npm install --save p-iteration-with-concurrency
Smooth asynchronous iteration using async/await
:
1const { map } = require('p-iteration-with-concurrency'); 2 3// map passing an async function as callback 4function getUsers (userIds) { 5 return map(userIds, async userId => { 6 const response = await fetch(`/api/users/${userId}`); 7 return response.json(); 8 }); 9} 10 11// map passing a non-async function as callback 12async function getRawResponses (userIds) { 13 const responses = await map(userIds, userId => fetch(`/api/users/${userId}`)); 14 // ... do some stuff 15 return responses; 16} 17 18// ...
1const { filter } = require('p-iteration-with-concurrency'); 2 3async function getFilteredUsers (userIds, name) { 4 const filteredUsers = await filter(userIds, async userId => { 5 const response = await fetch(`/api/users/${userId}`); 6 const user = await response.json(); 7 return user.name === name; 8 }); 9 // ... do some stuff 10 return filteredUsers; 11} 12 13// ...
All methods return a Promise so they can just be used outside an async function just with plain Promises:
1const { map } = require('p-iteration-with-concurrency'); 2 3map([123, 125, 156], (userId) => fetch(`/api/users/${userId}`)) 4 .then((result) => { 5 // ... 6 }) 7 .catch((error) => { 8 // ... 9 });
If there is a Promise in the array, it will be unwrapped before calling the callback:
1const { forEach } = require('p-iteration-with-concurrency'); 2const fetchJSON = require('nonexistent-module'); 3 4function logUsers () { 5 const users = [ 6 fetchJSON('/api/users/125'), // returns a Promise 7 { userId: 123, name: 'Jolyne', age: 19 }, 8 { userId: 156, name: 'Caesar', age: 20 } 9 ]; 10 return forEach(users, (user) => { 11 console.log(user); 12 }); 13}
1const { find } = require('p-iteration-with-concurrency'); 2const fetchJSON = require('nonexistent-module'); 3 4function findUser (name) { 5 const users = [ 6 fetchJSON('/api/users/125'), // returns a Promise 7 { userId: 123, name: 'Jolyne', age: 19 }, 8 { userId: 156, name: 'Caesar', age: 20 } 9 ]; 10 return find(users, (user) => user.name === name); 11}
The callback will be invoked as soon as the Promise is unwrapped:
1const { forEach } = require('p-iteration-with-concurrency'); 2 3// function that returns a Promise resolved after 'ms' passed 4const delay = (ms) => new Promise(resolve => setTimeout(() => resolve(ms), ms)); 5 6// 100, 200, 300 and 500 will be logged in this order 7async function logNumbers () { 8 const numbers = [ 9 delay(500), 10 delay(200), 11 delay(300), 12 100 13 ]; 14 await forEach(numbers, (number) => { 15 console.log(number); 16 }); 17}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
63 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-12
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More