This file contains 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
// run here (use the data-uri below as an address): | |
// data:text/html;ascii,<script src="https://gist.github.com/raw/4427971/cef83fed8b6de8bfbb9fa3ae461b724fff87c057/gistfile1.js" type="text/javascript"></script> | |
// The technique used here is based on an article by Ashley Gullen: http://netm.ag/SWI0E5 | |
// Array#slice returns an array with the seleted range of items. | |
// Because a new array is created every time you use this method, however, | |
// all these arrays are in memory, which means the JavaScript GC (Garbage Collection) | |
// has to collect up all of these unused arrays and throw them away. | |
// In performance-critical situations, such as in a game-loop that needs to run within |
This file contains 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
var util = require('util') | |
function hook_stdout(callback) { | |
var old_write = process.stdout.write | |
process.stdout.write = (function(write) { | |
return function(string, encoding, fd) { | |
write.apply(process.stdout, arguments) | |
callback(string, encoding, fd) | |
} |