Skip to main content

bud.pipe

Pipe a value through an array of functions.

Unlike bud.sequence the output of each function is used as input for the next.

Usage

Pass an array of functions to be executed in sequence. Execution order is guaranteed even if the functions are async.

The output of each function will be used as input for the next arrayed function. The intial function will receive the bud.js instance as input.

await bud.pipe([
async bud => bud.minimize(),
async bud => await bud.fs.read(`./src/index.js`),
])

You can pass a second parameter to be used as an initial value.

await bud.pipe(
[
async v => `${v}!`, // `this in the initial value!`
async v => `${v}!`, // `this is the initial value!!`
async v => `${v}!`, // `this is the initial value!!!`
],
`this is the initial value`,
)