This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+17
View File
@@ -0,0 +1,17 @@
'use strict';
// TODO: Use rest/spread when targeting Node.js 6
module.exports = function (input) {
const args = Array.isArray(input) ? input : [].slice.apply(arguments);
if (args.length === 0) {
return Promise.reject(new Error('Expected at least one argument'));
}
return args.slice(1).reduce((a, b) => {
return function () {
return Promise.resolve(a.apply(null, arguments)).then(b);
};
}, args[0]);
};
+21
View File
@@ -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.
+112
View File
@@ -0,0 +1,112 @@
{
"_args": [
[
{
"raw": "p-pipe@^1.1.0",
"scope": null,
"escapedName": "p-pipe",
"name": "p-pipe",
"rawSpec": "^1.1.0",
"spec": ">=1.1.0 <2.0.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\imagemin"
]
],
"_from": "p-pipe@>=1.1.0 <2.0.0",
"_id": "p-pipe@1.1.0",
"_inCache": true,
"_location": "/p-pipe",
"_nodeVersion": "4.8.3",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/p-pipe-1.1.0.tgz_1494610971464_0.26622557477094233"
},
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"_npmVersion": "2.15.11",
"_phantomChildren": {},
"_requested": {
"raw": "p-pipe@^1.1.0",
"scope": null,
"escapedName": "p-pipe",
"name": "p-pipe",
"rawSpec": "^1.1.0",
"spec": ">=1.1.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/imagemin"
],
"_resolved": "https://registry.npmjs.org/p-pipe/-/p-pipe-1.1.0.tgz",
"_shasum": "2e9dc7cc57ce67d2ce2db348ca03f28731854075",
"_shrinkwrap": null,
"_spec": "p-pipe@^1.1.0",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\imagemin",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/p-pipe/issues"
},
"dependencies": {},
"description": "Compose promise-returning & async functions into a reusable pipeline",
"devDependencies": {
"ava": "*",
"xo": "*"
},
"directories": {},
"dist": {
"shasum": "2e9dc7cc57ce67d2ce2db348ca03f28731854075",
"tarball": "https://registry.npmjs.org/p-pipe/-/p-pipe-1.1.0.tgz"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"gitHead": "25b546b502b1281f2a4e404c0122bb437728db7f",
"homepage": "https://github.com/sindresorhus/p-pipe#readme",
"keywords": [
"promise",
"pipe",
"pipeline",
"compose",
"composition",
"combine",
"flow",
"serial",
"functions",
"reusable",
"async",
"await",
"promises",
"bluebird"
],
"license": "MIT",
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"name": "p-pipe",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/p-pipe.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "1.1.0",
"xo": {
"esnext": true
}
}
+53
View File
@@ -0,0 +1,53 @@
# p-pipe [![Build Status](https://travis-ci.org/sindresorhus/p-pipe.svg?branch=master)](https://travis-ci.org/sindresorhus/p-pipe)
> Compose promise-returning & async functions into a reusable pipeline
## Install
```
$ npm install --save p-pipe
```
## Usage
```js
const pPipe = require('p-pipe');
const addUnicorn = str => Promise.resolve(`${str} Unicorn`);
const addRainbow = str => Promise.resolve(`${str} Rainbow`);
const pipeline = pPipe(addUnicorn, addRainbow);
pipeline('❤️').then(console.log);
//=> '❤️ Unicorn Rainbow'
```
## API
### pPipe(input, …)
The `input` functions are applied from left to right.
You can also specify an array as the first argument instead of multiple function arguments. Mostly only useful if you have to support Node.js 4. With Node.js 6 and above you can just use spread syntax.
#### input
Type: `Function`
Expected to return a `Promise` or any value.
## Related
- [p-each-series](https://github.com/sindresorhus/p-each-series) - Iterate over promises serially
- [p-series](https://github.com/sindresorhus/p-series) - Run promise-returning & async functions in series
- [p-waterfall](https://github.com/sindresorhus/p-waterfall) - Run promise-returning & async functions in series, each passing its result to the next
- [More…](https://github.com/sindresorhus/promise-fun)
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)