Socket
Socket
Sign inDemoInstall

promise.prototype.finally

Package Overview
Dependencies
65
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 2.0.0

.eslintrc

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc