Skip to content

Commit

Permalink
[Refactor] avoid reassigning arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 24, 2021
1 parent da0cdf1 commit 5c4052f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions index.js
Expand Up @@ -23,13 +23,13 @@ module.exports = (function () {
};

lazyLoad.createStream = function (opts) {
if (!opts) opts = {};
var options = opts || {};
if (!harness) {
var output = through();
getHarness({ stream: output, objectMode: opts.objectMode });
getHarness({ stream: output, objectMode: options.objectMode });
return output;
}
return harness.createStream(opts);
return harness.createStream(options);
};

lazyLoad.onFinish = function () {
Expand All @@ -53,9 +53,9 @@ module.exports = (function () {
})();

function createExitHarness(conf) {
if (!conf) conf = {};
var config = conf || {};
var harness = createHarness({
autoclose: defined(conf.autoclose, false)
autoclose: defined(config.autoclose, false)
});

var stream = harness.createStream({ objectMode: conf.objectMode });
Expand All @@ -67,7 +67,7 @@ function createExitHarness(conf) {
var ended = false;
stream.on('end', function () { ended = true; });

if (conf.exit === false) return harness;
if (config.exit === false) return harness;
if (!canEmitExit || !canExit) return harness;

process.on('exit', function (code) {
Expand Down Expand Up @@ -97,9 +97,8 @@ module.exports.test = module.exports; // tap compat
module.exports.test.skip = Test.skip;

function createHarness(conf_) {
if (!conf_) conf_ = {};
var results = createResult();
if (conf_.autoclose !== false) {
if (!conf_ || conf_.autoclose !== false) {
results.once('done', function () { results.close(); });
}

Expand Down

0 comments on commit 5c4052f

Please sign in to comment.