maacl/js-tree-cursor — comment on commit 76f39c0d5973ccdb6f3649c69af44c31c5f6879a
File:  line 0
By dyoo:

Not sure I like this yet. The dynamic lookup of attributes should be outside the inner loop.

The iteration with chain() is an idea, but the attribute lookup can be eliminated. e.g.

TreeCursor.prototype.nUp = function(i) {
return this.chain(this.up, i);
};

TreeCursor.prototype.chain = function(f, i) {
var n = this;
while(i--) { n = f.call(n); }
return n;
};

// ...

Similar idea for the canChain work. Rather than use the name of the function as an argument, use the function itself. The up-side is that this approach should be able to avoid all the string slicing.

Do you want to try your hand at it first?