Skip to content

Instantly share code, notes, and snippets.

@JoeStanton
Last active January 28, 2016 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoeStanton/9bae712a7c40eb0c5270 to your computer and use it in GitHub Desktop.
Save JoeStanton/9bae712a7c40eb0c5270 to your computer and use it in GitHub Desktop.
Piping - In the absence of the `|>` operator, a Clojure-like threading function
import {map, unique} from "prelude-ls";
function pipe(input, ...funcs) {
return funcs.reduce((step, f) => f(step), input);
}
function curry(fn, ...args) {
if (args.length >= fn.length) {
return fn(...args);
}
return curry.bind(this, fn, ...args);
}
const arr = ["hello", "is", "it", "me", "you're", "looking", "for", "for"];
console.log(
pipe(arr,
map(a => a.toUpperCase())
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment