Last active
October 14, 2020 16:16
-
-
Save princefishthrower/380ac13357dbabd2d65031b15bc94a02 to your computer and use it in GitHub Desktop.
partial.js - partially evaluate a function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// partial.js - partially evaluate a function | |
// taken from https://egghead.io/lessons/react-pass-data-to-event-handlers-with-partial-function-application | |
// usage: | |
// const addTwo(a, b) => a + b; | |
// const partialAddTwo = partial(addTwo, 10); | |
// const sum = partialAddTwo(5); | |
// console.log(sum); | |
// 15 | |
export const partial(fn, ...args) => fn.bind(null, ...args); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment