3.1.8 • Published 3 months ago

promise.prototype.finally v3.1.8

Weekly downloads
2,458,822
License
MIT
Repository
github
Last release
3 months ago

promise.prototype.finally Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

ES Proposal spec-compliant shim for Promise.prototype.finally. Invoke its "shim" method to shim Promise.prototype.finally 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 promiseFinally = require('promise.prototype.finally');

var resolved = Promise.resolve(42);
var rejected = Promise.reject(-1);

promiseFinally(resolved, function () {
	assert.equal(arguments.length, 0);

	return Promise.resolve(true);
}).then(function (x) {
	assert.equal(x, 42);
});

promiseFinally(rejected, function () {
	assert.equal(arguments.length, 0);
}).catch(function (e) {
	assert.equal(e, -1);
});

promiseFinally(rejected, function () {
	assert.equal(arguments.length, 0);

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

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

resolved.finally(function () {
	assert.equal(arguments.length, 0);

	return Promise.resolve(true);
}).then(function (x) {
	assert.equal(x, 42);
});

rejected.finally(function () {
	assert.equal(arguments.length, 0);
}).catch(function (e) {
	assert.equal(e, -1);
});

rejected.finally(function () {
	assert.equal(arguments.length, 0);

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

Tests

Simply clone the repo, npm install, and run npm test

Thanks

Huge thanks go out to @matthew-andrews, who provided the npm package name for v2 of this module. v1 is both in the original repo and preserved in a branch

airbnb-js-shimsgohiei-bull@ventusrisk/jsliblamia-shell@dw/d-utilstdpro-clikin-promise-finally@infinitebrahmanuniverse/nolb-promise_@saaspe/componentspxt-core@everything-registry/sub-chunk-2481xm-entadmin-mainxtc_watermarkyrvue-base-oavue-fast-oawebsocket-as-promisedvue-modelwpvip-clitmta-coretopbetta-frontendtimortext-loadingtext-modalteamcity-build-queuets-async-iterable-functionsuhnoxi-music-webuhnoxi-music-web-buildu-library@ethan021/homebridge-nestzillow-js-shimsvocabspree-sdktredux-materialtredux-material-updated@hkube/bullswagger-to-interfaces@infocentric/http-clientnvxpromise-helperspromised-websocketdesign-system-fitbank-450desknotifierdesknotifyqbrtdetect-and-shimrainbow-node-sdkrainbow-s2s-starterkit-nodejsraywebsocketpromiseddfin-jkitreactjs-pull-loadsequelcomponentshuangqiu-mycommentsophon-utilsstucumberstucumber-extsuperdesk-planningsvelte-component-lib@openpass/openpass-js-sdk@monibrand/bull@otris/node-sds@openziti/ziti-browzer-core@openziti/ziti-sdk-jsx-axios-helperwxa-cli2-apple@journeyapps/core@jy-fe/utils@lego-js/tests@mara/xnode-synchronizednode-red-contrib-ccupassionfruitd-utils-litecriticalcssreact-left-slide-deletereact-form-component-libraryconfigoramaparvan_componentsparvan_reactjs_components@ryokit/site@rauny_henrique/bull@ryoframework/atlas@ryoframework/support@ryokit/app@pageboard/core@paulcbetts/electron-rxdb@podlubnaja/ui-kit@nimiq/libswapexcelwatermark@vulkano/core@windyroad/wait-on-mysqljs-utils-m@wxa/cli2@wrecking-ball-software/bullionic-coreoelectron-rxdb@sharegulch/gus@shivarajapple/first-library@skeetboothppq/component-library@sky0014/store@unified-tv/polyfill
3.1.8

3 months ago

3.1.7

8 months ago

3.1.5

8 months ago

3.1.4

1 year ago

3.1.3

3 years ago

3.1.2

4 years ago

3.1.1

5 years ago

3.1.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.1

9 years ago

1.0.0

10 years ago