Registry / http-networking / p-every

p-every

JSON →
library2.0.0jsnpmunverified

p-every is a utility package that tests whether all promises in an iterable pass a provided asynchronous testing function, similar to `Array.prototype.every()` but designed for concurrent promise execution. The current stable version is 2.0.0. This library is part of a broader ecosystem of promise utilities (`p-*` packages), known for their focused functionality and robust asynchronous control. A key differentiator is its `concurrency` option, allowing developers to limit the number of `testFunction` calls running in parallel, which is crucial for managing resource usage or API rate limits. While release cadence is not strictly defined, packages in this family typically receive stable updates with major versions introducing significant changes, including potential shifts in module format. It is particularly useful for validating collections of asynchronous operations efficiently.

npm install p-every
INSTALL
IMPORT
SIG · P-EVERY
P
p-every
http-networkingjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pEvery
import pEvery from 'p-every';
import { pEvery } from 'p-every';
As a utility function, p-every is likely a default export in its ESM form. Named import might fail.
pEvery
const pEvery = require('p-every');
const { pEvery } = require('p-every');
Version 2.0.0 primarily uses CommonJS `require()`, treating `pEvery` as a default export from the module. Be aware that newer major versions of similar `p-*` packages have transitioned to ESM-only.

This quickstart demonstrates how to use `p-every` to check if all items in an array of promises (or values) satisfy an asynchronous test condition, with optional concurrency control.

import pEvery from 'p-every'; const getCapital = async (country) => { // Simulate an async operation, e.g., fetching from an API const capitals = { 'Norway': { name: 'Oslo', continent: 'Europe' }, 'Thailand': { name: 'Bangkok', continent: 'Asia' }, 'Germany': { name: 'Berlin', continent: 'Europe' }, 'Japan': { name: 'Tokyo', continent: 'Asia' } }; return new Promise(resolve => setTimeout(() => { const info = Object.values(capitals).find(c => c.name.includes(country) || country.includes(c.name)); resolve(info); }, 50)); }; const getContinent = async (place) => { // Simulate an async operation for continent lookup const continents = { 'Oslo, Norway': 'europe', 'Bangkok, Thailand': 'asia', 'Berlin, Germany': 'europe', 'Tokyo, Japan': 'asia' }; return new Promise(resolve => setTimeout(() => { resolve(continents[place]); }, 20)); }; (async () => { const places = [ getCapital('Norway').then(info => `${info.name}, ${'Norway'}`), 'Bangkok, Thailand', 'Berlin, Germany', 'Tokyo, Japan' ]; const testFunction = async place => { const continent = await getContinent(place); return continent === 'europe'; }; const result = await pEvery(places, testFunction, { concurrency: 2 }); console.log('Are all places in Europe?', result); //=> false (because Bangkok and Tokyo are in Asia) const allEuropeanPlaces = [ 'Oslo, Norway', 'Berlin, Germany' ]; const allEuropeanResult = await pEvery(allEuropeanPlaces, testFunction); console.log('Are all European places in Europe?', allEuropeanResult); //=> true })();
Debug
Known issues
breakingAs a major version bump, `p-every@2.0.0` likely includes breaking changes from `1.x.x` versions, adhering to semantic versioning principles. Specific details would typically be found in a changelog or release notes on the GitHub repository. Users upgrading from `1.x.x` should review their usage.
fix
Consult the project's GitHub releases or changelog (if available) for migration guidance when upgrading from `p-every@1.x.x`.
affects: >=2.0.0
gotchaFuture major versions of `p-every` may transition to being pure ES Module (ESM) packages, similar to other related `p-*` libraries (e.g., `p-limit@4.0.0+`). This means `require('p-every')` will no longer work and you will need to use `import pEvery from 'p-every'` in an ESM context.
fix
To prepare for a potential ESM-only future, ensure your project supports ES Modules. This typically involves setting `"type": "module"` in your `package.json` and using `import` statements. If still in CommonJS, you might need to use dynamic `import()` or stick to an older CommonJS-compatible version.
affects: Future major versions (e.g., >=3.0.0)
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/node_modules/p-every/index.js
Attempting to `require()` an ESM-only version of `p-every` from a CommonJS module.
fix
Either convert your consuming module to ESM (by adding `"type": "module"` to your `package.json` and using `import pEvery from 'p-every';`) or use dynamic `await import('p-every')` if remaining in CommonJS. Alternatively, if available, downgrade to a CommonJS-compatible version.
TypeError: pEvery is not a function
Incorrectly importing `pEvery` as a named export (`import { pEvery } from 'p-every';`) when it is a default export.
fix
Use a default import: `import pEvery from 'p-every';`. If using CommonJS, ensure you are not destructuring: `const pEvery = require('p-every');`.
TypeError: testFunction is not a function
The `testFunction` argument passed to `pEvery` is not a valid function or cannot be awaited.
fix
Ensure `testFunction` is a correctly defined and callable function, typically an `async` function or one that returns a Promise or a boolean value.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
p-every — npm install p-every · libregistry