Created
January 25, 2012 15:10
-
-
Save mooz/1676706 to your computer and use it in GitHub Desktop.
Gecko Console Logger
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
// "Foo".red.log(); | |
Object.defineProperty(String.prototype, "log", { | |
value: function () { | |
dump(this + "\n"); | |
} | |
}); | |
let (colerCodePairs = { | |
black : 30, | |
red : 31, | |
green : 32, | |
yellow : 33, | |
blue : 34, | |
magenta : 35, | |
cyan : 36, | |
white : 37, | |
on_black : 40, | |
on_red : 41, | |
on_green : 42, | |
on_yellow : 43, | |
on_blue : 44, | |
on_magenta : 45, | |
on_cyan : 46, | |
on_white : 47 | |
}) { | |
for (let [color, code] in Iterator(colerCodePairs)) { | |
let codeBound = code; | |
Object.defineProperty(String.prototype, color, { | |
get: function () { | |
return "\033[1;" + codeBound + "m" + this + "\033[0m"; | |
} | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment