This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/browser-stdout/index.js
2020-11-01 22:46:04 +00:00

26 lines
649 B
JavaScript

var WritableStream = require('stream').Writable
var inherits = require('util').inherits
module.exports = BrowserStdout
inherits(BrowserStdout, WritableStream)
function BrowserStdout(opts) {
if (!(this instanceof BrowserStdout)) return new BrowserStdout(opts)
opts = opts || {}
WritableStream.call(this, opts)
this.label = (opts.label !== undefined) ? opts.label : 'stdout'
}
BrowserStdout.prototype._write = function(chunks, encoding, cb) {
var output = chunks.toString ? chunks.toString() : chunks
if (this.label === false) {
console.log(output)
} else {
console.log(this.label+':', output)
}
process.nextTick(cb)
}