MCPcopy Index your code
hub / github.com/es-shims/Promise.prototype.finally

github.com/es-shims/Promise.prototype.finally @v3.1.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.1.8 ↗ · + Follow
10 symbols 16 edges 13 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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

Core symbols most depended-on inside this repo

assertArray
called by 19
test/tests.js
onFinally
called by 2
test/tests.js
createThenFinally
called by 1
implementation.js
createCatchFinally
called by 1
implementation.js
valueThunk
called by 0
implementation.js
thrower
called by 0
implementation.js
onFulfill
called by 0
test/tests.js
onReject
called by 0
test/tests.js

Shape

Function 10

Languages

TypeScript100%

Modules by API surface

test/tests.js6 symbols
implementation.js4 symbols

For agents

$ claude mcp add Promise.prototype.finally \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact