Skip to content

Commit

Permalink
refactor(defaults): simplify defaults() using ...spread
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Jul 5, 2018
1 parent ad58a1f commit 69a4465
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ export const deregAll = (functions: Function[]) =>
* Earlier objects in the defaultsList take precedence when applying defaults.
*/
export function defaults(opts, ...defaultsList: Obj[]) {
const _defaultsList = defaultsList.concat({}).reverse();
const defaultVals = extend.apply(null, _defaultsList);
return extend({}, defaultVals, pick(opts || {}, Object.keys(defaultVals)));
const defaultVals = extend({}, ...defaultsList.reverse());
return extend(defaultVals, pick(opts || {}, Object.keys(defaultVals)));
}

/** Reduce function that merges each element of the list into a single object, using extend */
Expand Down

0 comments on commit 69a4465

Please sign in to comment.