Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50655 views
1
var WritableStream = require('stream').Writable
2
var inherits = require('util').inherits
3
4
module.exports = BrowserStdout
5
6
7
inherits(BrowserStdout, WritableStream)
8
9
function BrowserStdout(opts) {
10
if (!(this instanceof BrowserStdout)) return new BrowserStdout(opts)
11
12
opts = opts || {}
13
WritableStream.call(this, opts)
14
this.label = (opts.label !== undefined) ? opts.label : 'stdout'
15
}
16
17
BrowserStdout.prototype._write = function(chunks, encoding, cb) {
18
var output = chunks.toString ? chunks.toString() : chunks
19
if (this.label === false) {
20
console.log(output)
21
} else {
22
console.log(this.label+':', output)
23
}
24
process.nextTick(cb)
25
}
26
27