Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit f255555

Browse files
committed
avoid Object.assign
1 parent 68f1a0d commit f255555

File tree

7 files changed

+26
-19
lines changed

7 files changed

+26
-19
lines changed

package-lock.json

Lines changed: 10 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ window.chartColors = {
8787
},
8888

8989
randomBoxPlot: function(config) {
90-
const base = this.numbers(Object.assign({}, config, {count: 10}));
90+
const base = this.numbers({...config, count: 10});
9191
base.sort(function(a,b) { return a - b; });
9292
const shift = 3;
9393
return {
@@ -113,7 +113,7 @@ window.chartColors = {
113113
const count = (config || {}).count || 8;
114114
const data = [];
115115
for(let i = 0; i < count; ++i) {
116-
data.push(this.numbers(Object.assign(config, {count: 50})));
116+
data.push(this.numbers({...config, count: 50}));
117117
}
118118
return data;
119119
},

src/controllers/boxplot.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const defaults = {
2424
Chart.defaults.boxplot = Chart.helpers.merge({}, [Chart.defaults.bar, verticalDefaults, defaults]);
2525
Chart.defaults.horizontalBoxplot = Chart.helpers.merge({}, [Chart.defaults.horizontalBar, horizontalDefaults, defaults]);
2626

27-
const boxplot = Object.assign({}, base, {
28-
27+
const boxplot = {
28+
...base,
2929
dataElementType: Chart.elements.BoxAndWhiskers,
3030

3131
_elementOptions() {
@@ -60,7 +60,7 @@ const boxplot = Object.assign({}, base, {
6060
this._calculateCommonModel(r, data, v, scale);
6161
return r;
6262
}
63-
});
63+
};
6464
/**
6565
* This class is based off controller.bar.js from the upstream Chart.js library
6666
*/

src/controllers/violin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const defaults = {};
99
Chart.defaults.violin = Chart.helpers.merge({}, [Chart.defaults.bar, verticalDefaults, defaults]);
1010
Chart.defaults.horizontalViolin = Chart.helpers.merge({}, [Chart.defaults.horizontalBar, horizontalDefaults, defaults]);
1111

12-
const controller = Object.assign({}, base, {
13-
12+
const controller = {
13+
...base,
1414
dataElementType: Chart.elements.Violin,
1515

1616
_elementOptions() {
@@ -55,7 +55,7 @@ const controller = Object.assign({}, base, {
5555
this._calculateCommonModel(r, data, violin, scale);
5656
return r;
5757
}
58-
});
58+
};
5959
/**
6060
* This class is based off controller.bar.js from the upstream Chart.js library
6161
*/

src/elements/base.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import * as Chart from 'chart.js';
44
import {rnd} from '../data';
55

6-
export const defaults = Object.assign({}, Chart.defaults.global.elements.rectangle, {
6+
export const defaults = {
7+
...Chart.defaults.global.elements.rectangle,
78
borderWidth: 1,
89
outlierRadius: 2,
910
outlierColor: Chart.defaults.global.elements.rectangle.backgroundColor,
@@ -12,7 +13,7 @@ export const defaults = Object.assign({}, Chart.defaults.global.elements.rectang
1213
itemBackgroundColor: Chart.defaults.global.elements.rectangle.backgroundColor,
1314
itemBorderColor: Chart.defaults.global.elements.rectangle.borderColor,
1415
hitPadding: 2
15-
});
16+
};
1617

1718
const ArrayElementBase = Chart.Element.extend({
1819
isVertical() {

src/elements/boxandwhiskers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as Chart from 'chart.js';
44
import ArrayElementBase, {defaults} from './base';
55

66

7-
Chart.defaults.global.elements.boxandwhiskers = Object.assign({}, defaults);
7+
Chart.defaults.global.elements.boxandwhiskers = {...defaults};
88

99
function transitionBoxPlot(start, view, model, ease) {
1010
const keys = Object.keys(model);

src/elements/violin.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import * as Chart from 'chart.js';
44
import ArrayElementBase, {defaults} from './base';
55

66

7-
Chart.defaults.global.elements.violin = Object.assign({
8-
points: 100
9-
}, defaults);
7+
Chart.defaults.global.elements.violin = {
8+
points: 100,
9+
...defaults
10+
};
1011

1112
function transitionViolin(start, view, model, ease) {
1213
const keys = Object.keys(model);

0 commit comments

Comments
 (0)