Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const where = (...funcs) => {
- const bindings = funcs.reduce((vars, f) => ({
- ...vars, ...f(vars)
- }), {})
- return ({
- in: f => f(bindings)
- })
- }
- where(
- () => ({ x: 3 }),
- ({ x }) => ({ y: x * x })
- ).in(({ x, y }) => console.log('X', x, 'Y', y)) // prints `X 3 Y 9`
Add Comment
Please, Sign In to add comment