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

Use ES6 and allow V8 to optimize mergeOptions #3743

Merged
merged 1 commit into from
Nov 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/js/utils/merge-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,17 @@ function customizer(destination, source) {
* provided objects
* @function mergeOptions
*/
export default function mergeOptions() {
// contruct the call dynamically to handle the variable number of
// objects to merge
const args = Array.prototype.slice.call(arguments);
export default function mergeOptions(...objects) {

// unshift an empty object into the front of the call as the target
// of the merge
args.unshift({});
objects.unshift({});

// customize conflict resolution to match our historical merge behavior
args.push(customizer);
objects.push(customizer);

merge.apply(null, args);
merge.apply(null, objects);

// return the mutated result object
return args[0];
return objects[0];
}