{"library":"p-every","title":"p-every","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install p-every"],"cli":null},"imports":["import pEvery from 'p-every';","const pEvery = require('p-every');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pEvery from 'p-every';\n\nconst getCapital = async (country) => {\n  // Simulate an async operation, e.g., fetching from an API\n  const capitals = {\n    'Norway': { name: 'Oslo', continent: 'Europe' },\n    'Thailand': { name: 'Bangkok', continent: 'Asia' },\n    'Germany': { name: 'Berlin', continent: 'Europe' },\n    'Japan': { name: 'Tokyo', continent: 'Asia' }\n  };\n  return new Promise(resolve => setTimeout(() => {\n    const info = Object.values(capitals).find(c => c.name.includes(country) || country.includes(c.name));\n    resolve(info);\n  }, 50));\n};\n\nconst getContinent = async (place) => {\n  // Simulate an async operation for continent lookup\n  const continents = {\n    'Oslo, Norway': 'europe',\n    'Bangkok, Thailand': 'asia',\n    'Berlin, Germany': 'europe',\n    'Tokyo, Japan': 'asia'\n  };\n  return new Promise(resolve => setTimeout(() => {\n    resolve(continents[place]);\n  }, 20));\n};\n\n(async () => {\n  const places = [\n    getCapital('Norway').then(info => `${info.name}, ${'Norway'}`),\n    'Bangkok, Thailand',\n    'Berlin, Germany',\n    'Tokyo, Japan'\n  ];\n\n  const testFunction = async place => {\n    const continent = await getContinent(place);\n    return continent === 'europe';\n  };\n\n  const result = await pEvery(places, testFunction, { concurrency: 2 });\n  console.log('Are all places in Europe?', result);\n  //=> false (because Bangkok and Tokyo are in Asia)\n\n  const allEuropeanPlaces = [\n    'Oslo, Norway',\n    'Berlin, Germany'\n  ];\n  const allEuropeanResult = await pEvery(allEuropeanPlaces, testFunction);\n  console.log('Are all European places in Europe?', allEuropeanResult);\n  //=> true\n})();","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}