aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/utils')
-rw-r--r--src/js/utils/animation.js2
-rw-r--r--src/js/utils/elements.js4
-rw-r--r--src/js/utils/events.js6
-rw-r--r--src/js/utils/is.js38
-rw-r--r--src/js/utils/load-sprite.js2
-rw-r--r--src/js/utils/objects.js2
-rw-r--r--src/js/utils/strings.js2
-rw-r--r--src/js/utils/style.js2
-rw-r--r--src/js/utils/time.js8
9 files changed, 33 insertions, 33 deletions
diff --git a/src/js/utils/animation.js b/src/js/utils/animation.js
index d9e7615e..b4ccf268 100644
--- a/src/js/utils/animation.js
+++ b/src/js/utils/animation.js
@@ -14,7 +14,7 @@ export const transitionEndEvent = (() => {
transition: 'transitionend',
};
- const type = Object.keys(events).find(event => element.style[event] !== undefined);
+ const type = Object.keys(events).find((event) => element.style[event] !== undefined);
return is.string(type) ? events[type] : false;
})();
diff --git a/src/js/utils/elements.js b/src/js/utils/elements.js
index 1d13b701..e8d2e595 100644
--- a/src/js/utils/elements.js
+++ b/src/js/utils/elements.js
@@ -138,7 +138,7 @@ export function getAttributesFromSelector(sel, existingAttributes) {
const attributes = {};
const existing = extend({}, existingAttributes);
- sel.split(',').forEach(s => {
+ sel.split(',').forEach((s) => {
// Remove whitespace
const selector = s.trim();
const className = selector.replace('.', '');
@@ -198,7 +198,7 @@ export function toggleHidden(element, hidden) {
// Mirror Element.classList.toggle, with IE compatibility for "force" argument
export function toggleClass(element, className, force) {
if (is.nodeList(element)) {
- return Array.from(element).map(e => toggleClass(e, className, force));
+ return Array.from(element).map((e) => toggleClass(e, className, force));
}
if (is.element(element)) {
diff --git a/src/js/utils/events.js b/src/js/utils/events.js
index 235eb629..287129f1 100644
--- a/src/js/utils/events.js
+++ b/src/js/utils/events.js
@@ -50,7 +50,7 @@ export function toggleListener(element, event, callback, toggle = false, passive
}
// If a single node is passed, bind the event listener
- events.forEach(type => {
+ events.forEach((type) => {
if (this && this.eventListeners && toggle) {
// Cache event listener
this.eventListeners.push({ element, type, callback, options });
@@ -100,7 +100,7 @@ export function triggerEvent(element, type = '', bubbles = false, detail = {}) {
// Unbind all cached event listeners
export function unbindListeners() {
if (this && this.eventListeners) {
- this.eventListeners.forEach(item => {
+ this.eventListeners.forEach((item) => {
const { element, type, callback, options } = item;
element.removeEventListener(type, callback, options);
});
@@ -111,7 +111,7 @@ export function unbindListeners() {
// Run method when / if player is ready
export function ready() {
- return new Promise(resolve =>
+ return new Promise((resolve) =>
this.ready ? setTimeout(resolve, 0) : on.call(this, this.elements.container, 'ready', resolve),
).then(() => {});
}
diff --git a/src/js/utils/is.js b/src/js/utils/is.js
index 1cc33848..3bb50a00 100644
--- a/src/js/utils/is.js
+++ b/src/js/utils/is.js
@@ -2,31 +2,31 @@
// Type checking utils
// ==========================================================================
-const getConstructor = input => (input !== null && typeof input !== 'undefined' ? input.constructor : null);
+const getConstructor = (input) => (input !== null && typeof input !== 'undefined' ? input.constructor : null);
const instanceOf = (input, constructor) => Boolean(input && constructor && input instanceof constructor);
-const isNullOrUndefined = input => input === null || typeof input === 'undefined';
-const isObject = input => getConstructor(input) === Object;
-const isNumber = input => getConstructor(input) === Number && !Number.isNaN(input);
-const isString = input => getConstructor(input) === String;
-const isBoolean = input => getConstructor(input) === Boolean;
-const isFunction = input => getConstructor(input) === Function;
-const isArray = input => Array.isArray(input);
-const isWeakMap = input => instanceOf(input, WeakMap);
-const isNodeList = input => instanceOf(input, NodeList);
-const isElement = input => instanceOf(input, Element);
-const isTextNode = input => getConstructor(input) === Text;
-const isEvent = input => instanceOf(input, Event);
-const isKeyboardEvent = input => instanceOf(input, KeyboardEvent);
-const isCue = input => instanceOf(input, window.TextTrackCue) || instanceOf(input, window.VTTCue);
-const isTrack = input => instanceOf(input, TextTrack) || (!isNullOrUndefined(input) && isString(input.kind));
-const isPromise = input => instanceOf(input, Promise) && isFunction(input.then);
+const isNullOrUndefined = (input) => input === null || typeof input === 'undefined';
+const isObject = (input) => getConstructor(input) === Object;
+const isNumber = (input) => getConstructor(input) === Number && !Number.isNaN(input);
+const isString = (input) => getConstructor(input) === String;
+const isBoolean = (input) => getConstructor(input) === Boolean;
+const isFunction = (input) => getConstructor(input) === Function;
+const isArray = (input) => Array.isArray(input);
+const isWeakMap = (input) => instanceOf(input, WeakMap);
+const isNodeList = (input) => instanceOf(input, NodeList);
+const isElement = (input) => instanceOf(input, Element);
+const isTextNode = (input) => getConstructor(input) === Text;
+const isEvent = (input) => instanceOf(input, Event);
+const isKeyboardEvent = (input) => instanceOf(input, KeyboardEvent);
+const isCue = (input) => instanceOf(input, window.TextTrackCue) || instanceOf(input, window.VTTCue);
+const isTrack = (input) => instanceOf(input, TextTrack) || (!isNullOrUndefined(input) && isString(input.kind));
+const isPromise = (input) => instanceOf(input, Promise) && isFunction(input.then);
-const isEmpty = input =>
+const isEmpty = (input) =>
isNullOrUndefined(input) ||
((isString(input) || isArray(input) || isNodeList(input)) && !input.length) ||
(isObject(input) && !Object.keys(input).length);
-const isUrl = input => {
+const isUrl = (input) => {
// Accept a URL object
if (instanceOf(input, window.URL)) {
return true;
diff --git a/src/js/utils/load-sprite.js b/src/js/utils/load-sprite.js
index 0a4eff99..293163e5 100644
--- a/src/js/utils/load-sprite.js
+++ b/src/js/utils/load-sprite.js
@@ -54,7 +54,7 @@ export default function loadSprite(url, id) {
// Get the sprite
fetch(url)
- .then(result => {
+ .then((result) => {
if (is.empty(result)) {
return;
}
diff --git a/src/js/utils/objects.js b/src/js/utils/objects.js
index a327e488..d64002ae 100644
--- a/src/js/utils/objects.js
+++ b/src/js/utils/objects.js
@@ -26,7 +26,7 @@ export function extend(target = {}, ...sources) {
return target;
}
- Object.keys(source).forEach(key => {
+ Object.keys(source).forEach((key) => {
if (is.object(source[key])) {
if (!Object.keys(target).includes(key)) {
Object.assign(target, { [key]: {} });
diff --git a/src/js/utils/strings.js b/src/js/utils/strings.js
index b7de04c1..d4cc1efa 100644
--- a/src/js/utils/strings.js
+++ b/src/js/utils/strings.js
@@ -33,7 +33,7 @@ export const replaceAll = (input = '', find = '', replace = '') =>
// Convert to title case
export const toTitleCase = (input = '') =>
- input.toString().replace(/\w\S*/g, text => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase());
+ input.toString().replace(/\w\S*/g, (text) => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase());
// Convert string to pascalCase
export function toPascalCase(input = '') {
diff --git a/src/js/utils/style.js b/src/js/utils/style.js
index c2004fcb..fcb089b4 100644
--- a/src/js/utils/style.js
+++ b/src/js/utils/style.js
@@ -27,7 +27,7 @@ export function reduceAspectRatio(ratio) {
}
export function getAspectRatio(input) {
- const parse = ratio => (validateRatio(ratio) ? ratio.split(':').map(Number) : null);
+ const parse = (ratio) => (validateRatio(ratio) ? ratio.split(':').map(Number) : null);
// Try provided ratio
let ratio = parse(input);
diff --git a/src/js/utils/time.js b/src/js/utils/time.js
index 31660c4a..36e0d59b 100644
--- a/src/js/utils/time.js
+++ b/src/js/utils/time.js
@@ -5,9 +5,9 @@
import is from './is';
// Time helpers
-export const getHours = value => Math.trunc((value / 60 / 60) % 60, 10);
-export const getMinutes = value => Math.trunc((value / 60) % 60, 10);
-export const getSeconds = value => Math.trunc(value % 60, 10);
+export const getHours = (value) => Math.trunc((value / 60 / 60) % 60, 10);
+export const getMinutes = (value) => Math.trunc((value / 60) % 60, 10);
+export const getSeconds = (value) => Math.trunc(value % 60, 10);
// Format time to UI friendly string
export function formatTime(time = 0, displayHours = false, inverted = false) {
@@ -17,7 +17,7 @@ export function formatTime(time = 0, displayHours = false, inverted = false) {
}
// Format time component to add leading zero
- const format = value => `0${value}`.slice(-2);
+ const format = (value) => `0${value}`.slice(-2);
// Breakdown to hours, mins, secs
let hours = getHours(time);
const mins = getMinutes(time);