3.1.8 • Published 1 year ago

promise.prototype.finally v3.1.8

Weekly downloads
2,458,822
License
MIT
Repository
github
Last release
1 year 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/components@everything-registry/sub-chunk-2481swagger-to-interfaceswkl-test-uiwpvip-clix-axios-helperxm-entadmin-mainwxa-cli2-appleteamcity-build-queuesuperdesk-planningsvelte-component-libtext-modaltext-loadingvocabspree-sdkvue-fast-oavue-base-oa@coreo/ionic-core@coreo/ionic-map@calblueprint/whales@blkmarketco/components-libraryjs-utils-mionic-coreokilldata-componenthomebridge-wifisprinklerhomebridge-wifitempcustomhomebridge-wifithermostatcustomhomebridge-wifiaccustomhomebridge-wifigatecustomhomebridge-wifilawnmowerhomebridge-wifipower_lawnrobothomebridge-wifisensrefcustomstucumberstucumber-extsophon-utilsuhnoxi-music-webuhnoxi-music-web-buildu-librarytmta-coretredux-materialtredux-material-updatedtopbetta-frontendtimor@arianee/arianeejs@arianee/arianeejs-speakez@assistant/conversation-testing@alicloud/fun@beisen-phoenix/person-selector@activfinancial/one-api@activfinancial/cg-api@activfinancial/cg-api-fsbl@dfroehli42/infinispan@danieldx/ncadmin-coreyrzillow-js-shimsvue-modelts-async-iterable-functionsxtc_watermark@hkube/bull@ethan021/homebridge-nest@infocentric/http-client@lego-js/tests@mara/x@nimiq/libswap@monibrand/bull@journeyapps/core@jy-fe/utils@rauny_henrique/bull@ryoframework/atlas@ryoframework/support@ryokit/app@ryokit/site@podlubnaja/ui-kit@paulcbetts/electron-rxdb@openziti/ziti-browzer-core@openziti/ziti-sdk-js@pageboard/core@otris/node-sds@skeetboothppq/component-library@sky0014/store@shivarajapple/first-librarymy-tnm-2n2-isomorphic-corenvxparvan_componentsparvan_reactjs_componentspassionfruitraywebsocketpromisedreact-left-slide-deletepromise-helpersreactjs-pull-loadreact-form-component-librarysequelcomponent
3.1.8

1 year ago

3.1.7

2 years ago

3.1.5

2 years ago

3.1.4

3 years ago

3.1.3

4 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.0.1

10 years ago

1.0.0

11 years ago