Compose promise-returning & async functions into a reusable pipeline
$ npm install p-pipe
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'
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.
Type: Function
Expected to return a Promise
or any value.
MIT © Sindre Sorhus
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.