Guest User

Untitled

a guest
Oct 11th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. Object.defineProperty Object.prototype, '_bind',
  2. enumerable: false
  3. get: ->
  4. new Proxy this,
  5. get: (thing, prop) =>
  6. thing[prop].bind(thing)
  7.  
  8.  
  9. # Usage
  10. foo.on 'thing', console._bind.log
  11.  
  12.  
  13. Function::curry = (params...) ->
  14. (rest...) => this(params..., rest...)
  15.  
  16.  
  17. # Usage
  18. foo.on 'thing', log.curry('A thing:')
  19.  
  20.  
  21. _ = _it = new Proxy {},
  22. get: (_, prop) ->
  23. retrieve = (props...) ->
  24. fn = (obj) ->
  25. props.reduce (obj, prop) ->
  26. obj[prop]
  27. , obj
  28.  
  29. new Proxy fn,
  30. get: (_, prop) ->
  31. retrieve(props..., prop)
  32.  
  33. retrieve(prop)
  34.  
  35. # Usage
  36. foo.map _.some.field
Add Comment
Please, Sign In to add comment