diff options
Diffstat (limited to 'node_modules/p-finally')
| -rw-r--r-- | node_modules/p-finally/index.js | 15 | ||||
| -rw-r--r-- | node_modules/p-finally/license | 21 | ||||
| -rw-r--r-- | node_modules/p-finally/package.json | 42 | ||||
| -rw-r--r-- | node_modules/p-finally/readme.md | 47 | 
4 files changed, 125 insertions, 0 deletions
diff --git a/node_modules/p-finally/index.js b/node_modules/p-finally/index.js new file mode 100644 index 000000000..52b7b49c5 --- /dev/null +++ b/node_modules/p-finally/index.js @@ -0,0 +1,15 @@ +'use strict'; +module.exports = (promise, onFinally) => { +	onFinally = onFinally || (() => {}); + +	return promise.then( +		val => new Promise(resolve => { +			resolve(onFinally()); +		}).then(() => val), +		err => new Promise(resolve => { +			resolve(onFinally()); +		}).then(() => { +			throw err; +		}) +	); +}; diff --git a/node_modules/p-finally/license b/node_modules/p-finally/license new file mode 100644 index 000000000..654d0bfe9 --- /dev/null +++ b/node_modules/p-finally/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/p-finally/package.json b/node_modules/p-finally/package.json new file mode 100644 index 000000000..b26ab5188 --- /dev/null +++ b/node_modules/p-finally/package.json @@ -0,0 +1,42 @@ +{ +  "name": "p-finally", +  "version": "1.0.0", +  "description": "`Promise#finally()` ponyfill - Invoked when the promise is settled regardless of outcome", +  "license": "MIT", +  "repository": "sindresorhus/p-finally", +  "author": { +    "name": "Sindre Sorhus", +    "email": "sindresorhus@gmail.com", +    "url": "sindresorhus.com" +  }, +  "engines": { +    "node": ">=4" +  }, +  "scripts": { +    "test": "xo && ava" +  }, +  "files": [ +    "index.js" +  ], +  "keywords": [ +    "promise", +    "finally", +    "handler", +    "function", +    "async", +    "await", +    "promises", +    "settled", +    "ponyfill", +    "polyfill", +    "shim", +    "bluebird" +  ], +  "devDependencies": { +    "ava": "*", +    "xo": "*" +  }, +  "xo": { +    "esnext": true +  } +} diff --git a/node_modules/p-finally/readme.md b/node_modules/p-finally/readme.md new file mode 100644 index 000000000..09ef36416 --- /dev/null +++ b/node_modules/p-finally/readme.md @@ -0,0 +1,47 @@ +# p-finally [](https://travis-ci.org/sindresorhus/p-finally) + +> [`Promise#finally()`](https://github.com/tc39/proposal-promise-finally) [ponyfill](https://ponyfill.com) - Invoked when the promise is settled regardless of outcome + +Useful for cleanup. + + +## Install + +``` +$ npm install --save p-finally +``` + + +## Usage + +```js +const pFinally = require('p-finally'); + +const dir = createTempDir(); + +pFinally(write(dir), () => cleanup(dir)); +``` + + +## API + +### pFinally(promise, [onFinally]) + +Returns a `Promise`. + +#### onFinally + +Type: `Function` + +Note: Throwing or returning a rejected promise will reject `promise` with the rejection reason. + + +## Related + +- [p-try](https://github.com/sindresorhus/p-try) - `Promise#try()` ponyfill - Starts a promise chain +- [More…](https://github.com/sindresorhus/promise-fun) + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com)  | 
