Friday, October 29, 2021

Pipe Function in JavaScript (functional programming, like F#)


pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x);


pipe( getName, uppercase, get6Characters, reverse )(
  { name: 'Buckethead' }); // 'TEKCUB'


has same same effect as nested function calls, with many brackets

reverse(get6Characters(uppercase(getName({ 
    name: 'Buckethead' })))); // 'TEKCUB'


Array.prototype.reduce() - JavaScript | MDN


How JavaScript rest parameters actually work | by Yazeed Bzadough | We’ve moved to freeCodeCamp.org/news | Medium


 Pipe Function in JavaScript. Hello, in this blog post I am going to… | by Neerthigan S | Medium

Unix: "A pipe is a form of redirection that is used to send the output of one program to another program for further processing."


(F#) Pipe Operator (|>) for JavaScript








No comments: