Skip to content

Instantly share code, notes, and snippets.

@gordonbrander

gordonbrander/rest.js

Last active Sep 14, 2018
Embed
What would you like to do?
rest - decorate functions so you can bind "rest" arguments with f.rest().
// Decorate a function with a method that allows you to bind "rest" args
// (everything except the first argument).
// Usage:
//
// const f = rest((a, b, c) => a + b + c)
// const fbc = f.rest("b", "c")
// fbc("a")
// // "abc"
const rest = f => {
f.rest = (...rest) => v => f(v, ...rest)
return f
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.