# promise.try

> ES Proposal spec-compliant shim for Promise.try

Latest version **2.0.2** (published 2026-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install promise.try
pnpm add promise.try
yarn add promise.try
bun add promise.try
```

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2026-09-09 |
| First published | 2016-08-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >= 0.4 |
| Dependencies | 5 |
| Unpacked size | 14.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | Promise, promises, try, Promise.try, shim, polyfill, es-shim API |

## Links

- npm: https://www.npmjs.com/package/promise.try
- Repository: https://github.com/es-shims/Promise.try
- Homepage: https://github.com/es-shims/Promise.try#readme
- Issues: https://github.com/es-shims/Promise.try/issues
- npm.io page: https://npm.io/package/promise.try

## Dependencies (5)

- [call-bind](https://npm.io/package/call-bind.md) ^1.0.9
- [es-errors](https://npm.io/package/es-errors.md) ^1.3.0
- [es-abstract](https://npm.io/package/es-abstract.md) ^1.24.2
- [define-properties](https://npm.io/package/define-properties.md) ^1.2.1
- [set-function-name](https://npm.io/package/set-function-name.md) ^2.0.2

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 2.0.2 (latest) — 2026-09-09
- 2.0.1 — 2026-01-02
- 2.0.0 — 2024-04-09
- 1.0.0 — 2016-08-21

## README

# promise.try <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

ES Proposal spec-compliant shim for `Promise.try`. Invoke its "shim" method to shim `Promise.try` if it is unavailable or noncompliant. **Note**: a global `Promise` must already exist: the [es6-shim](https://github.com/es-shims/es6-shim) is recommended.

This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment that has `Promise` available globally, and complies with the [proposed spec](https://tc39.es/proposal-promise-try/).

Most common usage:
```js
var assert = require('assert');
var promiseTry = require('promise.try');

promiseTry(function (e) {
	throw e;
}, 42).catch(function (e) {
	assert.equal(e, 42);
});

promiseTry(function () {
	return Infinity;
}).then(function (x) {
	assert.equal(x, Infinity);
});

promiseTry.shim(); // will be a no-op if not needed

Promise.try(function () {
	throw 42;
}).catch(function (e) {
	assert.equal(e, 42);
});

Promise.try(function () {
	return Infinity;
}).then(function (x) {
	assert.equal(x, Infinity);
});
```

## Tests
Simply clone the repo, `npm install`, and run `npm test`

[package-url]: https://npmjs.com/package/promise.try
[npm-version-svg]: http://versionbadg.es/es-shims/Promise.try.svg
[deps-svg]: https://david-dm.org/es-shims/Promise.try.svg
[deps-url]: https://david-dm.org/es-shims/Promise.try
[dev-deps-svg]: https://david-dm.org/es-shims/Promise.try/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/Promise.try#info=devDependencies
[testling-svg]: https://ci.testling.com/es-shims/Promise.try.png
[testling-url]: https://ci.testling.com/es-shims/Promise.try
[npm-badge-png]: https://nodei.co/npm/promise.try.png?downloads=true&stars=true
[license-image]: http://img.shields.io/npm/l/promise.try.svg
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/promise.try.svg
[downloads-url]: http://npm-stat.com/charts.html?package=promise.try
[codecov-image]: https://codecov.io/gh/es-shims/Promise.try/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/es-shims/Promise.try/
[actions-image]: https://img.shields.io/github/check-runs/es-shims/Promise.try/main
[actions-url]: https://github.com/es-shims/Promise.try/actions

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