Issues (2242)

node_modules/browser-stdout/index.js (3 issues)

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)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11
12
  opts = opts || {}
13
  WritableStream.call(this, opts)
14
  this.label = (opts.label !== undefined) ? opts.label : 'stdout'
15
}
0 ignored issues
show
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
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)
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
21
  } else {
22
    console.log(this.label+':', output)
23
  }
24
  process.nextTick(cb)
25
}
26