Travis build: 1014 [cron]

This commit is contained in:
30secondsofcode
2019-02-23 15:09:00 +00:00
parent 240e38b4a0
commit 2a5d58b801
7 changed files with 495 additions and 450 deletions

450
dist/_30s.es5.js vendored
View File

@ -118,6 +118,54 @@
var crypto = typeof require !== "undefined" && require('crypto'); var crypto = typeof require !== "undefined" && require('crypto');
var CSVToArray = function CSVToArray(data) {
var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
var omitFirstRow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
return data.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0).split('\n').map(function (v) {
return v.split(delimiter);
});
};
var CSVToJSON = function CSVToJSON(data) {
var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
var titles = data.slice(0, data.indexOf('\n')).split(delimiter);
return data.slice(data.indexOf('\n') + 1).split('\n').map(function (v) {
var values = v.split(delimiter);
return titles.reduce(function (obj, title, index) {
return obj[title] = values[index], obj;
}, {});
});
};
var JSONToFile = function JSONToFile(obj, filename) {
return fs.writeFile("".concat(filename, ".json"), JSON.stringify(obj, null, 2));
};
var JSONtoCSV = function JSONtoCSV(arr, columns) {
var delimiter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ',';
return [columns.join(delimiter)].concat(_toConsumableArray(arr.map(function (obj) {
return columns.reduce(function (acc, key) {
return "".concat(acc).concat(!acc.length ? '' : delimiter, "\"").concat(!obj[key] ? '' : obj[key], "\"");
}, '');
}))).join('\n');
};
var RGBToHex = function RGBToHex(r, g, b) {
return ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
};
var URLJoin = function URLJoin() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args.join('/').replace(/[\/]+/g, '/').replace(/^(.+):\//, '$1://').replace(/^file:/, 'file:/').replace(/\/(\?|&|#[^!])/g, '$1').replace(/\?/g, '&').replace('&', '?');
};
var UUIDGeneratorBrowser = function UUIDGeneratorBrowser() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
});
};
var UUIDGeneratorNode = function UUIDGeneratorNode() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
return (c ^ crypto.randomBytes(1)[0] & 15 >> c / 4).toString(16);
});
};
var all = function all(arr) { var all = function all(arr) {
var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Boolean; var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Boolean;
return arr.every(fn); return arr.every(fn);
@ -152,8 +200,8 @@
}; };
var ary = function ary(fn, n) { var ary = function ary(fn, n) {
return function () { return function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key] = arguments[_key]; args[_key2] = arguments[_key2];
} }
return fn.apply(void 0, _toConsumableArray(args.slice(0, n))); return fn.apply(void 0, _toConsumableArray(args.slice(0, n)));
@ -164,8 +212,8 @@
}; };
var attempt = function attempt(fn) { var attempt = function attempt(fn) {
try { try {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key2 - 1] = arguments[_key2]; args[_key3 - 1] = arguments[_key3];
} }
return fn.apply(void 0, args); return fn.apply(void 0, args);
@ -174,8 +222,8 @@
} }
}; };
var average = function average() { var average = function average() {
for (var _len3 = arguments.length, nums = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { for (var _len4 = arguments.length, nums = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
nums[_key3] = arguments[_key3]; nums[_key4] = arguments[_key4];
} }
return nums.reduce(function (acc, val) { return nums.reduce(function (acc, val) {
@ -200,21 +248,21 @@
}, [[], []]); }, [[], []]);
}; };
var bind = function bind(fn, context) { var bind = function bind(fn, context) {
for (var _len4 = arguments.length, boundArgs = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) { for (var _len5 = arguments.length, boundArgs = new Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) {
boundArgs[_key4 - 2] = arguments[_key4]; boundArgs[_key5 - 2] = arguments[_key5];
} }
return function () { return function () {
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key5] = arguments[_key5]; args[_key6] = arguments[_key6];
} }
return fn.apply(context, boundArgs.concat(args)); return fn.apply(context, boundArgs.concat(args));
}; };
}; };
var bindAll = function bindAll(obj) { var bindAll = function bindAll(obj) {
for (var _len6 = arguments.length, fns = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) { for (var _len7 = arguments.length, fns = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
fns[_key6 - 1] = arguments[_key6]; fns[_key7 - 1] = arguments[_key7];
} }
return fns.forEach(function (fn) { return fns.forEach(function (fn) {
@ -224,13 +272,13 @@
}); });
}; };
var bindKey = function bindKey(context, fn) { var bindKey = function bindKey(context, fn) {
for (var _len7 = arguments.length, boundArgs = new Array(_len7 > 2 ? _len7 - 2 : 0), _key7 = 2; _key7 < _len7; _key7++) { for (var _len8 = arguments.length, boundArgs = new Array(_len8 > 2 ? _len8 - 2 : 0), _key8 = 2; _key8 < _len8; _key8++) {
boundArgs[_key7 - 2] = arguments[_key7]; boundArgs[_key8 - 2] = arguments[_key8];
} }
return function () { return function () {
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
args[_key8] = arguments[_key8]; args[_key9] = arguments[_key9];
} }
return context[fn].apply(context, boundArgs.concat(args)); return context[fn].apply(context, boundArgs.concat(args));
@ -260,8 +308,8 @@
return new Blob([str]).size; return new Blob([str]).size;
}; };
var call = function call(key) { var call = function call(key) {
for (var _len9 = arguments.length, args = new Array(_len9 > 1 ? _len9 - 1 : 0), _key9 = 1; _key9 < _len9; _key9++) { for (var _len10 = arguments.length, args = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) {
args[_key9 - 1] = arguments[_key9]; args[_key10 - 1] = arguments[_key10];
} }
return function (context) { return function (context) {
@ -309,8 +357,8 @@
return new RegExp(regExp.source, regExp.flags); return new RegExp(regExp.source, regExp.flags);
}; };
var coalesce = function coalesce() { var coalesce = function coalesce() {
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) { for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
args[_key10] = arguments[_key10]; args[_key11] = arguments[_key11];
} }
return args.find(function (_) { return args.find(function (_) {
@ -319,8 +367,8 @@
}; };
var coalesceFactory = function coalesceFactory(valid) { var coalesceFactory = function coalesceFactory(valid) {
return function () { return function () {
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) { for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
args[_key11] = arguments[_key11]; args[_key12] = arguments[_key12];
} }
return args.find(valid); return args.find(valid);
@ -328,16 +376,16 @@
}; };
var collectInto = function collectInto(fn) { var collectInto = function collectInto(fn) {
return function () { return function () {
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) { for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
args[_key12] = arguments[_key12]; args[_key13] = arguments[_key13];
} }
return fn(args); return fn(args);
}; };
}; };
var colorize = function colorize() { var colorize = function colorize() {
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) { for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
args[_key13] = arguments[_key13]; args[_key14] = arguments[_key14];
} }
return { return {
@ -366,8 +414,8 @@
return str.replace(/\s{2,}/g, ' '); return str.replace(/\s{2,}/g, ' ');
}; };
var compose = function compose() { var compose = function compose() {
for (var _len14 = arguments.length, fns = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) { for (var _len15 = arguments.length, fns = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
fns[_key14] = arguments[_key14]; fns[_key15] = arguments[_key15];
} }
return fns.reduce(function (f, g) { return fns.reduce(function (f, g) {
@ -377,8 +425,8 @@
}); });
}; };
var composeRight = function composeRight() { var composeRight = function composeRight() {
for (var _len15 = arguments.length, fns = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) { for (var _len16 = arguments.length, fns = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
fns[_key15] = arguments[_key15]; fns[_key16] = arguments[_key16];
} }
return fns.reduce(function (f, g) { return fns.reduce(function (f, g) {
@ -389,8 +437,8 @@
}; };
var converge = function converge(converger, fns) { var converge = function converge(converger, fns) {
return function () { return function () {
for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) { for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
args[_key16] = arguments[_key16]; args[_key17] = arguments[_key17];
} }
return converger.apply(void 0, _toConsumableArray(fns.map(function (fn) { return converger.apply(void 0, _toConsumableArray(fns.map(function (fn) {
@ -423,6 +471,11 @@
return acc; return acc;
}, {}); }, {});
}; };
var countOccurrences = function countOccurrences(arr, val) {
return arr.reduce(function (a, v) {
return v === val ? a + 1 : a;
}, 0);
};
var counter = function counter(selector, start, end) { var counter = function counter(selector, start, end) {
var step = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; var step = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
var duration = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 2000; var duration = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 2000;
@ -438,11 +491,6 @@
return timer; return timer;
}; };
var countOccurrences = function countOccurrences(arr, val) {
return arr.reduce(function (a, v) {
return v === val ? a + 1 : a;
}, 0);
};
var createDirIfNotExists = function createDirIfNotExists(dir) { var createDirIfNotExists = function createDirIfNotExists(dir) {
return !fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined; return !fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined;
}; };
@ -471,31 +519,14 @@
} }
}; };
}; };
var CSVToArray = function CSVToArray(data) {
var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
var omitFirstRow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
return data.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0).split('\n').map(function (v) {
return v.split(delimiter);
});
};
var CSVToJSON = function CSVToJSON(data) {
var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
var titles = data.slice(0, data.indexOf('\n')).split(delimiter);
return data.slice(data.indexOf('\n') + 1).split('\n').map(function (v) {
var values = v.split(delimiter);
return titles.reduce(function (obj, title, index) {
return obj[title] = values[index], obj;
}, {});
});
};
var currentURL = function currentURL() { var currentURL = function currentURL() {
return window.location.href; return window.location.href;
}; };
var curry = function curry(fn) { var curry = function curry(fn) {
var arity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : fn.length; var arity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : fn.length;
for (var _len17 = arguments.length, args = new Array(_len17 > 2 ? _len17 - 2 : 0), _key17 = 2; _key17 < _len17; _key17++) { for (var _len18 = arguments.length, args = new Array(_len18 > 2 ? _len18 - 2 : 0), _key18 = 2; _key18 < _len18; _key18++) {
args[_key17 - 2] = arguments[_key17]; args[_key18 - 2] = arguments[_key18];
} }
return arity <= args.length ? fn.apply(void 0, args) : curry.bind.apply(curry, [null, fn, arity].concat(args)); return arity <= args.length ? fn.apply(void 0, args) : curry.bind.apply(curry, [null, fn, arity].concat(args));
@ -509,8 +540,8 @@
return function () { return function () {
var _this = this; var _this = this;
for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) { for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
args[_key18] = arguments[_key18]; args[_key19] = arguments[_key19];
} }
clearTimeout(timeoutId); clearTimeout(timeoutId);
@ -556,15 +587,15 @@
}, {}) : obj; }, {}) : obj;
}; };
var defaults = function defaults(obj) { var defaults = function defaults(obj) {
for (var _len19 = arguments.length, defs = new Array(_len19 > 1 ? _len19 - 1 : 0), _key19 = 1; _key19 < _len19; _key19++) { for (var _len20 = arguments.length, defs = new Array(_len20 > 1 ? _len20 - 1 : 0), _key20 = 1; _key20 < _len20; _key20++) {
defs[_key19 - 1] = arguments[_key19]; defs[_key20 - 1] = arguments[_key20];
} }
return Object.assign.apply(Object, [{}, obj].concat(_toConsumableArray(defs.reverse()), [obj])); return Object.assign.apply(Object, [{}, obj].concat(_toConsumableArray(defs.reverse()), [obj]));
}; };
var defer = function defer(fn) { var defer = function defer(fn) {
for (var _len20 = arguments.length, args = new Array(_len20 > 1 ? _len20 - 1 : 0), _key20 = 1; _key20 < _len20; _key20++) { for (var _len21 = arguments.length, args = new Array(_len21 > 1 ? _len21 - 1 : 0), _key21 = 1; _key21 < _len21; _key21++) {
args[_key20 - 1] = arguments[_key20]; args[_key21 - 1] = arguments[_key21];
} }
return setTimeout.apply(void 0, [fn, 1].concat(args)); return setTimeout.apply(void 0, [fn, 1].concat(args));
@ -573,8 +604,8 @@
return deg * Math.PI / 180.0; return deg * Math.PI / 180.0;
}; };
var delay = function delay(fn, wait) { var delay = function delay(fn, wait) {
for (var _len21 = arguments.length, args = new Array(_len21 > 2 ? _len21 - 2 : 0), _key21 = 2; _key21 < _len21; _key21++) { for (var _len22 = arguments.length, args = new Array(_len22 > 2 ? _len22 - 2 : 0), _key22 = 2; _key22 < _len22; _key22++) {
args[_key21 - 2] = arguments[_key21]; args[_key22 - 2] = arguments[_key22];
} }
return setTimeout.apply(void 0, [fn, wait].concat(args)); return setTimeout.apply(void 0, [fn, wait].concat(args));
@ -795,8 +826,8 @@
}; };
var flip = function flip(fn) { var flip = function flip(fn) {
return function (first) { return function (first) {
for (var _len22 = arguments.length, rest = new Array(_len22 > 1 ? _len22 - 1 : 0), _key22 = 1; _key22 < _len22; _key22++) { for (var _len23 = arguments.length, rest = new Array(_len23 > 1 ? _len23 - 1 : 0), _key23 = 1; _key23 < _len23; _key23++) {
rest[_key22 - 1] = arguments[_key22]; rest[_key23 - 1] = arguments[_key23];
} }
return fn.apply(void 0, rest.concat([first])); return fn.apply(void 0, rest.concat([first]));
@ -805,6 +836,16 @@
var forEachRight = function forEachRight(arr, callback) { var forEachRight = function forEachRight(arr, callback) {
return arr.slice(0).reverse().forEach(callback); return arr.slice(0).reverse().forEach(callback);
}; };
var forOwn = function forOwn(obj, fn) {
return Object.keys(obj).forEach(function (key) {
return fn(obj[key], key, obj);
});
};
var forOwnRight = function forOwnRight(obj, fn) {
return Object.keys(obj).reverse().forEach(function (key) {
return fn(obj[key], key, obj);
});
};
var formatDuration = function formatDuration(ms) { var formatDuration = function formatDuration(ms) {
if (ms < 0) ms = -ms; if (ms < 0) ms = -ms;
var time = { var time = {
@ -824,16 +865,6 @@
return "".concat(val, " ").concat(key).concat(val !== 1 ? 's' : ''); return "".concat(val, " ").concat(key).concat(val !== 1 ? 's' : '');
}).join(', '); }).join(', ');
}; };
var forOwn = function forOwn(obj, fn) {
return Object.keys(obj).forEach(function (key) {
return fn(obj[key], key, obj);
});
};
var forOwnRight = function forOwnRight(obj, fn) {
return Object.keys(obj).reverse().forEach(function (key) {
return fn(obj[key], key, obj);
});
};
var fromCamelCase = function fromCamelCase(str) { var fromCamelCase = function fromCamelCase(str) {
var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '_'; var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '_';
return str.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2').replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2').toLowerCase(); return str.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2').replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2').toLowerCase();
@ -852,8 +883,8 @@
return !y ? x : gcd(y, x % y); return !y ? x : gcd(y, x % y);
}; };
for (var _len23 = arguments.length, arr = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) { for (var _len24 = arguments.length, arr = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
arr[_key23] = arguments[_key23]; arr[_key24] = arguments[_key24];
} }
return arr.concat().reduce(function (a, b) { return arr.concat().reduce(function (a, b) {
@ -870,8 +901,8 @@
}); });
}; };
var get = function get(from) { var get = function get(from) {
for (var _len24 = arguments.length, selectors = new Array(_len24 > 1 ? _len24 - 1 : 0), _key24 = 1; _key24 < _len24; _key24++) { for (var _len25 = arguments.length, selectors = new Array(_len25 > 1 ? _len25 - 1 : 0), _key25 = 1; _key25 < _len25; _key25++) {
selectors[_key24 - 1] = arguments[_key24]; selectors[_key25 - 1] = arguments[_key25];
} }
return selectors.concat().map(function (s) { return selectors.concat().map(function (s) {
@ -933,8 +964,8 @@
return el.classList.contains(className); return el.classList.contains(className);
}; };
var hasFlags = function hasFlags() { var hasFlags = function hasFlags() {
for (var _len25 = arguments.length, flags = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) { for (var _len26 = arguments.length, flags = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
flags[_key25] = arguments[_key25]; flags[_key26] = arguments[_key26];
} }
return flags.every(function (flag) { return flags.every(function (flag) {
@ -973,8 +1004,8 @@
return 'rgb' + (alpha ? 'a' : '') + '(' + (h >>> (alpha ? 24 : 16)) + ', ' + ((h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8)) + ', ' + ((h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0)) + (alpha ? ", ".concat(h & 0x000000ff) : '') + ')'; return 'rgb' + (alpha ? 'a' : '') + '(' + (h >>> (alpha ? 24 : 16)) + ', ' + ((h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8)) + ', ' + ((h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0)) + (alpha ? ", ".concat(h & 0x000000ff) : '') + ')';
}; };
var hide = function hide() { var hide = function hide() {
for (var _len26 = arguments.length, el = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) { for (var _len27 = arguments.length, el = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
el[_key26] = arguments[_key26]; el[_key27] = arguments[_key27];
} }
return el.concat().forEach(function (e) { return el.concat().forEach(function (e) {
@ -1025,6 +1056,17 @@
return 1000 * iterations / (performance.now() - before); return 1000 * iterations / (performance.now() - before);
}; };
var inRange = function inRange(n, start) {
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
if (end && start > end) {
var _ref12 = [start, end];
end = _ref12[0];
start = _ref12[1];
}
return end == null ? n >= 0 && n < start : n >= start && n < end;
};
var indentString = function indentString(str, count) { var indentString = function indentString(str, count) {
var indent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' '; var indent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' ';
return str.replace(/^/gm, indent.repeat(count)); return str.replace(/^/gm, indent.repeat(count));
@ -1070,8 +1112,8 @@
return Array(n).fill(val); return Array(n).fill(val);
}; };
var initializeNDArray = function initializeNDArray(val) { var initializeNDArray = function initializeNDArray(val) {
for (var _len27 = arguments.length, args = new Array(_len27 > 1 ? _len27 - 1 : 0), _key27 = 1; _key27 < _len27; _key27++) { for (var _len28 = arguments.length, args = new Array(_len28 > 1 ? _len28 - 1 : 0), _key28 = 1; _key28 < _len28; _key28++) {
args[_key27 - 1] = arguments[_key27]; args[_key28 - 1] = arguments[_key28];
} }
return args.length === 0 ? val : Array.from({ return args.length === 0 ? val : Array.from({
@ -1080,17 +1122,6 @@
return initializeNDArray.apply(void 0, [val].concat(_toConsumableArray(args.slice(1)))); return initializeNDArray.apply(void 0, [val].concat(_toConsumableArray(args.slice(1))));
}); });
}; };
var inRange = function inRange(n, start) {
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
if (end && start > end) {
var _ref12 = [start, end];
end = _ref12[0];
start = _ref12[1];
}
return end == null ? n >= 0 && n < start : n >= start && n < end;
};
var insertAfter = function insertAfter(el, htmlString) { var insertAfter = function insertAfter(el, htmlString) {
return el.insertAdjacentHTML('afterend', htmlString); return el.insertAdjacentHTML('afterend', htmlString);
}; };
@ -1281,17 +1312,6 @@
return i === arr.length - 2 ? acc + val + end : i === arr.length - 1 ? acc + val : acc + val + separator; return i === arr.length - 2 ? acc + val + end : i === arr.length - 1 ? acc + val : acc + val + separator;
}, ''); }, '');
}; };
var JSONtoCSV = function JSONtoCSV(arr, columns) {
var delimiter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ',';
return [columns.join(delimiter)].concat(_toConsumableArray(arr.map(function (obj) {
return columns.reduce(function (acc, key) {
return "".concat(acc).concat(!acc.length ? '' : delimiter, "\"").concat(!obj[key] ? '' : obj[key], "\"");
}, '');
}))).join('\n');
};
var JSONToFile = function JSONToFile(obj, filename) {
return fs.writeFile("".concat(filename, ".json"), JSON.stringify(obj, null, 2));
};
var last = function last(arr) { var last = function last(arr) {
return arr[arr.length - 1]; return arr[arr.length - 1];
}; };
@ -1304,8 +1324,8 @@
return x * y / gcd(x, y); return x * y / gcd(x, y);
}; };
for (var _len28 = arguments.length, arr = new Array(_len28), _key28 = 0; _key28 < _len28; _key28++) { for (var _len29 = arguments.length, arr = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) {
arr[_key28] = arguments[_key28]; arr[_key29] = arguments[_key29];
} }
return arr.concat().reduce(function (a, b) { return arr.concat().reduce(function (a, b) {
@ -1313,8 +1333,8 @@
}); });
}; };
var longestItem = function longestItem() { var longestItem = function longestItem() {
for (var _len29 = arguments.length, vals = new Array(_len29), _key29 = 0; _key29 < _len29; _key29++) { for (var _len30 = arguments.length, vals = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) {
vals[_key29] = arguments[_key29]; vals[_key30] = arguments[_key30];
} }
return vals.reduce(function (a, x) { return vals.reduce(function (a, x) {
@ -1388,8 +1408,8 @@
var maxDate = function maxDate() { var maxDate = function maxDate() {
var _Math$max; var _Math$max;
for (var _len30 = arguments.length, dates = new Array(_len30), _key30 = 0; _key30 < _len30; _key30++) { for (var _len31 = arguments.length, dates = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) {
dates[_key30] = arguments[_key30]; dates[_key31] = arguments[_key31];
} }
return new Date((_Math$max = Math.max).apply.apply(_Math$max, [null].concat(dates))); return new Date((_Math$max = Math.max).apply.apply(_Math$max, [null].concat(dates)));
@ -1419,8 +1439,8 @@
return cached; return cached;
}; };
var merge = function merge() { var merge = function merge() {
for (var _len31 = arguments.length, objs = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) { for (var _len32 = arguments.length, objs = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) {
objs[_key31] = arguments[_key31]; objs[_key32] = arguments[_key32];
} }
return objs.concat().reduce(function (acc, obj) { return objs.concat().reduce(function (acc, obj) {
@ -1449,8 +1469,8 @@
var minDate = function minDate() { var minDate = function minDate() {
var _Math$min; var _Math$min;
for (var _len32 = arguments.length, dates = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) { for (var _len33 = arguments.length, dates = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) {
dates[_key32] = arguments[_key32]; dates[_key33] = arguments[_key33];
} }
return new Date((_Math$min = Math.min).apply.apply(_Math$min, [null].concat(dates))); return new Date((_Math$min = Math.min).apply.apply(_Math$min, [null].concat(dates)));
@ -1499,8 +1519,8 @@
}; };
var nthArg = function nthArg(n) { var nthArg = function nthArg(n) {
return function () { return function () {
for (var _len33 = arguments.length, args = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) { for (var _len34 = arguments.length, args = new Array(_len34), _key34 = 0; _key34 < _len34; _key34++) {
args[_key33] = arguments[_key33]; args[_key34] = arguments[_key34];
} }
return args.slice(n)[0]; return args.slice(n)[0];
@ -1571,19 +1591,6 @@
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;
}; };
var once = function once(fn) {
var called = false;
return function () {
if (called) return;
called = true;
for (var _len34 = arguments.length, args = new Array(_len34), _key34 = 0; _key34 < _len34; _key34++) {
args[_key34] = arguments[_key34];
}
return fn.apply(this, args);
};
};
var onUserInputChange = function onUserInputChange(callback) { var onUserInputChange = function onUserInputChange(callback) {
var type = 'mouse', var type = 'mouse',
lastTime = 0; lastTime = 0;
@ -1599,6 +1606,19 @@
type = 'touch', callback(type), document.addEventListener('mousemove', mousemoveHandler); type = 'touch', callback(type), document.addEventListener('mousemove', mousemoveHandler);
}); });
}; };
var once = function once(fn) {
var called = false;
return function () {
if (called) return;
called = true;
for (var _len35 = arguments.length, args = new Array(_len35), _key35 = 0; _key35 < _len35; _key35++) {
args[_key35] = arguments[_key35];
}
return fn.apply(this, args);
};
};
var orderBy = function orderBy(arr, props, orders) { var orderBy = function orderBy(arr, props, orders) {
return _toConsumableArray(arr).sort(function (a, b) { return _toConsumableArray(arr).sort(function (a, b) {
return props.reduce(function (acc, prop, i) { return props.reduce(function (acc, prop, i) {
@ -1616,13 +1636,13 @@
}); });
}; };
var over = function over() { var over = function over() {
for (var _len35 = arguments.length, fns = new Array(_len35), _key35 = 0; _key35 < _len35; _key35++) { for (var _len36 = arguments.length, fns = new Array(_len36), _key36 = 0; _key36 < _len36; _key36++) {
fns[_key35] = arguments[_key35]; fns[_key36] = arguments[_key36];
} }
return function () { return function () {
for (var _len36 = arguments.length, args = new Array(_len36), _key36 = 0; _key36 < _len36; _key36++) { for (var _len37 = arguments.length, args = new Array(_len37), _key37 = 0; _key37 < _len37; _key37++) {
args[_key36] = arguments[_key36]; args[_key37] = arguments[_key37];
} }
return fns.map(function (fn) { return fns.map(function (fn) {
@ -1632,8 +1652,8 @@
}; };
var overArgs = function overArgs(fn, transforms) { var overArgs = function overArgs(fn, transforms) {
return function () { return function () {
for (var _len37 = arguments.length, args = new Array(_len37), _key37 = 0; _key37 < _len37; _key37++) { for (var _len38 = arguments.length, args = new Array(_len38), _key38 = 0; _key38 < _len38; _key38++) {
args[_key37] = arguments[_key37]; args[_key38] = arguments[_key38];
} }
return fn.apply(void 0, _toConsumableArray(args.map(function (val, i) { return fn.apply(void 0, _toConsumableArray(args.map(function (val, i) {
@ -1658,26 +1678,26 @@
}, {}); }, {});
}; };
var partial = function partial(fn) { var partial = function partial(fn) {
for (var _len38 = arguments.length, partials = new Array(_len38 > 1 ? _len38 - 1 : 0), _key38 = 1; _key38 < _len38; _key38++) { for (var _len39 = arguments.length, partials = new Array(_len39 > 1 ? _len39 - 1 : 0), _key39 = 1; _key39 < _len39; _key39++) {
partials[_key38 - 1] = arguments[_key38]; partials[_key39 - 1] = arguments[_key39];
} }
return function () { return function () {
for (var _len39 = arguments.length, args = new Array(_len39), _key39 = 0; _key39 < _len39; _key39++) { for (var _len40 = arguments.length, args = new Array(_len40), _key40 = 0; _key40 < _len40; _key40++) {
args[_key39] = arguments[_key39]; args[_key40] = arguments[_key40];
} }
return fn.apply(void 0, partials.concat(args)); return fn.apply(void 0, partials.concat(args));
}; };
}; };
var partialRight = function partialRight(fn) { var partialRight = function partialRight(fn) {
for (var _len40 = arguments.length, partials = new Array(_len40 > 1 ? _len40 - 1 : 0), _key40 = 1; _key40 < _len40; _key40++) { for (var _len41 = arguments.length, partials = new Array(_len41 > 1 ? _len41 - 1 : 0), _key41 = 1; _key41 < _len41; _key41++) {
partials[_key40 - 1] = arguments[_key40]; partials[_key41 - 1] = arguments[_key41];
} }
return function () { return function () {
for (var _len41 = arguments.length, args = new Array(_len41), _key41 = 0; _key41 < _len41; _key41++) { for (var _len42 = arguments.length, args = new Array(_len42), _key42 = 0; _key42 < _len42; _key42++) {
args[_key41] = arguments[_key41]; args[_key42] = arguments[_key42];
} }
return fn.apply(void 0, args.concat(partials)); return fn.apply(void 0, args.concat(partials));
@ -1715,8 +1735,8 @@
}, {}); }, {});
}; };
var pipeAsyncFunctions = function pipeAsyncFunctions() { var pipeAsyncFunctions = function pipeAsyncFunctions() {
for (var _len42 = arguments.length, fns = new Array(_len42), _key42 = 0; _key42 < _len42; _key42++) { for (var _len43 = arguments.length, fns = new Array(_len43), _key43 = 0; _key43 < _len43; _key43++) {
fns[_key42] = arguments[_key42]; fns[_key43] = arguments[_key43];
} }
return function (arg) { return function (arg) {
@ -1726,8 +1746,8 @@
}; };
}; };
var pipeFunctions = function pipeFunctions() { var pipeFunctions = function pipeFunctions() {
for (var _len43 = arguments.length, fns = new Array(_len43), _key43 = 0; _key43 < _len43; _key43++) { for (var _len44 = arguments.length, fns = new Array(_len44), _key44 = 0; _key44 < _len44; _key44++) {
fns[_key43] = arguments[_key43]; fns[_key44] = arguments[_key44];
} }
return fns.reduce(function (f, g) { return fns.reduce(function (f, g) {
@ -1794,8 +1814,8 @@
}; };
var promisify = function promisify(func) { var promisify = function promisify(func) {
return function () { return function () {
for (var _len44 = arguments.length, args = new Array(_len44), _key44 = 0; _key44 < _len44; _key44++) { for (var _len45 = arguments.length, args = new Array(_len45), _key45 = 0; _key45 < _len45; _key45++) {
args[_key44] = arguments[_key44]; args[_key45] = arguments[_key45];
} }
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
@ -1806,8 +1826,8 @@
}; };
}; };
var pull = function pull(arr) { var pull = function pull(arr) {
for (var _len45 = arguments.length, args = new Array(_len45 > 1 ? _len45 - 1 : 0), _key45 = 1; _key45 < _len45; _key45++) { for (var _len46 = arguments.length, args = new Array(_len46 > 1 ? _len46 - 1 : 0), _key46 = 1; _key46 < _len46; _key46++) {
args[_key45 - 1] = arguments[_key45]; args[_key46 - 1] = arguments[_key46];
} }
var argState = Array.isArray(args[0]) ? args[0] : args; var argState = Array.isArray(args[0]) ? args[0] : args;
@ -1847,8 +1867,8 @@
return removed; return removed;
}; };
var pullBy = function pullBy(arr) { var pullBy = function pullBy(arr) {
for (var _len46 = arguments.length, args = new Array(_len46 > 1 ? _len46 - 1 : 0), _key46 = 1; _key46 < _len46; _key46++) { for (var _len47 = arguments.length, args = new Array(_len47 > 1 ? _len47 - 1 : 0), _key47 = 1; _key47 < _len47; _key47++) {
args[_key46 - 1] = arguments[_key46]; args[_key47 - 1] = arguments[_key47];
} }
var length = args.length; var length = args.length;
@ -1891,8 +1911,8 @@
}; };
var rearg = function rearg(fn, indexes) { var rearg = function rearg(fn, indexes) {
return function () { return function () {
for (var _len47 = arguments.length, args = new Array(_len47), _key47 = 0; _key47 < _len47; _key47++) { for (var _len48 = arguments.length, args = new Array(_len48), _key48 = 0; _key48 < _len48; _key48++) {
args[_key47] = arguments[_key47]; args[_key48] = arguments[_key48];
} }
return fn.apply(void 0, _toConsumableArray(indexes.map(function (i) { return fn.apply(void 0, _toConsumableArray(indexes.map(function (i) {
@ -1932,14 +1952,6 @@
var asLink = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var asLink = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
return asLink ? window.location.href = url : window.location.replace(url); return asLink ? window.location.href = url : window.location.replace(url);
}; };
var reducedFilter = function reducedFilter(data, keys, fn) {
return data.filter(fn).map(function (el) {
return keys.reduce(function (acc, key) {
acc[key] = el[key];
return acc;
}, {});
});
};
var reduceSuccessive = function reduceSuccessive(arr, fn, acc) { var reduceSuccessive = function reduceSuccessive(arr, fn, acc) {
return arr.reduce(function (res, val, i, arr) { return arr.reduce(function (res, val, i, arr) {
return res.push(fn(res.slice(-1)[0], val, i, arr)), res; return res.push(fn(res.slice(-1)[0], val, i, arr)), res;
@ -1953,6 +1965,14 @@
return comparator(a, b) >= 0 ? b : a; return comparator(a, b) >= 0 ? b : a;
}); });
}; };
var reducedFilter = function reducedFilter(data, keys, fn) {
return data.filter(fn).map(function (el) {
return keys.reduce(function (acc, key) {
acc[key] = el[key];
return acc;
}, {});
});
};
var reject = function reject(pred, array) { var reject = function reject(pred, array) {
return array.filter(function () { return array.filter(function () {
return !pred.apply(void 0, arguments); return !pred.apply(void 0, arguments);
@ -1975,9 +1995,6 @@
var reverseString = function reverseString(str) { var reverseString = function reverseString(str) {
return _toConsumableArray(str).reverse().join(''); return _toConsumableArray(str).reverse().join('');
}; };
var RGBToHex = function RGBToHex(r, g, b) {
return ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
};
var round = function round(n) { var round = function round(n) {
var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
return Number("".concat(Math.round("".concat(n, "e").concat(decimals)), "e-").concat(decimals)); return Number("".concat(Math.round("".concat(n, "e").concat(decimals)), "e-").concat(decimals));
@ -2048,15 +2065,15 @@
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var delCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var delCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
for (var _len48 = arguments.length, elements = new Array(_len48 > 3 ? _len48 - 3 : 0), _key48 = 3; _key48 < _len48; _key48++) { for (var _len49 = arguments.length, elements = new Array(_len49 > 3 ? _len49 - 3 : 0), _key49 = 3; _key49 < _len49; _key49++) {
elements[_key48 - 3] = arguments[_key48]; elements[_key49 - 3] = arguments[_key49];
} }
return arr.slice(0, index).concat(elements).concat(arr.slice(index + delCount)); return arr.slice(0, index).concat(elements).concat(arr.slice(index + delCount));
}; };
var show = function show() { var show = function show() {
for (var _len49 = arguments.length, el = new Array(_len49), _key49 = 0; _key49 < _len49; _key49++) { for (var _len50 = arguments.length, el = new Array(_len50), _key50 = 0; _key50 < _len50; _key50++) {
el[_key49] = arguments[_key49]; el[_key50] = arguments[_key50];
} }
return el.concat().forEach(function (e) { return el.concat().forEach(function (e) {
@ -2175,8 +2192,8 @@
return str.replace(/<[^>]*>/g, ''); return str.replace(/<[^>]*>/g, '');
}; };
var sum = function sum() { var sum = function sum() {
for (var _len50 = arguments.length, arr = new Array(_len50), _key50 = 0; _key50 < _len50; _key50++) { for (var _len51 = arguments.length, arr = new Array(_len51), _key51 = 0; _key51 < _len51; _key51++) {
arr[_key50] = arguments[_key50]; arr[_key51] = arguments[_key51];
} }
return arr.concat().reduce(function (acc, val) { return arr.concat().reduce(function (acc, val) {
@ -2299,18 +2316,18 @@
} }
}; };
}; };
var times = function times(n, fn) {
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
var i = 0;
while (fn.call(context, i) !== false && ++i < n) {}
};
var timeTaken = function timeTaken(callback) { var timeTaken = function timeTaken(callback) {
console.time('timeTaken'); console.time('timeTaken');
var r = callback(); var r = callback();
console.timeEnd('timeTaken'); console.timeEnd('timeTaken');
return r; return r;
}; };
var times = function times(n, fn) {
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
var i = 0;
while (fn.call(context, i) !== false && ++i < n) {}
};
var toCamelCase = function toCamelCase(str) { var toCamelCase = function toCamelCase(str) {
var s = str && str.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map(function (x) { var s = str && str.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map(function (x) {
return x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase(); return x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase();
@ -2327,9 +2344,6 @@
var toDecimalMark = function toDecimalMark(num) { var toDecimalMark = function toDecimalMark(num) {
return num.toLocaleString('en-US'); return num.toLocaleString('en-US');
}; };
var toggleClass = function toggleClass(el, className) {
return el.classList.toggle(className);
};
var toHash = function toHash(object, key) { var toHash = function toHash(object, key) {
return Array.prototype.reduce.call(object, function (acc, data, index) { return Array.prototype.reduce.call(object, function (acc, data, index) {
return acc[!key ? index : data[key]] = data, acc; return acc[!key ? index : data[key]] = data, acc;
@ -2340,11 +2354,6 @@
return x.toLowerCase(); return x.toLowerCase();
}).join('-'); }).join('-');
}; };
var tomorrow = function tomorrow() {
var t = new Date();
t.setDate(t.getDate() + 1);
return t.toISOString().split('T')[0];
};
var toOrdinalSuffix = function toOrdinalSuffix(num) { var toOrdinalSuffix = function toOrdinalSuffix(num) {
var int = parseInt(num), var int = parseInt(num),
digits = [int % 10, int % 100], digits = [int % 10, int % 100],
@ -2366,6 +2375,14 @@
return x.charAt(0).toUpperCase() + x.slice(1); return x.charAt(0).toUpperCase() + x.slice(1);
}).join(' '); }).join(' ');
}; };
var toggleClass = function toggleClass(el, className) {
return el.classList.toggle(className);
};
var tomorrow = function tomorrow() {
var t = new Date();
t.setDate(t.getDate() + 1);
return t.toISOString().split('T')[0];
};
var transform = function transform(obj, fn, acc) { var transform = function transform(obj, fn, acc) {
return Object.keys(obj).reduce(function (a, k) { return Object.keys(obj).reduce(function (a, k) {
return fn(a, obj[k], k, obj); return fn(a, obj[k], k, obj);
@ -2400,8 +2417,8 @@
}; };
}; };
for (var _len51 = arguments.length, args = new Array(_len51), _key51 = 0; _key51 < _len51; _key51++) { for (var _len52 = arguments.length, args = new Array(_len52), _key52 = 0; _key52 < _len52; _key52++) {
args[_key51] = arguments[_key51]; args[_key52] = arguments[_key52];
} }
if (n > args.length) throw new RangeError('Arguments too few!'); if (n > args.length) throw new RangeError('Arguments too few!');
@ -2514,23 +2531,6 @@
return fn.apply(void 0, _toConsumableArray(val)); return fn.apply(void 0, _toConsumableArray(val));
}); });
}; };
var URLJoin = function URLJoin() {
for (var _len52 = arguments.length, args = new Array(_len52), _key52 = 0; _key52 < _len52; _key52++) {
args[_key52] = arguments[_key52];
}
return args.join('/').replace(/[\/]+/g, '/').replace(/^(.+):\//, '$1://').replace(/^file:/, 'file:/').replace(/\/(\?|&|#[^!])/g, '$1').replace(/\?/g, '&').replace('&', '?');
};
var UUIDGeneratorBrowser = function UUIDGeneratorBrowser() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
});
};
var UUIDGeneratorNode = function UUIDGeneratorNode() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
return (c ^ crypto.randomBytes(1)[0] & 15 >> c / 4).toString(16);
});
};
var validateNumber = function validateNumber(n) { var validateNumber = function validateNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; return !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;
}; };
@ -2605,6 +2605,14 @@
}); });
}; };
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;
@ -2644,13 +2652,11 @@
exports.converge = converge; exports.converge = converge;
exports.copyToClipboard = copyToClipboard; exports.copyToClipboard = copyToClipboard;
exports.countBy = countBy; exports.countBy = countBy;
exports.counter = counter;
exports.countOccurrences = countOccurrences; exports.countOccurrences = countOccurrences;
exports.counter = counter;
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;
@ -2696,9 +2702,9 @@
exports.flattenObject = flattenObject; exports.flattenObject = flattenObject;
exports.flip = flip; exports.flip = flip;
exports.forEachRight = forEachRight; exports.forEachRight = forEachRight;
exports.formatDuration = formatDuration;
exports.forOwn = forOwn; exports.forOwn = forOwn;
exports.forOwnRight = forOwnRight; exports.forOwnRight = forOwnRight;
exports.formatDuration = formatDuration;
exports.fromCamelCase = fromCamelCase; exports.fromCamelCase = fromCamelCase;
exports.functionName = functionName; exports.functionName = functionName;
exports.functions = functions; exports.functions = functions;
@ -2726,6 +2732,7 @@
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;
@ -2734,7 +2741,6 @@
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;
@ -2778,8 +2784,6 @@
exports.isValidJSON = isValidJSON; exports.isValidJSON = isValidJSON;
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;
@ -2818,8 +2822,8 @@
exports.omit = omit; exports.omit = omit;
exports.omitBy = omitBy; exports.omitBy = omitBy;
exports.on = on; exports.on = on;
exports.once = once;
exports.onUserInputChange = onUserInputChange; exports.onUserInputChange = onUserInputChange;
exports.once = once;
exports.orderBy = orderBy; exports.orderBy = orderBy;
exports.over = over; exports.over = over;
exports.overArgs = overArgs; exports.overArgs = overArgs;
@ -2854,15 +2858,14 @@
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;
@ -2903,19 +2906,19 @@
exports.takeRightWhile = takeRightWhile; exports.takeRightWhile = takeRightWhile;
exports.takeWhile = takeWhile; exports.takeWhile = takeWhile;
exports.throttle = throttle; exports.throttle = throttle;
exports.times = times;
exports.timeTaken = timeTaken; exports.timeTaken = timeTaken;
exports.times = times;
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;
@ -2935,9 +2938,6 @@
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.when = when; exports.when = when;
exports.without = without; exports.without = without;

File diff suppressed because one or more lines are too long

159
dist/_30s.esm.js vendored
View File

@ -1,6 +1,51 @@
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);
@ -124,6 +169,7 @@ 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,
@ -135,7 +181,6 @@ 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');
@ -156,21 +201,6 @@ const createEventHub = () => ({
if (i > -1) this.hub[event].splice(i, 1); if (i > -1) this.hub[event].splice(i, 1);
} }
}); });
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);
@ -348,6 +378,11 @@ 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 formatDuration = ms => { const formatDuration = ms => {
if (ms < 0) ms = -ms; if (ms < 0) ms = -ms;
const time = { const time = {
@ -362,11 +397,6 @@ const formatDuration = ms => {
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`) .map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
.join(', '); .join(', ');
}; };
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')
@ -495,6 +525,10 @@ 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);
@ -511,10 +545,6 @@ 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) => {
@ -626,18 +656,6 @@ 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));
@ -665,7 +683,8 @@ const mapKeys = (obj, fn) =>
acc[fn(obj[k], k, obj)] = obj[k]; acc[fn(obj[k], k, obj)] = obj[k];
return acc; return acc;
}, {}); }, {});
const mapNumRange = (num, inMin, inMax, outMin, outMax) => (num - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
const mapObject = (arr, fn) => const mapObject = (arr, fn) =>
(a => ( (a => (
(a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {}) (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {})
@ -771,14 +790,6 @@ 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;
@ -793,6 +804,14 @@ 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) => {
@ -951,6 +970,10 @@ 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) => {
@ -958,10 +981,6 @@ 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)
@ -980,7 +999,6 @@ 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(
@ -1155,16 +1173,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 &&
@ -1177,7 +1195,6 @@ 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,
@ -1190,11 +1207,6 @@ 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],
@ -1218,6 +1230,12 @@ 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 }));
@ -1302,23 +1320,6 @@ 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 when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x);
const without = (arr, ...args) => arr.filter(v => !args.includes(v)); const without = (arr, ...args) => arr.filter(v => !args.includes(v));
@ -1342,4 +1343,4 @@ const zipWith = (...array) => {
); );
}; };
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, 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, 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, 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, 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, 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, when, without, words, xProd, yesNo, zip, zipObject, zipWith }; 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, 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, 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, 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, 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, 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, when, without, words, xProd, yesNo, zip, zipObject, zipWith };

189
dist/_30s.js vendored
View File

@ -7,6 +7,51 @@
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);
@ -130,6 +175,7 @@
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,
@ -141,7 +187,6 @@
}, 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');
@ -162,21 +207,6 @@
if (i > -1) this.hub[event].splice(i, 1); if (i > -1) this.hub[event].splice(i, 1);
} }
}); });
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);
@ -354,6 +384,11 @@
.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 formatDuration = ms => { const formatDuration = ms => {
if (ms < 0) ms = -ms; if (ms < 0) ms = -ms;
const time = { const time = {
@ -368,11 +403,6 @@
.map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`) .map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)
.join(', '); .join(', ');
}; };
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')
@ -501,6 +531,10 @@
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);
@ -517,10 +551,6 @@
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) => {
@ -632,18 +662,6 @@
: 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));
@ -671,7 +689,8 @@
acc[fn(obj[k], k, obj)] = obj[k]; acc[fn(obj[k], k, obj)] = obj[k];
return acc; return acc;
}, {}); }, {});
const mapNumRange = (num, inMin, inMax, outMin, outMax) => (num - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
const mapObject = (arr, fn) => const mapObject = (arr, fn) =>
(a => ( (a => (
(a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {}) (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {})
@ -777,14 +796,6 @@
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;
@ -799,6 +810,14 @@
(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) => {
@ -957,6 +976,10 @@
}; };
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) => {
@ -964,10 +987,6 @@
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)
@ -986,7 +1005,6 @@
{} {}
); );
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(
@ -1161,16 +1179,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 &&
@ -1183,7 +1201,6 @@
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,
@ -1196,11 +1213,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.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],
@ -1224,6 +1236,12 @@
.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 }));
@ -1308,23 +1326,6 @@
}).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 when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x);
const without = (arr, ...args) => arr.filter(v => !args.includes(v)); const without = (arr, ...args) => arr.filter(v => !args.includes(v));
@ -1348,6 +1349,14 @@
); );
}; };
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;
@ -1387,13 +1396,11 @@
exports.converge = converge; exports.converge = converge;
exports.copyToClipboard = copyToClipboard; exports.copyToClipboard = copyToClipboard;
exports.countBy = countBy; exports.countBy = countBy;
exports.counter = counter;
exports.countOccurrences = countOccurrences; exports.countOccurrences = countOccurrences;
exports.counter = counter;
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;
@ -1439,9 +1446,9 @@
exports.flattenObject = flattenObject; exports.flattenObject = flattenObject;
exports.flip = flip; exports.flip = flip;
exports.forEachRight = forEachRight; exports.forEachRight = forEachRight;
exports.formatDuration = formatDuration;
exports.forOwn = forOwn; exports.forOwn = forOwn;
exports.forOwnRight = forOwnRight; exports.forOwnRight = forOwnRight;
exports.formatDuration = formatDuration;
exports.fromCamelCase = fromCamelCase; exports.fromCamelCase = fromCamelCase;
exports.functionName = functionName; exports.functionName = functionName;
exports.functions = functions; exports.functions = functions;
@ -1469,6 +1476,7 @@
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;
@ -1477,7 +1485,6 @@
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;
@ -1521,8 +1528,6 @@
exports.isValidJSON = isValidJSON; exports.isValidJSON = isValidJSON;
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;
@ -1561,8 +1566,8 @@
exports.omit = omit; exports.omit = omit;
exports.omitBy = omitBy; exports.omitBy = omitBy;
exports.on = on; exports.on = on;
exports.once = once;
exports.onUserInputChange = onUserInputChange; exports.onUserInputChange = onUserInputChange;
exports.once = once;
exports.orderBy = orderBy; exports.orderBy = orderBy;
exports.over = over; exports.over = over;
exports.overArgs = overArgs; exports.overArgs = overArgs;
@ -1597,15 +1602,14 @@
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;
@ -1646,19 +1650,19 @@
exports.takeRightWhile = takeRightWhile; exports.takeRightWhile = takeRightWhile;
exports.takeWhile = takeWhile; exports.takeWhile = takeWhile;
exports.throttle = throttle; exports.throttle = throttle;
exports.times = times;
exports.timeTaken = timeTaken; exports.timeTaken = timeTaken;
exports.times = times;
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;
@ -1678,9 +1682,6 @@
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.when = when; exports.when = when;
exports.without = without; exports.without = without;

View File

@ -811,7 +811,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "09451fcad1367841386a0d7ba7362e3492a0b425adb0e64391f24616cbe98ee9" "hash": "03b2d6752610b5912a1e4019ffc7ef9f199636595ffd8c58b14cdd9ffa0ec28a"
} }
}, },
{ {
@ -941,7 +941,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "79d1b63d3d85a17b8bc42d14262a929f9c2cc98064da2dae06156724b14652f6" "hash": "f982b4e8e3ec3c8b0c2ef4f19b38dac90df6ebe2dd4daa0126c917ebc07d3e62"
} }
}, },
{ {
@ -1162,7 +1162,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "8b0c9c74e4ec55c27f1341980374c525e7c67b8bc8c6a67668b682c5f8619c0c" "hash": "319e1a8fb41490965ee6e28db3e139e65c4ea5b7f43e332bc7216cd790e5d409"
} }
}, },
{ {
@ -2677,6 +2677,20 @@
"hash": "215198b03c4b2e9c7961de606fa9df83fa5964f2210fcf17b4ea69ee15294bcb" "hash": "215198b03c4b2e9c7961de606fa9df83fa5964f2210fcf17b4ea69ee15294bcb"
} }
}, },
{
"id": "mapNumRange",
"type": "snippetListing",
"attributes": {
"tags": [
"math",
"beginner"
],
"archived": false
},
"meta": {
"hash": "41e67e7f95334dcb734cf92acea7e1398540a18c2358d85cde5ff82e6149a44f"
}
},
{ {
"id": "mapObject", "id": "mapObject",
"type": "snippetListing", "type": "snippetListing",
@ -3377,7 +3391,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "0b04f5fe668888db0dc360535cd999669258019f0682eb6e4ad3a1164e408d13" "hash": "dcdf66e8d0eb4a1761c6b767b8cc350757087ae817ec371436faab0fff7c0051"
} }
}, },
{ {
@ -3749,7 +3763,7 @@
"archived": false "archived": false
}, },
"meta": { "meta": {
"hash": "536833a64ce0c000b82327ed1bb9bcb82e35b237f75aefcca0e0d2def4e9cb63" "hash": "2fd54c9fc1fb5b0a981df69501b518d5830ea77544d4d5290c7cc13745ca00ea"
} }
}, },
{ {

View File

@ -1196,7 +1196,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "09451fcad1367841386a0d7ba7362e3492a0b425adb0e64391f24616cbe98ee9" "hash": "03b2d6752610b5912a1e4019ffc7ef9f199636595ffd8c58b14cdd9ffa0ec28a"
} }
}, },
{ {
@ -1389,7 +1389,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "79d1b63d3d85a17b8bc42d14262a929f9c2cc98064da2dae06156724b14652f6" "hash": "f982b4e8e3ec3c8b0c2ef4f19b38dac90df6ebe2dd4daa0126c917ebc07d3e62"
} }
}, },
{ {
@ -1715,7 +1715,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "8b0c9c74e4ec55c27f1341980374c525e7c67b8bc8c6a67668b682c5f8619c0c" "hash": "319e1a8fb41490965ee6e28db3e139e65c4ea5b7f43e332bc7216cd790e5d409"
} }
}, },
{ {
@ -3944,6 +3944,27 @@
"hash": "215198b03c4b2e9c7961de606fa9df83fa5964f2210fcf17b4ea69ee15294bcb" "hash": "215198b03c4b2e9c7961de606fa9df83fa5964f2210fcf17b4ea69ee15294bcb"
} }
}, },
{
"id": "mapNumRange",
"type": "snippet",
"attributes": {
"fileName": "mapNumRange.md",
"text": "Maps a number from one range to another range.\n\nReturns `num` mapped between `outMin`-`outMax` from `inMin`-`inMax`.",
"codeBlocks": {
"es6": "const mapNumRange = (num, inMin, inMax, outMin, outMax) =>\n ((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;",
"es5": "var mapNumRange = function mapNumRange(num, inMin, inMax, outMin, outMax) {\n return (num - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;\n};",
"example": "mapNumRange(5, 0, 10, 0, 100); // 50"
},
"tags": [
"math",
"beginner"
]
},
"meta": {
"archived": false,
"hash": "41e67e7f95334dcb734cf92acea7e1398540a18c2358d85cde5ff82e6149a44f"
}
},
{ {
"id": "mapObject", "id": "mapObject",
"type": "snippet", "type": "snippet",
@ -4962,7 +4983,7 @@
"codeBlocks": { "codeBlocks": {
"es6": "const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg));", "es6": "const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg));",
"es5": "var pipeAsyncFunctions = function pipeAsyncFunctions() {\n for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {\n fns[_key] = arguments[_key];\n }\n\n return function (arg) {\n return fns.reduce(function (p, f) {\n return p.then(f);\n }, Promise.resolve(arg));\n };\n};", "es5": "var pipeAsyncFunctions = function pipeAsyncFunctions() {\n for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {\n fns[_key] = arguments[_key];\n }\n\n return function (arg) {\n return fns.reduce(function (p, f) {\n return p.then(f);\n }, Promise.resolve(arg));\n };\n};",
"example": "const sum = pipeAsyncFunctions(\n x => x + 1,\n x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),\n x => x + 3,\n async x => (await x) + 4\n);\n(async() => {\n console.log(await sum(5)); // 15 (after one second)\n})();" "example": "const sum = pipeAsyncFunctions(\n x => x + 1,\n x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),\n x => x + 3,\n async x => (await x) + 4\n);\n(async () => {\n console.log(await sum(5)); // 15 (after one second)\n})();"
}, },
"tags": [ "tags": [
"adapter", "adapter",
@ -4973,7 +4994,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "0b04f5fe668888db0dc360535cd999669258019f0682eb6e4ad3a1164e408d13" "hash": "dcdf66e8d0eb4a1761c6b767b8cc350757087ae817ec371436faab0fff7c0051"
} }
}, },
{ {
@ -5520,7 +5541,7 @@
}, },
"meta": { "meta": {
"archived": false, "archived": false,
"hash": "536833a64ce0c000b82327ed1bb9bcb82e35b237f75aefcca0e0d2def4e9cb63" "hash": "2fd54c9fc1fb5b0a981df69501b518d5830ea77544d4d5290c7cc13745ca00ea"
} }
}, },
{ {

View File

@ -1752,6 +1752,14 @@
], ],
"description": "Creates an object with keys generated by running the provided function for each key and the same values as the provided object.\n\nUse `Object.keys(obj)` to iterate over the object's keys.\nUse `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`" "description": "Creates an object with keys generated by running the provided function for each key and the same values as the provided object.\n\nUse `Object.keys(obj)` to iterate over the object's keys.\nUse `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`"
}, },
"mapNumRange": {
"prefix": "30s_mapNumRange",
"body": [
"const mapNumRange = (num, inMin, inMax, outMin, outMax) =>",
" ((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;"
],
"description": "Maps a number from one range to another range.\n\nReturns `num` mapped between `outMin`-`outMax` from `inMin`-`inMax`"
},
"mapObject": { "mapObject": {
"prefix": "30s_mapObject", "prefix": "30s_mapObject",
"body": [ "body": [