Dev HelpersOpen library
← Back

Pipe transformations

Pipe transformations. A self-contained example using the JavaScript runtime.

Open this example in the interactive library

Source code

const pipe =
  (...fns) =>
  (value) =>
    fns.reduce((v, f) => f(v), value);
console.log(
  pipe(
    (x) => x.trim(),
    (x) => x.toUpperCase(),
  )("  hello  "),
);

Sample output

HELLO