So, while there are bind methods out there that conform to the ECMA standard, they are far too slow for Sphere. I tested them and this is a 5x faster method.
// check against existing bind, since TS and SSFML have this for you.
if (!Function.prototype.bind) {
Function.prototype.bind = function(owner, arg1, arg2) {
var m = this;
return function(a1, a2) {
m.call(owner, a1 || arg1, a2 || arg2);
};
}
}
Thoughts, comments? I think for simple bound methods this is good. Yes it doesn't do exactly what bind does, but this is Sphere here, not the internet. So, I'm sure most games will play just fine with this.
It's faster for the two reasons:
1. No pesky Array.prototype.splice.call()'s
2. No "arguments" lookup. It's actually faster to hand-write the args right in. (If you need more than 2 args, just add more).