Last active
August 29, 2015 14:25
-
-
Save johannish/52c6d111201358b7ceac to your computer and use it in GitHub Desktop.
Node.js console.log synchronous
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
console.log('stdout._type:', process.stdout._type); | |
process.nextTick(function() { | |
process.exit(123); | |
}); | |
process.on('exit', function(code) { | |
process.nextTick(function() { | |
console.log('This does not run, as the docs say.'); | |
}); | |
console.log('This should not run if proces.stdout._type is pipe.'); | |
}); |
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
console.log("isTTY: ", process.stdout.isTTY); | |
// per https://nodejs.org/api/console.html, I expect this time to be before both x and y if terminal, and after if piped. | |
// invalid: parameter to console.log gets evaluated instantly, regardless of whether the log() function blocks or not. | |
console.log("Logged at: " + process.hrtime()); | |
x = process.hrtime(); | |
y = (function() {return process.hrtime()})(); | |
console.log("x: " + x); | |
console.log("y: " + y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment