# resolve-once

> Resolves a promise only once and memoizes the result

Latest version **1.0.11** (published 2026-10-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install resolve-once
pnpm add resolve-once
yarn add resolve-once
bun add resolve-once
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2026-10-12 |
| First published | 2018-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=0.8 |
| Dependencies | 0 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kevin Malakoff |
| Maintainers | kmalakoff |
| Keywords | promise, resolve, once, memoize, resolve-once |

## Links

- npm: https://www.npmjs.com/package/resolve-once
- Repository: https://github.com/kmalakoff/resolve-once
- Issues: https://github.com/kmalakoff/resolve-once/issues
- npm.io page: https://npm.io/package/resolve-once

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.11 (latest) — 2026-10-12
- 1.0.10 — 2026-09-12
- 1.0.9 — 2026-05-26
- 1.0.8 — 2025-12-12
- 1.0.7 — 2025-12-12
- 1.0.6 — 2025-12-04
- 1.0.5 — 2025-12-04
- 1.0.4 — 2025-12-02
- 1.0.3 — 2025-11-06
- 1.0.2 — 2025-10-21
- 1.0.1 — 2025-10-21
- 1.0.0 — 2025-06-21
- 0.6.21 — 2025-06-21
- 0.6.19 — 2025-06-20
- 0.6.18 — 2025-06-18
- … 23 more at https://npm.io/package/resolve-once/versions

## README

# resolve-once

Runs an asynchronous resolver once and memoizes its success or failure.

## Install

```sh
npm install resolve-once
```

## Use

The resolver below runs once even when several callers request its result at the same time:

```js
var resolveOnce = require('resolve-once');

var calls = 0;
var getValue = resolveOnce(function () {
  return new Promise(function (resolve) {
    calls += 1;
    setTimeout(function () { resolve({ calls: calls }); }, 10);
  });
});

Promise.all([getValue(), getValue()]).then(function (values) {
  console.log(values[0] === values[1], calls); // true 1
});
```

Each caller gets the result of the same resolver operation, but receives its own Promise. After the first operation settles, later calls return the cached value or reject with the cached error. The package does not retry after rejection.

The implementation uses the global `Promise`; environments without a Promise implementation must provide one.

## License

MIT

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