Socket
Book a DemoInstallSign in
Socket

promise.try

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise.try

ES Proposal spec-compliant shim for Promise.try

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
475
63.23%
Maintainers
1
Weekly downloads
 
Created
Source

promise.try Version Badge

github actions coverage License Downloads

npm badge

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 is recommended.

This package implements the es-shim API interface. It works in an ES3-supported environment that has Promise available globally, and complies with the proposed spec.

Most common usage:

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

Keywords

Promise

FAQs

Package last updated on 02 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts