-
-
Save kurtextrem/363398ba68c25d65252f to your computer and use it in GitHub Desktop.
Function.prototype.bind is slow in JS, so we fix it plus we have great compatibility (at least for 90% of common cases without partial args)
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
+function(proto, Object) { | |
'use strict' | |
var originalBind = proto.bind | |
Object.defineProperty(proto, 'bind', { | |
value: function bind(context) { | |
var callback = this | |
return arguments.length === 1 ? function () { return callback.apply(context, arguments) } : originalBind.apply(callback, arguments) | |
} | |
}) | |
}(Function.prototype, Object) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment