Sunday, 9 April 2017

Implementing stdout.write / stderr.write in browser

I have some Node.js code, and would like to get it running the browser. In many places in my Node.js code, I have made calls to process.stdout.write and process.stderr.write.

In the browser, we have console.log / console.error

I do not need high-performance here. If I implement these methods in the browser like so:

process.stdout.write = function(v){
   console.log(v);
};

process.stdout.error = function(v){
   console.error(v);
};

that's obviously not going to really get us what we want. Is there a way to hook into console.log / console.error in the browser to print to stdout/stderr without printing a newline char?



via Alexander Mills

No comments:

Post a Comment