Update packager script
Also check test and tester scripts
This commit is contained in:
@ -12,6 +12,11 @@ module.exports = {
|
|||||||
assetPath: `assets`,
|
assetPath: `assets`,
|
||||||
pagePath: `src/docs/pages`,
|
pagePath: `src/docs/pages`,
|
||||||
staticPartsPath: `src/static-parts`,
|
staticPartsPath: `src/static-parts`,
|
||||||
|
distPath: `dist`,
|
||||||
// General information
|
// General information
|
||||||
language: `js`,
|
language: `js`,
|
||||||
|
// Module information
|
||||||
|
moduleName: `_30s`,
|
||||||
|
rollupInputFile: `imports.temp.js`,
|
||||||
|
testModuleFile: `test/_30s.js`,
|
||||||
};
|
};
|
||||||
|
|||||||
839
dist/_30s.es5.js
vendored
839
dist/_30s.es5.js
vendored
File diff suppressed because it is too large
Load Diff
2
dist/_30s.es5.min.js
vendored
2
dist/_30s.es5.min.js
vendored
File diff suppressed because one or more lines are too long
336
dist/_30s.esm.js
vendored
336
dist/_30s.esm.js
vendored
@ -1,51 +1,6 @@
|
|||||||
const fs = typeof require !== "undefined" && require('fs');
|
const fs = typeof require !== "undefined" && require('fs');
|
||||||
const crypto = typeof require !== "undefined" && require('crypto');
|
const crypto = typeof require !== "undefined" && require('crypto');
|
||||||
|
|
||||||
const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>
|
|
||||||
data
|
|
||||||
.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0)
|
|
||||||
.split('\n')
|
|
||||||
.map(v => v.split(delimiter));
|
|
||||||
const CSVToJSON = (data, delimiter = ',') => {
|
|
||||||
const titles = data.slice(0, data.indexOf('\n')).split(delimiter);
|
|
||||||
return data
|
|
||||||
.slice(data.indexOf('\n') + 1)
|
|
||||||
.split('\n')
|
|
||||||
.map(v => {
|
|
||||||
const values = v.split(delimiter);
|
|
||||||
return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const JSONToFile = (obj, filename) =>
|
|
||||||
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
|
||||||
const JSONtoCSV = (arr, columns, delimiter = ',') =>
|
|
||||||
[
|
|
||||||
columns.join(delimiter),
|
|
||||||
...arr.map(obj =>
|
|
||||||
columns.reduce(
|
|
||||||
(acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`,
|
|
||||||
''
|
|
||||||
)
|
|
||||||
)
|
|
||||||
].join('\n');
|
|
||||||
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
|
||||||
const URLJoin = (...args) =>
|
|
||||||
args
|
|
||||||
.join('/')
|
|
||||||
.replace(/[\/]+/g, '/')
|
|
||||||
.replace(/^(.+):\//, '$1://')
|
|
||||||
.replace(/^file:/, 'file:/')
|
|
||||||
.replace(/\/(\?|&|#[^!])/g, '$1')
|
|
||||||
.replace(/\?/g, '&')
|
|
||||||
.replace('&', '?');
|
|
||||||
const UUIDGeneratorBrowser = () =>
|
|
||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
||||||
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
|
||||||
);
|
|
||||||
const UUIDGeneratorNode = () =>
|
|
||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
||||||
(c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
|
||||||
);
|
|
||||||
const all = (arr, fn = Boolean) => arr.every(fn);
|
const all = (arr, fn = Boolean) => arr.every(fn);
|
||||||
const allEqual = arr => arr.every(val => val === arr[0]);
|
const allEqual = arr => arr.every(val => val === arr[0]);
|
||||||
const any = (arr, fn = Boolean) => arr.some(fn);
|
const any = (arr, fn = Boolean) => arr.some(fn);
|
||||||
@ -172,7 +127,6 @@ const countBy = (arr, fn) =>
|
|||||||
acc[val] = (acc[val] || 0) + 1;
|
acc[val] = (acc[val] || 0) + 1;
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
|
|
||||||
const counter = (selector, start, end, step = 1, duration = 2000) => {
|
const counter = (selector, start, end, step = 1, duration = 2000) => {
|
||||||
let current = start,
|
let current = start,
|
||||||
_step = (end - start) * step < 0 ? -step : step,
|
_step = (end - start) * step < 0 ? -step : step,
|
||||||
@ -184,6 +138,7 @@ const counter = (selector, start, end, step = 1, duration = 2000) => {
|
|||||||
}, Math.abs(Math.floor(duration / (end - start))));
|
}, Math.abs(Math.floor(duration / (end - start))));
|
||||||
return timer;
|
return timer;
|
||||||
};
|
};
|
||||||
|
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
|
||||||
const createDirIfNotExists = dir => (!fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined);
|
const createDirIfNotExists = dir => (!fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined);
|
||||||
const createElement = str => {
|
const createElement = str => {
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
@ -205,6 +160,21 @@ const createEventHub = () => ({
|
|||||||
if (this.hub[event].length === 0) delete this.hub[event];
|
if (this.hub[event].length === 0) delete this.hub[event];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>
|
||||||
|
data
|
||||||
|
.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0)
|
||||||
|
.split('\n')
|
||||||
|
.map(v => v.split(delimiter));
|
||||||
|
const CSVToJSON = (data, delimiter = ',') => {
|
||||||
|
const titles = data.slice(0, data.indexOf('\n')).split(delimiter);
|
||||||
|
return data
|
||||||
|
.slice(data.indexOf('\n') + 1)
|
||||||
|
.split('\n')
|
||||||
|
.map(v => {
|
||||||
|
const values = v.split(delimiter);
|
||||||
|
return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});
|
||||||
|
});
|
||||||
|
};
|
||||||
const currentURL = () => window.location.href;
|
const currentURL = () => window.location.href;
|
||||||
const curry = (fn, arity = fn.length, ...args) =>
|
const curry = (fn, arity = fn.length, ...args) =>
|
||||||
arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
|
arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
|
||||||
@ -384,19 +354,6 @@ const forEachRight = (arr, callback) =>
|
|||||||
.slice(0)
|
.slice(0)
|
||||||
.reverse()
|
.reverse()
|
||||||
.forEach(callback);
|
.forEach(callback);
|
||||||
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
|
||||||
const forOwnRight = (obj, fn) =>
|
|
||||||
Object.keys(obj)
|
|
||||||
.reverse()
|
|
||||||
.forEach(key => fn(obj[key], key, obj));
|
|
||||||
const formToObject = form =>
|
|
||||||
Array.from(new FormData(form)).reduce(
|
|
||||||
(acc, [key, value]) => ({
|
|
||||||
...acc,
|
|
||||||
[key]: value
|
|
||||||
}),
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
const formatDuration = ms => {
|
const formatDuration = ms => {
|
||||||
if (ms < 0) ms = -ms;
|
if (ms < 0) ms = -ms;
|
||||||
const time = {
|
const time = {
|
||||||
@ -411,6 +368,19 @@ const formatDuration = ms => {
|
|||||||
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
|
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
|
||||||
.join(', ');
|
.join(', ');
|
||||||
};
|
};
|
||||||
|
const formToObject = form =>
|
||||||
|
Array.from(new FormData(form)).reduce(
|
||||||
|
(acc, [key, value]) => ({
|
||||||
|
...acc,
|
||||||
|
[key]: value
|
||||||
|
}),
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
||||||
|
const forOwnRight = (obj, fn) =>
|
||||||
|
Object.keys(obj)
|
||||||
|
.reverse()
|
||||||
|
.forEach(key => fn(obj[key], key, obj));
|
||||||
const fromCamelCase = (str, separator = '_') =>
|
const fromCamelCase = (str, separator = '_') =>
|
||||||
str
|
str
|
||||||
.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
|
.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
|
||||||
@ -539,10 +509,6 @@ const hz = (fn, iterations = 100) => {
|
|||||||
for (let i = 0; i < iterations; i++) fn();
|
for (let i = 0; i < iterations; i++) fn();
|
||||||
return (1000 * iterations) / (performance.now() - before);
|
return (1000 * iterations) / (performance.now() - before);
|
||||||
};
|
};
|
||||||
const inRange = (n, start, end = null) => {
|
|
||||||
if (end && start > end) [end, start] = [start, end];
|
|
||||||
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
|
||||||
};
|
|
||||||
const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count));
|
const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count));
|
||||||
const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
|
const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
|
||||||
const initial = arr => arr.slice(0, -1);
|
const initial = arr => arr.slice(0, -1);
|
||||||
@ -559,6 +525,10 @@ const initializeNDArray = (val, ...args) =>
|
|||||||
args.length === 0
|
args.length === 0
|
||||||
? val
|
? val
|
||||||
: Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1)));
|
: Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1)));
|
||||||
|
const inRange = (n, start, end = null) => {
|
||||||
|
if (end && start > end) [end, start] = [start, end];
|
||||||
|
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
||||||
|
};
|
||||||
const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString);
|
const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString);
|
||||||
const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString);
|
const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString);
|
||||||
const intersection = (a, b) => {
|
const intersection = (a, b) => {
|
||||||
@ -676,6 +646,18 @@ const join = (arr, separator = ',', end = separator) =>
|
|||||||
: acc + val + separator,
|
: acc + val + separator,
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
const JSONtoCSV = (arr, columns, delimiter = ',') =>
|
||||||
|
[
|
||||||
|
columns.join(delimiter),
|
||||||
|
...arr.map(obj =>
|
||||||
|
columns.reduce(
|
||||||
|
(acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
)
|
||||||
|
].join('\n');
|
||||||
|
const JSONToFile = (obj, filename) =>
|
||||||
|
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
||||||
const last = arr => arr[arr.length - 1];
|
const last = arr => arr[arr.length - 1];
|
||||||
const lcm = (...arr) => {
|
const lcm = (...arr) => {
|
||||||
const gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
const gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
||||||
@ -810,6 +792,14 @@ const on = (el, evt, fn, opts = {}) => {
|
|||||||
el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false);
|
el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false);
|
||||||
if (opts.target) return delegatorFn;
|
if (opts.target) return delegatorFn;
|
||||||
};
|
};
|
||||||
|
const once = fn => {
|
||||||
|
let called = false;
|
||||||
|
return function(...args) {
|
||||||
|
if (called) return;
|
||||||
|
called = true;
|
||||||
|
return fn.apply(this, args);
|
||||||
|
};
|
||||||
|
};
|
||||||
const onUserInputChange = callback => {
|
const onUserInputChange = callback => {
|
||||||
let type = 'mouse',
|
let type = 'mouse',
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
@ -824,14 +814,6 @@ const onUserInputChange = callback => {
|
|||||||
(type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);
|
(type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const once = fn => {
|
|
||||||
let called = false;
|
|
||||||
return function(...args) {
|
|
||||||
if (called) return;
|
|
||||||
called = true;
|
|
||||||
return fn.apply(this, args);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
const orderBy = (arr, props, orders) =>
|
const orderBy = (arr, props, orders) =>
|
||||||
[...arr].sort((a, b) =>
|
[...arr].sort((a, b) =>
|
||||||
props.reduce((acc, prop, i) => {
|
props.reduce((acc, prop, i) => {
|
||||||
@ -990,10 +972,6 @@ const recordAnimationFrames = (callback, autoStart = true) => {
|
|||||||
};
|
};
|
||||||
const redirect = (url, asLink = true) =>
|
const redirect = (url, asLink = true) =>
|
||||||
asLink ? (window.location.href = url) : window.location.replace(url);
|
asLink ? (window.location.href = url) : window.location.replace(url);
|
||||||
const reduceSuccessive = (arr, fn, acc) =>
|
|
||||||
arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]);
|
|
||||||
const reduceWhich = (arr, comparator = (a, b) => a - b) =>
|
|
||||||
arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a));
|
|
||||||
const reducedFilter = (data, keys, fn) =>
|
const reducedFilter = (data, keys, fn) =>
|
||||||
data.filter(fn).map(el =>
|
data.filter(fn).map(el =>
|
||||||
keys.reduce((acc, key) => {
|
keys.reduce((acc, key) => {
|
||||||
@ -1001,6 +979,10 @@ const reducedFilter = (data, keys, fn) =>
|
|||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {})
|
||||||
);
|
);
|
||||||
|
const reduceSuccessive = (arr, fn, acc) =>
|
||||||
|
arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]);
|
||||||
|
const reduceWhich = (arr, comparator = (a, b) => a - b) =>
|
||||||
|
arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a));
|
||||||
const reject = (pred, array) => array.filter((...args) => !pred(...args));
|
const reject = (pred, array) => array.filter((...args) => !pred(...args));
|
||||||
const remove = (arr, func) =>
|
const remove = (arr, func) =>
|
||||||
Array.isArray(arr)
|
Array.isArray(arr)
|
||||||
@ -1019,6 +1001,7 @@ const renameKeys = (keysMap, obj) =>
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
const reverseString = str => [...str].reverse().join('');
|
const reverseString = str => [...str].reverse().join('');
|
||||||
|
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
||||||
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
||||||
const runAsync = fn => {
|
const runAsync = fn => {
|
||||||
const worker = new Worker(
|
const worker = new Worker(
|
||||||
@ -1195,16 +1178,16 @@ const throttle = (fn, wait) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
const times = (n, fn, context = undefined) => {
|
||||||
|
let i = 0;
|
||||||
|
while (fn.call(context, i) !== false && ++i < n) {}
|
||||||
|
};
|
||||||
const timeTaken = callback => {
|
const timeTaken = callback => {
|
||||||
console.time('timeTaken');
|
console.time('timeTaken');
|
||||||
const r = callback();
|
const r = callback();
|
||||||
console.timeEnd('timeTaken');
|
console.timeEnd('timeTaken');
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
const times = (n, fn, context = undefined) => {
|
|
||||||
let i = 0;
|
|
||||||
while (fn.call(context, i) !== false && ++i < n) {}
|
|
||||||
};
|
|
||||||
const toCamelCase = str => {
|
const toCamelCase = str => {
|
||||||
let s =
|
let s =
|
||||||
str &&
|
str &&
|
||||||
@ -1217,6 +1200,7 @@ const toCamelCase = str => {
|
|||||||
const toCurrency = (n, curr, LanguageFormat = undefined) =>
|
const toCurrency = (n, curr, LanguageFormat = undefined) =>
|
||||||
Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
|
Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
|
||||||
const toDecimalMark = num => num.toLocaleString('en-US');
|
const toDecimalMark = num => num.toLocaleString('en-US');
|
||||||
|
const toggleClass = (el, className) => el.classList.toggle(className);
|
||||||
const toHash = (object, key) =>
|
const toHash = (object, key) =>
|
||||||
Array.prototype.reduce.call(
|
Array.prototype.reduce.call(
|
||||||
object,
|
object,
|
||||||
@ -1229,6 +1213,11 @@ const toKebabCase = str =>
|
|||||||
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
||||||
.map(x => x.toLowerCase())
|
.map(x => x.toLowerCase())
|
||||||
.join('-');
|
.join('-');
|
||||||
|
const tomorrow = () => {
|
||||||
|
let t = new Date();
|
||||||
|
t.setDate(t.getDate() + 1);
|
||||||
|
return t.toISOString().split('T')[0];
|
||||||
|
};
|
||||||
const toOrdinalSuffix = num => {
|
const toOrdinalSuffix = num => {
|
||||||
const int = parseInt(num),
|
const int = parseInt(num),
|
||||||
digits = [int % 10, int % 100],
|
digits = [int % 10, int % 100],
|
||||||
@ -1252,12 +1241,6 @@ const toTitleCase = str =>
|
|||||||
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
||||||
.map(x => x.charAt(0).toUpperCase() + x.slice(1))
|
.map(x => x.charAt(0).toUpperCase() + x.slice(1))
|
||||||
.join(' ');
|
.join(' ');
|
||||||
const toggleClass = (el, className) => el.classList.toggle(className);
|
|
||||||
const tomorrow = () => {
|
|
||||||
let t = new Date();
|
|
||||||
t.setDate(t.getDate() + 1);
|
|
||||||
return t.toISOString().split('T')[0];
|
|
||||||
};
|
|
||||||
const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
||||||
const triggerEvent = (el, eventType, detail) =>
|
const triggerEvent = (el, eventType, detail) =>
|
||||||
el.dispatchEvent(new CustomEvent(eventType, { detail }));
|
el.dispatchEvent(new CustomEvent(eventType, { detail }));
|
||||||
@ -1342,6 +1325,23 @@ const unzipWith = (arr, fn) =>
|
|||||||
}).map(x => [])
|
}).map(x => [])
|
||||||
)
|
)
|
||||||
.map(val => fn(...val));
|
.map(val => fn(...val));
|
||||||
|
const URLJoin = (...args) =>
|
||||||
|
args
|
||||||
|
.join('/')
|
||||||
|
.replace(/[\/]+/g, '/')
|
||||||
|
.replace(/^(.+):\//, '$1://')
|
||||||
|
.replace(/^file:/, 'file:/')
|
||||||
|
.replace(/\/(\?|&|#[^!])/g, '$1')
|
||||||
|
.replace(/\?/g, '&')
|
||||||
|
.replace('&', '?');
|
||||||
|
const UUIDGeneratorBrowser = () =>
|
||||||
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
|
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
||||||
|
);
|
||||||
|
const UUIDGeneratorNode = () =>
|
||||||
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
|
(c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
||||||
|
);
|
||||||
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
||||||
const vectorDistance = (...coords) => {
|
const vectorDistance = (...coords) => {
|
||||||
let pointLength = Math.trunc(coords.length / 2);
|
let pointLength = Math.trunc(coords.length / 2);
|
||||||
@ -1376,5 +1376,169 @@ const zipWith = (...array) => {
|
|||||||
(_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))
|
(_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const binarySearch = (arr, val, start = 0, end = arr.length - 1) => {
|
||||||
|
if (start > end) return -1;
|
||||||
|
const mid = Math.floor((start + end) / 2);
|
||||||
|
if (arr[mid] > val) return binarySearch(arr, val, start, mid - 1);
|
||||||
|
if (arr[mid] < val) return binarySearch(arr, val, mid + 1, end);
|
||||||
|
return mid;
|
||||||
|
};
|
||||||
|
const celsiusToFahrenheit = degrees => 1.8 * degrees + 32;
|
||||||
|
const cleanObj = (obj, keysToKeep = [], childIndicator) => {
|
||||||
|
Object.keys(obj).forEach(key => {
|
||||||
|
if (key === childIndicator) {
|
||||||
|
cleanObj(obj[key], keysToKeep, childIndicator);
|
||||||
|
} else if (!keysToKeep.includes(key)) {
|
||||||
|
delete obj[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
const collatz = n => (n % 2 === 0 ? n / 2 : 3 * n + 1);
|
||||||
|
const countVowels = str => (str.match(/[aeiou]/gi) || []).length;
|
||||||
|
const factors = (num, primes = false) => {
|
||||||
|
const isPrime = num => {
|
||||||
|
const boundary = Math.floor(Math.sqrt(num));
|
||||||
|
for (var i = 2; i <= boundary; i++) if (num % i === 0) return false;
|
||||||
|
return num >= 2;
|
||||||
|
};
|
||||||
|
const isNeg = num < 0;
|
||||||
|
num = isNeg ? -num : num;
|
||||||
|
let array = Array.from({ length: num - 1 })
|
||||||
|
.map((val, i) => (num % (i + 2) === 0 ? i + 2 : false))
|
||||||
|
.filter(val => val);
|
||||||
|
if (isNeg)
|
||||||
|
array = array.reduce((acc, val) => {
|
||||||
|
acc.push(val);
|
||||||
|
acc.push(-val);
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
return primes ? array.filter(isPrime) : array;
|
||||||
|
};
|
||||||
|
const fahrenheitToCelsius = degrees => (degrees - 32) * 5/9;
|
||||||
|
const fibonacciCountUntilNum = num =>
|
||||||
|
Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2));
|
||||||
|
const fibonacciUntilNum = num => {
|
||||||
|
let n = Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2));
|
||||||
|
return Array.from({ length: n }).reduce(
|
||||||
|
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const heronArea = (side_a, side_b, side_c) => {
|
||||||
|
const p = (side_a + side_b + side_c) / 2;
|
||||||
|
return Math.sqrt(p * (p-side_a) * (p-side_b) * (p-side_c))
|
||||||
|
};
|
||||||
|
const howManyTimes = (num, divisor) => {
|
||||||
|
if (divisor === 1 || divisor === -1) return Infinity;
|
||||||
|
if (divisor === 0) return 0;
|
||||||
|
let i = 0;
|
||||||
|
while (Number.isInteger(num / divisor)) {
|
||||||
|
i++;
|
||||||
|
num = num / divisor;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
};
|
||||||
|
const httpDelete = (url, callback, err = console.error) => {
|
||||||
|
const request = new XMLHttpRequest();
|
||||||
|
request.open('DELETE', url, true);
|
||||||
|
request.onload = () => callback(request);
|
||||||
|
request.onerror = () => err(request);
|
||||||
|
request.send();
|
||||||
|
};
|
||||||
|
const httpPut = (url, data, callback, err = console.error) => {
|
||||||
|
const request = new XMLHttpRequest();
|
||||||
|
request.open("PUT", url, true);
|
||||||
|
request.setRequestHeader('Content-type','application/json; charset=utf-8');
|
||||||
|
request.onload = () => callback(request);
|
||||||
|
request.onerror = () => err(request);
|
||||||
|
request.send(data);
|
||||||
|
};
|
||||||
|
const isArmstrongNumber = digits =>
|
||||||
|
(arr => arr.reduce((a, d) => a + parseInt(d) ** arr.length, 0) == digits)(
|
||||||
|
(digits + '').split('')
|
||||||
|
);
|
||||||
|
const isSimilar = (pattern, str) =>
|
||||||
|
[...str].reduce(
|
||||||
|
(matchIndex, char) =>
|
||||||
|
char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase()
|
||||||
|
? matchIndex + 1
|
||||||
|
: matchIndex,
|
||||||
|
0
|
||||||
|
) === pattern.length;
|
||||||
|
const JSONToDate = arr => {
|
||||||
|
const dt = new Date(parseInt(arr.toString().substr(6)));
|
||||||
|
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
|
||||||
|
};
|
||||||
|
const kmphToMph = (kmph) => 0.621371192 * kmph;
|
||||||
|
const levenshteinDistance = (string1, string2) => {
|
||||||
|
if (string1.length === 0) return string2.length;
|
||||||
|
if (string2.length === 0) return string1.length;
|
||||||
|
let matrix = Array(string2.length + 1)
|
||||||
|
.fill(0)
|
||||||
|
.map((x, i) => [i]);
|
||||||
|
matrix[0] = Array(string1.length + 1)
|
||||||
|
.fill(0)
|
||||||
|
.map((x, i) => i);
|
||||||
|
for (let i = 1; i <= string2.length; i++) {
|
||||||
|
for (let j = 1; j <= string1.length; j++) {
|
||||||
|
if (string2[i - 1] === string1[j - 1]) {
|
||||||
|
matrix[i][j] = matrix[i - 1][j - 1];
|
||||||
|
} else {
|
||||||
|
matrix[i][j] = Math.min(
|
||||||
|
matrix[i - 1][j - 1] + 1,
|
||||||
|
matrix[i][j - 1] + 1,
|
||||||
|
matrix[i - 1][j] + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matrix[string2.length][string1.length];
|
||||||
|
};
|
||||||
|
const mphToKmph = (mph) => 1.6093440006146922 * mph;
|
||||||
|
const pipeLog = data => console.log(data) || data;
|
||||||
|
const quickSort = ([n, ...nums], desc) =>
|
||||||
|
isNaN(n)
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),
|
||||||
|
n,
|
||||||
|
...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc)
|
||||||
|
];
|
||||||
|
const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi, repl);
|
||||||
|
const solveRPN = rpn => {
|
||||||
|
const OPERATORS = {
|
||||||
|
'*': (a, b) => a * b,
|
||||||
|
'+': (a, b) => a + b,
|
||||||
|
'-': (a, b) => a - b,
|
||||||
|
'/': (a, b) => a / b,
|
||||||
|
'**': (a, b) => a ** b
|
||||||
|
};
|
||||||
|
const [stack, solve] = [
|
||||||
|
[],
|
||||||
|
rpn
|
||||||
|
.replace(/\^/g, '**')
|
||||||
|
.split(/\s+/g)
|
||||||
|
.filter(el => !/\s+/.test(el) && el !== '')
|
||||||
|
];
|
||||||
|
solve.forEach(symbol => {
|
||||||
|
if (!isNaN(parseFloat(symbol)) && isFinite(symbol)) {
|
||||||
|
stack.push(symbol);
|
||||||
|
} else if (Object.keys(OPERATORS).includes(symbol)) {
|
||||||
|
const [a, b] = [stack.pop(), stack.pop()];
|
||||||
|
stack.push(OPERATORS[symbol](parseFloat(b), parseFloat(a)));
|
||||||
|
} else {
|
||||||
|
throw `${symbol} is not a recognized symbol`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (stack.length === 1) return stack.pop();
|
||||||
|
else throw `${rpn} is not a proper RPN. Please check it and try again`;
|
||||||
|
};
|
||||||
|
const speechSynthesis = message => {
|
||||||
|
const msg = new SpeechSynthesisUtterance(message);
|
||||||
|
msg.voice = window.speechSynthesis.getVoices()[0];
|
||||||
|
window.speechSynthesis.speak(msg);
|
||||||
|
};
|
||||||
|
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0);
|
||||||
|
|
||||||
export { CSVToArray, CSVToJSON, JSONToFile, JSONtoCSV, RGBToHex, URLJoin, UUIDGeneratorBrowser, UUIDGeneratorNode, all, allEqual, any, approximatelyEqual, arrayToCSV, arrayToHtmlList, ary, atob, attempt, average, averageBy, bifurcate, bifurcateBy, bind, bindAll, bindKey, binomialCoefficient, bottomVisible, btoa, byteSize, call, capitalize, capitalizeEveryWord, castArray, chainAsync, checkProp, chunk, clampNumber, cloneRegExp, coalesce, coalesceFactory, collectInto, colorize, compact, compactWhitespace, compose, composeRight, converge, copyToClipboard, countBy, countOccurrences, counter, createDirIfNotExists, createElement, createEventHub, currentURL, curry, dayOfYear, debounce, decapitalize, deepClone, deepFlatten, deepFreeze, deepGet, deepMapKeys, defaults, defer, degreesToRads, delay, detectDeviceType, difference, differenceBy, differenceWith, dig, digitize, distance, drop, dropRight, dropRightWhile, dropWhile, elementContains, elementIsVisibleInViewport, elo, equals, escapeHTML, escapeRegExp, everyNth, extendHex, factorial, fibonacci, filterFalsy, filterNonUnique, filterNonUniqueBy, findKey, findLast, findLastIndex, findLastKey, flatten, flattenObject, flip, forEachRight, forOwn, forOwnRight, formToObject, formatDuration, fromCamelCase, functionName, functions, gcd, geometricProgression, get, getColonTimeFromDate, getDaysDiffBetweenDates, getImages, getMeridiemSuffixOfInteger, getScrollPosition, getStyle, getType, getURLParameters, groupBy, hammingDistance, hasClass, hasFlags, hashBrowser, hashNode, head, hexToRGB, hide, httpGet, httpPost, httpsRedirect, hz, inRange, indentString, indexOfAll, initial, initialize2DArray, initializeArrayWithRange, initializeArrayWithRangeRight, initializeArrayWithValues, initializeNDArray, insertAfter, insertBefore, intersection, intersectionBy, intersectionWith, invertKeyValues, is, isAbsoluteURL, isAfterDate, isAnagram, isArrayLike, isBeforeDate, isBoolean, isBrowser, isBrowserTabFocused, isDivisible, isDuplexStream, isEmpty, isEven, isFunction, isLowerCase, isNegativeZero, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isPrime, isPrimitive, isPromiseLike, isReadableStream, isSameDate, isSorted, isStream, isString, isSymbol, isTravisCI, isUndefined, isUpperCase, isValidJSON, isWeekday, isWeekend, isWritableStream, join, last, lcm, longestItem, lowercaseKeys, luhnCheck, mapKeys, mapNumRange, mapObject, mapString, mapValues, mask, matches, matchesWith, maxBy, maxDate, maxN, median, memoize, merge, midpoint, minBy, minDate, minN, mostPerformant, negate, nest, nodeListToArray, none, nthArg, nthElement, objectFromPairs, objectToPairs, observeMutations, off, offset, omit, omitBy, on, onUserInputChange, once, orderBy, over, overArgs, pad, palindrome, parseCookie, partial, partialRight, partition, percentile, permutations, pick, pickBy, pipeAsyncFunctions, pipeFunctions, pluralize, powerset, prefix, prettyBytes, primes, promisify, pull, pullAtIndex, pullAtValue, pullBy, radsToDegrees, randomHexColorCode, randomIntArrayInRange, randomIntegerInRange, randomNumberInRange, readFileLines, rearg, recordAnimationFrames, redirect, reduceSuccessive, reduceWhich, reducedFilter, reject, remove, removeNonASCII, renameKeys, reverseString, round, runAsync, runPromisesInSeries, sample, sampleSize, scrollToTop, sdbm, serializeCookie, serializeForm, setStyle, shallowClone, shank, show, shuffle, similarity, size, sleep, smoothScroll, sortCharactersInString, sortedIndex, sortedIndexBy, sortedLastIndex, sortedLastIndexBy, splitLines, spreadOver, stableSort, standardDeviation, stringPermutations, stripHTMLTags, sum, sumBy, sumPower, symmetricDifference, symmetricDifferenceBy, symmetricDifferenceWith, tail, take, takeRight, takeRightWhile, takeWhile, throttle, timeTaken, times, toCamelCase, toCurrency, toDecimalMark, toHash, toKebabCase, toOrdinalSuffix, toSafeInteger, toSnakeCase, toTitleCase, toggleClass, tomorrow, transform, triggerEvent, truncateString, truthCheckCollection, unary, uncurry, unescapeHTML, unflattenObject, unfold, union, unionBy, unionWith, uniqueElements, uniqueElementsBy, uniqueElementsByRight, uniqueSymmetricDifference, untildify, unzip, unzipWith, validateNumber, vectorDistance, when, without, words, xProd, yesNo, yesterday, zip, zipObject, zipWith };
|
export { all, allEqual, any, approximatelyEqual, arrayToCSV, arrayToHtmlList, ary, atob, attempt, average, averageBy, bifurcate, bifurcateBy, bind, bindAll, bindKey, binomialCoefficient, bottomVisible, btoa, byteSize, call, capitalize, capitalizeEveryWord, castArray, chainAsync, checkProp, chunk, clampNumber, cloneRegExp, coalesce, coalesceFactory, collectInto, colorize, compact, compactWhitespace, compose, composeRight, converge, copyToClipboard, countBy, counter, countOccurrences, createDirIfNotExists, createElement, createEventHub, CSVToArray, CSVToJSON, currentURL, curry, dayOfYear, debounce, decapitalize, deepClone, deepFlatten, deepFreeze, deepGet, deepMapKeys, defaults, defer, degreesToRads, delay, detectDeviceType, difference, differenceBy, differenceWith, dig, digitize, distance, drop, dropRight, dropRightWhile, dropWhile, elementContains, elementIsVisibleInViewport, elo, equals, escapeHTML, escapeRegExp, everyNth, extendHex, factorial, fibonacci, filterFalsy, filterNonUnique, filterNonUniqueBy, findKey, findLast, findLastIndex, findLastKey, flatten, flattenObject, flip, forEachRight, formatDuration, formToObject, forOwn, forOwnRight, fromCamelCase, functionName, functions, gcd, geometricProgression, get, getColonTimeFromDate, getDaysDiffBetweenDates, getImages, getMeridiemSuffixOfInteger, getScrollPosition, getStyle, getType, getURLParameters, groupBy, hammingDistance, hasClass, hasFlags, hashBrowser, hashNode, head, hexToRGB, hide, httpGet, httpPost, httpsRedirect, hz, indentString, indexOfAll, initial, initialize2DArray, initializeArrayWithRange, initializeArrayWithRangeRight, initializeArrayWithValues, initializeNDArray, inRange, insertAfter, insertBefore, intersection, intersectionBy, intersectionWith, invertKeyValues, is, isAbsoluteURL, isAfterDate, isAnagram, isArrayLike, isBeforeDate, isBoolean, isBrowser, isBrowserTabFocused, isDivisible, isDuplexStream, isEmpty, isEven, isFunction, isLowerCase, isNegativeZero, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isPrime, isPrimitive, isPromiseLike, isReadableStream, isSameDate, isSorted, isStream, isString, isSymbol, isTravisCI, isUndefined, isUpperCase, isValidJSON, isWeekday, isWeekend, isWritableStream, join, JSONtoCSV, JSONToFile, last, lcm, longestItem, lowercaseKeys, luhnCheck, mapKeys, mapNumRange, mapObject, mapString, mapValues, mask, matches, matchesWith, maxBy, maxDate, maxN, median, memoize, merge, midpoint, minBy, minDate, minN, mostPerformant, negate, nest, nodeListToArray, none, nthArg, nthElement, objectFromPairs, objectToPairs, observeMutations, off, offset, omit, omitBy, on, once, onUserInputChange, orderBy, over, overArgs, pad, palindrome, parseCookie, partial, partialRight, partition, percentile, permutations, pick, pickBy, pipeAsyncFunctions, pipeFunctions, pluralize, powerset, prefix, prettyBytes, primes, promisify, pull, pullAtIndex, pullAtValue, pullBy, radsToDegrees, randomHexColorCode, randomIntArrayInRange, randomIntegerInRange, randomNumberInRange, readFileLines, rearg, recordAnimationFrames, redirect, reducedFilter, reduceSuccessive, reduceWhich, reject, remove, removeNonASCII, renameKeys, reverseString, RGBToHex, round, runAsync, runPromisesInSeries, sample, sampleSize, scrollToTop, sdbm, serializeCookie, serializeForm, setStyle, shallowClone, shank, show, shuffle, similarity, size, sleep, smoothScroll, sortCharactersInString, sortedIndex, sortedIndexBy, sortedLastIndex, sortedLastIndexBy, splitLines, spreadOver, stableSort, standardDeviation, stringPermutations, stripHTMLTags, sum, sumBy, sumPower, symmetricDifference, symmetricDifferenceBy, symmetricDifferenceWith, tail, take, takeRight, takeRightWhile, takeWhile, throttle, times, timeTaken, toCamelCase, toCurrency, toDecimalMark, toggleClass, toHash, toKebabCase, tomorrow, toOrdinalSuffix, toSafeInteger, toSnakeCase, toTitleCase, transform, triggerEvent, truncateString, truthCheckCollection, unary, uncurry, unescapeHTML, unflattenObject, unfold, union, unionBy, unionWith, uniqueElements, uniqueElementsBy, uniqueElementsByRight, uniqueSymmetricDifference, untildify, unzip, unzipWith, URLJoin, UUIDGeneratorBrowser, UUIDGeneratorNode, validateNumber, vectorDistance, when, without, words, xProd, yesNo, yesterday, zip, zipObject, zipWith, binarySearch, celsiusToFahrenheit, cleanObj, collatz, countVowels, factors, fahrenheitToCelsius, fibonacciCountUntilNum, fibonacciUntilNum, heronArea, howManyTimes, httpDelete, httpPut, isArmstrongNumber, isSimilar, JSONToDate, kmphToMph, levenshteinDistance, mphToKmph, pipeLog, quickSort, removeVowels, solveRPN, speechSynthesis, squareSum };
|
||||||
|
|||||||
395
dist/_30s.js
vendored
395
dist/_30s.js
vendored
@ -1,57 +1,12 @@
|
|||||||
(function (global, factory) {
|
(function (global, factory) {
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||||
(factory((global._30s = {})));
|
(factory((global[''] = global[''] || {}, global['']['/_30s'] = {})));
|
||||||
}(this, (function (exports) { 'use strict';
|
}(this, (function (exports) { 'use strict';
|
||||||
|
|
||||||
const fs = typeof require !== "undefined" && require('fs');
|
const fs = typeof require !== "undefined" && require('fs');
|
||||||
const crypto = typeof require !== "undefined" && require('crypto');
|
const crypto = typeof require !== "undefined" && require('crypto');
|
||||||
|
|
||||||
const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>
|
|
||||||
data
|
|
||||||
.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0)
|
|
||||||
.split('\n')
|
|
||||||
.map(v => v.split(delimiter));
|
|
||||||
const CSVToJSON = (data, delimiter = ',') => {
|
|
||||||
const titles = data.slice(0, data.indexOf('\n')).split(delimiter);
|
|
||||||
return data
|
|
||||||
.slice(data.indexOf('\n') + 1)
|
|
||||||
.split('\n')
|
|
||||||
.map(v => {
|
|
||||||
const values = v.split(delimiter);
|
|
||||||
return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const JSONToFile = (obj, filename) =>
|
|
||||||
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
|
||||||
const JSONtoCSV = (arr, columns, delimiter = ',') =>
|
|
||||||
[
|
|
||||||
columns.join(delimiter),
|
|
||||||
...arr.map(obj =>
|
|
||||||
columns.reduce(
|
|
||||||
(acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`,
|
|
||||||
''
|
|
||||||
)
|
|
||||||
)
|
|
||||||
].join('\n');
|
|
||||||
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
|
||||||
const URLJoin = (...args) =>
|
|
||||||
args
|
|
||||||
.join('/')
|
|
||||||
.replace(/[\/]+/g, '/')
|
|
||||||
.replace(/^(.+):\//, '$1://')
|
|
||||||
.replace(/^file:/, 'file:/')
|
|
||||||
.replace(/\/(\?|&|#[^!])/g, '$1')
|
|
||||||
.replace(/\?/g, '&')
|
|
||||||
.replace('&', '?');
|
|
||||||
const UUIDGeneratorBrowser = () =>
|
|
||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
||||||
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
|
||||||
);
|
|
||||||
const UUIDGeneratorNode = () =>
|
|
||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
||||||
(c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
|
||||||
);
|
|
||||||
const all = (arr, fn = Boolean) => arr.every(fn);
|
const all = (arr, fn = Boolean) => arr.every(fn);
|
||||||
const allEqual = arr => arr.every(val => val === arr[0]);
|
const allEqual = arr => arr.every(val => val === arr[0]);
|
||||||
const any = (arr, fn = Boolean) => arr.some(fn);
|
const any = (arr, fn = Boolean) => arr.some(fn);
|
||||||
@ -178,7 +133,6 @@
|
|||||||
acc[val] = (acc[val] || 0) + 1;
|
acc[val] = (acc[val] || 0) + 1;
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
|
|
||||||
const counter = (selector, start, end, step = 1, duration = 2000) => {
|
const counter = (selector, start, end, step = 1, duration = 2000) => {
|
||||||
let current = start,
|
let current = start,
|
||||||
_step = (end - start) * step < 0 ? -step : step,
|
_step = (end - start) * step < 0 ? -step : step,
|
||||||
@ -190,6 +144,7 @@
|
|||||||
}, Math.abs(Math.floor(duration / (end - start))));
|
}, Math.abs(Math.floor(duration / (end - start))));
|
||||||
return timer;
|
return timer;
|
||||||
};
|
};
|
||||||
|
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
|
||||||
const createDirIfNotExists = dir => (!fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined);
|
const createDirIfNotExists = dir => (!fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined);
|
||||||
const createElement = str => {
|
const createElement = str => {
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
@ -211,6 +166,21 @@
|
|||||||
if (this.hub[event].length === 0) delete this.hub[event];
|
if (this.hub[event].length === 0) delete this.hub[event];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>
|
||||||
|
data
|
||||||
|
.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0)
|
||||||
|
.split('\n')
|
||||||
|
.map(v => v.split(delimiter));
|
||||||
|
const CSVToJSON = (data, delimiter = ',') => {
|
||||||
|
const titles = data.slice(0, data.indexOf('\n')).split(delimiter);
|
||||||
|
return data
|
||||||
|
.slice(data.indexOf('\n') + 1)
|
||||||
|
.split('\n')
|
||||||
|
.map(v => {
|
||||||
|
const values = v.split(delimiter);
|
||||||
|
return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});
|
||||||
|
});
|
||||||
|
};
|
||||||
const currentURL = () => window.location.href;
|
const currentURL = () => window.location.href;
|
||||||
const curry = (fn, arity = fn.length, ...args) =>
|
const curry = (fn, arity = fn.length, ...args) =>
|
||||||
arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
|
arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
|
||||||
@ -390,19 +360,6 @@
|
|||||||
.slice(0)
|
.slice(0)
|
||||||
.reverse()
|
.reverse()
|
||||||
.forEach(callback);
|
.forEach(callback);
|
||||||
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
|
||||||
const forOwnRight = (obj, fn) =>
|
|
||||||
Object.keys(obj)
|
|
||||||
.reverse()
|
|
||||||
.forEach(key => fn(obj[key], key, obj));
|
|
||||||
const formToObject = form =>
|
|
||||||
Array.from(new FormData(form)).reduce(
|
|
||||||
(acc, [key, value]) => ({
|
|
||||||
...acc,
|
|
||||||
[key]: value
|
|
||||||
}),
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
const formatDuration = ms => {
|
const formatDuration = ms => {
|
||||||
if (ms < 0) ms = -ms;
|
if (ms < 0) ms = -ms;
|
||||||
const time = {
|
const time = {
|
||||||
@ -417,6 +374,19 @@
|
|||||||
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
|
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
|
||||||
.join(', ');
|
.join(', ');
|
||||||
};
|
};
|
||||||
|
const formToObject = form =>
|
||||||
|
Array.from(new FormData(form)).reduce(
|
||||||
|
(acc, [key, value]) => ({
|
||||||
|
...acc,
|
||||||
|
[key]: value
|
||||||
|
}),
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
||||||
|
const forOwnRight = (obj, fn) =>
|
||||||
|
Object.keys(obj)
|
||||||
|
.reverse()
|
||||||
|
.forEach(key => fn(obj[key], key, obj));
|
||||||
const fromCamelCase = (str, separator = '_') =>
|
const fromCamelCase = (str, separator = '_') =>
|
||||||
str
|
str
|
||||||
.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
|
.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
|
||||||
@ -545,10 +515,6 @@
|
|||||||
for (let i = 0; i < iterations; i++) fn();
|
for (let i = 0; i < iterations; i++) fn();
|
||||||
return (1000 * iterations) / (performance.now() - before);
|
return (1000 * iterations) / (performance.now() - before);
|
||||||
};
|
};
|
||||||
const inRange = (n, start, end = null) => {
|
|
||||||
if (end && start > end) [end, start] = [start, end];
|
|
||||||
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
|
||||||
};
|
|
||||||
const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count));
|
const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count));
|
||||||
const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
|
const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
|
||||||
const initial = arr => arr.slice(0, -1);
|
const initial = arr => arr.slice(0, -1);
|
||||||
@ -565,6 +531,10 @@
|
|||||||
args.length === 0
|
args.length === 0
|
||||||
? val
|
? val
|
||||||
: Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1)));
|
: Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1)));
|
||||||
|
const inRange = (n, start, end = null) => {
|
||||||
|
if (end && start > end) [end, start] = [start, end];
|
||||||
|
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
||||||
|
};
|
||||||
const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString);
|
const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString);
|
||||||
const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString);
|
const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString);
|
||||||
const intersection = (a, b) => {
|
const intersection = (a, b) => {
|
||||||
@ -682,6 +652,18 @@
|
|||||||
: acc + val + separator,
|
: acc + val + separator,
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
const JSONtoCSV = (arr, columns, delimiter = ',') =>
|
||||||
|
[
|
||||||
|
columns.join(delimiter),
|
||||||
|
...arr.map(obj =>
|
||||||
|
columns.reduce(
|
||||||
|
(acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
)
|
||||||
|
].join('\n');
|
||||||
|
const JSONToFile = (obj, filename) =>
|
||||||
|
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
||||||
const last = arr => arr[arr.length - 1];
|
const last = arr => arr[arr.length - 1];
|
||||||
const lcm = (...arr) => {
|
const lcm = (...arr) => {
|
||||||
const gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
const gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
||||||
@ -816,6 +798,14 @@
|
|||||||
el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false);
|
el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false);
|
||||||
if (opts.target) return delegatorFn;
|
if (opts.target) return delegatorFn;
|
||||||
};
|
};
|
||||||
|
const once = fn => {
|
||||||
|
let called = false;
|
||||||
|
return function(...args) {
|
||||||
|
if (called) return;
|
||||||
|
called = true;
|
||||||
|
return fn.apply(this, args);
|
||||||
|
};
|
||||||
|
};
|
||||||
const onUserInputChange = callback => {
|
const onUserInputChange = callback => {
|
||||||
let type = 'mouse',
|
let type = 'mouse',
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
@ -830,14 +820,6 @@
|
|||||||
(type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);
|
(type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const once = fn => {
|
|
||||||
let called = false;
|
|
||||||
return function(...args) {
|
|
||||||
if (called) return;
|
|
||||||
called = true;
|
|
||||||
return fn.apply(this, args);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
const orderBy = (arr, props, orders) =>
|
const orderBy = (arr, props, orders) =>
|
||||||
[...arr].sort((a, b) =>
|
[...arr].sort((a, b) =>
|
||||||
props.reduce((acc, prop, i) => {
|
props.reduce((acc, prop, i) => {
|
||||||
@ -996,10 +978,6 @@
|
|||||||
};
|
};
|
||||||
const redirect = (url, asLink = true) =>
|
const redirect = (url, asLink = true) =>
|
||||||
asLink ? (window.location.href = url) : window.location.replace(url);
|
asLink ? (window.location.href = url) : window.location.replace(url);
|
||||||
const reduceSuccessive = (arr, fn, acc) =>
|
|
||||||
arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]);
|
|
||||||
const reduceWhich = (arr, comparator = (a, b) => a - b) =>
|
|
||||||
arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a));
|
|
||||||
const reducedFilter = (data, keys, fn) =>
|
const reducedFilter = (data, keys, fn) =>
|
||||||
data.filter(fn).map(el =>
|
data.filter(fn).map(el =>
|
||||||
keys.reduce((acc, key) => {
|
keys.reduce((acc, key) => {
|
||||||
@ -1007,6 +985,10 @@
|
|||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {})
|
||||||
);
|
);
|
||||||
|
const reduceSuccessive = (arr, fn, acc) =>
|
||||||
|
arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]);
|
||||||
|
const reduceWhich = (arr, comparator = (a, b) => a - b) =>
|
||||||
|
arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a));
|
||||||
const reject = (pred, array) => array.filter((...args) => !pred(...args));
|
const reject = (pred, array) => array.filter((...args) => !pred(...args));
|
||||||
const remove = (arr, func) =>
|
const remove = (arr, func) =>
|
||||||
Array.isArray(arr)
|
Array.isArray(arr)
|
||||||
@ -1025,6 +1007,7 @@
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
const reverseString = str => [...str].reverse().join('');
|
const reverseString = str => [...str].reverse().join('');
|
||||||
|
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
||||||
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
||||||
const runAsync = fn => {
|
const runAsync = fn => {
|
||||||
const worker = new Worker(
|
const worker = new Worker(
|
||||||
@ -1201,16 +1184,16 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
const times = (n, fn, context = undefined) => {
|
||||||
|
let i = 0;
|
||||||
|
while (fn.call(context, i) !== false && ++i < n) {}
|
||||||
|
};
|
||||||
const timeTaken = callback => {
|
const timeTaken = callback => {
|
||||||
console.time('timeTaken');
|
console.time('timeTaken');
|
||||||
const r = callback();
|
const r = callback();
|
||||||
console.timeEnd('timeTaken');
|
console.timeEnd('timeTaken');
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
const times = (n, fn, context = undefined) => {
|
|
||||||
let i = 0;
|
|
||||||
while (fn.call(context, i) !== false && ++i < n) {}
|
|
||||||
};
|
|
||||||
const toCamelCase = str => {
|
const toCamelCase = str => {
|
||||||
let s =
|
let s =
|
||||||
str &&
|
str &&
|
||||||
@ -1223,6 +1206,7 @@
|
|||||||
const toCurrency = (n, curr, LanguageFormat = undefined) =>
|
const toCurrency = (n, curr, LanguageFormat = undefined) =>
|
||||||
Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
|
Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
|
||||||
const toDecimalMark = num => num.toLocaleString('en-US');
|
const toDecimalMark = num => num.toLocaleString('en-US');
|
||||||
|
const toggleClass = (el, className) => el.classList.toggle(className);
|
||||||
const toHash = (object, key) =>
|
const toHash = (object, key) =>
|
||||||
Array.prototype.reduce.call(
|
Array.prototype.reduce.call(
|
||||||
object,
|
object,
|
||||||
@ -1235,6 +1219,11 @@
|
|||||||
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
||||||
.map(x => x.toLowerCase())
|
.map(x => x.toLowerCase())
|
||||||
.join('-');
|
.join('-');
|
||||||
|
const tomorrow = () => {
|
||||||
|
let t = new Date();
|
||||||
|
t.setDate(t.getDate() + 1);
|
||||||
|
return t.toISOString().split('T')[0];
|
||||||
|
};
|
||||||
const toOrdinalSuffix = num => {
|
const toOrdinalSuffix = num => {
|
||||||
const int = parseInt(num),
|
const int = parseInt(num),
|
||||||
digits = [int % 10, int % 100],
|
digits = [int % 10, int % 100],
|
||||||
@ -1258,12 +1247,6 @@
|
|||||||
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
||||||
.map(x => x.charAt(0).toUpperCase() + x.slice(1))
|
.map(x => x.charAt(0).toUpperCase() + x.slice(1))
|
||||||
.join(' ');
|
.join(' ');
|
||||||
const toggleClass = (el, className) => el.classList.toggle(className);
|
|
||||||
const tomorrow = () => {
|
|
||||||
let t = new Date();
|
|
||||||
t.setDate(t.getDate() + 1);
|
|
||||||
return t.toISOString().split('T')[0];
|
|
||||||
};
|
|
||||||
const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
||||||
const triggerEvent = (el, eventType, detail) =>
|
const triggerEvent = (el, eventType, detail) =>
|
||||||
el.dispatchEvent(new CustomEvent(eventType, { detail }));
|
el.dispatchEvent(new CustomEvent(eventType, { detail }));
|
||||||
@ -1348,6 +1331,23 @@
|
|||||||
}).map(x => [])
|
}).map(x => [])
|
||||||
)
|
)
|
||||||
.map(val => fn(...val));
|
.map(val => fn(...val));
|
||||||
|
const URLJoin = (...args) =>
|
||||||
|
args
|
||||||
|
.join('/')
|
||||||
|
.replace(/[\/]+/g, '/')
|
||||||
|
.replace(/^(.+):\//, '$1://')
|
||||||
|
.replace(/^file:/, 'file:/')
|
||||||
|
.replace(/\/(\?|&|#[^!])/g, '$1')
|
||||||
|
.replace(/\?/g, '&')
|
||||||
|
.replace('&', '?');
|
||||||
|
const UUIDGeneratorBrowser = () =>
|
||||||
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
|
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
||||||
|
);
|
||||||
|
const UUIDGeneratorNode = () =>
|
||||||
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
|
(c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
||||||
|
);
|
||||||
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
||||||
const vectorDistance = (...coords) => {
|
const vectorDistance = (...coords) => {
|
||||||
let pointLength = Math.trunc(coords.length / 2);
|
let pointLength = Math.trunc(coords.length / 2);
|
||||||
@ -1382,15 +1382,171 @@
|
|||||||
(_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))
|
(_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const binarySearch = (arr, val, start = 0, end = arr.length - 1) => {
|
||||||
|
if (start > end) return -1;
|
||||||
|
const mid = Math.floor((start + end) / 2);
|
||||||
|
if (arr[mid] > val) return binarySearch(arr, val, start, mid - 1);
|
||||||
|
if (arr[mid] < val) return binarySearch(arr, val, mid + 1, end);
|
||||||
|
return mid;
|
||||||
|
};
|
||||||
|
const celsiusToFahrenheit = degrees => 1.8 * degrees + 32;
|
||||||
|
const cleanObj = (obj, keysToKeep = [], childIndicator) => {
|
||||||
|
Object.keys(obj).forEach(key => {
|
||||||
|
if (key === childIndicator) {
|
||||||
|
cleanObj(obj[key], keysToKeep, childIndicator);
|
||||||
|
} else if (!keysToKeep.includes(key)) {
|
||||||
|
delete obj[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
const collatz = n => (n % 2 === 0 ? n / 2 : 3 * n + 1);
|
||||||
|
const countVowels = str => (str.match(/[aeiou]/gi) || []).length;
|
||||||
|
const factors = (num, primes = false) => {
|
||||||
|
const isPrime = num => {
|
||||||
|
const boundary = Math.floor(Math.sqrt(num));
|
||||||
|
for (var i = 2; i <= boundary; i++) if (num % i === 0) return false;
|
||||||
|
return num >= 2;
|
||||||
|
};
|
||||||
|
const isNeg = num < 0;
|
||||||
|
num = isNeg ? -num : num;
|
||||||
|
let array = Array.from({ length: num - 1 })
|
||||||
|
.map((val, i) => (num % (i + 2) === 0 ? i + 2 : false))
|
||||||
|
.filter(val => val);
|
||||||
|
if (isNeg)
|
||||||
|
array = array.reduce((acc, val) => {
|
||||||
|
acc.push(val);
|
||||||
|
acc.push(-val);
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
return primes ? array.filter(isPrime) : array;
|
||||||
|
};
|
||||||
|
const fahrenheitToCelsius = degrees => (degrees - 32) * 5/9;
|
||||||
|
const fibonacciCountUntilNum = num =>
|
||||||
|
Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2));
|
||||||
|
const fibonacciUntilNum = num => {
|
||||||
|
let n = Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2));
|
||||||
|
return Array.from({ length: n }).reduce(
|
||||||
|
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const heronArea = (side_a, side_b, side_c) => {
|
||||||
|
const p = (side_a + side_b + side_c) / 2;
|
||||||
|
return Math.sqrt(p * (p-side_a) * (p-side_b) * (p-side_c))
|
||||||
|
};
|
||||||
|
const howManyTimes = (num, divisor) => {
|
||||||
|
if (divisor === 1 || divisor === -1) return Infinity;
|
||||||
|
if (divisor === 0) return 0;
|
||||||
|
let i = 0;
|
||||||
|
while (Number.isInteger(num / divisor)) {
|
||||||
|
i++;
|
||||||
|
num = num / divisor;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
};
|
||||||
|
const httpDelete = (url, callback, err = console.error) => {
|
||||||
|
const request = new XMLHttpRequest();
|
||||||
|
request.open('DELETE', url, true);
|
||||||
|
request.onload = () => callback(request);
|
||||||
|
request.onerror = () => err(request);
|
||||||
|
request.send();
|
||||||
|
};
|
||||||
|
const httpPut = (url, data, callback, err = console.error) => {
|
||||||
|
const request = new XMLHttpRequest();
|
||||||
|
request.open("PUT", url, true);
|
||||||
|
request.setRequestHeader('Content-type','application/json; charset=utf-8');
|
||||||
|
request.onload = () => callback(request);
|
||||||
|
request.onerror = () => err(request);
|
||||||
|
request.send(data);
|
||||||
|
};
|
||||||
|
const isArmstrongNumber = digits =>
|
||||||
|
(arr => arr.reduce((a, d) => a + parseInt(d) ** arr.length, 0) == digits)(
|
||||||
|
(digits + '').split('')
|
||||||
|
);
|
||||||
|
const isSimilar = (pattern, str) =>
|
||||||
|
[...str].reduce(
|
||||||
|
(matchIndex, char) =>
|
||||||
|
char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase()
|
||||||
|
? matchIndex + 1
|
||||||
|
: matchIndex,
|
||||||
|
0
|
||||||
|
) === pattern.length;
|
||||||
|
const JSONToDate = arr => {
|
||||||
|
const dt = new Date(parseInt(arr.toString().substr(6)));
|
||||||
|
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
|
||||||
|
};
|
||||||
|
const kmphToMph = (kmph) => 0.621371192 * kmph;
|
||||||
|
const levenshteinDistance = (string1, string2) => {
|
||||||
|
if (string1.length === 0) return string2.length;
|
||||||
|
if (string2.length === 0) return string1.length;
|
||||||
|
let matrix = Array(string2.length + 1)
|
||||||
|
.fill(0)
|
||||||
|
.map((x, i) => [i]);
|
||||||
|
matrix[0] = Array(string1.length + 1)
|
||||||
|
.fill(0)
|
||||||
|
.map((x, i) => i);
|
||||||
|
for (let i = 1; i <= string2.length; i++) {
|
||||||
|
for (let j = 1; j <= string1.length; j++) {
|
||||||
|
if (string2[i - 1] === string1[j - 1]) {
|
||||||
|
matrix[i][j] = matrix[i - 1][j - 1];
|
||||||
|
} else {
|
||||||
|
matrix[i][j] = Math.min(
|
||||||
|
matrix[i - 1][j - 1] + 1,
|
||||||
|
matrix[i][j - 1] + 1,
|
||||||
|
matrix[i - 1][j] + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matrix[string2.length][string1.length];
|
||||||
|
};
|
||||||
|
const mphToKmph = (mph) => 1.6093440006146922 * mph;
|
||||||
|
const pipeLog = data => console.log(data) || data;
|
||||||
|
const quickSort = ([n, ...nums], desc) =>
|
||||||
|
isNaN(n)
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),
|
||||||
|
n,
|
||||||
|
...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc)
|
||||||
|
];
|
||||||
|
const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi, repl);
|
||||||
|
const solveRPN = rpn => {
|
||||||
|
const OPERATORS = {
|
||||||
|
'*': (a, b) => a * b,
|
||||||
|
'+': (a, b) => a + b,
|
||||||
|
'-': (a, b) => a - b,
|
||||||
|
'/': (a, b) => a / b,
|
||||||
|
'**': (a, b) => a ** b
|
||||||
|
};
|
||||||
|
const [stack, solve] = [
|
||||||
|
[],
|
||||||
|
rpn
|
||||||
|
.replace(/\^/g, '**')
|
||||||
|
.split(/\s+/g)
|
||||||
|
.filter(el => !/\s+/.test(el) && el !== '')
|
||||||
|
];
|
||||||
|
solve.forEach(symbol => {
|
||||||
|
if (!isNaN(parseFloat(symbol)) && isFinite(symbol)) {
|
||||||
|
stack.push(symbol);
|
||||||
|
} else if (Object.keys(OPERATORS).includes(symbol)) {
|
||||||
|
const [a, b] = [stack.pop(), stack.pop()];
|
||||||
|
stack.push(OPERATORS[symbol](parseFloat(b), parseFloat(a)));
|
||||||
|
} else {
|
||||||
|
throw `${symbol} is not a recognized symbol`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (stack.length === 1) return stack.pop();
|
||||||
|
else throw `${rpn} is not a proper RPN. Please check it and try again`;
|
||||||
|
};
|
||||||
|
const speechSynthesis = message => {
|
||||||
|
const msg = new SpeechSynthesisUtterance(message);
|
||||||
|
msg.voice = window.speechSynthesis.getVoices()[0];
|
||||||
|
window.speechSynthesis.speak(msg);
|
||||||
|
};
|
||||||
|
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0);
|
||||||
|
|
||||||
exports.CSVToArray = CSVToArray;
|
|
||||||
exports.CSVToJSON = CSVToJSON;
|
|
||||||
exports.JSONToFile = JSONToFile;
|
|
||||||
exports.JSONtoCSV = JSONtoCSV;
|
|
||||||
exports.RGBToHex = RGBToHex;
|
|
||||||
exports.URLJoin = URLJoin;
|
|
||||||
exports.UUIDGeneratorBrowser = UUIDGeneratorBrowser;
|
|
||||||
exports.UUIDGeneratorNode = UUIDGeneratorNode;
|
|
||||||
exports.all = all;
|
exports.all = all;
|
||||||
exports.allEqual = allEqual;
|
exports.allEqual = allEqual;
|
||||||
exports.any = any;
|
exports.any = any;
|
||||||
@ -1431,11 +1587,13 @@
|
|||||||
exports.converge = converge;
|
exports.converge = converge;
|
||||||
exports.copyToClipboard = copyToClipboard;
|
exports.copyToClipboard = copyToClipboard;
|
||||||
exports.countBy = countBy;
|
exports.countBy = countBy;
|
||||||
exports.countOccurrences = countOccurrences;
|
|
||||||
exports.counter = counter;
|
exports.counter = counter;
|
||||||
|
exports.countOccurrences = countOccurrences;
|
||||||
exports.createDirIfNotExists = createDirIfNotExists;
|
exports.createDirIfNotExists = createDirIfNotExists;
|
||||||
exports.createElement = createElement;
|
exports.createElement = createElement;
|
||||||
exports.createEventHub = createEventHub;
|
exports.createEventHub = createEventHub;
|
||||||
|
exports.CSVToArray = CSVToArray;
|
||||||
|
exports.CSVToJSON = CSVToJSON;
|
||||||
exports.currentURL = currentURL;
|
exports.currentURL = currentURL;
|
||||||
exports.curry = curry;
|
exports.curry = curry;
|
||||||
exports.dayOfYear = dayOfYear;
|
exports.dayOfYear = dayOfYear;
|
||||||
@ -1482,10 +1640,10 @@
|
|||||||
exports.flattenObject = flattenObject;
|
exports.flattenObject = flattenObject;
|
||||||
exports.flip = flip;
|
exports.flip = flip;
|
||||||
exports.forEachRight = forEachRight;
|
exports.forEachRight = forEachRight;
|
||||||
|
exports.formatDuration = formatDuration;
|
||||||
|
exports.formToObject = formToObject;
|
||||||
exports.forOwn = forOwn;
|
exports.forOwn = forOwn;
|
||||||
exports.forOwnRight = forOwnRight;
|
exports.forOwnRight = forOwnRight;
|
||||||
exports.formToObject = formToObject;
|
|
||||||
exports.formatDuration = formatDuration;
|
|
||||||
exports.fromCamelCase = fromCamelCase;
|
exports.fromCamelCase = fromCamelCase;
|
||||||
exports.functionName = functionName;
|
exports.functionName = functionName;
|
||||||
exports.functions = functions;
|
exports.functions = functions;
|
||||||
@ -1513,7 +1671,6 @@
|
|||||||
exports.httpPost = httpPost;
|
exports.httpPost = httpPost;
|
||||||
exports.httpsRedirect = httpsRedirect;
|
exports.httpsRedirect = httpsRedirect;
|
||||||
exports.hz = hz;
|
exports.hz = hz;
|
||||||
exports.inRange = inRange;
|
|
||||||
exports.indentString = indentString;
|
exports.indentString = indentString;
|
||||||
exports.indexOfAll = indexOfAll;
|
exports.indexOfAll = indexOfAll;
|
||||||
exports.initial = initial;
|
exports.initial = initial;
|
||||||
@ -1522,6 +1679,7 @@
|
|||||||
exports.initializeArrayWithRangeRight = initializeArrayWithRangeRight;
|
exports.initializeArrayWithRangeRight = initializeArrayWithRangeRight;
|
||||||
exports.initializeArrayWithValues = initializeArrayWithValues;
|
exports.initializeArrayWithValues = initializeArrayWithValues;
|
||||||
exports.initializeNDArray = initializeNDArray;
|
exports.initializeNDArray = initializeNDArray;
|
||||||
|
exports.inRange = inRange;
|
||||||
exports.insertAfter = insertAfter;
|
exports.insertAfter = insertAfter;
|
||||||
exports.insertBefore = insertBefore;
|
exports.insertBefore = insertBefore;
|
||||||
exports.intersection = intersection;
|
exports.intersection = intersection;
|
||||||
@ -1567,6 +1725,8 @@
|
|||||||
exports.isWeekend = isWeekend;
|
exports.isWeekend = isWeekend;
|
||||||
exports.isWritableStream = isWritableStream;
|
exports.isWritableStream = isWritableStream;
|
||||||
exports.join = join;
|
exports.join = join;
|
||||||
|
exports.JSONtoCSV = JSONtoCSV;
|
||||||
|
exports.JSONToFile = JSONToFile;
|
||||||
exports.last = last;
|
exports.last = last;
|
||||||
exports.lcm = lcm;
|
exports.lcm = lcm;
|
||||||
exports.longestItem = longestItem;
|
exports.longestItem = longestItem;
|
||||||
@ -1605,8 +1765,8 @@
|
|||||||
exports.omit = omit;
|
exports.omit = omit;
|
||||||
exports.omitBy = omitBy;
|
exports.omitBy = omitBy;
|
||||||
exports.on = on;
|
exports.on = on;
|
||||||
exports.onUserInputChange = onUserInputChange;
|
|
||||||
exports.once = once;
|
exports.once = once;
|
||||||
|
exports.onUserInputChange = onUserInputChange;
|
||||||
exports.orderBy = orderBy;
|
exports.orderBy = orderBy;
|
||||||
exports.over = over;
|
exports.over = over;
|
||||||
exports.overArgs = overArgs;
|
exports.overArgs = overArgs;
|
||||||
@ -1641,14 +1801,15 @@
|
|||||||
exports.rearg = rearg;
|
exports.rearg = rearg;
|
||||||
exports.recordAnimationFrames = recordAnimationFrames;
|
exports.recordAnimationFrames = recordAnimationFrames;
|
||||||
exports.redirect = redirect;
|
exports.redirect = redirect;
|
||||||
|
exports.reducedFilter = reducedFilter;
|
||||||
exports.reduceSuccessive = reduceSuccessive;
|
exports.reduceSuccessive = reduceSuccessive;
|
||||||
exports.reduceWhich = reduceWhich;
|
exports.reduceWhich = reduceWhich;
|
||||||
exports.reducedFilter = reducedFilter;
|
|
||||||
exports.reject = reject;
|
exports.reject = reject;
|
||||||
exports.remove = remove;
|
exports.remove = remove;
|
||||||
exports.removeNonASCII = removeNonASCII;
|
exports.removeNonASCII = removeNonASCII;
|
||||||
exports.renameKeys = renameKeys;
|
exports.renameKeys = renameKeys;
|
||||||
exports.reverseString = reverseString;
|
exports.reverseString = reverseString;
|
||||||
|
exports.RGBToHex = RGBToHex;
|
||||||
exports.round = round;
|
exports.round = round;
|
||||||
exports.runAsync = runAsync;
|
exports.runAsync = runAsync;
|
||||||
exports.runPromisesInSeries = runPromisesInSeries;
|
exports.runPromisesInSeries = runPromisesInSeries;
|
||||||
@ -1690,19 +1851,19 @@
|
|||||||
exports.takeRightWhile = takeRightWhile;
|
exports.takeRightWhile = takeRightWhile;
|
||||||
exports.takeWhile = takeWhile;
|
exports.takeWhile = takeWhile;
|
||||||
exports.throttle = throttle;
|
exports.throttle = throttle;
|
||||||
exports.timeTaken = timeTaken;
|
|
||||||
exports.times = times;
|
exports.times = times;
|
||||||
|
exports.timeTaken = timeTaken;
|
||||||
exports.toCamelCase = toCamelCase;
|
exports.toCamelCase = toCamelCase;
|
||||||
exports.toCurrency = toCurrency;
|
exports.toCurrency = toCurrency;
|
||||||
exports.toDecimalMark = toDecimalMark;
|
exports.toDecimalMark = toDecimalMark;
|
||||||
|
exports.toggleClass = toggleClass;
|
||||||
exports.toHash = toHash;
|
exports.toHash = toHash;
|
||||||
exports.toKebabCase = toKebabCase;
|
exports.toKebabCase = toKebabCase;
|
||||||
|
exports.tomorrow = tomorrow;
|
||||||
exports.toOrdinalSuffix = toOrdinalSuffix;
|
exports.toOrdinalSuffix = toOrdinalSuffix;
|
||||||
exports.toSafeInteger = toSafeInteger;
|
exports.toSafeInteger = toSafeInteger;
|
||||||
exports.toSnakeCase = toSnakeCase;
|
exports.toSnakeCase = toSnakeCase;
|
||||||
exports.toTitleCase = toTitleCase;
|
exports.toTitleCase = toTitleCase;
|
||||||
exports.toggleClass = toggleClass;
|
|
||||||
exports.tomorrow = tomorrow;
|
|
||||||
exports.transform = transform;
|
exports.transform = transform;
|
||||||
exports.triggerEvent = triggerEvent;
|
exports.triggerEvent = triggerEvent;
|
||||||
exports.truncateString = truncateString;
|
exports.truncateString = truncateString;
|
||||||
@ -1722,6 +1883,9 @@
|
|||||||
exports.untildify = untildify;
|
exports.untildify = untildify;
|
||||||
exports.unzip = unzip;
|
exports.unzip = unzip;
|
||||||
exports.unzipWith = unzipWith;
|
exports.unzipWith = unzipWith;
|
||||||
|
exports.URLJoin = URLJoin;
|
||||||
|
exports.UUIDGeneratorBrowser = UUIDGeneratorBrowser;
|
||||||
|
exports.UUIDGeneratorNode = UUIDGeneratorNode;
|
||||||
exports.validateNumber = validateNumber;
|
exports.validateNumber = validateNumber;
|
||||||
exports.vectorDistance = vectorDistance;
|
exports.vectorDistance = vectorDistance;
|
||||||
exports.when = when;
|
exports.when = when;
|
||||||
@ -1733,6 +1897,31 @@
|
|||||||
exports.zip = zip;
|
exports.zip = zip;
|
||||||
exports.zipObject = zipObject;
|
exports.zipObject = zipObject;
|
||||||
exports.zipWith = zipWith;
|
exports.zipWith = zipWith;
|
||||||
|
exports.binarySearch = binarySearch;
|
||||||
|
exports.celsiusToFahrenheit = celsiusToFahrenheit;
|
||||||
|
exports.cleanObj = cleanObj;
|
||||||
|
exports.collatz = collatz;
|
||||||
|
exports.countVowels = countVowels;
|
||||||
|
exports.factors = factors;
|
||||||
|
exports.fahrenheitToCelsius = fahrenheitToCelsius;
|
||||||
|
exports.fibonacciCountUntilNum = fibonacciCountUntilNum;
|
||||||
|
exports.fibonacciUntilNum = fibonacciUntilNum;
|
||||||
|
exports.heronArea = heronArea;
|
||||||
|
exports.howManyTimes = howManyTimes;
|
||||||
|
exports.httpDelete = httpDelete;
|
||||||
|
exports.httpPut = httpPut;
|
||||||
|
exports.isArmstrongNumber = isArmstrongNumber;
|
||||||
|
exports.isSimilar = isSimilar;
|
||||||
|
exports.JSONToDate = JSONToDate;
|
||||||
|
exports.kmphToMph = kmphToMph;
|
||||||
|
exports.levenshteinDistance = levenshteinDistance;
|
||||||
|
exports.mphToKmph = mphToKmph;
|
||||||
|
exports.pipeLog = pipeLog;
|
||||||
|
exports.quickSort = quickSort;
|
||||||
|
exports.removeVowels = removeVowels;
|
||||||
|
exports.solveRPN = solveRPN;
|
||||||
|
exports.speechSynthesis = speechSynthesis;
|
||||||
|
exports.squareSum = squareSum;
|
||||||
|
|
||||||
Object.defineProperty(exports, '__esModule', { value: true });
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
|||||||
271
package-lock.json
generated
271
package-lock.json
generated
@ -14,25 +14,145 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/core": {
|
"@babel/core": {
|
||||||
"version": "7.1.2",
|
"version": "7.5.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.5.5.tgz",
|
||||||
"integrity": "sha512-IFeSSnjXdhDaoysIlev//UzHZbdEmm7D0EIH2qtse9xK7mXEZQpYjs2P00XlP1qYsYvid79p+Zgg6tz1mp6iVw==",
|
"integrity": "sha512-i4qoSr2KTtce0DmkuuQBV4AuQgGPUcPXMr9L5MyYAtk06z068lQ10a4O009fe5OB/DfNV+h+qqT7ddNV8UnRjg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/code-frame": "^7.0.0",
|
"@babel/code-frame": "^7.5.5",
|
||||||
"@babel/generator": "^7.1.2",
|
"@babel/generator": "^7.5.5",
|
||||||
"@babel/helpers": "^7.1.2",
|
"@babel/helpers": "^7.5.5",
|
||||||
"@babel/parser": "^7.1.2",
|
"@babel/parser": "^7.5.5",
|
||||||
"@babel/template": "^7.1.2",
|
"@babel/template": "^7.4.4",
|
||||||
"@babel/traverse": "^7.1.0",
|
"@babel/traverse": "^7.5.5",
|
||||||
"@babel/types": "^7.1.2",
|
"@babel/types": "^7.5.5",
|
||||||
"convert-source-map": "^1.1.0",
|
"convert-source-map": "^1.1.0",
|
||||||
"debug": "^3.1.0",
|
"debug": "^4.1.0",
|
||||||
"json5": "^0.5.0",
|
"json5": "^2.1.0",
|
||||||
"lodash": "^4.17.10",
|
"lodash": "^4.17.13",
|
||||||
"resolve": "^1.3.2",
|
"resolve": "^1.3.2",
|
||||||
"semver": "^5.4.1",
|
"semver": "^5.4.1",
|
||||||
"source-map": "^0.5.0"
|
"source-map": "^0.5.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/code-frame": {
|
||||||
|
"version": "7.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
|
||||||
|
"integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/highlight": "^7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@babel/generator": {
|
||||||
|
"version": "7.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.5.tgz",
|
||||||
|
"integrity": "sha512-ETI/4vyTSxTzGnU2c49XHv2zhExkv9JHLTwDAFz85kmcwuShvYG2H08FwgIguQf4JC75CBnXAUM5PqeF4fj0nQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/types": "^7.5.5",
|
||||||
|
"jsesc": "^2.5.1",
|
||||||
|
"lodash": "^4.17.13",
|
||||||
|
"source-map": "^0.5.0",
|
||||||
|
"trim-right": "^1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@babel/helper-split-export-declaration": {
|
||||||
|
"version": "7.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz",
|
||||||
|
"integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/types": "^7.4.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@babel/parser": {
|
||||||
|
"version": "7.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz",
|
||||||
|
"integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"@babel/template": {
|
||||||
|
"version": "7.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz",
|
||||||
|
"integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/code-frame": "^7.0.0",
|
||||||
|
"@babel/parser": "^7.4.4",
|
||||||
|
"@babel/types": "^7.4.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@babel/traverse": {
|
||||||
|
"version": "7.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.5.tgz",
|
||||||
|
"integrity": "sha512-MqB0782whsfffYfSjH4TM+LMjrJnhCNEDMDIjeTpl+ASaUvxcjoiVCo/sM1GhS1pHOXYfWVCYneLjMckuUxDaQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/code-frame": "^7.5.5",
|
||||||
|
"@babel/generator": "^7.5.5",
|
||||||
|
"@babel/helper-function-name": "^7.1.0",
|
||||||
|
"@babel/helper-split-export-declaration": "^7.4.4",
|
||||||
|
"@babel/parser": "^7.5.5",
|
||||||
|
"@babel/types": "^7.5.5",
|
||||||
|
"debug": "^4.1.0",
|
||||||
|
"globals": "^11.1.0",
|
||||||
|
"lodash": "^4.17.13"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@babel/types": {
|
||||||
|
"version": "7.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz",
|
||||||
|
"integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"esutils": "^2.0.2",
|
||||||
|
"lodash": "^4.17.13",
|
||||||
|
"to-fast-properties": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"debug": {
|
||||||
|
"version": "4.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||||
|
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"ms": "^2.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"version": "11.12.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
|
||||||
|
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"jsesc": {
|
||||||
|
"version": "2.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
|
||||||
|
"integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"json5": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"minimist": "^1.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"to-fast-properties": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/generator": {
|
"@babel/generator": {
|
||||||
@ -641,14 +761,127 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/helpers": {
|
"@babel/helpers": {
|
||||||
"version": "7.1.2",
|
"version": "7.5.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.5.5.tgz",
|
||||||
"integrity": "sha512-Myc3pUE8eswD73aWcartxB16K6CGmHDv9KxOmD2CeOs/FaEAQodr3VYGmlvOmog60vNQ2w8QbatuahepZwrHiA==",
|
"integrity": "sha512-nRq2BUhxZFnfEn/ciJuhklHvFOqjJUD5wpx+1bxUF2axL9C+v4DE/dmp5sT2dKnpOs4orZWzpAZqlCy8QqE/7g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/template": "^7.1.2",
|
"@babel/template": "^7.4.4",
|
||||||
"@babel/traverse": "^7.1.0",
|
"@babel/traverse": "^7.5.5",
|
||||||
"@babel/types": "^7.1.2"
|
"@babel/types": "^7.5.5"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/generator": {
|
||||||
|
"version": "7.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.5.tgz",
|
||||||
|
"integrity": "sha512-ETI/4vyTSxTzGnU2c49XHv2zhExkv9JHLTwDAFz85kmcwuShvYG2H08FwgIguQf4JC75CBnXAUM5PqeF4fj0nQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/types": "^7.5.5",
|
||||||
|
"jsesc": "^2.5.1",
|
||||||
|
"lodash": "^4.17.13",
|
||||||
|
"source-map": "^0.5.0",
|
||||||
|
"trim-right": "^1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@babel/helper-split-export-declaration": {
|
||||||
|
"version": "7.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz",
|
||||||
|
"integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/types": "^7.4.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@babel/parser": {
|
||||||
|
"version": "7.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz",
|
||||||
|
"integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"@babel/template": {
|
||||||
|
"version": "7.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz",
|
||||||
|
"integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/code-frame": "^7.0.0",
|
||||||
|
"@babel/parser": "^7.4.4",
|
||||||
|
"@babel/types": "^7.4.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@babel/traverse": {
|
||||||
|
"version": "7.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.5.tgz",
|
||||||
|
"integrity": "sha512-MqB0782whsfffYfSjH4TM+LMjrJnhCNEDMDIjeTpl+ASaUvxcjoiVCo/sM1GhS1pHOXYfWVCYneLjMckuUxDaQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/code-frame": "^7.5.5",
|
||||||
|
"@babel/generator": "^7.5.5",
|
||||||
|
"@babel/helper-function-name": "^7.1.0",
|
||||||
|
"@babel/helper-split-export-declaration": "^7.4.4",
|
||||||
|
"@babel/parser": "^7.5.5",
|
||||||
|
"@babel/types": "^7.5.5",
|
||||||
|
"debug": "^4.1.0",
|
||||||
|
"globals": "^11.1.0",
|
||||||
|
"lodash": "^4.17.13"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/code-frame": {
|
||||||
|
"version": "7.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
|
||||||
|
"integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@babel/highlight": "^7.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@babel/types": {
|
||||||
|
"version": "7.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz",
|
||||||
|
"integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"esutils": "^2.0.2",
|
||||||
|
"lodash": "^4.17.13",
|
||||||
|
"to-fast-properties": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"debug": {
|
||||||
|
"version": "4.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||||
|
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"ms": "^2.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"version": "11.12.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
|
||||||
|
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"jsesc": {
|
||||||
|
"version": "2.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
|
||||||
|
"integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"to-fast-properties": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/highlight": {
|
"@babel/highlight": {
|
||||||
|
|||||||
@ -34,12 +34,13 @@
|
|||||||
"homepage": "https://30secondsofcode.org/",
|
"homepage": "https://30secondsofcode.org/",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.1.2",
|
"@babel/core": "^7.5.5",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.5.0",
|
"@babel/plugin-proposal-class-properties": "^7.5.0",
|
||||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||||
"@babel/preset-env": "^7.5.4",
|
"@babel/preset-env": "^7.5.4",
|
||||||
"@babel/preset-react": "^7.0.0",
|
"@babel/preset-react": "^7.0.0",
|
||||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
|
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
|
||||||
|
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||||
"codacy-coverage": "^3.2.0",
|
"codacy-coverage": "^3.2.0",
|
||||||
"eslint": "^5.7.0",
|
"eslint": "^5.7.0",
|
||||||
"front-matter": "^3.0.2",
|
"front-matter": "^3.0.2",
|
||||||
|
|||||||
@ -9,35 +9,22 @@ const util = require('./util');
|
|||||||
const { rollup } = require('rollup');
|
const { rollup } = require('rollup');
|
||||||
const babel = require('rollup-plugin-babel');
|
const babel = require('rollup-plugin-babel');
|
||||||
const minify = require('rollup-plugin-babel-minify');
|
const minify = require('rollup-plugin-babel-minify');
|
||||||
|
const config = require('../config');
|
||||||
|
|
||||||
const MODULE_NAME = '_30s';
|
const MODULE_NAME = `./${config.moduleName}`;
|
||||||
const SNIPPETS_PATH = './snippets';
|
const SNIPPETS_PATH = `./${config.snippetPath}`;
|
||||||
const SNIPPETS_ARCHIVE_PATH = './snippets_archive';
|
const SNIPPETS_ARCHIVE_PATH = `./${config.snippetArchivePath}`;
|
||||||
const DIST_PATH = './dist';
|
const DIST_PATH = `./${config.distPath}`;
|
||||||
const ROLLUP_INPUT_FILE = './imports.temp.js';
|
const ROLLUP_INPUT_FILE = `./${config.rollupInputFile}`;
|
||||||
const TEST_MODULE_FILE = './test/_30s.js';
|
const TEST_MODULE_FILE = `./${config.testModuleFile}`;
|
||||||
const CODE_RE = /```\s*js([\s\S]*?)```/;
|
const CODE_RE = /```\s*js([\s\S]*?)```/;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the raw markdown string.
|
|
||||||
*/
|
|
||||||
function getRawSnippetString(snippetPath, snippet) {
|
|
||||||
return fs.readFileSync(path.join(snippetPath, snippet), 'utf8');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the JavaScript code from the raw markdown string.
|
|
||||||
*/
|
|
||||||
function getCode(rawSnippetString) {
|
|
||||||
return rawSnippetString.match(CODE_RE)[1].replace('\n', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the UMD + ESM files to the ./dist directory.
|
* Builds the UMD + ESM files to the ./dist directory.
|
||||||
*/
|
*/
|
||||||
async function doRollup() {
|
async function doRollup() {
|
||||||
// Plugins
|
// Plugins
|
||||||
const es5 = babel({ presets: ['@babel/preset-env'] });
|
const es5 = babel({ presets: ['@babel/preset-env'], plugins: ['transform-object-rest-spread'] });
|
||||||
const min = minify({ comments: false });
|
const min = minify({ comments: false });
|
||||||
|
|
||||||
const output = format => file => ({
|
const output = format => file => ({
|
||||||
@ -83,37 +70,27 @@ async function build() {
|
|||||||
fs.writeFileSync(ROLLUP_INPUT_FILE, '');
|
fs.writeFileSync(ROLLUP_INPUT_FILE, '');
|
||||||
fs.writeFileSync(TEST_MODULE_FILE, '');
|
fs.writeFileSync(TEST_MODULE_FILE, '');
|
||||||
|
|
||||||
// All the snippets that are Node.js-based and will break in a browser
|
// Synchronously read all snippets from snippets folder and sort them as necessary (case-insensitive)
|
||||||
// environment
|
snippets = util.readSnippets(SNIPPETS_PATH);
|
||||||
const nodeSnippets = fs
|
snippetsArray = Object.keys(snippets).reduce((acc, key) => {
|
||||||
.readFileSync('tag_database', 'utf8')
|
acc.push(snippets[key]);
|
||||||
.split('\n')
|
return acc;
|
||||||
.filter(v => v.search(/:.*node/g) !== -1)
|
}, []);
|
||||||
.map(v => v.slice(0, v.indexOf(':')));
|
archivedSnippets = util.readSnippets(SNIPPETS_ARCHIVE_PATH);
|
||||||
|
archivedSnippetsArray = Object.keys(archivedSnippets).reduce((acc, key) => {
|
||||||
|
acc.push(archivedSnippets[key]);
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
const snippets = fs.readdirSync(SNIPPETS_PATH);
|
[...snippetsArray, ...archivedSnippetsArray].forEach(snippet => {
|
||||||
const archivedSnippets = fs
|
let code = `${snippet.attributes.codeBlocks.es6}\n`;
|
||||||
.readdirSync(SNIPPETS_ARCHIVE_PATH)
|
if(snippet.attributes.tags.includes('node')) {
|
||||||
.filter(v => v !== 'README.md');
|
|
||||||
|
|
||||||
snippets.forEach(snippet => {
|
|
||||||
const rawSnippetString = getRawSnippetString(SNIPPETS_PATH, snippet);
|
|
||||||
const snippetName = snippet.replace('.md', '');
|
|
||||||
let code = getCode(rawSnippetString);
|
|
||||||
if (nodeSnippets.includes(snippetName)) {
|
|
||||||
requires.push(code.match(/const.*=.*require\(([^\)]*)\);/g));
|
requires.push(code.match(/const.*=.*require\(([^\)]*)\);/g));
|
||||||
code = code.replace(/const.*=.*require\(([^\)]*)\);/g, '');
|
code = code.replace(/const.*=.*require\(([^\)]*)\);/g, '');
|
||||||
}
|
}
|
||||||
esmExportString += `export ${code}`;
|
esmExportString += `export ${code}`;
|
||||||
cjsExportString += code;
|
cjsExportString += code;
|
||||||
});
|
});
|
||||||
archivedSnippets.forEach(snippet => {
|
|
||||||
const rawSnippetString = getRawSnippetString(
|
|
||||||
SNIPPETS_ARCHIVE_PATH,
|
|
||||||
snippet
|
|
||||||
);
|
|
||||||
cjsExportString += getCode(rawSnippetString);
|
|
||||||
});
|
|
||||||
|
|
||||||
requires = [
|
requires = [
|
||||||
...new Set(
|
...new Set(
|
||||||
@ -130,8 +107,8 @@ async function build() {
|
|||||||
|
|
||||||
fs.writeFileSync(ROLLUP_INPUT_FILE, `${requires}\n\n${esmExportString}`);
|
fs.writeFileSync(ROLLUP_INPUT_FILE, `${requires}\n\n${esmExportString}`);
|
||||||
|
|
||||||
const testExports = `module.exports = {${[...snippets, ...archivedSnippets]
|
const testExports = `module.exports = {${[...snippetsArray, ...archivedSnippetsArray]
|
||||||
.map(v => v.replace('.md', ''))
|
.map(v => v.id)
|
||||||
.join(',')}}`;
|
.join(',')}}`;
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
|
|||||||
184
test/_30s.js
184
test/_30s.js
@ -1,53 +1,6 @@
|
|||||||
const fs = typeof require !== "undefined" && require('fs');
|
const fs = typeof require !== "undefined" && require('fs');
|
||||||
const crypto = typeof require !== "undefined" && require('crypto');
|
const crypto = typeof require !== "undefined" && require('crypto');
|
||||||
|
|
||||||
const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>
|
|
||||||
data
|
|
||||||
.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0)
|
|
||||||
.split('\n')
|
|
||||||
.map(v => v.split(delimiter));
|
|
||||||
const CSVToJSON = (data, delimiter = ',') => {
|
|
||||||
const titles = data.slice(0, data.indexOf('\n')).split(delimiter);
|
|
||||||
return data
|
|
||||||
.slice(data.indexOf('\n') + 1)
|
|
||||||
.split('\n')
|
|
||||||
.map(v => {
|
|
||||||
const values = v.split(delimiter);
|
|
||||||
return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const JSONToFile = (obj, filename) =>
|
|
||||||
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
|
||||||
const JSONtoCSV = (arr, columns, delimiter = ',') =>
|
|
||||||
[
|
|
||||||
columns.join(delimiter),
|
|
||||||
...arr.map(obj =>
|
|
||||||
columns.reduce(
|
|
||||||
(acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`,
|
|
||||||
''
|
|
||||||
)
|
|
||||||
)
|
|
||||||
].join('\n');
|
|
||||||
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
|
||||||
const URLJoin = (...args) =>
|
|
||||||
args
|
|
||||||
.join('/')
|
|
||||||
.replace(/[\/]+/g, '/')
|
|
||||||
.replace(/^(.+):\//, '$1://')
|
|
||||||
.replace(/^file:/, 'file:/')
|
|
||||||
.replace(/\/(\?|&|#[^!])/g, '$1')
|
|
||||||
.replace(/\?/g, '&')
|
|
||||||
.replace('&', '?');
|
|
||||||
const UUIDGeneratorBrowser = () =>
|
|
||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
||||||
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
|
||||||
);
|
|
||||||
|
|
||||||
const UUIDGeneratorNode = () =>
|
|
||||||
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
|
||||||
(c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
|
||||||
);
|
|
||||||
const all = (arr, fn = Boolean) => arr.every(fn);
|
const all = (arr, fn = Boolean) => arr.every(fn);
|
||||||
const allEqual = arr => arr.every(val => val === arr[0]);
|
const allEqual = arr => arr.every(val => val === arr[0]);
|
||||||
const any = (arr, fn = Boolean) => arr.some(fn);
|
const any = (arr, fn = Boolean) => arr.some(fn);
|
||||||
@ -174,7 +127,6 @@ const countBy = (arr, fn) =>
|
|||||||
acc[val] = (acc[val] || 0) + 1;
|
acc[val] = (acc[val] || 0) + 1;
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
|
|
||||||
const counter = (selector, start, end, step = 1, duration = 2000) => {
|
const counter = (selector, start, end, step = 1, duration = 2000) => {
|
||||||
let current = start,
|
let current = start,
|
||||||
_step = (end - start) * step < 0 ? -step : step,
|
_step = (end - start) * step < 0 ? -step : step,
|
||||||
@ -186,6 +138,7 @@ const counter = (selector, start, end, step = 1, duration = 2000) => {
|
|||||||
}, Math.abs(Math.floor(duration / (end - start))));
|
}, Math.abs(Math.floor(duration / (end - start))));
|
||||||
return timer;
|
return timer;
|
||||||
};
|
};
|
||||||
|
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);
|
||||||
|
|
||||||
const createDirIfNotExists = dir => (!fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined);
|
const createDirIfNotExists = dir => (!fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined);
|
||||||
const createElement = str => {
|
const createElement = str => {
|
||||||
@ -208,6 +161,21 @@ const createEventHub = () => ({
|
|||||||
if (this.hub[event].length === 0) delete this.hub[event];
|
if (this.hub[event].length === 0) delete this.hub[event];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>
|
||||||
|
data
|
||||||
|
.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0)
|
||||||
|
.split('\n')
|
||||||
|
.map(v => v.split(delimiter));
|
||||||
|
const CSVToJSON = (data, delimiter = ',') => {
|
||||||
|
const titles = data.slice(0, data.indexOf('\n')).split(delimiter);
|
||||||
|
return data
|
||||||
|
.slice(data.indexOf('\n') + 1)
|
||||||
|
.split('\n')
|
||||||
|
.map(v => {
|
||||||
|
const values = v.split(delimiter);
|
||||||
|
return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});
|
||||||
|
});
|
||||||
|
};
|
||||||
const currentURL = () => window.location.href;
|
const currentURL = () => window.location.href;
|
||||||
const curry = (fn, arity = fn.length, ...args) =>
|
const curry = (fn, arity = fn.length, ...args) =>
|
||||||
arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
|
arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
|
||||||
@ -387,19 +355,6 @@ const forEachRight = (arr, callback) =>
|
|||||||
.slice(0)
|
.slice(0)
|
||||||
.reverse()
|
.reverse()
|
||||||
.forEach(callback);
|
.forEach(callback);
|
||||||
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
|
||||||
const forOwnRight = (obj, fn) =>
|
|
||||||
Object.keys(obj)
|
|
||||||
.reverse()
|
|
||||||
.forEach(key => fn(obj[key], key, obj));
|
|
||||||
const formToObject = form =>
|
|
||||||
Array.from(new FormData(form)).reduce(
|
|
||||||
(acc, [key, value]) => ({
|
|
||||||
...acc,
|
|
||||||
[key]: value
|
|
||||||
}),
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
const formatDuration = ms => {
|
const formatDuration = ms => {
|
||||||
if (ms < 0) ms = -ms;
|
if (ms < 0) ms = -ms;
|
||||||
const time = {
|
const time = {
|
||||||
@ -414,6 +369,19 @@ const formatDuration = ms => {
|
|||||||
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
|
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
|
||||||
.join(', ');
|
.join(', ');
|
||||||
};
|
};
|
||||||
|
const formToObject = form =>
|
||||||
|
Array.from(new FormData(form)).reduce(
|
||||||
|
(acc, [key, value]) => ({
|
||||||
|
...acc,
|
||||||
|
[key]: value
|
||||||
|
}),
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
||||||
|
const forOwnRight = (obj, fn) =>
|
||||||
|
Object.keys(obj)
|
||||||
|
.reverse()
|
||||||
|
.forEach(key => fn(obj[key], key, obj));
|
||||||
const fromCamelCase = (str, separator = '_') =>
|
const fromCamelCase = (str, separator = '_') =>
|
||||||
str
|
str
|
||||||
.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
|
.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2')
|
||||||
@ -543,10 +511,6 @@ const hz = (fn, iterations = 100) => {
|
|||||||
for (let i = 0; i < iterations; i++) fn();
|
for (let i = 0; i < iterations; i++) fn();
|
||||||
return (1000 * iterations) / (performance.now() - before);
|
return (1000 * iterations) / (performance.now() - before);
|
||||||
};
|
};
|
||||||
const inRange = (n, start, end = null) => {
|
|
||||||
if (end && start > end) [end, start] = [start, end];
|
|
||||||
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
|
||||||
};
|
|
||||||
const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count));
|
const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count));
|
||||||
const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
|
const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
|
||||||
const initial = arr => arr.slice(0, -1);
|
const initial = arr => arr.slice(0, -1);
|
||||||
@ -563,6 +527,10 @@ const initializeNDArray = (val, ...args) =>
|
|||||||
args.length === 0
|
args.length === 0
|
||||||
? val
|
? val
|
||||||
: Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1)));
|
: Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1)));
|
||||||
|
const inRange = (n, start, end = null) => {
|
||||||
|
if (end && start > end) [end, start] = [start, end];
|
||||||
|
return end == null ? n >= 0 && n < start : n >= start && n < end;
|
||||||
|
};
|
||||||
const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString);
|
const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString);
|
||||||
const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString);
|
const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString);
|
||||||
const intersection = (a, b) => {
|
const intersection = (a, b) => {
|
||||||
@ -680,6 +648,19 @@ const join = (arr, separator = ',', end = separator) =>
|
|||||||
: acc + val + separator,
|
: acc + val + separator,
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
const JSONtoCSV = (arr, columns, delimiter = ',') =>
|
||||||
|
[
|
||||||
|
columns.join(delimiter),
|
||||||
|
...arr.map(obj =>
|
||||||
|
columns.reduce(
|
||||||
|
(acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
)
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
const JSONToFile = (obj, filename) =>
|
||||||
|
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
|
||||||
const last = arr => arr[arr.length - 1];
|
const last = arr => arr[arr.length - 1];
|
||||||
const lcm = (...arr) => {
|
const lcm = (...arr) => {
|
||||||
const gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
const gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
||||||
@ -814,6 +795,14 @@ const on = (el, evt, fn, opts = {}) => {
|
|||||||
el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false);
|
el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false);
|
||||||
if (opts.target) return delegatorFn;
|
if (opts.target) return delegatorFn;
|
||||||
};
|
};
|
||||||
|
const once = fn => {
|
||||||
|
let called = false;
|
||||||
|
return function(...args) {
|
||||||
|
if (called) return;
|
||||||
|
called = true;
|
||||||
|
return fn.apply(this, args);
|
||||||
|
};
|
||||||
|
};
|
||||||
const onUserInputChange = callback => {
|
const onUserInputChange = callback => {
|
||||||
let type = 'mouse',
|
let type = 'mouse',
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
@ -828,14 +817,6 @@ const onUserInputChange = callback => {
|
|||||||
(type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);
|
(type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const once = fn => {
|
|
||||||
let called = false;
|
|
||||||
return function(...args) {
|
|
||||||
if (called) return;
|
|
||||||
called = true;
|
|
||||||
return fn.apply(this, args);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
const orderBy = (arr, props, orders) =>
|
const orderBy = (arr, props, orders) =>
|
||||||
[...arr].sort((a, b) =>
|
[...arr].sort((a, b) =>
|
||||||
props.reduce((acc, prop, i) => {
|
props.reduce((acc, prop, i) => {
|
||||||
@ -995,10 +976,6 @@ const recordAnimationFrames = (callback, autoStart = true) => {
|
|||||||
};
|
};
|
||||||
const redirect = (url, asLink = true) =>
|
const redirect = (url, asLink = true) =>
|
||||||
asLink ? (window.location.href = url) : window.location.replace(url);
|
asLink ? (window.location.href = url) : window.location.replace(url);
|
||||||
const reduceSuccessive = (arr, fn, acc) =>
|
|
||||||
arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]);
|
|
||||||
const reduceWhich = (arr, comparator = (a, b) => a - b) =>
|
|
||||||
arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a));
|
|
||||||
const reducedFilter = (data, keys, fn) =>
|
const reducedFilter = (data, keys, fn) =>
|
||||||
data.filter(fn).map(el =>
|
data.filter(fn).map(el =>
|
||||||
keys.reduce((acc, key) => {
|
keys.reduce((acc, key) => {
|
||||||
@ -1006,6 +983,10 @@ const reducedFilter = (data, keys, fn) =>
|
|||||||
return acc;
|
return acc;
|
||||||
}, {})
|
}, {})
|
||||||
);
|
);
|
||||||
|
const reduceSuccessive = (arr, fn, acc) =>
|
||||||
|
arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]);
|
||||||
|
const reduceWhich = (arr, comparator = (a, b) => a - b) =>
|
||||||
|
arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a));
|
||||||
const reject = (pred, array) => array.filter((...args) => !pred(...args));
|
const reject = (pred, array) => array.filter((...args) => !pred(...args));
|
||||||
const remove = (arr, func) =>
|
const remove = (arr, func) =>
|
||||||
Array.isArray(arr)
|
Array.isArray(arr)
|
||||||
@ -1024,6 +1005,7 @@ const renameKeys = (keysMap, obj) =>
|
|||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
const reverseString = str => [...str].reverse().join('');
|
const reverseString = str => [...str].reverse().join('');
|
||||||
|
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
|
||||||
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
||||||
const runAsync = fn => {
|
const runAsync = fn => {
|
||||||
const worker = new Worker(
|
const worker = new Worker(
|
||||||
@ -1200,16 +1182,16 @@ const throttle = (fn, wait) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
const times = (n, fn, context = undefined) => {
|
||||||
|
let i = 0;
|
||||||
|
while (fn.call(context, i) !== false && ++i < n) {}
|
||||||
|
};
|
||||||
const timeTaken = callback => {
|
const timeTaken = callback => {
|
||||||
console.time('timeTaken');
|
console.time('timeTaken');
|
||||||
const r = callback();
|
const r = callback();
|
||||||
console.timeEnd('timeTaken');
|
console.timeEnd('timeTaken');
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
const times = (n, fn, context = undefined) => {
|
|
||||||
let i = 0;
|
|
||||||
while (fn.call(context, i) !== false && ++i < n) {}
|
|
||||||
};
|
|
||||||
const toCamelCase = str => {
|
const toCamelCase = str => {
|
||||||
let s =
|
let s =
|
||||||
str &&
|
str &&
|
||||||
@ -1222,6 +1204,7 @@ const toCamelCase = str => {
|
|||||||
const toCurrency = (n, curr, LanguageFormat = undefined) =>
|
const toCurrency = (n, curr, LanguageFormat = undefined) =>
|
||||||
Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
|
Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
|
||||||
const toDecimalMark = num => num.toLocaleString('en-US');
|
const toDecimalMark = num => num.toLocaleString('en-US');
|
||||||
|
const toggleClass = (el, className) => el.classList.toggle(className);
|
||||||
const toHash = (object, key) =>
|
const toHash = (object, key) =>
|
||||||
Array.prototype.reduce.call(
|
Array.prototype.reduce.call(
|
||||||
object,
|
object,
|
||||||
@ -1234,6 +1217,11 @@ const toKebabCase = str =>
|
|||||||
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
||||||
.map(x => x.toLowerCase())
|
.map(x => x.toLowerCase())
|
||||||
.join('-');
|
.join('-');
|
||||||
|
const tomorrow = () => {
|
||||||
|
let t = new Date();
|
||||||
|
t.setDate(t.getDate() + 1);
|
||||||
|
return t.toISOString().split('T')[0];
|
||||||
|
};
|
||||||
const toOrdinalSuffix = num => {
|
const toOrdinalSuffix = num => {
|
||||||
const int = parseInt(num),
|
const int = parseInt(num),
|
||||||
digits = [int % 10, int % 100],
|
digits = [int % 10, int % 100],
|
||||||
@ -1257,12 +1245,6 @@ const toTitleCase = str =>
|
|||||||
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
||||||
.map(x => x.charAt(0).toUpperCase() + x.slice(1))
|
.map(x => x.charAt(0).toUpperCase() + x.slice(1))
|
||||||
.join(' ');
|
.join(' ');
|
||||||
const toggleClass = (el, className) => el.classList.toggle(className);
|
|
||||||
const tomorrow = () => {
|
|
||||||
let t = new Date();
|
|
||||||
t.setDate(t.getDate() + 1);
|
|
||||||
return t.toISOString().split('T')[0];
|
|
||||||
};
|
|
||||||
const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
||||||
const triggerEvent = (el, eventType, detail) =>
|
const triggerEvent = (el, eventType, detail) =>
|
||||||
el.dispatchEvent(new CustomEvent(eventType, { detail }));
|
el.dispatchEvent(new CustomEvent(eventType, { detail }));
|
||||||
@ -1347,6 +1329,24 @@ const unzipWith = (arr, fn) =>
|
|||||||
}).map(x => [])
|
}).map(x => [])
|
||||||
)
|
)
|
||||||
.map(val => fn(...val));
|
.map(val => fn(...val));
|
||||||
|
const URLJoin = (...args) =>
|
||||||
|
args
|
||||||
|
.join('/')
|
||||||
|
.replace(/[\/]+/g, '/')
|
||||||
|
.replace(/^(.+):\//, '$1://')
|
||||||
|
.replace(/^file:/, 'file:/')
|
||||||
|
.replace(/\/(\?|&|#[^!])/g, '$1')
|
||||||
|
.replace(/\?/g, '&')
|
||||||
|
.replace('&', '?');
|
||||||
|
const UUIDGeneratorBrowser = () =>
|
||||||
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
|
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
||||||
|
);
|
||||||
|
|
||||||
|
const UUIDGeneratorNode = () =>
|
||||||
|
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
|
(c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
|
||||||
|
);
|
||||||
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
|
||||||
const vectorDistance = (...coords) => {
|
const vectorDistance = (...coords) => {
|
||||||
let pointLength = Math.trunc(coords.length / 2);
|
let pointLength = Math.trunc(coords.length / 2);
|
||||||
@ -1381,10 +1381,6 @@ const zipWith = (...array) => {
|
|||||||
(_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))
|
(_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i]))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const JSONToDate = arr => {
|
|
||||||
const dt = new Date(parseInt(arr.toString().substr(6)));
|
|
||||||
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
|
|
||||||
};
|
|
||||||
const binarySearch = (arr, val, start = 0, end = arr.length - 1) => {
|
const binarySearch = (arr, val, start = 0, end = arr.length - 1) => {
|
||||||
if (start > end) return -1;
|
if (start > end) return -1;
|
||||||
const mid = Math.floor((start + end) / 2);
|
const mid = Math.floor((start + end) / 2);
|
||||||
@ -1475,6 +1471,10 @@ const isSimilar = (pattern, str) =>
|
|||||||
: matchIndex,
|
: matchIndex,
|
||||||
0
|
0
|
||||||
) === pattern.length;
|
) === pattern.length;
|
||||||
|
const JSONToDate = arr => {
|
||||||
|
const dt = new Date(parseInt(arr.toString().substr(6)));
|
||||||
|
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
|
||||||
|
};
|
||||||
const kmphToMph = (kmph) => 0.621371192 * kmph;
|
const kmphToMph = (kmph) => 0.621371192 * kmph;
|
||||||
const levenshteinDistance = (string1, string2) => {
|
const levenshteinDistance = (string1, string2) => {
|
||||||
if (string1.length === 0) return string2.length;
|
if (string1.length === 0) return string2.length;
|
||||||
@ -1547,4 +1547,4 @@ const speechSynthesis = message => {
|
|||||||
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0);
|
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0);
|
||||||
|
|
||||||
|
|
||||||
module.exports = {CSVToArray,CSVToJSON,JSONToFile,JSONtoCSV,RGBToHex,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,all,allEqual,any,approximatelyEqual,arrayToCSV,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,checkProp,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compactWhitespace,compose,composeRight,converge,copyToClipboard,countBy,countOccurrences,counter,createDirIfNotExists,createElement,createEventHub,currentURL,curry,dayOfYear,debounce,decapitalize,deepClone,deepFlatten,deepFreeze,deepGet,deepMapKeys,defaults,defer,degreesToRads,delay,detectDeviceType,difference,differenceBy,differenceWith,dig,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementContains,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterFalsy,filterNonUnique,filterNonUniqueBy,findKey,findLast,findLastIndex,findLastKey,flatten,flattenObject,flip,forEachRight,forOwn,forOwnRight,formToObject,formatDuration,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getImages,getMeridiemSuffixOfInteger,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,hz,inRange,indentString,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,initializeNDArray,insertAfter,insertBefore,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isAfterDate,isAnagram,isArrayLike,isBeforeDate,isBoolean,isBrowser,isBrowserTabFocused,isDivisible,isDuplexStream,isEmpty,isEven,isFunction,isLowerCase,isNegativeZero,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isReadableStream,isSameDate,isSorted,isStream,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,isWeekday,isWeekend,isWritableStream,join,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapNumRange,mapObject,mapString,mapValues,mask,matches,matchesWith,maxBy,maxDate,maxN,median,memoize,merge,midpoint,minBy,minDate,minN,mostPerformant,negate,nest,nodeListToArray,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,offset,omit,omitBy,on,onUserInputChange,once,orderBy,over,overArgs,pad,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prefix,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,recordAnimationFrames,redirect,reduceSuccessive,reduceWhich,reducedFilter,reject,remove,removeNonASCII,renameKeys,reverseString,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,serializeForm,setStyle,shallowClone,shank,show,shuffle,similarity,size,sleep,smoothScroll,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,timeTaken,times,toCamelCase,toCurrency,toDecimalMark,toHash,toKebabCase,toOrdinalSuffix,toSafeInteger,toSnakeCase,toTitleCase,toggleClass,tomorrow,transform,triggerEvent,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,uniqueElementsBy,uniqueElementsByRight,uniqueSymmetricDifference,untildify,unzip,unzipWith,validateNumber,vectorDistance,when,without,words,xProd,yesNo,yesterday,zip,zipObject,zipWith,JSONToDate,binarySearch,celsiusToFahrenheit,cleanObj,collatz,countVowels,factors,fahrenheitToCelsius,fibonacciCountUntilNum,fibonacciUntilNum,heronArea,howManyTimes,httpDelete,httpPut,isArmstrongNumber,isSimilar,kmphToMph,levenshteinDistance,mphToKmph,pipeLog,quickSort,removeVowels,solveRPN,speechSynthesis,squareSum}
|
module.exports = {all,allEqual,any,approximatelyEqual,arrayToCSV,arrayToHtmlList,ary,atob,attempt,average,averageBy,bifurcate,bifurcateBy,bind,bindAll,bindKey,binomialCoefficient,bottomVisible,btoa,byteSize,call,capitalize,capitalizeEveryWord,castArray,chainAsync,checkProp,chunk,clampNumber,cloneRegExp,coalesce,coalesceFactory,collectInto,colorize,compact,compactWhitespace,compose,composeRight,converge,copyToClipboard,countBy,counter,countOccurrences,createDirIfNotExists,createElement,createEventHub,CSVToArray,CSVToJSON,currentURL,curry,dayOfYear,debounce,decapitalize,deepClone,deepFlatten,deepFreeze,deepGet,deepMapKeys,defaults,defer,degreesToRads,delay,detectDeviceType,difference,differenceBy,differenceWith,dig,digitize,distance,drop,dropRight,dropRightWhile,dropWhile,elementContains,elementIsVisibleInViewport,elo,equals,escapeHTML,escapeRegExp,everyNth,extendHex,factorial,fibonacci,filterFalsy,filterNonUnique,filterNonUniqueBy,findKey,findLast,findLastIndex,findLastKey,flatten,flattenObject,flip,forEachRight,formatDuration,formToObject,forOwn,forOwnRight,fromCamelCase,functionName,functions,gcd,geometricProgression,get,getColonTimeFromDate,getDaysDiffBetweenDates,getImages,getMeridiemSuffixOfInteger,getScrollPosition,getStyle,getType,getURLParameters,groupBy,hammingDistance,hasClass,hasFlags,hashBrowser,hashNode,head,hexToRGB,hide,httpGet,httpPost,httpsRedirect,hz,indentString,indexOfAll,initial,initialize2DArray,initializeArrayWithRange,initializeArrayWithRangeRight,initializeArrayWithValues,initializeNDArray,inRange,insertAfter,insertBefore,intersection,intersectionBy,intersectionWith,invertKeyValues,is,isAbsoluteURL,isAfterDate,isAnagram,isArrayLike,isBeforeDate,isBoolean,isBrowser,isBrowserTabFocused,isDivisible,isDuplexStream,isEmpty,isEven,isFunction,isLowerCase,isNegativeZero,isNil,isNull,isNumber,isObject,isObjectLike,isPlainObject,isPrime,isPrimitive,isPromiseLike,isReadableStream,isSameDate,isSorted,isStream,isString,isSymbol,isTravisCI,isUndefined,isUpperCase,isValidJSON,isWeekday,isWeekend,isWritableStream,join,JSONtoCSV,JSONToFile,last,lcm,longestItem,lowercaseKeys,luhnCheck,mapKeys,mapNumRange,mapObject,mapString,mapValues,mask,matches,matchesWith,maxBy,maxDate,maxN,median,memoize,merge,midpoint,minBy,minDate,minN,mostPerformant,negate,nest,nodeListToArray,none,nthArg,nthElement,objectFromPairs,objectToPairs,observeMutations,off,offset,omit,omitBy,on,once,onUserInputChange,orderBy,over,overArgs,pad,palindrome,parseCookie,partial,partialRight,partition,percentile,permutations,pick,pickBy,pipeAsyncFunctions,pipeFunctions,pluralize,powerset,prefix,prettyBytes,primes,promisify,pull,pullAtIndex,pullAtValue,pullBy,radsToDegrees,randomHexColorCode,randomIntArrayInRange,randomIntegerInRange,randomNumberInRange,readFileLines,rearg,recordAnimationFrames,redirect,reducedFilter,reduceSuccessive,reduceWhich,reject,remove,removeNonASCII,renameKeys,reverseString,RGBToHex,round,runAsync,runPromisesInSeries,sample,sampleSize,scrollToTop,sdbm,serializeCookie,serializeForm,setStyle,shallowClone,shank,show,shuffle,similarity,size,sleep,smoothScroll,sortCharactersInString,sortedIndex,sortedIndexBy,sortedLastIndex,sortedLastIndexBy,splitLines,spreadOver,stableSort,standardDeviation,stringPermutations,stripHTMLTags,sum,sumBy,sumPower,symmetricDifference,symmetricDifferenceBy,symmetricDifferenceWith,tail,take,takeRight,takeRightWhile,takeWhile,throttle,times,timeTaken,toCamelCase,toCurrency,toDecimalMark,toggleClass,toHash,toKebabCase,tomorrow,toOrdinalSuffix,toSafeInteger,toSnakeCase,toTitleCase,transform,triggerEvent,truncateString,truthCheckCollection,unary,uncurry,unescapeHTML,unflattenObject,unfold,union,unionBy,unionWith,uniqueElements,uniqueElementsBy,uniqueElementsByRight,uniqueSymmetricDifference,untildify,unzip,unzipWith,URLJoin,UUIDGeneratorBrowser,UUIDGeneratorNode,validateNumber,vectorDistance,when,without,words,xProd,yesNo,yesterday,zip,zipObject,zipWith,binarySearch,celsiusToFahrenheit,cleanObj,collatz,countVowels,factors,fahrenheitToCelsius,fibonacciCountUntilNum,fibonacciUntilNum,heronArea,howManyTimes,httpDelete,httpPut,isArmstrongNumber,isSimilar,JSONToDate,kmphToMph,levenshteinDistance,mphToKmph,pipeLog,quickSort,removeVowels,solveRPN,speechSynthesis,squareSum}
|
||||||
Reference in New Issue
Block a user