Guest User

Untitled

a guest
Apr 25th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. const where = (...funcs) => {
  2. const bindings = funcs.reduce((vars, f) => ({
  3. ...vars, ...f(vars)
  4. }), {})
  5.  
  6. return ({
  7. in: f => f(bindings)
  8. })
  9. }
  10.  
  11. where(
  12. () => ({ x: 3 }),
  13. ({ x }) => ({ y: x * x })
  14. ).in(({ x, y }) => console.log('X', x, 'Y', y)) // prints `X 3 Y 9`
Add Comment
Please, Sign In to add comment