This file contains hidden or 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
// Add a handy super call for all objects | |
MyBaseClass.prototype.super = function () { | |
var parent = this.__proto__.__proto__; | |
var caller = arguments.callee.caller; | |
var fn; | |
if (caller.prototype === this.__proto__) { | |
return parent.constructor.apply(this, arguments); | |
} else { | |
// This is probably quite slow, but it doesn't seem to affect | |
// performance too much in real tests. |
This file contains hidden or 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
Number.implement({ | |
parsePermissions : function(){ | |
var types = {r : 4, w : 2, x : 1 }, levels = {u : 1, g : 8, o : 64 }, perms = {}; | |
for(l in levels){ | |
for(t in types) perms[l+t] = !!(this & (levels[l] * types[t])); | |
} | |
return perms; | |
} | |
}); |