Skip to content

Commit 4aed9c7

Browse files
authored
Merge pull request #2742 from SylvainCorlay/drop-underscore
Drop underscore usage
2 parents 3bba52b + 7d30030 commit 4aed9c7

22 files changed

+164
-152
lines changed

packages/controls/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
"@lumino/widgets": "^1.3.0",
4343
"d3-format": "^1.3.0",
4444
"jquery": "^3.1.1",
45-
"jquery-ui": "^1.12.1",
46-
"underscore": "^1.8.3"
45+
"jquery-ui": "^1.12.1"
4746
},
4847
"devDependencies": {
4948
"@jupyterlab/services": "^5.0.0-beta.2",

packages/controls/src/widget_audio.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@ import { DOMWidgetView } from '@jupyter-widgets/base';
55

66
import { CoreDOMWidgetModel } from './widget_core';
77

8-
import * as _ from 'underscore';
9-
108
export class AudioModel extends CoreDOMWidgetModel {
119
defaults(): Backbone.ObjectHash {
12-
return _.extend(super.defaults(), {
10+
return {
11+
...super.defaults(),
1312
_model_name: 'AudioModel',
1413
_view_name: 'AudioView',
1514
format: 'mp3',
1615
autoplay: true,
1716
loop: true,
1817
controls: true,
1918
value: new DataView(new ArrayBuffer(0))
20-
});
19+
};
2120
}
2221

2322
static serializers = {

packages/controls/src/widget_bool.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ import { DescriptionView } from './widget_description';
77

88
import { DOMWidgetView } from '@jupyter-widgets/base';
99

10-
import * as _ from 'underscore';
11-
1210
export class BoolModel extends CoreDescriptionModel {
1311
defaults(): Backbone.ObjectHash {
14-
return _.extend(super.defaults(), {
12+
return {
13+
...super.defaults(),
1514
value: false,
1615
disabled: false,
1716
_model_name: 'BoolModel'
18-
});
17+
};
1918
}
2019
}
2120

2221
export class CheckboxModel extends CoreDescriptionModel {
2322
defaults(): Backbone.ObjectHash {
24-
return _.extend(super.defaults(), {
23+
return {
24+
...super.defaults(),
2525
indent: true,
2626
_view_name: 'CheckboxView',
2727
_model_name: 'CheckboxModel'
28-
});
28+
};
2929
}
3030
}
3131

@@ -171,13 +171,14 @@ export class CheckboxView extends DescriptionView {
171171

172172
export class ToggleButtonModel extends BoolModel {
173173
defaults(): Backbone.ObjectHash {
174-
return _.extend(super.defaults(), {
174+
return {
175+
...super.defaults(),
175176
_view_name: 'ToggleButtonView',
176177
_model_name: 'ToggleButtonModel',
177178
tooltip: '',
178179
icon: '',
179180
button_style: ''
180-
});
181+
};
181182
}
182183
}
183184

@@ -287,11 +288,12 @@ export class ToggleButtonView extends DOMWidgetView {
287288

288289
export class ValidModel extends BoolModel {
289290
defaults(): Backbone.ObjectHash {
290-
return _.extend(super.defaults(), {
291+
return {
292+
...super.defaults(),
291293
readout: 'Invalid',
292294
_view_name: 'ValidView',
293295
_model_name: 'ValidModel'
294-
});
296+
};
295297
}
296298
}
297299

packages/controls/src/widget_box.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ import { MessageLoop } from '@lumino/messaging';
1919

2020
import { Widget } from '@lumino/widgets';
2121

22-
import * as _ from 'underscore';
2322
import $ from 'jquery';
2423

2524
export class BoxModel extends CoreDOMWidgetModel {
2625
defaults(): Backbone.ObjectHash {
27-
return _.extend(super.defaults(), {
26+
return {
27+
...super.defaults(),
2828
_view_name: 'BoxView',
2929
_model_name: 'BoxModel',
3030
children: [],
3131
box_style: ''
32-
});
32+
};
3333
}
3434

3535
static serializers = {
@@ -40,19 +40,21 @@ export class BoxModel extends CoreDOMWidgetModel {
4040

4141
export class HBoxModel extends BoxModel {
4242
defaults(): Backbone.ObjectHash {
43-
return _.extend(super.defaults(), {
43+
return {
44+
...super.defaults(),
4445
_view_name: 'HBoxView',
4546
_model_name: 'HBoxModel'
46-
});
47+
};
4748
}
4849
}
4950

5051
export class VBoxModel extends BoxModel {
5152
defaults(): Backbone.ObjectHash {
52-
return _.extend(super.defaults(), {
53+
return {
54+
...super.defaults(),
5355
_view_name: 'VBoxView',
5456
_model_name: 'VBoxModel'
55-
});
57+
};
5658
}
5759
}
5860

@@ -178,9 +180,10 @@ export class GridBoxView extends BoxView {
178180

179181
export class GridBoxModel extends BoxModel {
180182
defaults(): Backbone.ObjectHash {
181-
return _.extend(super.defaults(), {
183+
return {
184+
...super.defaults(),
182185
_view_name: 'GridBoxView',
183186
_model_name: 'GridBoxModel'
184-
});
187+
};
185188
}
186189
}

packages/controls/src/widget_button.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ import { CoreDOMWidgetModel } from './widget_core';
77

88
import { JUPYTER_CONTROLS_VERSION } from './version';
99

10-
import * as _ from 'underscore';
11-
1210
export class ButtonStyleModel extends StyleModel {
1311
defaults(): Backbone.ObjectHash {
14-
return _.extend(super.defaults(), {
12+
return {
13+
...super.defaults(),
1514
_model_name: 'ButtonStyleModel',
1615
_model_module: '@jupyter-widgets/controls',
1716
_model_module_version: JUPYTER_CONTROLS_VERSION
18-
});
17+
};
1918
}
2019

2120
public static styleProperties = {
@@ -34,7 +33,8 @@ export class ButtonStyleModel extends StyleModel {
3433

3534
export class ButtonModel extends CoreDOMWidgetModel {
3635
defaults(): Backbone.ObjectHash {
37-
return _.extend(super.defaults(), {
36+
return {
37+
...super.defaults(),
3838
description: '',
3939
tooltip: '',
4040
disabled: false,
@@ -43,7 +43,7 @@ export class ButtonModel extends CoreDOMWidgetModel {
4343
_view_name: 'ButtonView',
4444
_model_name: 'ButtonModel',
4545
style: null
46-
});
46+
};
4747
}
4848
}
4949

packages/controls/src/widget_color.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { DescriptionView } from './widget_description';
77

88
import { uuid } from './utils';
99

10-
import * as _ from 'underscore';
11-
1210
const named_colors: { [key: string]: string } = {
1311
aliceblue: '#f0f8ff',
1412
antiquewhite: '#faebd7',
@@ -161,12 +159,13 @@ const named_colors: { [key: string]: string } = {
161159

162160
export class ColorPickerModel extends CoreDescriptionModel {
163161
defaults(): Backbone.ObjectHash {
164-
return _.extend(super.defaults(), {
162+
return {
163+
...super.defaults(),
165164
value: 'black',
166165
concise: false,
167166
_model_name: 'ColorPickerModel',
168167
_view_name: 'ColorPickerView'
169-
});
168+
};
170169
}
171170
}
172171

packages/controls/src/widget_controller.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@ import { Widget, Panel } from '@lumino/widgets';
1717

1818
import { ArrayExt } from '@lumino/algorithm';
1919

20-
import * as _ from 'underscore';
21-
2220
import * as utils from './utils';
2321
import $ from 'jquery';
2422

2523
export class ControllerButtonModel extends CoreDOMWidgetModel {
2624
defaults(): Backbone.ObjectHash {
27-
return _.extend(super.defaults(), {
25+
return {
26+
...super.defaults(),
2827
_model_name: 'ControllerButtonModel',
2928
_view_name: 'ControllerButtonView',
3029
value: 0.0,
3130
pressed: false
32-
});
31+
};
3332
}
3433
}
3534

@@ -76,11 +75,12 @@ export class ControllerButtonView extends DOMWidgetView {
7675

7776
export class ControllerAxisModel extends CoreDOMWidgetModel {
7877
defaults(): Backbone.ObjectHash {
79-
return _.extend(super.defaults(), {
78+
return {
79+
...super.defaults(),
8080
_model_name: 'ControllerAxisModel',
8181
_view_name: 'ControllerAxisView',
8282
value: 0.0
83-
});
83+
};
8484
}
8585
}
8686

@@ -138,7 +138,8 @@ export class ControllerModel extends CoreDOMWidgetModel {
138138
};
139139

140140
defaults(): Backbone.ObjectHash {
141-
return _.extend(super.defaults(), {
141+
return {
142+
...super.defaults(),
142143
_model_name: 'ControllerModel',
143144
_view_name: 'ControllerView',
144145
index: 0,
@@ -148,7 +149,7 @@ export class ControllerModel extends CoreDOMWidgetModel {
148149
timestamp: 0,
149150
buttons: [],
150151
axes: []
151-
});
152+
};
152153
}
153154

154155
initialize(attributes: Backbone.ObjectHash, options: any): void {

packages/controls/src/widget_core.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,41 @@ import { DescriptionModel } from './widget_description';
1010

1111
import { JUPYTER_CONTROLS_VERSION } from './version';
1212

13-
import * as _ from 'underscore';
14-
1513
export class CoreWidgetModel extends WidgetModel {
1614
defaults(): Backbone.ObjectHash {
17-
return _.extend(super.defaults(), {
15+
return {
16+
...super.defaults(),
1817
_model_name: 'CoreWidgetModel',
1918
_view_module: '@jupyter-widgets/controls',
2019
_model_module: '@jupyter-widgets/controls',
2120
_view_module_version: JUPYTER_CONTROLS_VERSION,
2221
_model_module_version: JUPYTER_CONTROLS_VERSION
23-
});
22+
};
2423
}
2524
}
2625

2726
export class CoreDOMWidgetModel extends DOMWidgetModel {
2827
defaults(): Backbone.ObjectHash {
29-
return _.extend(super.defaults(), {
28+
return {
29+
...super.defaults(),
3030
_model_name: 'CoreDOMWidgetModel',
3131
_view_module: '@jupyter-widgets/controls',
3232
_model_module: '@jupyter-widgets/controls',
3333
_view_module_version: JUPYTER_CONTROLS_VERSION,
3434
_model_module_version: JUPYTER_CONTROLS_VERSION
35-
});
35+
};
3636
}
3737
}
3838

3939
export class CoreDescriptionModel extends DescriptionModel {
4040
defaults(): Backbone.ObjectHash {
41-
return _.extend(super.defaults(), {
41+
return {
42+
...super.defaults(),
4243
_model_name: 'CoreDescriptionModel',
4344
_view_module: '@jupyter-widgets/controls',
4445
_model_module: '@jupyter-widgets/controls',
4546
_view_module_version: JUPYTER_CONTROLS_VERSION,
4647
_model_module_version: JUPYTER_CONTROLS_VERSION
47-
});
48+
};
4849
}
4950
}

packages/controls/src/widget_date.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { CoreDescriptionModel } from './widget_core';
77

88
import { uuid } from './utils';
99

10-
import * as _ from 'underscore';
11-
1210
export interface ISerializedDate {
1311
/**
1412
* Full year
@@ -59,11 +57,12 @@ export class DatePickerModel extends CoreDescriptionModel {
5957
};
6058

6159
defaults(): Backbone.ObjectHash {
62-
return _.extend(super.defaults(), {
60+
return {
61+
...super.defaults(),
6362
value: null,
6463
_model_name: 'DatePickerModel',
6564
_view_name: 'DatePickerView'
66-
});
65+
};
6766
}
6867
}
6968

0 commit comments

Comments
 (0)