Skip to content

Instantly share code, notes, and snippets.

View JamesJansson's full-sized avatar

James Jansson JamesJansson

View GitHub Profile
@JamesJansson
JamesJansson / pipe.js
Created January 20, 2023 13:06
The pipe functions you want in JS right now
// There's a proposal for a new 'pipe' operation |> https://github.com/tc39/proposal-pipeline-operator
// Below are two methods (`pipe` and `pwhyp`) you could use right now to achieve the same result.
// `pipe` easy version. Use `.next(someFunction)` to apply a new function
function pipe(value) {
return {
next: (f) => pipe(f(value)),
end: () => value,