Last active
August 29, 2015 14:07
-
-
Save acatl/bdb6e4e867f08bd18bd8 to your computer and use it in GitHub Desktop.
callback slice args
This file contains hidden or 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
function callbackSliceArgs(callback, howMany) { | |
return function() { | |
var args = _.toArray(arguments); | |
args.splice(howMany, args.length); | |
return callback.apply(null, args); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use it when you only need to get passed the first X arguments to the callback, useful when using array/collection transformation methods
will print out: