Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: remove Object.assign polyfill #382

Merged
merged 2 commits into from
Jun 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 3 additions & 23 deletions espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,6 @@ var lookahead,
extra,
lastToken;

/**
* Object.assign polyfill for Node < 4
* @param {Object} target The target object
* @param {...Object} sources Sources for the object
* @returns {Object} `target` after being mutated
*/
var assign = Object.assign || function assign(target) {
for (var argIndex = 1; argIndex < arguments.length; argIndex++) {
if (arguments[argIndex] !== null && typeof arguments[argIndex] === "object") {
var keys = Object.keys(arguments[argIndex]);

for (var keyIndex = 0; keyIndex < keys.length; keyIndex++) {
target[keys[keyIndex]] = arguments[argIndex][keys[keyIndex]];
}
}
}

return target;
};

/**
* Resets the extra object to its default.
* @returns {void}
Expand Down Expand Up @@ -370,7 +350,7 @@ function tokenize(code, options) {
lookahead = null;

// Options matching.
options = assign({}, options);
options = Object.assign({}, options);

var acornOptions = {
ecmaVersion: DEFAULT_ECMA_VERSION,
Expand Down Expand Up @@ -406,7 +386,7 @@ function tokenize(code, options) {

// apply parsing flags
if (options.ecmaFeatures && typeof options.ecmaFeatures === "object") {
extra.ecmaFeatures = assign({}, options.ecmaFeatures);
extra.ecmaFeatures = Object.assign({}, options.ecmaFeatures);
impliedStrict = extra.ecmaFeatures.impliedStrict;
extra.ecmaFeatures.impliedStrict = typeof impliedStrict === "boolean" && impliedStrict;
}
Expand Down Expand Up @@ -542,7 +522,7 @@ function parse(code, options) {

// apply parsing flags after sourceType to allow overriding
if (options.ecmaFeatures && typeof options.ecmaFeatures === "object") {
extra.ecmaFeatures = assign({}, options.ecmaFeatures);
extra.ecmaFeatures = Object.assign({}, options.ecmaFeatures);
impliedStrict = extra.ecmaFeatures.impliedStrict;
extra.ecmaFeatures.impliedStrict = typeof impliedStrict === "boolean" && impliedStrict;
if (options.ecmaFeatures.globalReturn) {
Expand Down