Skip to content

Instantly share code, notes, and snippets.

@sgimeno
Forked from amatiasq/funct.js
Last active August 29, 2015 14:13
Show Gist options
  • Save sgimeno/4b09a1ad7c993351e9a6 to your computer and use it in GitHub Desktop.
Save sgimeno/4b09a1ad7c993351e9a6 to your computer and use it in GitHub Desktop.
_.merge = wrapFunct(_.merge);
_.union = wrapFunct(_.union);
_.merge(AJAX.get('foo'), [ 'en' ], AJAX.get('bar'));
// $q comes from angular
function wrapFunct(fn) {
return function() {
var context = this;
var args = [].slice.call(arguments);
var resolved = $q.all(args.map($q.when));
return resolved.then(function(values) {
return fn.apply(context, values);
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment