Skip to content

Commit

Permalink
Inline & simplify the node 8 extend workaround in evaluateSnippets.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjeffburke committed Jan 2, 2020
1 parent 425dc4d commit 1a22395
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions lib/evaluateSnippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ try {
};
}

function extend(target) {
for (var i = 1; i < arguments.length; i += 1) {
var source = arguments[i];
for (const key of Object.keys(source)) {
target[key] = source[key];
}
}
return target;
}

function isPromise(value) {
return (
value &&
Expand Down Expand Up @@ -65,7 +55,7 @@ function getErrorMessage(expect, format, error) {
}

module.exports = async function(snippets, options) {
var oldGlobal = extend({}, global);
var oldGlobal = Object.assign({}, global);
var expect = createExpect(options);
global.expect = expect.clone();
global.require = require;
Expand Down Expand Up @@ -149,6 +139,8 @@ module.exports = async function(snippets, options) {
}
}

// local function used for compatibility with node 8
extend(global, oldGlobal);
// inline function used for compatibility with node 8
for (const key of Object.keys(oldGlobal)) {
global[key] = oldGlobal[key];
}
};

0 comments on commit 1a22395

Please sign in to comment.