Socket
Socket
Sign inDemoInstall

p-pipe

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-pipe - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

index.d.ts

27

index.js
'use strict';
// TODO: Use rest/spread when targeting Node.js 6
module.exports = (...input) => {
if (input.length === 0) {
throw new Error('Expected at least one argument');
}
module.exports = function (input) {
const args = Array.isArray(input) ? input : arguments;
const iterator = input[Symbol.iterator]();
if (args.length === 0) {
return Promise.reject(new Error('Expected at least one argument'));
}
const loop = async current => {
const {done, value} = iterator.next();
return [].slice.call(args, 1).reduce((a, b) => {
return function () {
return Promise.resolve(a.apply(null, arguments)).then(b);
};
}, args[0]);
if (done) {
return current;
}
const next = await value(current);
return loop(next);
};
return loop;
};
{
"name": "p-pipe",
"version": "1.2.0",
"description": "Compose promise-returning & async functions into a reusable pipeline",
"license": "MIT",
"repository": "sindresorhus/p-pipe",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"promise",
"pipe",
"pipeline",
"compose",
"composition",
"combine",
"flow",
"serial",
"functions",
"reusable",
"async",
"await",
"promises",
"bluebird"
],
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "p-pipe",
"version": "2.0.0",
"description": "Compose promise-returning & async functions into a reusable pipeline",
"license": "MIT",
"repository": "sindresorhus/p-pipe",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd-check"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"promise",
"pipe",
"pipeline",
"compose",
"composition",
"combine",
"flow",
"serial",
"functions",
"reusable",
"async",
"await",
"promises",
"bluebird"
],
"devDependencies": {
"ava": "^1.2.0",
"sinon": "^7.2.3",
"tsd-check": "^0.3.0",
"xo": "^0.24.0"
}
}

@@ -18,9 +18,11 @@ # p-pipe [![Build Status](https://travis-ci.org/sindresorhus/p-pipe.svg?branch=master)](https://travis-ci.org/sindresorhus/p-pipe)

const addUnicorn = str => Promise.resolve(`${str} Unicorn`);
const addRainbow = str => Promise.resolve(`${str} Rainbow`);
const addUnicorn = async string => `${string} Unicorn`;
const addRainbow = async string => `${string} Rainbow`;
const pipeline = pPipe(addUnicorn, addRainbow);
pipeline('❤️').then(console.log);
//=> '❤️ Unicorn Rainbow'
(async () => {
console.log(await pipeline('❤️'));
//=> '❤️ Unicorn Rainbow'
})();
```

@@ -31,8 +33,6 @@

### pPipe(input, …)
### 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

@@ -39,0 +39,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc