1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
3 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
4 | (factory((global._30s = {})));
|
5 | }(this, (function (exports) { 'use strict';
|
6 |
|
7 | const fs = typeof require !== "undefined" && require('fs');
|
8 | const crypto = typeof require !== "undefined" && require('crypto');
|
9 |
|
10 | const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>
|
11 | data
|
12 | .slice(omitFirstRow ? data.indexOf('\n') + 1 : 0)
|
13 | .split('\n')
|
14 | .map(v => v.split(delimiter));
|
15 | const CSVToJSON = (data, delimiter = ',') => {
|
16 | const titles = data.slice(0, data.indexOf('\n')).split(delimiter);
|
17 | return data
|
18 | .slice(data.indexOf('\n') + 1)
|
19 | .split('\n')
|
20 | .map(v => {
|
21 | const values = v.split(delimiter);
|
22 | return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});
|
23 | });
|
24 | };
|
25 | const JSONToFile = (obj, filename) =>
|
26 | fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
27 | const JSONtoCSV = (arr, columns, delimiter = ',') =>
|
28 | [
|
29 | columns.join(delimiter),
|
30 | ...arr.map(obj =>
|
31 | columns.reduce(
|
32 | (acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`,
|
33 | ''
|
34 | )
|
35 | )
|
36 | ].join('\n');
|
37 | const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
38 | const URLJoin = (...args) =>
|
39 | args
|
40 | .join('/')
|
41 | .replace(/[\/]+/g, '/')
|
42 | .replace(/^(.+):\//, '$1://')
|
43 | .replace(/^file:/, 'file:/')
|
44 | .replace(/\/(\?|&|#[^!])/g, '$1')
|
45 | .replace(/\?/g, '&')
|
46 | .replace('&', '?');
|
47 | const UUIDGeneratorBrowser = () =>
|
48 | ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
49 | (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
50 | );
|
51 | const UUIDGeneratorNode = () =>
|
52 | ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
53 | (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
54 | );
|
55 | const all = (arr, fn = Boolean) => arr.every(fn);
|
56 | const allEqual = arr => arr.every(val => val === arr[0]);
|
57 | const any = (arr, fn = Boolean) => arr.some(fn);
|
58 | const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon;
|
59 | const arrayToCSV = (arr, delimiter = ',') =>
|
60 | arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n');
|
61 | const arrayToHtmlList = (arr, listID) =>
|
62 | (el => (
|
63 | (el = document.querySelector('#' + listID)),
|
64 | (el.innerHTML += arr.map(item => `<li>${item}</li>`).join(''))
|
65 | ))();
|
66 | const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
|
67 | const atob = str => Buffer.from(str, 'base64').toString('binary');
|
68 | const attempt = (fn, ...args) => {
|
69 | try {
|
70 | return fn(...args);
|
71 | } catch (e) {
|
72 | return e instanceof Error ? e : new Error(e);
|
73 | }
|
74 | };
|
75 | const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length;
|
76 | const averageBy = (arr, fn) =>
|
77 | arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) /
|
78 | arr.length;
|
79 | const bifurcate = (arr, filter) =>
|
80 | arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]);
|
81 | const bifurcateBy = (arr, fn) =>
|
82 | arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]);
|
83 | const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]);
|
84 | const bindAll = (obj, ...fns) =>
|
85 | fns.forEach(
|
86 | fn => (
|
87 | (f = obj[fn]),
|
88 | (obj[fn] = function() {
|
89 | return f.apply(obj);
|
90 | })
|
91 | )
|
92 | );
|
93 | const bindKey = (context, fn, ...boundArgs) => (...args) =>
|
94 | context[fn].apply(context, [...boundArgs, ...args]);
|
95 | const binomialCoefficient = (n, k) => {
|
96 | if (Number.isNaN(n) || Number.isNaN(k)) return NaN;
|
97 | if (k < 0 || k > n) return 0;
|
98 | if (k === 0 || k === n) return 1;
|
99 | if (k === 1 || k === n - 1) return n;
|
100 | if (n - k < k) k = n - k;
|
101 | let res = n;
|
102 | for (let j = 2; j <= k; j++) res *= (n - j + 1) / j;
|
103 | return Math.round(res);
|
104 | };
|
105 | const bottomVisible = () =>
|
106 | document.documentElement.clientHeight + window.scrollY >=
|
107 | (document.documentElement.scrollHeight || document.documentElement.clientHeight);
|
108 | const btoa = str => Buffer.from(str, 'binary').toString('base64');
|
109 | const byteSize = str => new Blob([str]).size;
|
110 | const call = (key, ...args) => context => context[key](...args);
|
111 | const capitalize = ([first, ...rest], lowerRest = false) =>
|
112 | first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join(''));
|
113 | const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
|
114 | const castArray = val => (Array.isArray(val) ? val : [val]);
|
115 | const chainAsync = fns => {
|
116 | let curr = 0;
|
117 | const next = () => fns[curr++](next);
|
118 | next();
|
119 | };
|
120 | const chunk = (arr, size) =>
|
121 | Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>
|
122 | arr.slice(i * size, i * size + size)
|
123 | );
|
124 | const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
|
125 | const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
|
126 | const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_));
|
127 | const coalesceFactory = valid => (...args) => args.find(valid);
|
128 | const collectInto = fn => (...args) => fn(args);
|
129 | const colorize = (...args) => ({
|
130 | black: `\x1b[30m${args.join(' ')}`,
|
131 | red: `\x1b[31m${args.join(' ')}`,
|
132 | green: `\x1b[32m${args.join(' ')}`,
|
133 | yellow: `\x1b[33m${args.join(' ')}`,
|
134 | blue: `\x1b[34m${args.join(' ')}`,
|
135 | magenta: `\x1b[35m${args.join(' ')}`,
|
136 | cyan: `\x1b[36m${args.join(' ')}`,
|
137 | white: `\x1b[37m${args.join(' ')}`,
|
138 | bgBlack: `\x1b[40m${args.join(' ')}\x1b[0m`,
|
139 | bgRed: `\x1b[41m${args.join(' ')}\x1b[0m`,
|
140 | bgGreen: `\x1b[42m${args.join(' ')}\x1b[0m`,
|
141 | bgYellow: `\x1b[43m${args.join(' ')}\x1b[0m`,
|
142 | bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`,
|
143 | bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`,
|
144 | bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`,
|
145 | bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m`
|
146 | });
|
147 | const compact = arr => arr.filter(Boolean);
|
148 | const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
|
149 | const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
|
150 | const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args)));
|
151 | const copyToClipboard = str => {
|
152 | const el = document.createElement('textarea');
|
153 | el.value = str;
|
154 | el.setAttribute('readonly', '');
|
155 | el.style.position = 'absolute';
|
156 | el.style.left = '-9999px';
|
157 | document.body.appendChild(el);
|
158 | const selected =
|
159 | document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false;
|
160 | el.select();
|
161 | document.execCommand('copy');
|
162 | document.body.removeChild(el);
|
163 | if (selected) {
|
164 | document.getSelection().removeAllRanges();
|
165 | document.getSelection().addRange(selected);
|
166 | }
|
167 | };
|
168 | const countBy = (arr, fn) =>
|
169 | arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => {
|
170 | acc[val] = (acc[val] || 0) + 1;
|
171 | return acc;
|
172 | }, {});
|
173 | const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
|
174 | const counter = (selector, start, end, step = 1, duration = 2000) => {
|
175 | let current = start,
|
176 | _step = (end - start) * step < 0 ? -step : step,
|
177 | timer = setInterval(() => {
|
178 | current += _step;
|
179 | document.querySelector(selector).innerHTML = current;
|
180 | if (current >= end) document.querySelector(selector).innerHTML = end;
|
181 | if (current >= end) clearInterval(timer);
|
182 | }, Math.abs(Math.floor(duration / (end - start))));
|
183 | return timer;
|
184 | };
|
185 | const createElement = str => {
|
186 | const el = document.createElement('div');
|
187 | el.innerHTML = str;
|
188 | return el.firstElementChild;
|
189 | };
|
190 | const createEventHub = () => ({
|
191 | hub: Object.create(null),
|
192 | emit(event, data) {
|
193 | (this.hub[event] || []).forEach(handler => handler(data));
|
194 | },
|
195 | on(event, handler) {
|
196 | if (!this.hub[event]) this.hub[event] = [];
|
197 | this.hub[event].push(handler);
|
198 | },
|
199 | off(event, handler) {
|
200 | const i = (this.hub[event] || []).findIndex(h => h === handler);
|
201 | if (i > -1) this.hub[event].splice(i, 1);
|
202 | }
|
203 | });
|
204 | const currentURL = () => window.location.href;
|
205 | const curry = (fn, arity = fn.length, ...args) =>
|
206 | arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
|
207 | const dayOfYear = date =>
|
208 | Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24);
|
209 | const debounce = (fn, ms = 0) => {
|
210 | let timeoutId;
|
211 | return function(...args) {
|
212 | clearTimeout(timeoutId);
|
213 | timeoutId = setTimeout(() => fn.apply(this, args), ms);
|
214 | };
|
215 | };
|
216 | const decapitalize = ([first, ...rest], upperRest = false) =>
|
217 | first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join(''));
|
218 | const deepClone = obj => {
|
219 | let clone = Object.assign({}, obj);
|
220 | Object.keys(clone).forEach(
|
221 | key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])
|
222 | );
|
223 | return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone;
|
224 | };
|
225 | const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v)));
|
226 | const deepFreeze = obj =>
|
227 | Object.keys(obj).forEach(
|
228 | prop =>
|
229 | !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])
|
230 | ) || Object.freeze(obj);
|
231 | const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
|
232 | const defer = (fn, ...args) => setTimeout(fn, 1, ...args);
|
233 | const degreesToRads = deg => (deg * Math.PI) / 180.0;
|
234 | const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args);
|
235 | const detectDeviceType = () =>
|
236 | /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
|
237 | ? 'Mobile'
|
238 | : 'Desktop';
|
239 | const difference = (a, b) => {
|
240 | const s = new Set(b);
|
241 | return a.filter(x => !s.has(x));
|
242 | };
|
243 | const differenceBy = (a, b, fn) => {
|
244 | const s = new Set(b.map(fn));
|
245 | return a.filter(x => !s.has(fn(x)));
|
246 | };
|
247 | const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1);
|
248 | const dig = (obj, target) =>
|
249 | target in obj
|
250 | ? obj[target]
|
251 | : Object.values(obj).reduce((acc, val) => {
|
252 | if (acc !== undefined) return acc;
|
253 | if (typeof val === 'object') return dig(val, target);
|
254 | }, undefined);
|
255 | const digitize = n => [...`${n}`].map(i => parseInt(i));
|
256 | const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);
|
257 | const drop = (arr, n = 1) => arr.slice(n);
|
258 | const dropRight = (arr, n = 1) => arr.slice(0, -n);
|
259 | const dropRightWhile = (arr, func) => {
|
260 | while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1);
|
261 | return arr;
|
262 | };
|
263 | const dropWhile = (arr, func) => {
|
264 | while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1);
|
265 | return arr;
|
266 | };
|
267 | const elementContains = (parent, child) => parent !== child && parent.contains(child);
|
268 | const elementIsVisibleInViewport = (el, partiallyVisible = false) => {
|
269 | const { top, left, bottom, right } = el.getBoundingClientRect();
|
270 | const { innerHeight, innerWidth } = window;
|
271 | return partiallyVisible
|
272 | ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) &&
|
273 | ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
|
274 | : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
|
275 | };
|
276 | const elo = ([...ratings], kFactor = 32, selfRating) => {
|
277 | const [a, b] = ratings;
|
278 | const expectedScore = (self, opponent) => 1 / (1 + 10 ** ((opponent - self) / 400));
|
279 | const newRating = (rating, i) =>
|
280 | (selfRating || rating) + kFactor * (i - expectedScore(i ? a : b, i ? b : a));
|
281 | if (ratings.length === 2) return [newRating(a, 1), newRating(b, 0)];
|
282 |
|
283 | for (let i = 0, len = ratings.length; i < len; i++) {
|
284 | let j = i;
|
285 | while (j < len - 1) {
|
286 | j++;
|
287 | [ratings[i], ratings[j]] = elo([ratings[i], ratings[j]], kFactor);
|
288 | }
|
289 | }
|
290 | return ratings;
|
291 | };
|
292 | const equals = (a, b) => {
|
293 | if (a === b) return true;
|
294 | if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime();
|
295 | if (!a || !b || (typeof a !== 'object' && typeof b !== 'object')) return a === b;
|
296 | if (a === null || a === undefined || b === null || b === undefined) return false;
|
297 | if (a.prototype !== b.prototype) return false;
|
298 | let keys = Object.keys(a);
|
299 | if (keys.length !== Object.keys(b).length) return false;
|
300 | return keys.every(k => equals(a[k], b[k]));
|
301 | };
|
302 | const escapeHTML = str =>
|
303 | str.replace(
|
304 | /[&<>'"]/g,
|
305 | tag =>
|
306 | ({
|
307 | '&': '&',
|
308 | '<': '<',
|
309 | '>': '>',
|
310 | "'": ''',
|
311 | '"': '"'
|
312 | }[tag] || tag)
|
313 | );
|
314 | const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
315 | const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);
|
316 | const extendHex = shortHex =>
|
317 | '#' +
|
318 | shortHex
|
319 | .slice(shortHex.startsWith('#') ? 1 : 0)
|
320 | .split('')
|
321 | .map(x => x + x)
|
322 | .join('');
|
323 | const factorial = n =>
|
324 | n < 0
|
325 | ? (() => {
|
326 | throw new TypeError('Negative numbers are not allowed!');
|
327 | })()
|
328 | : n <= 1
|
329 | ? 1
|
330 | : n * factorial(n - 1);
|
331 | const fibonacci = n =>
|
332 | Array.from({ length: n }).reduce(
|
333 | (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
|
334 | []
|
335 | );
|
336 | const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
|
337 | const filterNonUniqueBy = (arr, fn) =>
|
338 | arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j)));
|
339 | const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj));
|
340 | const findLast = (arr, fn) => arr.filter(fn).pop();
|
341 | const findLastIndex = (arr, fn) =>
|
342 | arr
|
343 | .map((val, i) => [i, val])
|
344 | .filter(([i, val]) => fn(val, i, arr))
|
345 | .pop()[0];
|
346 | const findLastKey = (obj, fn) =>
|
347 | Object.keys(obj)
|
348 | .reverse()
|
349 | .find(key => fn(obj[key], key, obj));
|
350 | const flatten = (arr, depth = 1) =>
|
351 | arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []);
|
352 | const flattenObject = (obj, prefix = '') =>
|
353 | Object.keys(obj).reduce((acc, k) => {
|
354 | const pre = prefix.length ? prefix + '.' : '';
|
355 | if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k));
|
356 | else acc[pre + k] = obj[k];
|
357 | return acc;
|
358 | }, {});
|
359 | const flip = fn => (first, ...rest) => fn(...rest, first);
|
360 | const forEachRight = (arr, callback) =>
|
361 | arr
|
362 | .slice(0)
|
363 | .reverse()
|
364 | .forEach(callback);
|
365 | const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
366 | const forOwnRight = (obj, fn) =>
|
367 | Object.keys(obj)
|
368 | .reverse()
|
369 | .forEach(key => fn(obj[key], key, obj));
|
370 | const formatDuration = ms => {
|
371 | if (ms < 0) ms = -ms;
|
372 | const time = {
|
373 | day: Math.floor(ms / 86400000),
|
374 | hour: Math.floor(ms / 3600000) % 24,
|
375 | minute: Math.floor(ms / 60000) % 60,
|
376 | second: Math.floor(ms / 1000) % 60,
|
377 | millisecond: Math.floor(ms) % 1000
|
378 | };
|
379 | return Object.entries(time)
|
380 | .filter(val => val[1] !== 0)
|
381 | .map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
|
382 | .join(', ');
|
383 | };
|
384 | const fromCamelCase = (str, separator = '_') =>
|
385 | str
|
386 | .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
|
387 | .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2')
|
388 | .toLowerCase();
|
389 | const functionName = fn => (console.debug(fn.name), fn);
|
390 | const functions = (obj, inherited = false) =>
|
391 | (inherited
|
392 | ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))]
|
393 | : Object.keys(obj)
|
394 | ).filter(key => typeof obj[key] === 'function');
|
395 | const gcd = (...arr) => {
|
396 | const _gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
397 | return [...arr].reduce((a, b) => _gcd(a, b));
|
398 | };
|
399 | const geometricProgression = (end, start = 1, step = 2) =>
|
400 | Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
|
401 | (v, i) => start * step ** i
|
402 | );
|
403 | const get = (from, ...selectors) =>
|
404 | [...selectors].map(s =>
|
405 | s
|
406 | .replace(/\[([^\[\]]*)\]/g, '.$1.')
|
407 | .split('.')
|
408 | .filter(t => t !== '')
|
409 | .reduce((prev, cur) => prev && prev[cur], from)
|
410 | );
|
411 | const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);
|
412 | const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
|
413 | (dateFinal - dateInitial) / (1000 * 3600 * 24);
|
414 | const getImages = (el, includeDuplicates = false) => {
|
415 | const images = [...el.getElementsByTagName('img')].map(img => img.getAttribute('src'));
|
416 | return includeDuplicates ? images : [...new Set(images)];
|
417 | };
|
418 | const getMeridiemSuffixOfInteger = num =>
|
419 | num === 0 || num === 24
|
420 | ? 12 + 'am'
|
421 | : num === 12
|
422 | ? 12 + 'pm'
|
423 | : num < 12
|
424 | ? (num % 12) + 'am'
|
425 | : (num % 12) + 'pm';
|
426 | const getScrollPosition = (el = window) => ({
|
427 | x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft,
|
428 | y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop
|
429 | });
|
430 | const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];
|
431 | const getType = v =>
|
432 | v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();
|
433 | const getURLParameters = url =>
|
434 | (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce(
|
435 | (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a),
|
436 | {}
|
437 | );
|
438 | const groupBy = (arr, fn) =>
|
439 | arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => {
|
440 | acc[val] = (acc[val] || []).concat(arr[i]);
|
441 | return acc;
|
442 | }, {});
|
443 | const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length;
|
444 | const hasClass = (el, className) => el.classList.contains(className);
|
445 | const hasFlags = (...flags) =>
|
446 | flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag));
|
447 | const hashBrowser = val =>
|
448 | crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => {
|
449 | let hexes = [],
|
450 | view = new DataView(h);
|
451 | for (let i = 0; i < view.byteLength; i += 4)
|
452 | hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8));
|
453 | return hexes.join('');
|
454 | });
|
455 | const hashNode = val =>
|
456 | new Promise(resolve =>
|
457 | setTimeout(
|
458 | () =>
|
459 | resolve(
|
460 | crypto
|
461 | .createHash('sha256')
|
462 | .update(val)
|
463 | .digest('hex')
|
464 | ),
|
465 | 0
|
466 | )
|
467 | );
|
468 | const head = arr => arr[0];
|
469 | const hexToRGB = hex => {
|
470 | let alpha = false,
|
471 | h = hex.slice(hex.startsWith('#') ? 1 : 0);
|
472 | if (h.length === 3) h = [...h].map(x => x + x).join('');
|
473 | else if (h.length === 8) alpha = true;
|
474 | h = parseInt(h, 16);
|
475 | return (
|
476 | 'rgb' +
|
477 | (alpha ? 'a' : '') +
|
478 | '(' +
|
479 | (h >>> (alpha ? 24 : 16)) +
|
480 | ', ' +
|
481 | ((h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8)) +
|
482 | ', ' +
|
483 | ((h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0)) +
|
484 | (alpha ? `, ${h & 0x000000ff}` : '') +
|
485 | ')'
|
486 | );
|
487 | };
|
488 | const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
|
489 | const httpGet = (url, callback, err = console.error) => {
|
490 | const request = new XMLHttpRequest();
|
491 | request.open('GET', url, true);
|
492 | request.onload = () => callback(request.responseText);
|
493 | request.onerror = () => err(request);
|
494 | request.send();
|
495 | };
|
496 | const httpPost = (url, data, callback, err = console.error) => {
|
497 | const request = new XMLHttpRequest();
|
498 | request.open('POST', url, true);
|
499 | request.setRequestHeader('Content-type', 'application/json; charset=utf-8');
|
500 | request.onload = () => callback(request.responseText);
|
501 | request.onerror = () => err(request);
|
502 | request.send(data);
|
503 | };
|
504 | const httpsRedirect = () => {
|
505 | if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);
|
506 | };
|
507 | const hz = (fn, iterations = 100) => {
|
508 | const before = performance.now();
|
509 | for (let i = 0; i < iterations; i++) fn();
|
510 | return (1000 * iterations) / (performance.now() - before);
|
511 | };
|
512 | const inRange = (n, start, end = null) => {
|
513 | if (end && start > end) [end, start] = [start, end];
|
514 | return end == null ? n >= 0 && n < start : n >= start && n < end;
|
515 | };
|
516 | const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count));
|
517 | const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
|
518 | const initial = arr => arr.slice(0, -1);
|
519 | const initialize2DArray = (w, h, val = null) =>
|
520 | Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val));
|
521 | const initializeArrayWithRange = (end, start = 0, step = 1) =>
|
522 | Array.from({ length: Math.ceil((end - start + 1) / step) }, (v, i) => i * step + start);
|
523 | const initializeArrayWithRangeRight = (end, start = 0, step = 1) =>
|
524 | Array.from({ length: Math.ceil((end + 1 - start) / step) }).map(
|
525 | (v, i, arr) => (arr.length - i - 1) * step + start
|
526 | );
|
527 | const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val);
|
528 | const initializeNDArray = (val, ...args) =>
|
529 | args.length === 0
|
530 | ? val
|
531 | : Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1)));
|
532 | const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString);
|
533 | const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString);
|
534 | const intersection = (a, b) => {
|
535 | const s = new Set(b);
|
536 | return a.filter(x => s.has(x));
|
537 | };
|
538 | const intersectionBy = (a, b, fn) => {
|
539 | const s = new Set(b.map(fn));
|
540 | return a.filter(x => s.has(fn(x)));
|
541 | };
|
542 | const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1);
|
543 | const invertKeyValues = (obj, fn) =>
|
544 | Object.keys(obj).reduce((acc, key) => {
|
545 | const val = fn ? fn(obj[key]) : obj[key];
|
546 | acc[val] = acc[val] || [];
|
547 | acc[val].push(key);
|
548 | return acc;
|
549 | }, {});
|
550 | const is = (type, val) => ![, null].includes(val) && val.constructor === type;
|
551 | const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str);
|
552 | const isAfterDate = (dateA, dateB) => dateA > dateB;
|
553 | const isAnagram = (str1, str2) => {
|
554 | const normalize = str =>
|
555 | str
|
556 | .toLowerCase()
|
557 | .replace(/[^a-z0-9]/gi, '')
|
558 | .split('')
|
559 | .sort()
|
560 | .join('');
|
561 | return normalize(str1) === normalize(str2);
|
562 | };
|
563 | const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'function';
|
564 | const isBeforeDate = (dateA, dateB) => dateA < dateB;
|
565 | const isBoolean = val => typeof val === 'boolean';
|
566 | const isBrowser = () => ![typeof window, typeof document].includes('undefined');
|
567 | const isBrowserTabFocused = () => !document.hidden;
|
568 | const isDivisible = (dividend, divisor) => dividend % divisor === 0;
|
569 | const isDuplexStream = val =>
|
570 | val !== null &&
|
571 | typeof val === 'object' &&
|
572 | typeof val.pipe === 'function' &&
|
573 | typeof val._read === 'function' &&
|
574 | typeof val._readableState === 'object' &&
|
575 | typeof val._write === 'function' &&
|
576 | typeof val._writableState === 'object';
|
577 | const isEmpty = val => val == null || !(Object.keys(val) || val).length;
|
578 | const isEven = num => num % 2 === 0;
|
579 | const isFunction = val => typeof val === 'function';
|
580 | const isLowerCase = str => str === str.toLowerCase();
|
581 | const isNegativeZero = val => val === 0 && 1 / val === -Infinity;
|
582 | const isNil = val => val === undefined || val === null;
|
583 | const isNull = val => val === null;
|
584 | const isNumber = val => typeof val === 'number';
|
585 | const isObject = obj => obj === Object(obj);
|
586 | const isObjectLike = val => val !== null && typeof val === 'object';
|
587 | const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object;
|
588 | const isPrime = num => {
|
589 | const boundary = Math.floor(Math.sqrt(num));
|
590 | for (var i = 2; i <= boundary; i++) if (num % i === 0) return false;
|
591 | return num >= 2;
|
592 | };
|
593 | const isPrimitive = val => Object(val) !== val;
|
594 | const isPromiseLike = obj =>
|
595 | obj !== null &&
|
596 | (typeof obj === 'object' || typeof obj === 'function') &&
|
597 | typeof obj.then === 'function';
|
598 | const isReadableStream = val =>
|
599 | val !== null &&
|
600 | typeof val === 'object' &&
|
601 | typeof val.pipe === 'function' &&
|
602 | typeof val._read === 'function' &&
|
603 | typeof val._readableState === 'object';
|
604 | const isSameDate = (dateA, dateB) => dateA.toISOString() === dateB.toISOString();
|
605 | const isSorted = arr => {
|
606 | let direction = -(arr[0] - arr[1]);
|
607 | for (let [i, val] of arr.entries()) {
|
608 | direction = !direction ? -(arr[i - 1] - arr[i]) : direction;
|
609 | if (i === arr.length - 1) return !direction ? 0 : direction;
|
610 | else if ((val - arr[i + 1]) * direction > 0) return 0;
|
611 | }
|
612 | };
|
613 | const isStream = val => val !== null && typeof val === 'object' && typeof val.pipe === 'function';
|
614 | const isString = val => typeof val === 'string';
|
615 | const isSymbol = val => typeof val === 'symbol';
|
616 | const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;
|
617 | const isUndefined = val => val === undefined;
|
618 | const isUpperCase = str => str === str.toUpperCase();
|
619 | const isValidJSON = str => {
|
620 | try {
|
621 | JSON.parse(str);
|
622 | return true;
|
623 | } catch (e) {
|
624 | return false;
|
625 | }
|
626 | };
|
627 | const isWritableStream = val =>
|
628 | val !== null &&
|
629 | typeof val === 'object' &&
|
630 | typeof val.pipe === 'function' &&
|
631 | typeof val._write === 'function' &&
|
632 | typeof val._writableState === 'object';
|
633 | const join = (arr, separator = ',', end = separator) =>
|
634 | arr.reduce(
|
635 | (acc, val, i) =>
|
636 | i === arr.length - 2
|
637 | ? acc + val + end
|
638 | : i === arr.length - 1
|
639 | ? acc + val
|
640 | : acc + val + separator,
|
641 | ''
|
642 | );
|
643 | const last = arr => arr[arr.length - 1];
|
644 | const lcm = (...arr) => {
|
645 | const gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
646 | const _lcm = (x, y) => (x * y) / gcd(x, y);
|
647 | return [...arr].reduce((a, b) => _lcm(a, b));
|
648 | };
|
649 | const longestItem = (...vals) => vals.reduce((a, x) => (x.length > a.length ? x : a));
|
650 | const lowercaseKeys = obj =>
|
651 | Object.keys(obj).reduce((acc, key) => {
|
652 | acc[key.toLowerCase()] = obj[key];
|
653 | return acc;
|
654 | }, {});
|
655 | const luhnCheck = num => {
|
656 | let arr = (num + '')
|
657 | .split('')
|
658 | .reverse()
|
659 | .map(x => parseInt(x));
|
660 | let lastDigit = arr.splice(0, 1)[0];
|
661 | let sum = arr.reduce((acc, val, i) => (i % 2 !== 0 ? acc + val : acc + ((val * 2) % 9) || 9), 0);
|
662 | sum += lastDigit;
|
663 | return sum % 10 === 0;
|
664 | };
|
665 | const mapKeys = (obj, fn) =>
|
666 | Object.keys(obj).reduce((acc, k) => {
|
667 | acc[fn(obj[k], k, obj)] = obj[k];
|
668 | return acc;
|
669 | }, {});
|
670 | const mapObject = (arr, fn) =>
|
671 | (a => (
|
672 | (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {})
|
673 | ))();
|
674 | const mapString = (str, fn) =>
|
675 | str
|
676 | .split('')
|
677 | .map((c, i) => fn(c, i, str))
|
678 | .join('');
|
679 | const mapValues = (obj, fn) =>
|
680 | Object.keys(obj).reduce((acc, k) => {
|
681 | acc[k] = fn(obj[k], k, obj);
|
682 | return acc;
|
683 | }, {});
|
684 | const mask = (cc, num = 4, mask = '*') => `${cc}`.slice(-num).padStart(`${cc}`.length, mask);
|
685 | const matches = (obj, source) =>
|
686 | Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]);
|
687 | const matchesWith = (obj, source, fn) =>
|
688 | Object.keys(source).every(
|
689 | key =>
|
690 | obj.hasOwnProperty(key) && fn
|
691 | ? fn(obj[key], source[key], key, obj, source)
|
692 | : obj[key] == source[key]
|
693 | );
|
694 | const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
|
695 | const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates));
|
696 | const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
|
697 | const median = arr => {
|
698 | const mid = Math.floor(arr.length / 2),
|
699 | nums = [...arr].sort((a, b) => a - b);
|
700 | return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
|
701 | };
|
702 | const memoize = fn => {
|
703 | const cache = new Map();
|
704 | const cached = function(val) {
|
705 | return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);
|
706 | };
|
707 | cached.cache = cache;
|
708 | return cached;
|
709 | };
|
710 | const merge = (...objs) =>
|
711 | [...objs].reduce(
|
712 | (acc, obj) =>
|
713 | Object.keys(obj).reduce((a, k) => {
|
714 | acc[k] = acc.hasOwnProperty(k) ? [].concat(acc[k]).concat(obj[k]) : obj[k];
|
715 | return acc;
|
716 | }, {}),
|
717 | {}
|
718 | );
|
719 | const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
|
720 | const minDate = (...dates) => new Date(Math.min.apply(null, ...dates));
|
721 | const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
|
722 | const mostPerformant = (fns, iterations = 10000) => {
|
723 | const times = fns.map(fn => {
|
724 | const before = performance.now();
|
725 | for (let i = 0; i < iterations; i++) fn();
|
726 | return performance.now() - before;
|
727 | });
|
728 | return times.indexOf(Math.min(...times));
|
729 | };
|
730 | const negate = func => (...args) => !func(...args);
|
731 | const nest = (items, id = null, link = 'parent_id') =>
|
732 | items
|
733 | .filter(item => item[link] === id)
|
734 | .map(item => ({ ...item, children: nest(items, item.id) }));
|
735 | const nodeListToArray = nodeList => [...nodeList];
|
736 | const none = (arr, fn = Boolean) => !arr.some(fn);
|
737 | const nthArg = n => (...args) => args.slice(n)[0];
|
738 | const nthElement = (arr, n = 0) => (n === -1 ? arr.slice(n) : arr.slice(n, n + 1))[0];
|
739 | const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {});
|
740 | const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
|
741 | const observeMutations = (element, callback, options) => {
|
742 | const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m)));
|
743 | observer.observe(
|
744 | element,
|
745 | Object.assign(
|
746 | {
|
747 | childList: true,
|
748 | attributes: true,
|
749 | attributeOldValue: true,
|
750 | characterData: true,
|
751 | characterDataOldValue: true,
|
752 | subtree: true
|
753 | },
|
754 | options
|
755 | )
|
756 | );
|
757 | return observer;
|
758 | };
|
759 | const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts);
|
760 | const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)];
|
761 | const omit = (obj, arr) =>
|
762 | Object.keys(obj)
|
763 | .filter(k => !arr.includes(k))
|
764 | .reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
|
765 | const omitBy = (obj, fn) =>
|
766 | Object.keys(obj)
|
767 | .filter(k => !fn(obj[k], k))
|
768 | .reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
|
769 | const on = (el, evt, fn, opts = {}) => {
|
770 | const delegatorFn = e => e.target.matches(opts.target) && fn.call(e.target, e);
|
771 | el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false);
|
772 | if (opts.target) return delegatorFn;
|
773 | };
|
774 | const onUserInputChange = callback => {
|
775 | let type = 'mouse',
|
776 | lastTime = 0;
|
777 | const mousemoveHandler = () => {
|
778 | const now = performance.now();
|
779 | if (now - lastTime < 20)
|
780 | (type = 'mouse'), callback(type), document.removeEventListener('mousemove', mousemoveHandler);
|
781 | lastTime = now;
|
782 | };
|
783 | document.addEventListener('touchstart', () => {
|
784 | if (type === 'touch') return;
|
785 | (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);
|
786 | });
|
787 | };
|
788 | const once = fn => {
|
789 | let called = false;
|
790 | return function(...args) {
|
791 | if (called) return;
|
792 | called = true;
|
793 | return fn.apply(this, args);
|
794 | };
|
795 | };
|
796 | const orderBy = (arr, props, orders) =>
|
797 | [...arr].sort((a, b) =>
|
798 | props.reduce((acc, prop, i) => {
|
799 | if (acc === 0) {
|
800 | const [p1, p2] = orders && orders[i] === 'desc' ? [b[prop], a[prop]] : [a[prop], b[prop]];
|
801 | acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0;
|
802 | }
|
803 | return acc;
|
804 | }, 0)
|
805 | );
|
806 | const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));
|
807 | const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val)));
|
808 | const pad = (str, length, char = ' ') =>
|
809 | str.padStart((str.length + length) / 2, char).padEnd(length, char);
|
810 | const palindrome = str => {
|
811 | const s = str.toLowerCase().replace(/[\W_]/g, '');
|
812 | return s === [...s].reverse().join('');
|
813 | };
|
814 | const parseCookie = str =>
|
815 | str
|
816 | .split(';')
|
817 | .map(v => v.split('='))
|
818 | .reduce((acc, v) => {
|
819 | acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim());
|
820 | return acc;
|
821 | }, {});
|
822 | const partial = (fn, ...partials) => (...args) => fn(...partials, ...args);
|
823 | const partialRight = (fn, ...partials) => (...args) => fn(...args, ...partials);
|
824 | const partition = (arr, fn) =>
|
825 | arr.reduce(
|
826 | (acc, val, i, arr) => {
|
827 | acc[fn(val, i, arr) ? 0 : 1].push(val);
|
828 | return acc;
|
829 | },
|
830 | [[], []]
|
831 | );
|
832 | const percentile = (arr, val) =>
|
833 | (100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0)) / arr.length;
|
834 | const permutations = arr => {
|
835 | if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr;
|
836 | return arr.reduce(
|
837 | (acc, item, i) =>
|
838 | acc.concat(
|
839 | permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val])
|
840 | ),
|
841 | []
|
842 | );
|
843 | };
|
844 | const pick = (obj, arr) =>
|
845 | arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {});
|
846 | const pickBy = (obj, fn) =>
|
847 | Object.keys(obj)
|
848 | .filter(k => fn(obj[k], k))
|
849 | .reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
|
850 | const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg));
|
851 | const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
|
852 | const pluralize = (val, word, plural = word + 's') => {
|
853 | const _pluralize = (num, word, plural = word + 's') =>
|
854 | [1, -1].includes(Number(num)) ? word : plural;
|
855 | if (typeof val === 'object') return (num, word) => _pluralize(num, word, val[word]);
|
856 | return _pluralize(val, word, plural);
|
857 | };
|
858 | const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]);
|
859 | const prefix = prop => {
|
860 | const capitalizedProp = prop.charAt(0).toUpperCase() + prop.slice(1);
|
861 | const prefixes = ['', 'webkit', 'moz', 'ms', 'o'];
|
862 | const i = prefixes.findIndex(
|
863 | prefix => typeof document.body.style[prefix ? prefix + capitalizedProp : prop] !== 'undefined'
|
864 | );
|
865 | return i !== -1 ? (i === 0 ? prop : prefixes[i] + capitalizedProp) : null;
|
866 | };
|
867 | const prettyBytes = (num, precision = 3, addSpace = true) => {
|
868 | const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
869 | if (Math.abs(num) < 1) return num + (addSpace ? ' ' : '') + UNITS[0];
|
870 | const exponent = Math.min(Math.floor(Math.log10(num < 0 ? -num : num) / 3), UNITS.length - 1);
|
871 | const n = Number(((num < 0 ? -num : num) / 1000 ** exponent).toPrecision(precision));
|
872 | return (num < 0 ? '-' : '') + n + (addSpace ? ' ' : '') + UNITS[exponent];
|
873 | };
|
874 | const primes = num => {
|
875 | let arr = Array.from({ length: num - 1 }).map((x, i) => i + 2),
|
876 | sqroot = Math.floor(Math.sqrt(num)),
|
877 | numsTillSqroot = Array.from({ length: sqroot - 1 }).map((x, i) => i + 2);
|
878 | numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y === x)));
|
879 | return arr;
|
880 | };
|
881 | const promisify = func => (...args) =>
|
882 | new Promise((resolve, reject) =>
|
883 | func(...args, (err, result) => (err ? reject(err) : resolve(result)))
|
884 | );
|
885 | const pull = (arr, ...args) => {
|
886 | let argState = Array.isArray(args[0]) ? args[0] : args;
|
887 | let pulled = arr.filter((v, i) => !argState.includes(v));
|
888 | arr.length = 0;
|
889 | pulled.forEach(v => arr.push(v));
|
890 | };
|
891 | const pullAtIndex = (arr, pullArr) => {
|
892 | let removed = [];
|
893 | let pulled = arr
|
894 | .map((v, i) => (pullArr.includes(i) ? removed.push(v) : v))
|
895 | .filter((v, i) => !pullArr.includes(i));
|
896 | arr.length = 0;
|
897 | pulled.forEach(v => arr.push(v));
|
898 | return removed;
|
899 | };
|
900 | const pullAtValue = (arr, pullArr) => {
|
901 | let removed = [],
|
902 | pushToRemove = arr.forEach((v, i) => (pullArr.includes(v) ? removed.push(v) : v)),
|
903 | mutateTo = arr.filter((v, i) => !pullArr.includes(v));
|
904 | arr.length = 0;
|
905 | mutateTo.forEach(v => arr.push(v));
|
906 | return removed;
|
907 | };
|
908 | const pullBy = (arr, ...args) => {
|
909 | const length = args.length;
|
910 | let fn = length > 1 ? args[length - 1] : undefined;
|
911 | fn = typeof fn == 'function' ? (args.pop(), fn) : undefined;
|
912 | let argState = (Array.isArray(args[0]) ? args[0] : args).map(val => fn(val));
|
913 | let pulled = arr.filter((v, i) => !argState.includes(fn(v)));
|
914 | arr.length = 0;
|
915 | pulled.forEach(v => arr.push(v));
|
916 | };
|
917 | const radsToDegrees = rad => (rad * 180.0) / Math.PI;
|
918 | const randomHexColorCode = () => {
|
919 | let n = (Math.random() * 0xfffff * 1000000).toString(16);
|
920 | return '#' + n.slice(0, 6);
|
921 | };
|
922 | const randomIntArrayInRange = (min, max, n = 1) =>
|
923 | Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min);
|
924 | const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
|
925 | const randomNumberInRange = (min, max) => Math.random() * (max - min) + min;
|
926 | const readFileLines = filename =>
|
927 | fs
|
928 | .readFileSync(filename)
|
929 | .toString('UTF8')
|
930 | .split('\n');
|
931 | const rearg = (fn, indexes) => (...args) => fn(...indexes.map(i => args[i]));
|
932 | const recordAnimationFrames = (callback, autoStart = true) => {
|
933 | let running = true,
|
934 | raf;
|
935 | const stop = () => {
|
936 | running = false;
|
937 | cancelAnimationFrame(raf);
|
938 | };
|
939 | const start = () => {
|
940 | running = true;
|
941 | run();
|
942 | };
|
943 | const run = () => {
|
944 | raf = requestAnimationFrame(() => {
|
945 | callback();
|
946 | if (running) run();
|
947 | });
|
948 | };
|
949 | if (autoStart) start();
|
950 | return { start, stop };
|
951 | };
|
952 | const redirect = (url, asLink = true) =>
|
953 | asLink ? (window.location.href = url) : window.location.replace(url);
|
954 | const reduceSuccessive = (arr, fn, acc) =>
|
955 | arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]);
|
956 | const reduceWhich = (arr, comparator = (a, b) => a - b) =>
|
957 | arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a));
|
958 | const reducedFilter = (data, keys, fn) =>
|
959 | data.filter(fn).map(el =>
|
960 | keys.reduce((acc, key) => {
|
961 | acc[key] = el[key];
|
962 | return acc;
|
963 | }, {})
|
964 | );
|
965 | const reject = (pred, array) => array.filter((...args) => !pred(...args));
|
966 | const remove = (arr, func) =>
|
967 | Array.isArray(arr)
|
968 | ? arr.filter(func).reduce((acc, val) => {
|
969 | arr.splice(arr.indexOf(val), 1);
|
970 | return acc.concat(val);
|
971 | }, [])
|
972 | : [];
|
973 | const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, '');
|
974 | const renameKeys = (keysMap, obj) =>
|
975 | Object.keys(obj).reduce(
|
976 | (acc, key) => ({
|
977 | ...acc,
|
978 | ...{ [keysMap[key] || key]: obj[key] }
|
979 | }),
|
980 | {}
|
981 | );
|
982 | const reverseString = str => [...str].reverse().join('');
|
983 | const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
984 | const runAsync = fn => {
|
985 | const worker = new Worker(
|
986 | URL.createObjectURL(new Blob([`postMessage((${fn})());`]), {
|
987 | type: 'application/javascript; charset=utf-8'
|
988 | })
|
989 | );
|
990 | return new Promise((res, rej) => {
|
991 | worker.onmessage = ({ data }) => {
|
992 | res(data), worker.terminate();
|
993 | };
|
994 | worker.onerror = err => {
|
995 | rej(err), worker.terminate();
|
996 | };
|
997 | });
|
998 | };
|
999 | const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve());
|
1000 | const sample = arr => arr[Math.floor(Math.random() * arr.length)];
|
1001 | const sampleSize = ([...arr], n = 1) => {
|
1002 | let m = arr.length;
|
1003 | while (m) {
|
1004 | const i = Math.floor(Math.random() * m--);
|
1005 | [arr[m], arr[i]] = [arr[i], arr[m]];
|
1006 | }
|
1007 | return arr.slice(0, n);
|
1008 | };
|
1009 | const scrollToTop = () => {
|
1010 | const c = document.documentElement.scrollTop || document.body.scrollTop;
|
1011 | if (c > 0) {
|
1012 | window.requestAnimationFrame(scrollToTop);
|
1013 | window.scrollTo(0, c - c / 8);
|
1014 | }
|
1015 | };
|
1016 | const sdbm = str => {
|
1017 | let arr = str.split('');
|
1018 | return arr.reduce(
|
1019 | (hashCode, currentVal) =>
|
1020 | (hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode),
|
1021 | 0
|
1022 | );
|
1023 | };
|
1024 | const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`;
|
1025 | const setStyle = (el, ruleName, val) => (el.style[ruleName] = val);
|
1026 | const shallowClone = obj => Object.assign({}, obj);
|
1027 | const shank = (arr, index = 0, delCount = 0, ...elements) =>
|
1028 | arr
|
1029 | .slice(0, index)
|
1030 | .concat(elements)
|
1031 | .concat(arr.slice(index + delCount));
|
1032 | const show = (...el) => [...el].forEach(e => (e.style.display = ''));
|
1033 | const shuffle = ([...arr]) => {
|
1034 | let m = arr.length;
|
1035 | while (m) {
|
1036 | const i = Math.floor(Math.random() * m--);
|
1037 | [arr[m], arr[i]] = [arr[i], arr[m]];
|
1038 | }
|
1039 | return arr;
|
1040 | };
|
1041 | const similarity = (arr, values) => arr.filter(v => values.includes(v));
|
1042 | const size = val =>
|
1043 | Array.isArray(val)
|
1044 | ? val.length
|
1045 | : val && typeof val === 'object'
|
1046 | ? val.size || val.length || Object.keys(val).length
|
1047 | : typeof val === 'string'
|
1048 | ? new Blob([val]).size
|
1049 | : 0;
|
1050 | const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
1051 | const smoothScroll = element =>
|
1052 | document.querySelector(element).scrollIntoView({
|
1053 | behavior: 'smooth'
|
1054 | });
|
1055 | const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join('');
|
1056 | const sortedIndex = (arr, n) => {
|
1057 | const isDescending = arr[0] > arr[arr.length - 1];
|
1058 | const index = arr.findIndex(el => (isDescending ? n >= el : n <= el));
|
1059 | return index === -1 ? arr.length : index;
|
1060 | };
|
1061 | const sortedIndexBy = (arr, n, fn) => {
|
1062 | const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]);
|
1063 | const val = fn(n);
|
1064 | const index = arr.findIndex(el => (isDescending ? val >= fn(el) : val <= fn(el)));
|
1065 | return index === -1 ? arr.length : index;
|
1066 | };
|
1067 | const sortedLastIndex = (arr, n) => {
|
1068 | const isDescending = arr[0] > arr[arr.length - 1];
|
1069 | const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el));
|
1070 | return index === -1 ? 0 : arr.length - index;
|
1071 | };
|
1072 | const sortedLastIndexBy = (arr, n, fn) => {
|
1073 | const isDescending = fn(arr[0]) > fn(arr[arr.length - 1]);
|
1074 | const val = fn(n);
|
1075 | const index = arr
|
1076 | .map(fn)
|
1077 | .reverse()
|
1078 | .findIndex(el => (isDescending ? val <= el : val >= el));
|
1079 | return index === -1 ? 0 : arr.length - index;
|
1080 | };
|
1081 | const splitLines = str => str.split(/\r?\n/);
|
1082 | const spreadOver = fn => argsArr => fn(...argsArr);
|
1083 | const stableSort = (arr, compare) =>
|
1084 | arr
|
1085 | .map((item, index) => ({ item, index }))
|
1086 | .sort((a, b) => compare(a.item, b.item) || a.index - b.index)
|
1087 | .map(({ item }) => item);
|
1088 | const standardDeviation = (arr, usePopulation = false) => {
|
1089 | const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length;
|
1090 | return Math.sqrt(
|
1091 | arr.reduce((acc, val) => acc.concat((val - mean) ** 2), []).reduce((acc, val) => acc + val, 0) /
|
1092 | (arr.length - (usePopulation ? 0 : 1))
|
1093 | );
|
1094 | };
|
1095 | const stringPermutations = str => {
|
1096 | if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str];
|
1097 | return str
|
1098 | .split('')
|
1099 | .reduce(
|
1100 | (acc, letter, i) =>
|
1101 | acc.concat(stringPermutations(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)),
|
1102 | []
|
1103 | );
|
1104 | };
|
1105 | const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');
|
1106 | const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0);
|
1107 | const sumBy = (arr, fn) =>
|
1108 | arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0);
|
1109 | const sumPower = (end, power = 2, start = 1) =>
|
1110 | Array(end + 1 - start)
|
1111 | .fill(0)
|
1112 | .map((x, i) => (i + start) ** power)
|
1113 | .reduce((a, b) => a + b, 0);
|
1114 | const symmetricDifference = (a, b) => {
|
1115 | const sA = new Set(a),
|
1116 | sB = new Set(b);
|
1117 | return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))];
|
1118 | };
|
1119 | const symmetricDifferenceBy = (a, b, fn) => {
|
1120 | const sA = new Set(a.map(v => fn(v))),
|
1121 | sB = new Set(b.map(v => fn(v)));
|
1122 | return [...a.filter(x => !sB.has(fn(x))), ...b.filter(x => !sA.has(fn(x)))];
|
1123 | };
|
1124 | const symmetricDifferenceWith = (arr, val, comp) => [
|
1125 | ...arr.filter(a => val.findIndex(b => comp(a, b)) === -1),
|
1126 | ...val.filter(a => arr.findIndex(b => comp(a, b)) === -1)
|
1127 | ];
|
1128 | const tail = arr => (arr.length > 1 ? arr.slice(1) : arr);
|
1129 | const take = (arr, n = 1) => arr.slice(0, n);
|
1130 | const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length);
|
1131 | const takeRightWhile = (arr, func) =>
|
1132 | arr.reduceRight((acc, el) => (func(el) ? acc : [el, ...acc]), []);
|
1133 | const takeWhile = (arr, func) => {
|
1134 | for (const [i, val] of arr.entries()) if (func(val)) return arr.slice(0, i);
|
1135 | return arr;
|
1136 | };
|
1137 | const throttle = (fn, wait) => {
|
1138 | let inThrottle, lastFn, lastTime;
|
1139 | return function() {
|
1140 | const context = this,
|
1141 | args = arguments;
|
1142 | if (!inThrottle) {
|
1143 | fn.apply(context, args);
|
1144 | lastTime = Date.now();
|
1145 | inThrottle = true;
|
1146 | } else {
|
1147 | clearTimeout(lastFn);
|
1148 | lastFn = setTimeout(function() {
|
1149 | if (Date.now() - lastTime >= wait) {
|
1150 | fn.apply(context, args);
|
1151 | lastTime = Date.now();
|
1152 | }
|
1153 | }, Math.max(wait - (Date.now() - lastTime), 0));
|
1154 | }
|
1155 | };
|
1156 | };
|
1157 | const timeTaken = callback => {
|
1158 | console.time('timeTaken');
|
1159 | const r = callback();
|
1160 | console.timeEnd('timeTaken');
|
1161 | return r;
|
1162 | };
|
1163 | const times = (n, fn, context = undefined) => {
|
1164 | let i = 0;
|
1165 | while (fn.call(context, i) !== false && ++i < n) {}
|
1166 | };
|
1167 | const toCamelCase = str => {
|
1168 | let s =
|
1169 | str &&
|
1170 | str
|
1171 | .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
1172 | .map(x => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase())
|
1173 | .join('');
|
1174 | return s.slice(0, 1).toLowerCase() + s.slice(1);
|
1175 | };
|
1176 | const toCurrency = (n, curr, LanguageFormat = undefined) =>
|
1177 | Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
|
1178 | const toDecimalMark = num => num.toLocaleString('en-US');
|
1179 | const toHash = (object, key) =>
|
1180 | Array.prototype.reduce.call(
|
1181 | object,
|
1182 | (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc),
|
1183 | {}
|
1184 | );
|
1185 | const toKebabCase = str =>
|
1186 | str &&
|
1187 | str
|
1188 | .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
1189 | .map(x => x.toLowerCase())
|
1190 | .join('-');
|
1191 | const toOrdinalSuffix = num => {
|
1192 | const int = parseInt(num),
|
1193 | digits = [int % 10, int % 100],
|
1194 | ordinals = ['st', 'nd', 'rd', 'th'],
|
1195 | oPattern = [1, 2, 3, 4],
|
1196 | tPattern = [11, 12, 13, 14, 15, 16, 17, 18, 19];
|
1197 | return oPattern.includes(digits[0]) && !tPattern.includes(digits[1])
|
1198 | ? int + ordinals[digits[0] - 1]
|
1199 | : int + ordinals[3];
|
1200 | };
|
1201 | const toSafeInteger = num =>
|
1202 | Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER));
|
1203 | const toSnakeCase = str =>
|
1204 | str &&
|
1205 | str
|
1206 | .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
1207 | .map(x => x.toLowerCase())
|
1208 | .join('_');
|
1209 | const toTitleCase = str =>
|
1210 | str
|
1211 | .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
1212 | .map(x => x.charAt(0).toUpperCase() + x.slice(1))
|
1213 | .join(' ');
|
1214 | const toggleClass = (el, className) => el.classList.toggle(className);
|
1215 | const tomorrow = (long = false) => {
|
1216 | let t = new Date();
|
1217 | t.setDate(t.getDate() + 1);
|
1218 | const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
|
1219 | t.getDate()
|
1220 | ).padStart(2, '0')}`;
|
1221 | return !long ? ret : `${ret}T00:00:00`;
|
1222 | };
|
1223 | const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
1224 | const triggerEvent = (el, eventType, detail) =>
|
1225 | el.dispatchEvent(new CustomEvent(eventType, { detail }));
|
1226 | const truncateString = (str, num) =>
|
1227 | str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
|
1228 | const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]);
|
1229 | const unary = fn => val => fn(val);
|
1230 | const uncurry = (fn, n = 1) => (...args) => {
|
1231 | const next = acc => args => args.reduce((x, y) => x(y), acc);
|
1232 | if (n > args.length) throw new RangeError('Arguments too few!');
|
1233 | return next(fn)(args.slice(0, n));
|
1234 | };
|
1235 | const unescapeHTML = str =>
|
1236 | str.replace(
|
1237 | /&|<|>|'|"/g,
|
1238 | tag =>
|
1239 | ({
|
1240 | '&': '&',
|
1241 | '<': '<',
|
1242 | '>': '>',
|
1243 | ''': "'",
|
1244 | '"': '"'
|
1245 | }[tag] || tag)
|
1246 | );
|
1247 | const unflattenObject = obj =>
|
1248 | Object.keys(obj).reduce((acc, k) => {
|
1249 | if (k.indexOf('.') !== -1) {
|
1250 | const keys = k.split('.');
|
1251 | Object.assign(
|
1252 | acc,
|
1253 | JSON.parse(
|
1254 | '{' +
|
1255 | keys.map((v, i) => (i !== keys.length - 1 ? `"${v}":{` : `"${v}":`)).join('') +
|
1256 | obj[k] +
|
1257 | '}'.repeat(keys.length)
|
1258 | )
|
1259 | );
|
1260 | } else acc[k] = obj[k];
|
1261 | return acc;
|
1262 | }, {});
|
1263 | const unfold = (fn, seed) => {
|
1264 | let result = [],
|
1265 | val = [null, seed];
|
1266 | while ((val = fn(val[1]))) result.push(val[0]);
|
1267 | return result;
|
1268 | };
|
1269 | const union = (a, b) => Array.from(new Set([...a, ...b]));
|
1270 | const unionBy = (a, b, fn) => {
|
1271 | const s = new Set(a.map(fn));
|
1272 | return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))]));
|
1273 | };
|
1274 | const unionWith = (a, b, comp) =>
|
1275 | Array.from(new Set([...a, ...b.filter(x => a.findIndex(y => comp(x, y)) === -1)]));
|
1276 | const uniqueElements = arr => [...new Set(arr)];
|
1277 | const uniqueElementsBy = (arr, fn) =>
|
1278 | arr.reduce((acc, v) => {
|
1279 | if (!acc.some(x => fn(v, x))) acc.push(v);
|
1280 | return acc;
|
1281 | }, []);
|
1282 | const uniqueElementsByRight = (arr, fn) =>
|
1283 | arr.reduceRight((acc, v) => {
|
1284 | if (!acc.some(x => fn(v, x))) acc.push(v);
|
1285 | return acc;
|
1286 | }, []);
|
1287 | const uniqueSymmetricDifference = (a, b) => [
|
1288 | ...new Set([...a.filter(v => !b.includes(v)), ...b.filter(v => !a.includes(v))])
|
1289 | ];
|
1290 | const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`);
|
1291 | const unzip = arr =>
|
1292 | arr.reduce(
|
1293 | (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc),
|
1294 | Array.from({
|
1295 | length: Math.max(...arr.map(x => x.length))
|
1296 | }).map(x => [])
|
1297 | );
|
1298 | const unzipWith = (arr, fn) =>
|
1299 | arr
|
1300 | .reduce(
|
1301 | (acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc),
|
1302 | Array.from({
|
1303 | length: Math.max(...arr.map(x => x.length))
|
1304 | }).map(x => [])
|
1305 | )
|
1306 | .map(val => fn(...val));
|
1307 | const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
1308 | const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x);
|
1309 | const without = (arr, ...args) => arr.filter(v => !args.includes(v));
|
1310 | const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean);
|
1311 | const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []);
|
1312 | const yesNo = (val, def = false) =>
|
1313 | /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def;
|
1314 | const zip = (...arrays) => {
|
1315 | const maxLength = Math.max(...arrays.map(x => x.length));
|
1316 | return Array.from({ length: maxLength }).map((_, i) => {
|
1317 | return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]);
|
1318 | });
|
1319 | };
|
1320 | const zipObject = (props, values) =>
|
1321 | props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {});
|
1322 | const zipWith = (...array) => {
|
1323 | const fn = typeof array[array.length - 1] === 'function' ? array.pop() : undefined;
|
1324 | return Array.from(
|
1325 | { length: Math.max(...array.map(a => a.length)) },
|
1326 | (_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))
|
1327 | );
|
1328 | };
|
1329 |
|
1330 | exports.CSVToArray = CSVToArray;
|
1331 | exports.CSVToJSON = CSVToJSON;
|
1332 | exports.JSONToFile = JSONToFile;
|
1333 | exports.JSONtoCSV = JSONtoCSV;
|
1334 | exports.RGBToHex = RGBToHex;
|
1335 | exports.URLJoin = URLJoin;
|
1336 | exports.UUIDGeneratorBrowser = UUIDGeneratorBrowser;
|
1337 | exports.UUIDGeneratorNode = UUIDGeneratorNode;
|
1338 | exports.all = all;
|
1339 | exports.allEqual = allEqual;
|
1340 | exports.any = any;
|
1341 | exports.approximatelyEqual = approximatelyEqual;
|
1342 | exports.arrayToCSV = arrayToCSV;
|
1343 | exports.arrayToHtmlList = arrayToHtmlList;
|
1344 | exports.ary = ary;
|
1345 | exports.atob = atob;
|
1346 | exports.attempt = attempt;
|
1347 | exports.average = average;
|
1348 | exports.averageBy = averageBy;
|
1349 | exports.bifurcate = bifurcate;
|
1350 | exports.bifurcateBy = bifurcateBy;
|
1351 | exports.bind = bind;
|
1352 | exports.bindAll = bindAll;
|
1353 | exports.bindKey = bindKey;
|
1354 | exports.binomialCoefficient = binomialCoefficient;
|
1355 | exports.bottomVisible = bottomVisible;
|
1356 | exports.btoa = btoa;
|
1357 | exports.byteSize = byteSize;
|
1358 | exports.call = call;
|
1359 | exports.capitalize = capitalize;
|
1360 | exports.capitalizeEveryWord = capitalizeEveryWord;
|
1361 | exports.castArray = castArray;
|
1362 | exports.chainAsync = chainAsync;
|
1363 | exports.chunk = chunk;
|
1364 | exports.clampNumber = clampNumber;
|
1365 | exports.cloneRegExp = cloneRegExp;
|
1366 | exports.coalesce = coalesce;
|
1367 | exports.coalesceFactory = coalesceFactory;
|
1368 | exports.collectInto = collectInto;
|
1369 | exports.colorize = colorize;
|
1370 | exports.compact = compact;
|
1371 | exports.compose = compose;
|
1372 | exports.composeRight = composeRight;
|
1373 | exports.converge = converge;
|
1374 | exports.copyToClipboard = copyToClipboard;
|
1375 | exports.countBy = countBy;
|
1376 | exports.countOccurrences = countOccurrences;
|
1377 | exports.counter = counter;
|
1378 | exports.createElement = createElement;
|
1379 | exports.createEventHub = createEventHub;
|
1380 | exports.currentURL = currentURL;
|
1381 | exports.curry = curry;
|
1382 | exports.dayOfYear = dayOfYear;
|
1383 | exports.debounce = debounce;
|
1384 | exports.decapitalize = decapitalize;
|
1385 | exports.deepClone = deepClone;
|
1386 | exports.deepFlatten = deepFlatten;
|
1387 | exports.deepFreeze = deepFreeze;
|
1388 | exports.defaults = defaults;
|
1389 | exports.defer = defer;
|
1390 | exports.degreesToRads = degreesToRads;
|
1391 | exports.delay = delay;
|
1392 | exports.detectDeviceType = detectDeviceType;
|
1393 | exports.difference = difference;
|
1394 | exports.differenceBy = differenceBy;
|
1395 | exports.differenceWith = differenceWith;
|
1396 | exports.dig = dig;
|
1397 | exports.digitize = digitize;
|
1398 | exports.distance = distance;
|
1399 | exports.drop = drop;
|
1400 | exports.dropRight = dropRight;
|
1401 | exports.dropRightWhile = dropRightWhile;
|
1402 | exports.dropWhile = dropWhile;
|
1403 | exports.elementContains = elementContains;
|
1404 | exports.elementIsVisibleInViewport = elementIsVisibleInViewport;
|
1405 | exports.elo = elo;
|
1406 | exports.equals = equals;
|
1407 | exports.escapeHTML = escapeHTML;
|
1408 | exports.escapeRegExp = escapeRegExp;
|
1409 | exports.everyNth = everyNth;
|
1410 | exports.extendHex = extendHex;
|
1411 | exports.factorial = factorial;
|
1412 | exports.fibonacci = fibonacci;
|
1413 | exports.filterNonUnique = filterNonUnique;
|
1414 | exports.filterNonUniqueBy = filterNonUniqueBy;
|
1415 | exports.findKey = findKey;
|
1416 | exports.findLast = findLast;
|
1417 | exports.findLastIndex = findLastIndex;
|
1418 | exports.findLastKey = findLastKey;
|
1419 | exports.flatten = flatten;
|
1420 | exports.flattenObject = flattenObject;
|
1421 | exports.flip = flip;
|
1422 | exports.forEachRight = forEachRight;
|
1423 | exports.forOwn = forOwn;
|
1424 | exports.forOwnRight = forOwnRight;
|
1425 | exports.formatDuration = formatDuration;
|
1426 | exports.fromCamelCase = fromCamelCase;
|
1427 | exports.functionName = functionName;
|
1428 | exports.functions = functions;
|
1429 | exports.gcd = gcd;
|
1430 | exports.geometricProgression = geometricProgression;
|
1431 | exports.get = get;
|
1432 | exports.getColonTimeFromDate = getColonTimeFromDate;
|
1433 | exports.getDaysDiffBetweenDates = getDaysDiffBetweenDates;
|
1434 | exports.getImages = getImages;
|
1435 | exports.getMeridiemSuffixOfInteger = getMeridiemSuffixOfInteger;
|
1436 | exports.getScrollPosition = getScrollPosition;
|
1437 | exports.getStyle = getStyle;
|
1438 | exports.getType = getType;
|
1439 | exports.getURLParameters = getURLParameters;
|
1440 | exports.groupBy = groupBy;
|
1441 | exports.hammingDistance = hammingDistance;
|
1442 | exports.hasClass = hasClass;
|
1443 | exports.hasFlags = hasFlags;
|
1444 | exports.hashBrowser = hashBrowser;
|
1445 | exports.hashNode = hashNode;
|
1446 | exports.head = head;
|
1447 | exports.hexToRGB = hexToRGB;
|
1448 | exports.hide = hide;
|
1449 | exports.httpGet = httpGet;
|
1450 | exports.httpPost = httpPost;
|
1451 | exports.httpsRedirect = httpsRedirect;
|
1452 | exports.hz = hz;
|
1453 | exports.inRange = inRange;
|
1454 | exports.indentString = indentString;
|
1455 | exports.indexOfAll = indexOfAll;
|
1456 | exports.initial = initial;
|
1457 | exports.initialize2DArray = initialize2DArray;
|
1458 | exports.initializeArrayWithRange = initializeArrayWithRange;
|
1459 | exports.initializeArrayWithRangeRight = initializeArrayWithRangeRight;
|
1460 | exports.initializeArrayWithValues = initializeArrayWithValues;
|
1461 | exports.initializeNDArray = initializeNDArray;
|
1462 | exports.insertAfter = insertAfter;
|
1463 | exports.insertBefore = insertBefore;
|
1464 | exports.intersection = intersection;
|
1465 | exports.intersectionBy = intersectionBy;
|
1466 | exports.intersectionWith = intersectionWith;
|
1467 | exports.invertKeyValues = invertKeyValues;
|
1468 | exports.is = is;
|
1469 | exports.isAbsoluteURL = isAbsoluteURL;
|
1470 | exports.isAfterDate = isAfterDate;
|
1471 | exports.isAnagram = isAnagram;
|
1472 | exports.isArrayLike = isArrayLike;
|
1473 | exports.isBeforeDate = isBeforeDate;
|
1474 | exports.isBoolean = isBoolean;
|
1475 | exports.isBrowser = isBrowser;
|
1476 | exports.isBrowserTabFocused = isBrowserTabFocused;
|
1477 | exports.isDivisible = isDivisible;
|
1478 | exports.isDuplexStream = isDuplexStream;
|
1479 | exports.isEmpty = isEmpty;
|
1480 | exports.isEven = isEven;
|
1481 | exports.isFunction = isFunction;
|
1482 | exports.isLowerCase = isLowerCase;
|
1483 | exports.isNegativeZero = isNegativeZero;
|
1484 | exports.isNil = isNil;
|
1485 | exports.isNull = isNull;
|
1486 | exports.isNumber = isNumber;
|
1487 | exports.isObject = isObject;
|
1488 | exports.isObjectLike = isObjectLike;
|
1489 | exports.isPlainObject = isPlainObject;
|
1490 | exports.isPrime = isPrime;
|
1491 | exports.isPrimitive = isPrimitive;
|
1492 | exports.isPromiseLike = isPromiseLike;
|
1493 | exports.isReadableStream = isReadableStream;
|
1494 | exports.isSameDate = isSameDate;
|
1495 | exports.isSorted = isSorted;
|
1496 | exports.isStream = isStream;
|
1497 | exports.isString = isString;
|
1498 | exports.isSymbol = isSymbol;
|
1499 | exports.isTravisCI = isTravisCI;
|
1500 | exports.isUndefined = isUndefined;
|
1501 | exports.isUpperCase = isUpperCase;
|
1502 | exports.isValidJSON = isValidJSON;
|
1503 | exports.isWritableStream = isWritableStream;
|
1504 | exports.join = join;
|
1505 | exports.last = last;
|
1506 | exports.lcm = lcm;
|
1507 | exports.longestItem = longestItem;
|
1508 | exports.lowercaseKeys = lowercaseKeys;
|
1509 | exports.luhnCheck = luhnCheck;
|
1510 | exports.mapKeys = mapKeys;
|
1511 | exports.mapObject = mapObject;
|
1512 | exports.mapString = mapString;
|
1513 | exports.mapValues = mapValues;
|
1514 | exports.mask = mask;
|
1515 | exports.matches = matches;
|
1516 | exports.matchesWith = matchesWith;
|
1517 | exports.maxBy = maxBy;
|
1518 | exports.maxDate = maxDate;
|
1519 | exports.maxN = maxN;
|
1520 | exports.median = median;
|
1521 | exports.memoize = memoize;
|
1522 | exports.merge = merge;
|
1523 | exports.minBy = minBy;
|
1524 | exports.minDate = minDate;
|
1525 | exports.minN = minN;
|
1526 | exports.mostPerformant = mostPerformant;
|
1527 | exports.negate = negate;
|
1528 | exports.nest = nest;
|
1529 | exports.nodeListToArray = nodeListToArray;
|
1530 | exports.none = none;
|
1531 | exports.nthArg = nthArg;
|
1532 | exports.nthElement = nthElement;
|
1533 | exports.objectFromPairs = objectFromPairs;
|
1534 | exports.objectToPairs = objectToPairs;
|
1535 | exports.observeMutations = observeMutations;
|
1536 | exports.off = off;
|
1537 | exports.offset = offset;
|
1538 | exports.omit = omit;
|
1539 | exports.omitBy = omitBy;
|
1540 | exports.on = on;
|
1541 | exports.onUserInputChange = onUserInputChange;
|
1542 | exports.once = once;
|
1543 | exports.orderBy = orderBy;
|
1544 | exports.over = over;
|
1545 | exports.overArgs = overArgs;
|
1546 | exports.pad = pad;
|
1547 | exports.palindrome = palindrome;
|
1548 | exports.parseCookie = parseCookie;
|
1549 | exports.partial = partial;
|
1550 | exports.partialRight = partialRight;
|
1551 | exports.partition = partition;
|
1552 | exports.percentile = percentile;
|
1553 | exports.permutations = permutations;
|
1554 | exports.pick = pick;
|
1555 | exports.pickBy = pickBy;
|
1556 | exports.pipeAsyncFunctions = pipeAsyncFunctions;
|
1557 | exports.pipeFunctions = pipeFunctions;
|
1558 | exports.pluralize = pluralize;
|
1559 | exports.powerset = powerset;
|
1560 | exports.prefix = prefix;
|
1561 | exports.prettyBytes = prettyBytes;
|
1562 | exports.primes = primes;
|
1563 | exports.promisify = promisify;
|
1564 | exports.pull = pull;
|
1565 | exports.pullAtIndex = pullAtIndex;
|
1566 | exports.pullAtValue = pullAtValue;
|
1567 | exports.pullBy = pullBy;
|
1568 | exports.radsToDegrees = radsToDegrees;
|
1569 | exports.randomHexColorCode = randomHexColorCode;
|
1570 | exports.randomIntArrayInRange = randomIntArrayInRange;
|
1571 | exports.randomIntegerInRange = randomIntegerInRange;
|
1572 | exports.randomNumberInRange = randomNumberInRange;
|
1573 | exports.readFileLines = readFileLines;
|
1574 | exports.rearg = rearg;
|
1575 | exports.recordAnimationFrames = recordAnimationFrames;
|
1576 | exports.redirect = redirect;
|
1577 | exports.reduceSuccessive = reduceSuccessive;
|
1578 | exports.reduceWhich = reduceWhich;
|
1579 | exports.reducedFilter = reducedFilter;
|
1580 | exports.reject = reject;
|
1581 | exports.remove = remove;
|
1582 | exports.removeNonASCII = removeNonASCII;
|
1583 | exports.renameKeys = renameKeys;
|
1584 | exports.reverseString = reverseString;
|
1585 | exports.round = round;
|
1586 | exports.runAsync = runAsync;
|
1587 | exports.runPromisesInSeries = runPromisesInSeries;
|
1588 | exports.sample = sample;
|
1589 | exports.sampleSize = sampleSize;
|
1590 | exports.scrollToTop = scrollToTop;
|
1591 | exports.sdbm = sdbm;
|
1592 | exports.serializeCookie = serializeCookie;
|
1593 | exports.setStyle = setStyle;
|
1594 | exports.shallowClone = shallowClone;
|
1595 | exports.shank = shank;
|
1596 | exports.show = show;
|
1597 | exports.shuffle = shuffle;
|
1598 | exports.similarity = similarity;
|
1599 | exports.size = size;
|
1600 | exports.sleep = sleep;
|
1601 | exports.smoothScroll = smoothScroll;
|
1602 | exports.sortCharactersInString = sortCharactersInString;
|
1603 | exports.sortedIndex = sortedIndex;
|
1604 | exports.sortedIndexBy = sortedIndexBy;
|
1605 | exports.sortedLastIndex = sortedLastIndex;
|
1606 | exports.sortedLastIndexBy = sortedLastIndexBy;
|
1607 | exports.splitLines = splitLines;
|
1608 | exports.spreadOver = spreadOver;
|
1609 | exports.stableSort = stableSort;
|
1610 | exports.standardDeviation = standardDeviation;
|
1611 | exports.stringPermutations = stringPermutations;
|
1612 | exports.stripHTMLTags = stripHTMLTags;
|
1613 | exports.sum = sum;
|
1614 | exports.sumBy = sumBy;
|
1615 | exports.sumPower = sumPower;
|
1616 | exports.symmetricDifference = symmetricDifference;
|
1617 | exports.symmetricDifferenceBy = symmetricDifferenceBy;
|
1618 | exports.symmetricDifferenceWith = symmetricDifferenceWith;
|
1619 | exports.tail = tail;
|
1620 | exports.take = take;
|
1621 | exports.takeRight = takeRight;
|
1622 | exports.takeRightWhile = takeRightWhile;
|
1623 | exports.takeWhile = takeWhile;
|
1624 | exports.throttle = throttle;
|
1625 | exports.timeTaken = timeTaken;
|
1626 | exports.times = times;
|
1627 | exports.toCamelCase = toCamelCase;
|
1628 | exports.toCurrency = toCurrency;
|
1629 | exports.toDecimalMark = toDecimalMark;
|
1630 | exports.toHash = toHash;
|
1631 | exports.toKebabCase = toKebabCase;
|
1632 | exports.toOrdinalSuffix = toOrdinalSuffix;
|
1633 | exports.toSafeInteger = toSafeInteger;
|
1634 | exports.toSnakeCase = toSnakeCase;
|
1635 | exports.toTitleCase = toTitleCase;
|
1636 | exports.toggleClass = toggleClass;
|
1637 | exports.tomorrow = tomorrow;
|
1638 | exports.transform = transform;
|
1639 | exports.triggerEvent = triggerEvent;
|
1640 | exports.truncateString = truncateString;
|
1641 | exports.truthCheckCollection = truthCheckCollection;
|
1642 | exports.unary = unary;
|
1643 | exports.uncurry = uncurry;
|
1644 | exports.unescapeHTML = unescapeHTML;
|
1645 | exports.unflattenObject = unflattenObject;
|
1646 | exports.unfold = unfold;
|
1647 | exports.union = union;
|
1648 | exports.unionBy = unionBy;
|
1649 | exports.unionWith = unionWith;
|
1650 | exports.uniqueElements = uniqueElements;
|
1651 | exports.uniqueElementsBy = uniqueElementsBy;
|
1652 | exports.uniqueElementsByRight = uniqueElementsByRight;
|
1653 | exports.uniqueSymmetricDifference = uniqueSymmetricDifference;
|
1654 | exports.untildify = untildify;
|
1655 | exports.unzip = unzip;
|
1656 | exports.unzipWith = unzipWith;
|
1657 | exports.validateNumber = validateNumber;
|
1658 | exports.when = when;
|
1659 | exports.without = without;
|
1660 | exports.words = words;
|
1661 | exports.xProd = xProd;
|
1662 | exports.yesNo = yesNo;
|
1663 | exports.zip = zip;
|
1664 | exports.zipObject = zipObject;
|
1665 | exports.zipWith = zipWith;
|
1666 |
|
1667 | Object.defineProperty(exports, '__esModule', { value: true });
|
1668 |
|
1669 | })));
|
1670 |
|
\ | No newline at end of file |