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
#names of functions to create KV versions of and arg lists (in order) | |
to_kv = throttle: ['func', 'wait'], delay: ['func', 'wait'], defer: ['func'], bind: ['func', 'context'] | |
mixin = {} | |
for name, arglist of to_kv | |
do (name, arglist) -> | |
mixin["#{name}KV"] = (kvargs) -> | |
args = (kvargs[arg] for arg in arglist when kvargs[arg]?) | |
if arglist.length isnt args.length then throw new Error "missing args" | |
_[name](args...) |