promise.prototype.finally
Advanced tools
Comparing version 3.1.2 to 3.1.3
@@ -0,1 +1,18 @@ | ||
3.1.3 / 2021-10-04 | ||
================= | ||
* [Refactor] update `es-abstract`; use `call-bind` instead of `function-bind` | ||
* [Deps] update `es-abstract` | ||
* [readme] add github actions/codecov badges | ||
* [meta] remove unneeded token; update checkout action | ||
* [actions] use `node/install` instead of `node/run`; use `codecov` action | ||
* [actions] add Require Allow Edits workflow | ||
* [actions] switch Automatic Rebase workflow to `pull_request_target` event | ||
* [Tests] increase coverage | ||
* [Tests] migrate tests to Github Actions (#29) | ||
* [Tests] run `nyc` on all tests; use `tape` runner; add implementation tests; mark failing impl tests as TODO | ||
* [Tests] skip "observable calls" tests in node 6-9 | ||
* [Tests] add passing tests from https://github.com/tc39/test262/pull/2752 | ||
* [Tests] refactor Subclass tests to capture receiver | ||
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `aud`, `es6-shim`, `tape` | ||
3.1.2 / 2019-12-11 | ||
@@ -2,0 +19,0 @@ ================= |
@@ -7,5 +7,5 @@ 'use strict'; | ||
var IsCallable = require('es-abstract/2018/IsCallable'); | ||
var SpeciesConstructor = require('es-abstract/2018/SpeciesConstructor'); | ||
var Type = require('es-abstract/2018/Type'); | ||
var IsCallable = require('es-abstract/2021/IsCallable'); | ||
var SpeciesConstructor = require('es-abstract/2021/SpeciesConstructor'); | ||
var Type = require('es-abstract/2021/Type'); | ||
@@ -12,0 +12,0 @@ var promiseResolve = function PromiseResolve(C, value) { |
'use strict'; | ||
var bind = require('function-bind'); | ||
var callBind = require('call-bind'); | ||
var define = require('define-properties'); | ||
@@ -10,3 +10,3 @@ | ||
var bound = bind.call(Function.call, getPolyfill()); | ||
var bound = callBind(getPolyfill()); | ||
@@ -13,0 +13,0 @@ define(bound, { |
{ | ||
"name": "promise.prototype.finally", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"author": "Jordan Harband <ljharb@gmail.com>", | ||
@@ -27,11 +27,7 @@ "funding": { | ||
"posttest": "npx aud --production", | ||
"tests-only": "es-shim-api --bound && npm run --silent test:shimmed && npm run --silent test:module && npm run --silent tests:es5", | ||
"tests:es5": "npm run --silent test:promise-shimmed", | ||
"test:shimmed": "node test/shimmed.js", | ||
"test:module": "node test/index.js", | ||
"test:promise-shimmed": "node test/promise-shimmed.js", | ||
"test:native": "node --harmony-promise-finally test/native", | ||
"coverage": "covert test/*.js", | ||
"coverage-quiet": "covert test/*.js --quiet", | ||
"lint": "eslint ." | ||
"tests-only": "nyc tape test/{implementation,index,shimmed}.js", | ||
"test:promise-shimmed": "nyc node test/promise-shimmed", | ||
"test:native": "nyc node test/native", | ||
"lint": "eslint .", | ||
"postlint": "es-shim-api --bound" | ||
}, | ||
@@ -55,14 +51,15 @@ "repository": { | ||
"dependencies": { | ||
"call-bind": "^1.0.2", | ||
"define-properties": "^1.1.3", | ||
"es-abstract": "^1.17.0-next.0", | ||
"function-bind": "^1.1.1" | ||
"es-abstract": "^1.19.1" | ||
}, | ||
"devDependencies": { | ||
"@es-shims/api": "^2.1.2", | ||
"@ljharb/eslint-config": "^15.0.2", | ||
"covert": "^1.1.1", | ||
"es6-shim": "^0.35.5", | ||
"eslint": "^6.7.2", | ||
"@es-shims/api": "^2.2.2", | ||
"@ljharb/eslint-config": "^18.0.0", | ||
"aud": "^1.1.5", | ||
"es6-shim": "^0.35.6", | ||
"eslint": "^7.32.0", | ||
"nyc": "^10.3.2", | ||
"safe-publish-latest": "^1.1.4", | ||
"tape": "^4.11.0" | ||
"tape": "^5.3.1" | ||
}, | ||
@@ -69,0 +66,0 @@ "testling": { |
# promise.prototype.finally <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
[![Build Status][travis-svg]][travis-url] | ||
[![github actions][actions-image]][actions-url] | ||
[![coverage][codecov-image]][codecov-url] | ||
[![dependency status][deps-svg]][deps-url] | ||
@@ -11,4 +12,2 @@ [![dev dependency status][dev-deps-svg]][dev-deps-url] | ||
[![browser support][testling-svg]][testling-url] | ||
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](https://github.com/es-shims/es6-shim) is recommended. | ||
@@ -81,4 +80,2 @@ | ||
[npm-version-svg]: http://versionbadg.es/es-shims/Promise.prototype.finally.svg | ||
[travis-svg]: https://travis-ci.org/es-shims/Promise.prototype.finally.svg | ||
[travis-url]: https://travis-ci.org/es-shims/Promise.prototype.finally | ||
[deps-svg]: https://david-dm.org/es-shims/Promise.prototype.finally.svg | ||
@@ -97,1 +94,5 @@ [deps-url]: https://david-dm.org/es-shims/Promise.prototype.finally | ||
[v1-branch-url]: https://github.com/es-shims/Promise.prototype.finally/tree/v1 | ||
[codecov-image]: https://codecov.io/gh/es-shims/Promise.prototype.finally/branch/main/graphs/badge.svg | ||
[codecov-url]: https://app.codecov.io/gh/es-shims/Promise.prototype.finally/ | ||
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Promise.prototype.finally | ||
[actions-url]: https://github.com/es-shims/Promise.prototype.finally/actions |
'use strict'; | ||
var defineProperties = require('define-properties'); | ||
var bind = require('function-bind'); | ||
var callBind = require('call-bind'); | ||
var isEnumerable = Object.prototype.propertyIsEnumerable; | ||
@@ -31,3 +31,3 @@ var functionsHaveNames = function f() {}.name === 'f'; | ||
runTests(bind.call(Function.call, Promise.prototype['finally']), t); | ||
runTests(callBind(Promise.prototype['finally']), t); | ||
}; |
'use strict'; | ||
var promiseFinally = require('../'); | ||
promiseFinally.shim(); | ||
require('../auto'); | ||
@@ -6,0 +5,0 @@ var test = require('tape'); |
@@ -34,11 +34,11 @@ 'use strict'; | ||
t.test('onFinally arguments', function (st) { | ||
st.plan(2); | ||
st.plan(4); | ||
promiseFinally(Promise.resolve(42), function () { | ||
st.equal(arguments.length, 0, 'resolved promise passes no arguments to onFinally'); | ||
})['catch'](st.fail); | ||
}).then(st.pass, st.fail); | ||
promiseFinally(Promise.reject(NaN), function () { | ||
st.equal(arguments.length, 0, 'rejected promise passes no arguments to onFinally'); | ||
}).then(st.fail); | ||
}).then(st.fail, st.pass); | ||
}); | ||
@@ -77,3 +77,3 @@ | ||
// eslint-disable-next-line no-new-func | ||
return Function('class Subclass extends Promise { constructor(...args) { super(...args); this.thenArgs = []; } then(...args) { Subclass.thenArgs.push(args); this.thenArgs.push(args); return super.then(...args); } } Subclass.thenArgs = []; return Subclass;')(); | ||
return Function('class Subclass extends Promise { constructor(...args) { super(...args); this.thenArgs = []; } then(...args) { Subclass.thenArgs.push({ promise: this, args: args }); this.thenArgs.push({ promise: this, args: args }); return super.then(...args); } } Subclass.thenArgs = []; return Subclass;')(); | ||
} catch (e) { /**/ } | ||
@@ -133,6 +133,6 @@ | ||
assertArray(s2t, original.thenArgs, 1, Array.isArray); | ||
assertArray(s2t, Subclass.thenArgs, 1, Array.isArray); | ||
assertArray(s2t, original.thenArgs, 1, function (x) { s2t.ok(Array.isArray(x.args)); }); | ||
assertArray(s2t, Subclass.thenArgs, 1, function (x) { s2t.ok(Array.isArray(x.args)); }); | ||
assertArray(s2t, original.thenArgs[0], 2, function (x) { s2t.equal(x, sentinel); }); | ||
assertArray(s2t, original.thenArgs[0].args, 2, function (x) { s2t.equal(x, sentinel); }); | ||
@@ -154,7 +154,7 @@ s2t.end(); | ||
assertArray(s2t, original.thenArgs, 1, Array.isArray); | ||
assertArray(s2t, Subclass.thenArgs, 1, Array.isArray); | ||
assertArray(s2t, original.thenArgs, 1, function (x) { s2t.ok(Array.isArray(x.args)); }); | ||
assertArray(s2t, Subclass.thenArgs, 1, function (x) { s2t.ok(Array.isArray(x.args)); }); | ||
var thenArgs = original.thenArgs[0]; | ||
assertArray(s2t, thenArgs, 2, function (x) { s2t.equal(typeof x, 'function'); }); | ||
assertArray(s2t, thenArgs.args, 2, function (x) { s2t.equal(typeof x, 'function'); }); | ||
@@ -198,13 +198,15 @@ s2t.deepEqual(onFinallyArgs, [], 'onFinally not yet called'); | ||
assertArray(s3t, Subclass.thenArgs, 3); | ||
// 1) initial call with thenFinally/catchFinally | ||
// 2) rejectedPromise.then call | ||
// 3) rejectedPromise.then -> onFinally call | ||
assertArray(s3t, Subclass.thenArgs[0], 2, function (x) { s3t.equal(typeof x, 'function'); }); | ||
/* | ||
* 1) initial call with thenFinally/catchFinally | ||
* 2) rejectedPromise.then call | ||
* 3) rejectedPromise.then -> onFinally call | ||
*/ | ||
assertArray(s3t, Subclass.thenArgs[0].args, 2, function (x) { s3t.equal(typeof x, 'function'); }); | ||
assertArray(s3t, Subclass.thenArgs[1], 2); | ||
s3t.deepEqual(Subclass.thenArgs[1], [s3t.fail, rejectedPromiseCatch], 'rejectedPromise.then call args'); | ||
assertArray(s3t, Subclass.thenArgs[1].args, 2); | ||
s3t.deepEqual(Subclass.thenArgs[1].args, [s3t.fail, rejectedPromiseCatch], 'rejectedPromise.then call args'); | ||
assertArray(s3t, Subclass.thenArgs[2], 2); | ||
s3t.equal(Subclass.thenArgs[2][0], undefined, 'final .then call gets no onFulfill'); | ||
s3t.equal(typeof Subclass.thenArgs[2][1], 'function', 'final .then call gets an onReject'); | ||
assertArray(s3t, Subclass.thenArgs[2].args, 2); | ||
s3t.equal(Subclass.thenArgs[2].args[0], undefined, 'final .then call gets no onFulfill'); | ||
s3t.equal(typeof Subclass.thenArgs[2].args[1], 'function', 'final .then call gets an onReject'); | ||
@@ -219,2 +221,45 @@ s3t.end(); | ||
}); | ||
st.test('observable then calls', { todo: true }, function (s2t) { | ||
var mp1Value = {}; | ||
var mp1 = Subclass.resolve(mp1Value); | ||
var mp2 = Subclass.resolve(42); | ||
var mp3 = Subclass.reject(mp1Value); | ||
var mp4 = Subclass.reject(42); | ||
mp3['catch'](function () {}); // avoid unhandled rejection warning | ||
mp4['catch'](function () {}); // avoid unhandled rejection warning | ||
s2t.test('resolved observable then calls', { todo: true }, function (s3t) { | ||
var orig = Subclass.thenArgs.length; | ||
s3t.plan(6); | ||
return promiseFinally(mp1, function () { return mp2; }).then(function () { | ||
assertArray(s3t, Subclass.thenArgs, orig + 5); | ||
var mp2Calls = Subclass.thenArgs.filter(function (c) { return c.promise === mp2; }); | ||
assertArray(s3t, mp2Calls, 1); | ||
s3t.equal(mp2Calls[0].args[1], undefined, '`reject` is undefined'); | ||
s3t.equal(mp2Calls[0].args[0](), mp1Value, '`resolve` produces `mp1Value`'); | ||
}); | ||
}); | ||
s2t.test('rejected observable then calls', { todo: true }, function (s3t) { | ||
var orig = Subclass.thenArgs.length; | ||
s3t.plan(7); | ||
return promiseFinally(mp3, function () { return mp4; }).then(s3t.fail, function () { | ||
assertArray(s3t, Subclass.thenArgs, orig + 5); | ||
var mp4Calls = Subclass.thenArgs.filter(function (c) { return c.promise === mp4; }); | ||
assertArray(s3t, mp4Calls, 1); | ||
s3t.equal(mp4Calls[0].args[1], undefined, '`reject` is undefined'); | ||
var thrown = false; | ||
try { | ||
mp4Calls[0].args[0](); | ||
} catch (error) { | ||
thrown = true; | ||
s3t.equal(error, mp1Value, 'rejects to `mp1Value`'); | ||
} | ||
s3t.ok(thrown, 'threw an error'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -221,0 +266,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27106
21
377
96
8
+ Addedcall-bind@^1.0.2
- Removedfunction-bind@^1.1.1
Updatedes-abstract@^1.19.1