0.0.8 • Published 6 years ago
@devmastery/pipe v0.0.8
@devmastery/pipe
An implementation of a pipe
function that works with a mix of promises and non-promises.
pipe
is a function that receives a list of functions and returns a new function that executes the given list from left to right passing the result from each previous function to the next.
For example:
const promiseToAddOne = async x => x + 1
const double = x => x * 2
const promiseToDouble = async x => x * 2
const addOneThenDoubleTwice = pipe(
promiseToAddOne,
double,
promiseToDouble
)
addOneThenDoubleTwice(1).then(console.log) // logs 8