Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A node polyfill for process.stderr in a browser
var WritableStream = require('stream');
var inherits = require('util').inherits;
module.exports = BrowserStderr;
inherits(BrowserStderr, WritableStream);
function BrowserStderr(opts) {
if (!(this instanceof BrowserStderr)) return new BrowserStderr(opts);
opts = opts || {};, opts);
this.label = (opts.label !== undefined) ? opts.label : 'stderr';
BrowserStderr.prototype.write = function(chunks, encoding, cb) {
var output = chunks.toString ? chunks.toString() : chunks;
if (this.label === false) {
} else {
console.log(this.label+':', output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.