// Nothing here -- never executed. => Why a function then? Is it ever used even as a constructor? If not, a singleton might be what you need.
isPrototypeOf => Why not instanceof?
"Could as well be defined as an interface" => There is this TypeScript thing. You should check it out ;-)
Math methods => Maybe the deferencing takes time and you should put them on top. Not sure.
typeof is a bitch
=> You can replace that test with: Object(x) === x
risk of infinite loop => I imagine you don't use it this way, but the traverse function can do an infinite loop if you have circular references. Also, you may want to protect the .call with a try/catch block so that one error thrown doesn't stop the traversing. But try/cacth hurts perf I heard, so I'll let you judge whether it's appropriate.
Une fonction de trop
=> return window.performance.now.bind(performance)
rAF polyfill
=> Interesting. I think the value passed to the callback is buggy. You may want to call getTimestamp inside the setTimeout callback so you can pass a value as accurate as possible given on when the function is actually called (instead of scheduled to be called)
You may also want to update lastTime
inside the setTimeout callback.
Let's put some code on what I would expect:
var lastTime = 0;
this.requestAnimationFrame = function(callback) {
var currTime = JSSMS.Utils.getTimestamp();
var timeToCall = Math.max(0, 1000/60 - (currTime - lastTime));
window.setTimeout(function() {
lastTime = JSSMS.Utils.getTimestamp();
callback(lastTime);
}, timeToCall);
};
Maybe rAF should be part of Utils? (hiding prefix and polyfill bullshit in there)
jQuery => Given you're certainly targeting only modern browsers, you may not really need it ;-)
Love the AST-based JS generation code.
Actually recently I've learned the
~~
trick to floor numbers faster. It can be a good way to improve the performace without degrading much the readability.