Skip to content

Instantly share code, notes, and snippets.

@mattn
Created July 4, 2012 00:18
Show Gist options
  • Save mattn/3044319 to your computer and use it in GitHub Desktop.
Save mattn/3044319 to your computer and use it in GitHub Desktop.
#!node
function safe_quit(code) {
if (!process.stdout.write(""))
process.stdout.on('drain', function() {
process.exit(code);
})
else
process.exit(code);
}
var outputLength = 1000;
var output = '';
for (var i = 0; i < outputLength; i++) {
output += i + ': ' + Math.random() + "\n";
}
console.log(output);
safe_quit(3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment