# p-every

> Test whether all promises passes a testing function

Latest version **2.0.0** (published 2019-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install p-every
pnpm add p-every
yarn add p-every
bun add p-every
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-03-15 |
| First published | 2017-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/p-every) |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Kevin Martensson |
| Maintainers | kevva |
| Keywords | async, await, bluebird, collection, concurrency, concurrently, every, filter, fulfilled, iterable, iterator, parallel, promise, promises |

## Links

- npm: https://www.npmjs.com/package/p-every
- Repository: https://github.com/kevva/p-every
- Homepage: https://github.com/kevva/p-every#readme
- Issues: https://github.com/kevva/p-every/issues
- npm.io page: https://npm.io/package/p-every

## Dependencies (1)

- [p-map](https://npm.io/package/p-map.md) ^2.0.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2019-03-15
- 1.0.2 — 2017-05-25
- 1.0.1 — 2017-05-24
- 1.0.0 — 2017-05-24

## README

# p-every [![Build Status](https://travis-ci.org/kevva/p-every.svg?branch=master)](https://travis-ci.org/kevva/p-every)

> Test whether all promises passes a testing function

Like [`Array.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) for promises.

## Install

```
$ npm install --save p-every
```


## Usage

```js
const pEvery = require('p-every');
const getContinent = require('get-continent'); // not a real module

const places = [
	getCapital('Norway').then(info => info.name),
	'Bangkok, Thailand',
	'Berlin, Germany',
	'Tokyo, Japan'
];

const testFunction = async place => {
	const continent = await getContinent(place);
	return continent === 'europe';
}

(async () => {
	const result = await pEvery(places, testFunction);
	console.log(result);
	//=> false
})();
```


## API

### pEvery(input, testFunction, [options])

Returns a `Promise` that is fulfilled when all promises in `input` and ones returned from `testFunction` are fulfilled, or rejects if any of the promises reject. The fulfilled value is a `boolean` that is `true` if all Promises passed the test and `false` otherwise.

#### input

Type: `Iterable<Promise|any>`

Iterated over concurrently in the `testFunction` function.

#### testFunction(element, index)

Type: `Function`

Predicate function, expected to return a `Promise<boolean>` or `boolean`.

#### options

Type: `Object`

##### concurrency

Type: `number`<br>
Default: `Infinity`<br>
Minimum: `1`

Number of concurrently pending promises returned by `testFunction`.


## Related

* [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently
* [p-locate](https://github.com/sindresorhus/p-locate) - Get the first fulfilled promise that satisfies the provided testing function
* [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
* [More…](https://github.com/sindresorhus/promise-fun)


## License

MIT © [Kevin Martensson](http://github.com/kevva)

---
_Source: https://npm.io/package/p-every · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
