💄 Cache last argument in parseArgs

This is to eliminate the need to access the array twice.
This commit is contained in:
Steve Kinney 2016-05-07 08:52:52 -06:00
parent f58b3f853e
commit 6708e2a302

View file

@ -35,8 +35,9 @@ var parseArgs = function (window, options, callback, ...args) {
}
// Fallback to using very last argument as the callback function
if ((callback == null) && typeof args[args.length - 1] === 'function') {
callback = args[args.length - 1]
var lastArgument = args[args.length - 1]
if ((callback == null) && typeof lastArgument === 'function') {
callback = lastArgument
}
return [window, options, callback]