Skip to content

Instantly share code, notes, and snippets.

shaunxcode /
Created May 7, 2012 — forked from jimtla/
Add CoffeeScript friendly kv args to Underscore.js
#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"