promise.prototype.finally
Advanced tools
Comparing version 1.0.1 to 2.0.0
104
package.json
{ | ||
"name": "promise.prototype.finally", | ||
"description": "A polyfill for Promise.prototype.finally for ES6 compliant promises", | ||
"version": "1.0.1", | ||
"scripts": { | ||
"test": "npm run lintspaces && npm run jshint && ./node_modules/.bin/mocha test", | ||
"files": "find . \\( -name '*.js' -o -name '*.json' \\) ! -path './node_modules/*'", | ||
"lintspaces": "./node_modules/.bin/lintspaces -i js-comments -e .editorconfig `npm run -s files`", | ||
"jshint": "./node_modules/.bin/jshint `npm run -s files`" | ||
}, | ||
"main": "finally.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/matthew-andrews/Promise.prototype.finally" | ||
}, | ||
"devDependencies": { | ||
"es6-promise": "^1.0.0", | ||
"jshint": "^2.5.6", | ||
"lintspaces-cli": "0.0.4", | ||
"mocha": "^1.21.4" | ||
} | ||
"name": "promise.prototype.finally", | ||
"version": "2.0.0", | ||
"author": "Jordan Harband", | ||
"contributors": [ | ||
{ | ||
"name": "Matt Andrews", | ||
"email": "matt@mattandre.ws" | ||
}, | ||
{ | ||
"name": "Jordan Harband", | ||
"email": "ljharb@gmail.com", | ||
"url": "http://ljharb.codes" | ||
} | ||
], | ||
"description": "ES Proposal spec-compliant shim for Promise.prototype.finally", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"scripts": { | ||
"prepublish": "safe-publish-latest", | ||
"pretest": "npm run --silent lint", | ||
"test": "npm run --silent tests-only", | ||
"posttest": "npm run --silent security", | ||
"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", | ||
"coverage": "covert test/*.js", | ||
"coverage-quiet": "covert test/*.js --quiet", | ||
"lint": "eslint test/*.js *.js", | ||
"security": "nsp check" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/es-shims/Promise.prototype.finally.git" | ||
}, | ||
"keywords": [ | ||
"Promise", | ||
"promises", | ||
"finally", | ||
"promise.prototype.finally", | ||
"ES7", | ||
"ES8", | ||
"ES2017", | ||
"shim", | ||
"polyfill", | ||
"es-shim API" | ||
], | ||
"dependencies": { | ||
"define-properties": "^1.1.2", | ||
"es-abstract": "^1.6.0", | ||
"function-bind": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"@es-shims/api": "^1.2.0", | ||
"@ljharb/eslint-config": "^6.0.0", | ||
"covert": "^1.1.0", | ||
"es6-shim": "^0.35.1", | ||
"eslint": "^3.0.1", | ||
"nsp": "^2.5.0", | ||
"tape": "^4.6.0", | ||
"safe-publish-latest": "^1.0.1" | ||
}, | ||
"testling": { | ||
"files": "test/index.js", | ||
"browsers": [ | ||
"iexplore/9.0..latest", | ||
"firefox/4.0..6.0", | ||
"firefox/15.0..latest", | ||
"firefox/nightly", | ||
"chrome/4.0..10.0", | ||
"chrome/20.0..latest", | ||
"chrome/canary", | ||
"opera/11.6..latest", | ||
"opera/next", | ||
"safari/5.0..latest", | ||
"ipad/6.0..latest", | ||
"iphone/6.0..latest", | ||
"android-browser/4.2" | ||
] | ||
}, | ||
"engines": { | ||
"node": ">= 0.4" | ||
} | ||
} |
104
README.md
@@ -1,36 +0,94 @@ | ||
# Promise.prototype.finally [ ![Codeship Status for matthew-andrews/Promise.prototype.finally](https://codeship.io/projects/d2ed45d0-3364-0132-3c6b-26237c03a86a/status)](https://codeship.io/projects/40589) | ||
# promise.prototype.finally <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
A polyfill for `Promise.prototype.finally`. See docs on what finally is on [your favourite pre-ES6 promise library](https://github.com/tildeio/rsvp.js/blob/master/README.md#finally). | ||
[![Build Status][travis-svg]][travis-url] | ||
[![dependency status][deps-svg]][deps-url] | ||
[![dev dependency status][dev-deps-svg]][dev-deps-url] | ||
[![License][license-image]][license-url] | ||
[![Downloads][downloads-image]][downloads-url] | ||
Warning: This micro-library doesn't force you to use any particular Promise implementation by using whatever `Promise` has been defined as globally. This is so that you may use any ES6 standard Promise compliant library - or, of course, native ES6 Promises. | ||
[![npm badge][npm-badge-png]][package-url] | ||
If you're running the code on a browser or node version that doesn't include native promises you will need to include a polyfill. The following polyfills are tested as part of this module's test suite:- | ||
[![browser support][testling-svg]][testling-url] | ||
- [Jake Archibald](https://twitter.com/jaffathecake)'s [ES6 Promise library](https://github.com/jakearchibald/es6-promise) (which is actually adapted from [Stefan Penner](https://twitter.com/stefanpenner)'s [RSVP.js](https://github.com/tildeio/rsvp.js)). - `require('es6-promise').polyfill();` | ||
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. | ||
## Installation | ||
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment that has `Promise` available globally, and complies with the [proposed spec](https://github.com/tc39/proposal-promise-finally). | ||
``` | ||
npm install promise.prototype.finally --save | ||
``` | ||
Most common usage: | ||
```js | ||
var assert = require('assert'); | ||
var promiseFinally = require('promise.prototype.finally'); | ||
## Examples | ||
var resolved = Promise.resolve(42); | ||
var rejected = Promise.reject(-1); | ||
```js | ||
require('es6-promise').polyfill(); | ||
require('promise.prototype.finally'); | ||
promiseFinally(resolved, function () { | ||
assert.equal(arguments.length, 0); | ||
Promise.resolve(6) | ||
.finally(function() { | ||
console.log('this will always be called'); | ||
}); | ||
return Promise.resolve(true); | ||
}).then(function (x) { | ||
assert.equal(x, 42); | ||
}); | ||
Promise.reject(6) | ||
.finally(function() { | ||
console.log('this will always be called'); | ||
}); | ||
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); | ||
}); | ||
``` | ||
## Credits and collaboration | ||
## Tests | ||
Simply clone the repo, `npm install`, and run `npm test` | ||
The lead developer of **Promise.prototype.finally** is [Matt Andrews](http://twitter.com/andrewsmatt) at FT, the code is based on [a snippet](https://github.com/domenic/promises-unwrapping/issues/18#issuecomment-57801572) by [Stefan Penner](https://twitter.com/stefanpenner) - used [with permission](https://twitter.com/stefanpenner/status/520904347073667072). All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request. | ||
## Thanks | ||
Huge thanks go out to [@matthew-andrews](https://github.com/matthew-andrews), who provided the npm package name for v2 of this module. v1 is both in [the original repo][v1-repo-url] and preserved in [a branch][v1-branch-url] | ||
[package-url]: https://npmjs.com/package/promise.prototype.finally | ||
[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 | ||
[deps-url]: https://david-dm.org/es-shims/Promise.prototype.finally | ||
[dev-deps-svg]: https://david-dm.org/es-shims/Promise.prototype.finally/dev-status.svg | ||
[dev-deps-url]: https://david-dm.org/es-shims/Promise.prototype.finally#info=devDependencies | ||
[testling-svg]: https://ci.testling.com/es-shims/Promise.prototype.finally.png | ||
[testling-url]: https://ci.testling.com/es-shims/Promise.prototype.finally | ||
[npm-badge-png]: https://nodei.co/npm/promise.prototype.finally.png?downloads=true&stars=true | ||
[license-image]: http://img.shields.io/npm/l/promise.prototype.finally.svg | ||
[license-url]: LICENSE | ||
[downloads-image]: http://img.shields.io/npm/dm/promise.prototype.finally.svg | ||
[downloads-url]: http://npm-stat.com/charts.html?package=promise.prototype.finally | ||
[v1-repo-url]: https://github.com/matthew-andrews/Promise.prototype.finally | ||
[v1-branch-url]: https://github.com/es-shims/Promise.prototype.finally/tree/v1 |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
18324
17
1
193
0
1
95
3
8
2
+ Addeddefine-properties@^1.1.2
+ Addedes-abstract@^1.6.0
+ Addedfunction-bind@^1.1.0
+ Addedarray-buffer-byte-length@1.0.1(transitive)
+ Addedarraybuffer.prototype.slice@1.0.3(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addeddata-view-buffer@1.0.1(transitive)
+ Addeddata-view-byte-length@1.0.1(transitive)
+ Addeddata-view-byte-offset@1.0.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addedes-abstract@1.23.3(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedes-set-tostringtag@2.0.3(transitive)
+ Addedes-to-primitive@1.2.1(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedfunction.prototype.name@1.1.6(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedget-symbol-description@1.0.2(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-bigints@1.0.2(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinternal-slot@1.0.7(transitive)
+ Addedis-array-buffer@3.0.4(transitive)
+ Addedis-bigint@1.0.4(transitive)
+ Addedis-boolean-object@1.1.2(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-data-view@1.0.1(transitive)
+ Addedis-date-object@1.0.5(transitive)
+ Addedis-negative-zero@2.0.3(transitive)
+ Addedis-number-object@1.0.7(transitive)
+ Addedis-regex@1.1.4(transitive)
+ Addedis-shared-array-buffer@1.0.3(transitive)
+ Addedis-string@1.0.7(transitive)
+ Addedis-symbol@1.0.4(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedis-weakref@1.0.2(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedobject-inspect@1.13.1(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.5(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedregexp.prototype.flags@1.5.2(transitive)
+ Addedsafe-array-concat@1.1.2(transitive)
+ Addedsafe-regex-test@1.0.3(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstring.prototype.trim@1.2.9(transitive)
+ Addedstring.prototype.trimend@1.0.8(transitive)
+ Addedstring.prototype.trimstart@1.0.8(transitive)
+ Addedtyped-array-buffer@1.0.2(transitive)
+ Addedtyped-array-byte-length@1.0.1(transitive)
+ Addedtyped-array-byte-offset@1.0.2(transitive)
+ Addedtyped-array-length@1.0.6(transitive)
+ Addedunbox-primitive@1.0.2(transitive)
+ Addedwhich-boxed-primitive@1.0.2(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)