Skip to content

pipe 함수

OD edited this page Feb 15, 2023 · 2 revisions
function pipe(arg, ...fns) {
  return fns.reduce((v, fn) => fn(v), arg);
}
const result = pipe(
  numbers,
  filter((v) => v % 2 == 0),
  map((v) => v + 1),
  slice(0, 3),
  Array.from
);

Clone this wiki locally