DEV Community

loading...

Discussion on: A simple explanation of functional pipe in JavaScript

Collapse
leunardo profile image
Leonardo Alves • Edited

We can create another function to let pipe even more readable than pipeWith with the following function:

function pipeValue(args) {
    return {
        to: (...fns) => pipe(...fns)(args)
    }
}

const array = [1,2,3,4];
pipeValue(array).to(
    odds,
    double,
    log
);
Collapse
dmitriz profile image
Dmitri Zaitsev

Or use the curried pipeline where you can pass your arguments directly.

Collapse
jesse profile image
Jesse Barkdoll • Edited

This API really resonates with me. Thanks for sharing.

Collapse
josgraha profile image
Joe Graham

Not a fan, this breaks functional composition