# promise-any-polyfill

> A polyfill for the `Promise.any` function.

Latest version **1.0.1** (published 2021-09-10) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install promise-any-polyfill
pnpm add promise-any-polyfill
yarn add promise-any-polyfill
bun add promise-any-polyfill
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-09-10 |
| First published | 2019-10-29 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 42 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Trevor Sears |
| Maintainers | t99 |
| Keywords | polyfill, promise, promises, promise-any, promise.any, typescript |

## Links

- npm: https://www.npmjs.com/package/promise-any-polyfill
- Repository: https://github.com/T99/promise-any-polyfill
- Homepage: https://github.com/T99/promise-any-polyfill#readme
- Issues: https://github.com/T99/promise-any-polyfill/issues
- npm.io page: https://npm.io/package/promise-any-polyfill

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-09-10
- 1.0.0 — 2021-09-10
- 0.1.2 — 2019-10-29
- 0.1.1 — 2019-10-29
- 0.1.0 — 2019-10-29

## README

# `Promise.any` Polyfill

A polyfill for the `Promise.any` function.

### [Find promise-any-polyfill on NPM.](https://www.npmjs.com/package/promise-any-polyfill)

## Table of Contents

 - [Installation](#installation)
 - [Basic Usage](#basic-usage)
 - [Documentation](#documentation)
 - [License](#license)

## Installation

Install from NPM with

```
$ npm install --save promise-any-polyfill
```

## Basic Usage

This package implements the upcoming `Promise.any(...)` functionality, and it can be used as follows:

```typescript
Promise.any([
    timedResolvingPromise(50, "what's up?"),
    timedResolvingPromise(25, "I'm quick!"),
    timedResolvingPromise(75, "I'm late!")
]).then((result: string): void => console.log(result)); //=> "I'm quick!"
```

As you can see from the above example, `Promise.any` will resolve to the value of the first resolving Promise that was
passed to the function`.

If all promises reject, `Promise.any` will reject with an array of each of the rejection values from the Promises passed
to the function.

```typescript
Promise.any([
    timedRejectingPromise(50, "...somewhere down the middle..."),
    timedRejectingPromise(25, "I failed first!"),
    timedRejectingPromise(75, "...at least I failed last!")
]).catch((error: string): void => console.error(error)); //=> ["I failed first!", "...somewhere down the middle...", "...at least I failed last!"]
```

`Promise.any` will ignore any rejecting Promises so long as at least one of the Promises passed to the function
resolves.

```typescript
Promise.any([
	timedRejectingPromise(25, "I'm first, but I'm failing!"),
	timedResolvingPromise(50, "I'm the only one resolving!"),
    timedRejectingPromise(75, "I'm last AND failing!")
]).then((result: string): void => console.log(result)); //=> "I'm the only one resolving!"
```

## Documentation

See the [wiki](https://github.com/T99/promise-any-polyfill/wiki) for full documentation.

## License

promise-any-polyfill is made available under the GNU General Public License v3.

Copyright (C) 2021 Trevor Sears

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