Skip to content

Commit d2300bc

Browse files
committed
more moving of utils
1 parent f641c0f commit d2300bc

32 files changed

+240
-412
lines changed

src/js/button.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import ClickableComponent from './clickable-component.js';
55
import Component from './component';
66
import log from './utils/log.js';
7-
import {assign} from './utils/obj';
87
import keycode from 'keycode';
98
import {createEl} from './utils/dom.js';
109

@@ -34,12 +33,12 @@ class Button extends ClickableComponent {
3433
createEl(tag, props = {}, attributes = {}) {
3534
tag = 'button';
3635

37-
props = assign({
36+
props = Object.assign({
3837
className: this.buildCSSClass()
3938
}, props);
4039

4140
// Add attributes for button element
42-
attributes = assign({
41+
attributes = Object.assign({
4342

4443
// Necessary since the default button type is "submit"
4544
type: 'button'

src/js/clickable-component.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import Component from './component';
55
import * as Dom from './utils/dom.js';
66
import log from './utils/log.js';
7-
import {assign} from './utils/obj';
87
import keycode from 'keycode';
98

109
/**
@@ -68,7 +67,7 @@ class ClickableComponent extends Component {
6867
* The element that gets created.
6968
*/
7069
createEl(tag = 'div', props = {}, attributes = {}) {
71-
props = assign({
70+
props = Object.assign({
7271
className: this.buildCSSClass(),
7372
tabIndex: 0
7473
}, props);
@@ -78,7 +77,7 @@ class ClickableComponent extends Component {
7877
}
7978

8079
// Add ARIA attributes for clickable element which is not a native HTML button
81-
attributes = assign({
80+
attributes = Object.assign({
8281
role: 'button'
8382
}, attributes);
8483

src/js/control-bar/progress-control/load-progress-bar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import Component from '../../component.js';
55
import * as Dom from '../../utils/dom.js';
6-
import clamp from '../../utils/clamp';
6+
import {clamp} from '../../utils/num';
77
import document from 'global/document';
88

99
// get the percent width of a time compared to the total end

src/js/control-bar/progress-control/progress-control.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import Component from '../../component.js';
55
import * as Dom from '../../utils/dom.js';
6-
import clamp from '../../utils/clamp.js';
6+
import {clamp} from '../../utils/num';
77
import {bind, throttle, UPDATE_REFRESH_INTERVAL} from '../../utils/fn.js';
88
import {silencePromise} from '../../utils/promise';
99

src/js/control-bar/progress-control/seek-bar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Component from '../../component.js';
66
import {IS_IOS, IS_ANDROID} from '../../utils/browser.js';
77
import * as Dom from '../../utils/dom.js';
88
import * as Fn from '../../utils/fn.js';
9-
import formatTime from '../../utils/format-time.js';
9+
import {formatTime} from '../../utils/time';
1010
import {silencePromise} from '../../utils/promise';
1111
import keycode from 'keycode';
1212
import document from 'global/document';

src/js/control-bar/progress-control/time-tooltip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import Component from '../../component';
55
import * as Dom from '../../utils/dom.js';
6-
import formatTime from '../../utils/format-time.js';
6+
import { formatTime } from '../../utils/time';
77
import * as Fn from '../../utils/fn.js';
88

99
/**

src/js/control-bar/time-controls/time-display.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import document from 'global/document';
55
import Component from '../../component.js';
66
import * as Dom from '../../utils/dom.js';
7-
import formatTime from '../../utils/format-time.js';
7+
import { formatTime } from '../../utils/time';
88
import log from '../../utils/log.js';
99

1010
/**

src/js/control-bar/volume-control/volume-bar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import Slider from '../../slider/slider.js';
55
import Component from '../../component.js';
66
import * as Dom from '../../utils/dom.js';
7-
import clamp from '../../utils/clamp.js';
7+
import {clamp} from '../../utils/num';
88
import {IS_IOS, IS_ANDROID} from '../../utils/browser.js';
99

1010
// Required children

src/js/media-error.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file media-error.js
33
*/
4-
import {assign, isObject} from './utils/obj';
4+
import {isObject} from './utils/obj';
55

66
/**
77
* A Custom `MediaError` class which mimics the standard HTML5 `MediaError` class.
@@ -41,7 +41,7 @@ function MediaError(value) {
4141
this.code = value.code;
4242
}
4343

44-
assign(this, value);
44+
Object.assign(this, value);
4545
}
4646

4747
if (!this.message) {

src/js/menu/menu-item.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44
import ClickableComponent from '../clickable-component.js';
55
import Component from '../component.js';
6-
import {assign} from '../utils/obj';
76
import {MenuKeys} from './menu-keys.js';
87
import keycode from 'keycode';
98
import {createEl} from '../utils/dom.js';
@@ -64,7 +63,7 @@ class MenuItem extends ClickableComponent {
6463
// The control is textual, not just an icon
6564
this.nonIconControl = true;
6665

67-
const el = super.createEl('li', assign({
66+
const el = super.createEl('li', Object.assign({
6867
className: 'vjs-menu-item',
6968
tabIndex: -1
7069
}, props), attrs);

src/js/mixins/evented.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import window from 'global/window';
66
import * as Dom from '../utils/dom';
77
import * as Events from '../utils/events';
88
import * as Fn from '../utils/fn';
9-
import * as Obj from '../utils/obj';
109
import EventTarget from '../event-target';
1110
import DomData from '../utils/dom-data';
1211
import log from '../utils/log';
@@ -489,7 +488,7 @@ function evented(target, options = {}) {
489488
target.eventBusEl_ = Dom.createEl('span', {className: 'vjs-event-bus'});
490489
}
491490

492-
Obj.assign(target, EventedMixin);
491+
Object.assign(target, EventedMixin);
493492

494493
if (target.eventedCallbacks) {
495494
target.eventedCallbacks.forEach((callback) => {

src/js/mixins/stateful.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ const StatefulMixin = {
103103
* Returns the `target`.
104104
*/
105105
function stateful(target, defaultState) {
106-
Obj.assign(target, StatefulMixin);
106+
Object.assign(target, StatefulMixin);
107107

108108
// This happens after the mixing-in because we need to replace the `state`
109109
// added in that step.
110-
target.state = Obj.assign({}, target.state, defaultState);
110+
target.state = Object.assign({}, target.state, defaultState);
111111

112112
// Auto-bind the `handleStateChanged` method of the target object if it exists.
113113
if (typeof target.handleStateChanged === 'function' && isEvented(target)) {

src/js/player.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import * as browser from './utils/browser.js';
1717
import {IE_VERSION, IS_CHROME, IS_WINDOWS} from './utils/browser.js';
1818
import log, { createLogger } from './utils/log.js';
1919
import {toTitleCase, titleCaseEquals} from './utils/str.js';
20-
import { createTimeRange } from './utils/time-ranges.js';
20+
import { createTimeRanges } from './utils/time';
2121
import { bufferedPercent } from './utils/buffer.js';
2222
import * as stylesheet from './utils/stylesheet.js';
2323
import FullscreenApi from './fullscreen-api.js';
@@ -32,7 +32,7 @@ import {ALL as TRACK_TYPES} from './tracks/track-types';
3232
import filterSource from './utils/filter-source';
3333
import {getMimetype, findMimetype} from './utils/mimetypes';
3434
import {hooks} from './utils/hooks';
35-
import {assign, merge, isObject} from './utils/obj';
35+
import {merge, isObject} from './utils/obj';
3636
import keycode from 'keycode';
3737

3838
// The following imports are used only to ensure that the corresponding modules
@@ -310,7 +310,7 @@ class Player extends Component {
310310
// which overrides globally set options.
311311
// This latter part coincides with the load order
312312
// (tag must exist before Player)
313-
options = assign(Player.getTagSettings(tag), options);
313+
options = Object.assign(Player.getTagSettings(tag), options);
314314

315315
// Delay the initialization of children because we need to set up
316316
// player properties first, and can't use `this` before `super()`
@@ -1185,9 +1185,9 @@ class Player extends Component {
11851185
techOptions[props.getterName] = this[props.privateName];
11861186
});
11871187

1188-
assign(techOptions, this.options_[titleTechName]);
1189-
assign(techOptions, this.options_[camelTechName]);
1190-
assign(techOptions, this.options_[techName.toLowerCase()]);
1188+
Object.assign(techOptions, this.options_[titleTechName]);
1189+
Object.assign(techOptions, this.options_[camelTechName]);
1190+
Object.assign(techOptions, this.options_[techName.toLowerCase()]);
11911191

11921192
if (this.tag) {
11931193
techOptions.tag = this.tag;
@@ -2487,7 +2487,7 @@ class Player extends Component {
24872487
* been played.
24882488
*/
24892489
played() {
2490-
return this.techGet_('played') || createTimeRange(0, 0);
2490+
return this.techGet_('played') || createTimeRanges(0, 0);
24912491
}
24922492

24932493
/**
@@ -2650,7 +2650,7 @@ class Player extends Component {
26502650
let buffered = this.techGet_('buffered');
26512651

26522652
if (!buffered || !buffered.length) {
2653-
buffered = createTimeRange(0, 0);
2653+
buffered = createTimeRanges(0, 0);
26542654
}
26552655

26562656
return buffered;
@@ -4796,18 +4796,18 @@ class Player extends Component {
47964796

47974797
// Used as a getter.
47984798
if (breakpoints === undefined) {
4799-
return assign(this.breakpoints_);
4799+
return Object.assign(this.breakpoints_);
48004800
}
48014801

48024802
this.breakpoint_ = '';
4803-
this.breakpoints_ = assign({}, DEFAULT_BREAKPOINTS, breakpoints);
4803+
this.breakpoints_ = Object.assign({}, DEFAULT_BREAKPOINTS, breakpoints);
48044804

48054805
// When breakpoint definitions change, we need to update the currently
48064806
// selected breakpoint.
48074807
this.updateCurrentBreakpoint_();
48084808

48094809
// Clone the breakpoints before returning.
4810-
return assign(this.breakpoints_);
4810+
return Object.assign(this.breakpoints_);
48114811
}
48124812

48134813
/**
@@ -5037,10 +5037,10 @@ class Player extends Component {
50375037
if (err) {
50385038
log.error(err);
50395039
}
5040-
assign(tagOptions, data);
5040+
Object.assign(tagOptions, data);
50415041
}
50425042

5043-
assign(baseOptions, tagOptions);
5043+
Object.assign(baseOptions, tagOptions);
50445044

50455045
// Get tag children settings
50465046
if (tag.hasChildNodes()) {

src/js/slider/slider.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
*/
44
import Component from '../component.js';
55
import * as Dom from '../utils/dom.js';
6-
import {assign} from '../utils/obj';
76
import {IS_CHROME} from '../utils/browser.js';
8-
import clamp from '../utils/clamp.js';
7+
import {clamp} from '../utils/num';
98
import keycode from 'keycode';
109

1110
/**
@@ -126,11 +125,11 @@ class Slider extends Component {
126125
createEl(type, props = {}, attributes = {}) {
127126
// Add the slider element class to all sub classes
128127
props.className = props.className + ' vjs-slider';
129-
props = assign({
128+
props = Object.assign({
130129
tabIndex: 0
131130
}, props);
132131

133-
attributes = assign({
132+
attributes = Object.assign({
134133
'role': 'slider',
135134
'aria-valuenow': 0,
136135
'aria-valuemin': 0,

src/js/tech/html5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import log from '../utils/log.js';
88
import * as browser from '../utils/browser.js';
99
import document from 'global/document';
1010
import window from 'global/window';
11-
import {assign, merge} from '../utils/obj';
11+
import {merge} from '../utils/obj';
1212
import {toTitleCase} from '../utils/str.js';
1313
import {NORMAL as TRACK_TYPES, REMOTE} from '../tracks/track-types';
1414
import setupSourceset from './setup-sourceset';
@@ -392,7 +392,7 @@ class Html5 extends Tech {
392392

393393
Dom.setAttributes(
394394
el,
395-
assign(attributes, {
395+
Object.assign(attributes, {
396396
id: this.options_.techId,
397397
class: 'vjs-tech'
398398
})

src/js/tech/middleware.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* @file middleware.js
33
* @module middleware
44
*/
5-
import { assign } from '../utils/obj.js';
65
import {toTitleCase} from '../utils/str.js';
76

87
const middlewares = {};
@@ -301,7 +300,7 @@ function setSourceHelper(src = {}, middleware = [], next, player, acc = [], last
301300
return setSourceHelper(src, mwrest, next, player, acc, lastRun);
302301
}
303302

304-
mw.setSource(assign({}, src), function(err, _src) {
303+
mw.setSource(Object.assign({}, src), function(err, _src) {
305304

306305
// something happened, try the next middleware on the current level
307306
// make sure to use the old src

src/js/tech/tech.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Component from '../component';
66
import * as Fn from '../utils/fn.js';
77
import log from '../utils/log.js';
8-
import { createTimeRange } from '../utils/time-ranges.js';
8+
import { createTimeRanges } from '../utils/time';
99
import { bufferedPercent } from '../utils/buffer.js';
1010
import MediaError from '../media-error.js';
1111
import window from 'global/window';
@@ -279,7 +279,7 @@ class Tech extends Component {
279279
* The time range object that was created.
280280
*/
281281
buffered() {
282-
return createTimeRange(0, 0);
282+
return createTimeRanges(0, 0);
283283
}
284284

285285
/**
@@ -486,9 +486,9 @@ class Tech extends Component {
486486
*/
487487
played() {
488488
if (this.hasStarted_) {
489-
return createTimeRange(0, 0);
489+
return createTimeRanges(0, 0);
490490
}
491-
return createTimeRange();
491+
return createTimeRanges();
492492
}
493493

494494
/**

src/js/utils/buffer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file buffer.js
33
* @module buffer
44
*/
5-
import { createTimeRange } from './time-ranges.js';
5+
import { createTimeRanges } from './time';
66

77
/**
88
* Compute the percentage of the media that has been buffered.
@@ -26,7 +26,7 @@ export function bufferedPercent(buffered, duration) {
2626
}
2727

2828
if (!buffered || !buffered.length) {
29-
buffered = createTimeRange(0, 0);
29+
buffered = createTimeRanges(0, 0);
3030
}
3131

3232
for (let i = 0; i < buffered.length; i++) {

0 commit comments

Comments
 (0)