@flekschas/utils
Advanced tools
Comparing version 0.29.0 to 0.30.0
@@ -0,1 +1,6 @@ | ||
## 0.30.0 | ||
- Add and test `hasSameElements(arrayA, arrayB)` | ||
- Improve implementation of `randomString()` | ||
## v0.29.0 | ||
@@ -2,0 +7,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/* eslint no-param-reassign:0 */ | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -48,2 +48,19 @@ * Restrict value to be within [min, max] | ||
/** | ||
* Check if two arrays contain the same elements | ||
* @param {array} a - First array | ||
* @param {array} b - Second array | ||
* @return {boolean} If `true` the two arrays contain the same elements | ||
*/ | ||
const hasSameElements = (a, b) => { | ||
if (a === b) return true; | ||
if (a.length !== b.length) return false; | ||
const aSet = new Set(a); | ||
const bSet = new Set(b); | ||
// Since the arrays could contain duplicates, we have to check the set length | ||
// as well | ||
if (aSet.size !== bSet.size) return false; | ||
return b.every((element) => aSet.has(element)); | ||
}; | ||
/** | ||
* Return unique values of an array | ||
@@ -68,2 +85,2 @@ * @param {array} a - Input array | ||
export { array2dTranspose, clearArray, unique }; | ||
export { array2dTranspose, clearArray, hasSameElements, unique }; |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Test if a variable is an array |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Store the values of an iterator in an array. |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
const XMLNS = 'http://www.w3.org/2000/svg'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Clone an event by invoking the source event's constructor and passing in |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Restrict value to be within [min, max] |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * L distance between a pair of vectors |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
const mergeMaps = (map1, map2) => | ||
@@ -3,0 +3,0 @@ new Map( |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Restrict value to be within [min, max] |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
const assign = (target, ...sources) => { | ||
@@ -3,0 +3,0 @@ sources.forEach((source) => { |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -20,4 +20,7 @@ * Create a worker from a function | ||
/** | ||
* Synonym for `toVoid()` because it's a convention | ||
*/ | ||
const noop = toVoid; | ||
export { createWorker, noop, toVoid }; |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Restrict value to be within [min, max] |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
const camelToConst = (str) => | ||
@@ -34,8 +34,6 @@ str | ||
const randomString = (length, alphabet = 'abcdefghijklmnopqrstuvwxyz') => | ||
Array(length) | ||
.join() | ||
.split(',') | ||
.map(() => alphabet.charAt(Math.floor(Math.random() * alphabet.length))) | ||
.join(''); | ||
Array.from({ length }, () => | ||
alphabet.charAt(Math.floor(Math.random() * alphabet.length)) | ||
).join(''); | ||
export { camelToConst, capitalize, nthIndexOf, randomString }; |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -179,4 +179,7 @@ * Debounce a function call. | ||
/** | ||
* Synonym for `wait()` because `await timeout(250)` reads nicer | ||
*/ | ||
const timeout = wait; | ||
export { debounce, nextAnimationFrame, throttle, throttleAndDebounce, timeout, wait }; |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Test if a variable is an array |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Restrict value to be within [min, max] |
{ | ||
"name": "@flekschas/utils", | ||
"version": "0.29.0", | ||
"version": "0.30.0", | ||
"description": "A set of utility functions I use across projects", | ||
@@ -5,0 +5,0 @@ "author": { |
# A collection of handy utility functions | ||
[![NPM Version](https://img.shields.io/npm/v/@flekschas/utils.svg?style=flat-square&color=7f99ff)](https://npmjs.org/package/@flekschas/utils) | ||
[![Build Status](https://img.shields.io/github/workflow/status/flekschas/utils/build?color=a17fff&style=flat-square)](https://github.com/flekschas/utils/actions?query=workflow%3Abuild) | ||
[![Build Status](https://img.shields.io/github/actions/workflow/status/flekschas/utils/build.yml?branch=master&color=a17fff&style=flat-square)](https://github.com/flekschas/utils/actions?query=workflow%3Abuild) | ||
[![File Size](http://img.badgesize.io/https://unpkg.com/@flekschas/utils/dist/utils.min.js?compression=gzip&style=flat-square&color=e17fff)](https://bundlephobia.com/result?p=@flekschas/utils) | ||
@@ -6,0 +6,0 @@ [![Code Style Prettier](https://img.shields.io/badge/code%20style-prettier-ff7fe1.svg?style=flat-square)](https://github.com/prettier/prettier#readme) |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -62,2 +62,21 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/toConsumableArray')) : | ||
/** | ||
* Check if two arrays contain the same elements | ||
* @param {array} a - First array | ||
* @param {array} b - Second array | ||
* @return {boolean} If `true` the two arrays contain the same elements | ||
*/ | ||
var hasSameElements = function hasSameElements(a, b) { | ||
if (a === b) return true; | ||
if (a.length !== b.length) return false; | ||
var aSet = new Set(a); | ||
var bSet = new Set(b); // Since the arrays could contain duplicates, we have to check the set length | ||
// as well | ||
if (aSet.size !== bSet.size) return false; | ||
return b.every(function (element) { | ||
return aSet.has(element); | ||
}); | ||
}; | ||
/** | ||
* Return unique values of an array | ||
@@ -87,2 +106,3 @@ * @param {array} a - Input array | ||
exports.clearArray = clearArray; | ||
exports.hasSameElements = hasSameElements; | ||
exports.unique = unique; | ||
@@ -89,0 +109,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@babel/runtime/helpers/toConsumableArray")):"function"==typeof define&&define.amd?define(["exports","@babel/runtime/helpers/toConsumableArray"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).utils=e.utils||{},e._toConsumableArray)}(this,(function(e,n){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(n),o=function(e){return e};e.array2dTranspose=function(e){for(var n=r.default(new Array(e[0].length).fill().map((function(){return[]}))),t=0;t<e.length;t++)for(var o=0;o<e[t].length;o++)n[o][t]=e[t][o];return n},e.clearArray=function(e){return e.splice(0,e.length),e},e.unique=function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o,t=new Set,r=[],u=0;u<e.length;u++){var l=n(e[u]);t.has(l)||(t.add(l),r.push(l))}return r},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@babel/runtime/helpers/toConsumableArray")):"function"==typeof define&&define.amd?define(["exports","@babel/runtime/helpers/toConsumableArray"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).utils=e.utils||{},e._toConsumableArray)}(this,(function(e,n){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(n),u=function(e){return e};e.array2dTranspose=function(e){for(var n=r.default(new Array(e[0].length).fill().map((function(){return[]}))),t=0;t<e.length;t++)for(var u=0;u<e[t].length;u++)n[u][t]=e[t][u];return n},e.clearArray=function(e){return e.splice(0,e.length),e},e.hasSameElements=function(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;var t=new Set(e),r=new Set(n);return t.size===r.size&&n.every((function(e){return t.has(e)}))},e.unique=function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u,t=new Set,r=[],o=0;o<e.length;o++){var i=n(e[o]);t.has(i)||(t.add(i),r.push(i))}return r},Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/toConsumableArray')) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -8,3 +8,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
@@ -11,0 +11,0 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).utils=t.utils||{})}(this,(function(t){"use strict";function e(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,f=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return f=t.done,t},e:function(t){a=!0,u=t},f:function(){try{f||null==r.return||r.return()}finally{if(a)throw u}}}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}t.iteratorToArray=function(t){var n,r=[],o=e(t);try{for(o.s();!(n=o.n()).done;){var i=n.value;r.push(i)}}catch(t){o.e(t)}finally{o.f()}return r},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).utils=t.utils||{})}(this,(function(t){"use strict";function e(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,f=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return f=t.done,t},e:function(t){a=!0,u=t},f:function(){try{f||null==r.return||r.return()}finally{if(a)throw u}}}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}t.iteratorToArray=function(t){var n,r=[],o=e(t);try{for(o.s();!(n=o.n()).done;){var i=n.value;r.push(i)}}catch(t){o.e(t)}finally{o.f()}return r},Object.defineProperty(t,"__esModule",{value:!0})})); |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/defineEnumerableProperties'), require('@babel/runtime/helpers/defineProperty'), require('@babel/runtime/helpers/typeof')) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -88,4 +88,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/slicedToArray')) : | ||
var isXInside = // bBox1 is x-wise inside of bBox2 | ||
xd1 < 0 && xd3 > 0 || xd2 < 0 && xd4 > 0 || // bBox2 is x-wise inside of bBox1 | ||
xd1 > 0 && xd2 < 0 || xd3 > 0 && xd4 < 0; | ||
xd1 < 0 && xd3 > 0 || xd2 < 0 && xd4 > 0 || xd1 > 0 && xd2 < 0 || xd3 > 0 && xd4 < 0; | ||
var yd1 = bBox2.minY - bBox1.minY; | ||
@@ -96,4 +95,3 @@ var yd2 = bBox2.minY - bBox1.maxY; | ||
var isYInside = // bBox1 is y-wise inside of bBox2 | ||
yd1 < 0 && yd3 > 0 || yd2 < 0 && yd4 > 0 || // bBox2 is y-wise inside of bBox1 | ||
yd1 > 0 && yd2 < 0 || yd3 > 0 && yd4 < 0; | ||
yd1 < 0 && yd3 > 0 || yd2 < 0 && yd4 > 0 || yd1 > 0 && yd2 < 0 || yd3 > 0 && yd4 < 0; | ||
if (isXInside && isYInside) return 0; | ||
@@ -100,0 +98,0 @@ var minYDist = Math.min(Math.abs(yd1), Math.abs(yd2), Math.abs(yd3), Math.abs(yd4)); |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/regenerator')) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/typeof')) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -24,2 +24,6 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
var toVoid = function toVoid() {}; | ||
/** | ||
* Synonym for `toVoid()` because it's a convention | ||
*/ | ||
var noop = toVoid; | ||
@@ -26,0 +30,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/slicedToArray')) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -43,3 +43,5 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
var alphabet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'abcdefghijklmnopqrstuvwxyz'; | ||
return Array(length).join().split(',').map(function () { | ||
return Array.from({ | ||
length: length | ||
}, function () { | ||
return alphabet.charAt(Math.floor(Math.random() * alphabet.length)); | ||
@@ -46,0 +48,0 @@ }).join(''); |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).utils=e.utils||{})}(this,(function(e){"use strict";e.camelToConst=function(e){return e.split(/(?=[A-Z])/).join("_").toUpperCase()},e.capitalize=function(e){return"".concat(e[0].toUpperCase()).concat(e.substr(1))},e.nthIndexOf=function(e,n){for(var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=0,i=e.indexOf(n);o<t&&i>=0;)i=e.indexOf(n,i+1),o++;return i},e.randomString=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz";return Array(e).join().split(",").map((function(){return n.charAt(Math.floor(Math.random()*n.length))})).join("")},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).utils=e.utils||{})}(this,(function(e){"use strict";e.camelToConst=function(e){return e.split(/(?=[A-Z])/).join("_").toUpperCase()},e.capitalize=function(e){return"".concat(e[0].toUpperCase()).concat(e.substr(1))},e.nthIndexOf=function(e,n){for(var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=0,i=e.indexOf(n);o<t&&i>=0;)i=e.indexOf(n,i+1),o++;return i},e.randomString=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz";return Array.from({length:e},(function(){return n.charAt(Math.floor(Math.random()*n.length))})).join("")},Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -200,2 +200,6 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
}; | ||
/** | ||
* Synonym for `wait()` because `await timeout(250)` reads nicer | ||
*/ | ||
var timeout = wait; | ||
@@ -202,0 +206,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.29.0 Copyright 2021 Fritz Lekschas | ||
// @flekschas/utils v0.30.0 Copyright 2023 Fritz Lekschas | ||
/* eslint no-param-reassign:0 */ | ||
@@ -1129,7 +1129,5 @@ | ||
const randomString = (length, alphabet = 'abcdefghijklmnopqrstuvwxyz') => | ||
Array(length) | ||
.join() | ||
.split(',') | ||
.map(() => alphabet.charAt(Math.floor(Math.random() * alphabet.length))) | ||
.join(''); | ||
Array.from({ length }, () => | ||
alphabet.charAt(Math.floor(Math.random() * alphabet.length)) | ||
).join(''); | ||
@@ -1489,2 +1487,5 @@ /** | ||
/** | ||
* Synonym for `toVoid()` because it's a convention | ||
*/ | ||
const noop = toVoid; | ||
@@ -1738,6 +1739,9 @@ | ||
/** | ||
* Synonym for `wait()` because `await timeout(250)` reads nicer | ||
*/ | ||
const timeout = wait; | ||
var version = "0.29.0"; | ||
var version = "0.30.0"; | ||
export { addClass, aggregate, argSort, array2dTranspose, assign, camelToConst, capitalize, clamp, clearArray, cloneEvent, createHtmlByTemplate, createWorker, cubicIn, cubicInOut, cubicOut, debounce, decToRgb, deepClone, diff, extend, forEach, forwardEvent, hasClass, hexToDec, hexToRgbArray, hexToRgbaArray, identity, interpolateNumber, interpolateVector, isArray, isClose, isFunction, isHex, isNormFloat, isNormFloatArray, isNumber, isObject, isParentOf, isPointHalfwayInRect, isPointInPolygon, isPointInRect, isRgbArray, isRgbStr, isRgbaArray, isRgbaStr, isString, isUint8, isUint8Array, iteratorToArray, l1Dist, l1DistByDim, l1PointDist, l2Dist, l2DistByDim, l2Norm, l2PointDist, lDist, lPointDist, lRectDist, linear, map, mapFilter, max, maxNan, maxVector, mean, meanNan, meanVector, median, medianVector, mergeMaps, min, minNan, minVector, mod, nextAnimationFrame, noop, normalize, nthIndexOf, pipe, quadIn, quadInOut, quadOut, quartIn, quartInOut, quartOut, quintIn, quintInOut, quintOut, randomString, range, rangeMap, removeAllChildren, removeClass, removeLastChild, rgbStrToDec, rgbStrToRgbArray, rgbToHex, rgbaStrToRgbaArray, some, sortAsc, sortDesc, sortPos, sum, sumNan, sumVector, throttle, throttleAndDebounce, timeout, toRgbaArray, toVoid, unionIntegers, unique, update, version, wait, withConstructor, withForwardedMethod, withProperty, withReadOnlyProperty, withStaticProperty }; |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/defineEnumerableProperties"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/regenerator")):"function"==typeof define&&define.amd?define(["exports","@babel/runtime/helpers/toConsumableArray","@babel/runtime/helpers/defineEnumerableProperties","@babel/runtime/helpers/defineProperty","@babel/runtime/helpers/typeof","@babel/runtime/helpers/slicedToArray","@babel/runtime/regenerator"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).utils={},n._toConsumableArray,n._defineEnumerableProperties,n._defineProperty,n._typeof,n._slicedToArray,n._regeneratorRuntime)}(this,(function(n,t,r,e,u,o,i){"use strict";function a(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var c=a(t),f=a(r),s=a(e),l=a(u),d=a(o),h=a(i),p=function(n,t,r){return n*(1-(r=Math.min(1,Math.max(0,r))))+t*r},m=function(n){return n},v=Array.isArray,g=function(n){return!!(n&&n.constructor&&n.call&&n.apply)},b=function(n){return/(^#[0-9A-Fa-f]{6}$)|(^#[0-9A-Fa-f]{3}$)/i.test(n)},y=function(n){return A(n)&&n>=0&&n<=1},w=function(n){return Array.isArray(n)&&n.every(y)},A=function(n){return"number"==typeof n},M=function(n){return 3===n.length&&(w(n)||x(n))},O=function(n){return 4===n.length&&(w(n)||x(n)||x(n.slice(0,3))&&y(n[3]))},j=function(n){return Number.isInteger(n)&&n>=0&&n<=255},x=function(n){return Array.isArray(n)&&n.every(j)},P=function(n){return Math.sqrt(n.reduce((function(n,t){return n+Math.pow(t,2)}),0))},T=function(n){return n.reduce((function(n,t){return t>n?t:n}),-1/0)},R=T,N=function(n){return n[Math.floor(n.length/2)]},q=N,I=function(n){return n.reduce((function(n,t){return t<n?t:n}),1/0)},C=I,E=function(n){var t=P(n);return n.map((function(n){return n/t}))},S=function(n){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(n){return n},r=[],e=0;e<n;e++)r.push(t(e,n));return r},D=function(n){return n.reduce((function(n,t){return t?n+t:n}),0)},F=D,_=function(n){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return n.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(n,t,r,e){return"#".concat(t).concat(t).concat(r).concat(r).concat(e).concat(e)})).substring(1).match(/.{2}/g).map((function(n){return parseInt(n,16)/Math.pow(255,t)}))},U=function(n){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return[].concat(c.default(_(n,t)),[Math.pow(255,!t)])},L=function(n){return n.match(/[\d.]+/g).slice(0,4).map((function(n){return+n}))},Y=L;function X(n,t){var r;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(r=function(n,t){if(!n)return;if("string"==typeof n)return k(n,t);var r=Object.prototype.toString.call(n).slice(8,-1);"Object"===r&&n.constructor&&(r=n.constructor.name);if("Map"===r||"Set"===r)return Array.from(n);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return k(n,t)}(n))||t&&n&&"number"==typeof n.length){r&&(n=r);var e=0,u=function(){};return{s:u,n:function(){return e>=n.length?{done:!0}:{done:!1,value:n[e++]}},e:function(n){throw n},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){r=n[Symbol.iterator]()},n:function(){var n=r.next();return i=n.done,n},e:function(n){a=!0,o=n},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw o}}}}function k(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}var V="http://www.w3.org/2000/svg",B=function(n,t){if(n.namespaceURI===V){var r=n.getAttribute("class");return r&&!!r.match(new RegExp("(\\s|^)".concat(t,"(\\s|$)")))}return n.classList?n.classList.contains(t):!!n.className.match(new RegExp("(\\s|^)".concat(t,"(\\s|$)")))},H=function(n){var t=new n.constructor(n.type,n);return t.sourceUid=n.sourceUid,t.forwarded=n.forwarded,t},$=function(n){for(var t=arguments.length,r=new Array(t>1?t-1:0),e=1;e<t;e++)r[e-1]=arguments[e];return r.forEach((function(t){var r=Object.keys(t).reduce((function(n,r){return n[r]=Object.getOwnPropertyDescriptor(t,r),n}),{});Object.getOwnPropertySymbols(t).forEach((function(n){var e=Object.getOwnPropertyDescriptor(t,n);e.enumerable&&(r[n]=e)})),Object.defineProperties(n,r)})),n},z=function n(t,r){if(null===r||"object"!==l.default(r))return r;if(r.constructor!==Object&&r.constructor!==Array)return r;if(r.constructor===Date||r.constructor===RegExp||r.constructor===Function||r.constructor===String||r.constructor===Number||r.constructor===Boolean)return new r.constructor(r);var e=t||new r.constructor;return Object.keys(r).forEach((function(t){var u=Object.getOwnPropertyDescriptor(r,t);void 0===e[t]&&(void 0===u.value?Object.defineProperty(e,t,u):e[t]=n(void 0,r[t]))})),e},G=function(n){return"".concat(n[0].toUpperCase()).concat(n.substr(1))},W=function(){},Z=W,J=function(n,t){return n-t},K=function(n){return new Promise((function(t){return setTimeout(t,n)}))},Q=K;n.addClass=function(n,t){if(n.namespaceURI===V){if(!B(n,t)){var r=n.getAttribute("class")||"";n.setAttribute("class","".concat(r," ").concat(t))}}else n.classList?n.classList.add(t):B(n,t)||(n.className+=" ".concat(t))},n.aggregate=function(n,t,r){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=e.getter,o=void 0===u?m:u,i=g(t),a=i?[t]:t,c=i?[r]:r,f=n.reduce((function(n,t){return a.map((function(r,e){return r(n[e],o(t))}))}),void 0===c?Array(a.length).fill(0):c);return i?f[0]:f},n.argSort=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.getter,e=void 0===r?m:r,u=t.comparator,o=void 0===u?J:u,i=t.ignoreNull,a=void 0!==i&&i;return n.map(a?function(n,t){return null===e(n)?void 0:[e(n),t]}:function(n,t){return[e(n),t]}).sort((function(n,t){return o(n[0],t[0])})).reduce((function(n,t){return t?(n.push(t[1]),n):n}),[])},n.array2dTranspose=function(n){for(var t=c.default(new Array(n[0].length).fill().map((function(){return[]}))),r=0;r<n.length;r++)for(var e=0;e<n[r].length;e++)t[e][r]=n[r][e];return t},n.assign=$,n.camelToConst=function(n){return n.split(/(?=[A-Z])/).join("_").toUpperCase()},n.capitalize=G,n.clamp=function(n,t,r){return n<t?t:n>r?r:n},n.clearArray=function(n){return n.splice(0,n.length),n},n.cloneEvent=H,n.createHtmlByTemplate=function(n){var t=document.createElement("div");return t.insertAdjacentHTML("beforeend",n),t.firstChild},n.createWorker=function(n){return new Worker(window.URL.createObjectURL(new Blob(["(".concat(n.toString(),")()")],{type:"text/javascript"})))},n.cubicIn=function(n){return n*n*n},n.cubicInOut=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},n.cubicOut=function(n){return--n*n*n+1},n.debounce=function(n,t){var r,e=function(){for(var e=arguments.length,u=new Array(e),o=0;o<e;o++)u[o]=arguments[o];var i=function(){r=null,n.apply(void 0,u)};clearTimeout(r),r=setTimeout(i,t)};return e.cancel=function(){clearTimeout(r)},e.now=function(){return n.apply(void 0,arguments)},e},n.decToRgb=function(n){return[n>>16,(n>>8)%256,n%256]},n.deepClone=function(n){return z(undefined,n)},n.diff=function(n,t){return n.map((function(n,r){return n-t[r]}))},n.extend=z,n.forEach=function(n){return function(t){return Array.prototype.forEach.call(t,n)}},n.forwardEvent=function(n,t){t.dispatchEvent(H(n))},n.hasClass=B,n.hexToDec=function(n){return parseInt(n.substr(1),16)},n.hexToRgbArray=_,n.hexToRgbaArray=U,n.identity=m,n.interpolateNumber=p,n.interpolateVector=function(n,t,r){return n.map((function(n,e){return p(n,t[e],r)}))},n.isArray=v,n.isClose=function(n,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6;return Math.abs(n-t)<Math.pow(10,-r)},n.isFunction=g,n.isHex=b,n.isNormFloat=y,n.isNormFloatArray=w,n.isNumber=A,n.isObject=function(n){return!!n&&n.constructor===Object},n.isParentOf=function(n,t){for(var r=n;r&&r!==t&&"HTML"!==r.tagName;)r=r.parentNode;return r===t},n.isPointHalfwayInRect=function(n,t){var r=d.default(n,2),e=r[0],u=r[1],o=d.default(t,4),i=o[0],a=o[1],c=o[2],f=o[3];return e>=i&&e<=a||u>=c&&u<=f},n.isPointInPolygon=function(){for(var n,t,r,e,u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=d.default(u,2),i=o[0],a=o[1],c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],f=!1,s=0,l=c.length-2;s<c.length;s+=2)n=c[s],t=c[s+1],r=c[l],t>a!=(e=c[l+1])>a&&i<(r-n)*(a-t)/(e-t)+n&&(f=!f),l=s;return f},n.isPointInRect=function(n,t){var r=d.default(n,2),e=r[0],u=r[1],o=d.default(t,4),i=o[0],a=o[1],c=o[2],f=o[3];return e>=i&&e<=a&&u>=c&&u<=f},n.isRgbArray=M,n.isRgbStr=function(n){return/rgb\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*\)/i.test(n)},n.isRgbaArray=O,n.isRgbaStr=function(n){return/rgba\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*\)/i.test(n)},n.isString=function(n){return"string"==typeof n||n instanceof String},n.isUint8=j,n.isUint8Array=x,n.iteratorToArray=function(n){var t,r=[],e=X(n);try{for(e.s();!(t=e.n()).done;){var u=t.value;r.push(u)}}catch(n){e.e(n)}finally{e.f()}return r},n.l1Dist=function(n,t){return n.length===t.length?n.reduce((function(n,r,e){return n+Math.abs(r-t[e])}),0):void 0},n.l1DistByDim=function(n){var t=Array(n).fill().map((function(n,t){return"s += Math.abs(v[".concat(t,"] - w[").concat(t,"]);")})).join(" ");return new Function("v","w","let s = 0; ".concat(t," return s;"))},n.l1PointDist=function(n,t,r,e){return Math.abs(n-r)+Math.abs(t-e)},n.l2Dist=function(n,t){return n.length===t.length?Math.sqrt(n.reduce((function(n,r,e){return n+Math.pow(r-t[e],2)}),0)):void 0},n.l2DistByDim=function(n){var t=Array(n).fill().map((function(n,t){return"s += Math.pow(v[".concat(t,"] - w[").concat(t,"], 2);")})).join(" ");return new Function("v","w","let s = 0; ".concat(t," return Math.sqrt(s);"))},n.l2Norm=P,n.l2PointDist=function(n,t,r,e){return Math.sqrt(Math.pow(n-r,2)+Math.pow(t-e,2))},n.lDist=function(n,t){if(Number.isNaN(+t))return function(t,r){return t.length===r.length?Math.pow(t.reduce((function(t,e,u){return t+Math.pow(Math.abs(e-r[u]),n)}),0),1/n):void 0};var r=Array(t).fill().map((function(n,t){return"s += Math.abs(v[".concat(t,"] - w[").concat(t,"]) ** l;")})).join(" ");return new Function("v","w","const l = ".concat(n,"; let s = 0; ").concat(r," return s ** (1 / l);"))},n.lPointDist=function(n){return function(t,r,e,u){return Math.pow(Math.pow(Math.abs(t-e),n)+Math.pow(Math.abs(r-u),n),1/n)}},n.lRectDist=function(n){return function(t,r){var e=r.minX-t.minX,u=r.minX-t.maxX,o=r.maxX-t.minX,i=r.maxX-t.maxX,a=e<0&&o>0||u<0&&i>0||e>0&&u<0||o>0&&i<0,c=r.minY-t.minY,f=r.minY-t.maxY,s=r.maxY-t.minY,l=r.maxY-t.maxY,d=c<0&&s>0||f<0&&l>0||c>0&&f<0||s>0&&l<0;if(a&&d)return 0;var h=Math.min(Math.abs(c),Math.abs(f),Math.abs(s),Math.abs(l));if(a)return h;var p=Math.min(Math.abs(e),Math.abs(u),Math.abs(o),Math.abs(i));return d?p:Math.pow(Math.pow(p,n)+Math.pow(h,n),1/n)}},n.linear=function(n){return n},n.map=function(n){return function(t){return Array.prototype.map.call(t,n)}},n.mapFilter=function(n,t){return function(r){for(var e=[],u=0;u<r.length;u++){var o=n(r[u],u);t(o,e.length)&&e.push(o)}return e}},n.max=T,n.maxNan=R,n.maxVector=function(n){switch(n.length){case 0:return[];case 1:return n[0];default:return n.reduce((function(n,t){return t.map((function(t,r){return n[r]>t?n[r]:t}))}),new Array(n[0].length).fill(-1/0))}},n.mean=function(n){return D(n)/n.length},n.meanNan=function(n){var t=0;return n.reduce((function(n,r){return r||0===r?++t&&n+r:n}),0)/t},n.meanVector=function(n){switch(n.length){case 0:return[];case 1:return n[0];default:return n.reduce((function(t,r){return r.map((function(r,e){return t[e]+r/n.length}))}),new Array(n[0].length).fill(0))}},n.median=N,n.medianVector=q,n.mergeMaps=function(n,t){return new Map(h.default.mark((function r(){return h.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(n,"t0",1);case 1:return r.delegateYield(t,"t1",2);case 2:case"end":return r.stop()}}),r)}))())},n.min=I,n.minNan=C,n.minVector=function(n){switch(n.length){case 0:return[];case 1:return n[0];default:return n.reduce((function(n,t){return t.map((function(t,r){return n[r]<t?n[r]:t}))}),new Array(n[0].length).fill(1/0))}},n.mod=function(n,t){return(n%t+n)%t},n.nextAnimationFrame=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(t){var r=0;!function e(){return requestAnimationFrame((function(){++r<n?e():t()}))}()}))},n.noop=Z,n.normalize=E,n.nthIndexOf=function(n,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,e=0,u=n.indexOf(t);e<r&&u>=0;)u=n.indexOf(t,u+1),e++;return u},n.pipe=function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];return function(n){return t.reduce((function(n,t){return t(n)}),n)}},n.quadIn=function(n){return n*n},n.quadInOut=function(n){return n<.5?2*n*n:(4-2*n)*n-1},n.quadOut=function(n){return n*(2-n)},n.quartIn=function(n){return n*n*n*n},n.quartInOut=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},n.quartOut=function(n){return 1- --n*n*n*n},n.quintIn=function(n){return n*n*n*n*n},n.quintInOut=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},n.quintOut=function(n){return 1+--n*n*n*n*n},n.randomString=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz";return Array(n).join().split(",").map((function(){return t.charAt(Math.floor(Math.random()*t.length))})).join("")},n.range=function(n,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,e=r*Math.sign(t-n);return Number.isNaN(+t)?S(n):S(Math.ceil(Math.abs(t-n)/Math.abs(r)),(function(t){return n+t*e}))},n.rangeMap=S,n.removeAllChildren=function(n){for(;n.firstChild;)n.removeChild(n.firstChild)},n.removeClass=function(n,t){var r=new RegExp("(\\s|^)".concat(t,"(\\s|$)"));if(n.namespaceURI===V){var e=n.getAttribute("class")||"";n.setAttribute("class",e.replace(r," "))}else n.classList?n.classList.remove(t):B(n,t)&&(n.className=n.className.replace(r," "))},n.removeLastChild=function(n){n.removeChild(n.lastChild)},n.rgbStrToDec=function(n){return L(n).slice(0,3).map((function(n,t){return+n<<8*(2-t)})).reduce((function(n,t){return t+n}),0)},n.rgbStrToRgbArray=L,n.rgbToHex=function(n,t,r){var e=function(n){var t=n.toString(16);return 1===t.length?"0".concat(t):t};return"#".concat(e(n)).concat(e(t)).concat(e(r))},n.rgbaStrToRgbaArray=Y,n.some=function(n){return function(t){return Array.prototype.some.call(t,n)}},n.sortAsc=J,n.sortDesc=function(n,t){return t-n},n.sortPos=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.getter,e=void 0===r?m:r,u=t.comparator,o=void 0===u?J:u,i=t.ignoreNull,a=void 0!==i&&i;return Object.entries(n).map(a?function(n){var t=d.default(n,2),r=t[0],u=t[1];return null===e(u)?void 0:[r,e(u)]}:function(n){var t=d.default(n,2),r=t[0],u=t[1];return[r,e(u)]}).sort((function(n,t){return o(n[1],t[1])})).reduce((function(n,t,r){return t?(n[t[0]]=r,n):n}),new n.constructor)},n.sum=D,n.sumNan=F,n.sumVector=function(n){switch(n.length){case 0:return[];case 1:return n[0];default:return n.reduce((function(n,t){return t.map((function(t,r){return n[r]+t}))}),new Array(n[0].length).fill(0))}},n.throttle=function(n,t){var r=!1,e=function(){r||(n.apply(void 0,arguments),r=!0,setTimeout((function(){r=!1}),t))};return e.reset=function(){r=!1},e.now=function(){return n.apply(void 0,arguments)},e},n.throttleAndDebounce=function(n,t){var r,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=0;e=null===e?t:e;var o=function(){for(var t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];var a=function(){u>0&&(n.apply(void 0,o),u=0)};clearTimeout(r),r=setTimeout(a,e)},i=!1,a=function(){i?(u++,o.apply(void 0,arguments)):(n.apply(void 0,arguments),o.apply(void 0,arguments),i=!0,u=0,setTimeout((function(){i=!1}),t))};return a.reset=function(){i=!1},a.cancel=function(){clearTimeout(r)},a.now=function(){return n.apply(void 0,arguments)},a},n.timeout=Q,n.toRgbaArray=function(n,t){return O(n)?t&&!w(n)?t(n):n:M(n)?[].concat(c.default(t?E(n):n),[Math.pow(255,!t)]):b(n)?U(n,t):(console.warn("Only HEX, RGB, and RGBA are handled by this function. Returning white instead."),t?[1,1,1,1]:[255,255,255,255])},n.toVoid=W,n.unionIntegers=function(n,t){var r=[];return n.forEach((function(n){r[n]=!0})),t.forEach((function(n){r[n]=!0})),r.reduce((function(n,t,r){return t&&n.push(r),n}),[])},n.unique=function(n){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m,r=new Set,e=[],u=0;u<n.length;u++){var o=t(n[u]);r.has(o)||(r.add(o),e.push(o))}return e},n.update=function n(t,r){if(null===r||"object"!==l.default(r))return r;if(r.constructor!==Object&&r.constructor!==Array)return new r.constructor(r);var e=new t.constructor,u=!1;return Object.keys(r).forEach((function(o){var i=Object.getOwnPropertyDescriptor(r,o);void 0===t[o]?void 0===i.value?Object.defineProperty(e,o,i):e[o]=z(void 0,r[o]):e[o]=n(t[o],r[o]),u=u||e[o]!==t[o]})),(u=u||Object.keys(t).filter((function(n){return void 0===r[n]})).length)?e:t},n.version="0.29.0",n.wait=K,n.withConstructor=function(n){return function(t){return $({__proto__:{constructor:n}},t)}},n.withForwardedMethod=function(n,t){return function(r){return $(r,s.default({},n,(function(){for(var n=arguments.length,r=new Array(n),e=0;e<n;e++)r[e]=arguments[e];return t.apply(this,r)})))}},n.withProperty=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.initialValue,e=void 0===r?void 0:r,u=t.getter,o=t.setter,i=t.cloner,a=void 0===i?m:i,c=t.transformer,l=void 0===c?m:c,d=t.validator,h=void 0===d?function(){return!0}:d;return function(t){var r,i,c=e,d=u?function(){return u()}:function(){return a(c)},p=o?function(n){return o(n)}:function(n){var t=l(n);c=h(t)?t:c};return $(t,(r={},(i={})[n]=i[n]||{},i[n].get=function(){return d()},s.default(r,"set".concat(G(n)),(function(n){p(n)})),f.default(r,i),r))}},n.withReadOnlyProperty=function(n,t){return function(r){var e,u;return $(r,(e={},(u={})[n]=u[n]||{},u[n].get=function(){return t()},f.default(e,u),e))}},n.withStaticProperty=function(n,t){return function(r){var e,u;return $(r,(e={},(u={})[n]=u[n]||{},u[n].get=function(){return t},f.default(e,u),e))}},Object.defineProperty(n,"__esModule",{value:!0})})); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/defineEnumerableProperties"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/regenerator")):"function"==typeof define&&define.amd?define(["exports","@babel/runtime/helpers/toConsumableArray","@babel/runtime/helpers/defineEnumerableProperties","@babel/runtime/helpers/defineProperty","@babel/runtime/helpers/typeof","@babel/runtime/helpers/slicedToArray","@babel/runtime/regenerator"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).utils={},n._toConsumableArray,n._defineEnumerableProperties,n._defineProperty,n._typeof,n._slicedToArray,n._regeneratorRuntime)}(this,(function(n,t,r,e,u,o,i){"use strict";function a(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var c=a(t),f=a(r),s=a(e),l=a(u),d=a(o),h=a(i),p=function(n,t,r){return n*(1-(r=Math.min(1,Math.max(0,r))))+t*r},v=function(n){return n},m=Array.isArray,g=function(n){return!!(n&&n.constructor&&n.call&&n.apply)},b=function(n){return/(^#[0-9A-Fa-f]{6}$)|(^#[0-9A-Fa-f]{3}$)/i.test(n)},y=function(n){return A(n)&&n>=0&&n<=1},w=function(n){return Array.isArray(n)&&n.every(y)},A=function(n){return"number"==typeof n},M=function(n){return 3===n.length&&(w(n)||x(n))},O=function(n){return 4===n.length&&(w(n)||x(n)||x(n.slice(0,3))&&y(n[3]))},j=function(n){return Number.isInteger(n)&&n>=0&&n<=255},x=function(n){return Array.isArray(n)&&n.every(j)},P=function(n){return Math.sqrt(n.reduce((function(n,t){return n+Math.pow(t,2)}),0))},T=function(n){return n.reduce((function(n,t){return t>n?t:n}),-1/0)},R=T,N=function(n){return n[Math.floor(n.length/2)]},q=N,I=function(n){return n.reduce((function(n,t){return t<n?t:n}),1/0)},C=I,E=function(n){var t=P(n);return n.map((function(n){return n/t}))},D=function(n){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(n){return n},r=[],e=0;e<n;e++)r.push(t(e,n));return r},S=function(n){return n.reduce((function(n,t){return t?n+t:n}),0)},F=S,_=function(n){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return n.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(n,t,r,e){return"#".concat(t).concat(t).concat(r).concat(r).concat(e).concat(e)})).substring(1).match(/.{2}/g).map((function(n){return parseInt(n,16)/Math.pow(255,t)}))},U=function(n){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return[].concat(c.default(_(n,t)),[Math.pow(255,!t)])},L=function(n){return n.match(/[\d.]+/g).slice(0,4).map((function(n){return+n}))},Y=L;function X(n,t){var r="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(!r){if(Array.isArray(n)||(r=function(n,t){if(!n)return;if("string"==typeof n)return k(n,t);var r=Object.prototype.toString.call(n).slice(8,-1);"Object"===r&&n.constructor&&(r=n.constructor.name);if("Map"===r||"Set"===r)return Array.from(n);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return k(n,t)}(n))||t&&n&&"number"==typeof n.length){r&&(n=r);var e=0,u=function(){};return{s:u,n:function(){return e>=n.length?{done:!0}:{done:!1,value:n[e++]}},e:function(n){throw n},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){r=r.call(n)},n:function(){var n=r.next();return i=n.done,n},e:function(n){a=!0,o=n},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw o}}}}function k(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}var V="http://www.w3.org/2000/svg",B=function(n,t){if(n.namespaceURI===V){var r=n.getAttribute("class");return r&&!!r.match(new RegExp("(\\s|^)".concat(t,"(\\s|$)")))}return n.classList?n.classList.contains(t):!!n.className.match(new RegExp("(\\s|^)".concat(t,"(\\s|$)")))},H=function(n){var t=new n.constructor(n.type,n);return t.sourceUid=n.sourceUid,t.forwarded=n.forwarded,t},$=function(n){for(var t=arguments.length,r=new Array(t>1?t-1:0),e=1;e<t;e++)r[e-1]=arguments[e];return r.forEach((function(t){var r=Object.keys(t).reduce((function(n,r){return n[r]=Object.getOwnPropertyDescriptor(t,r),n}),{});Object.getOwnPropertySymbols(t).forEach((function(n){var e=Object.getOwnPropertyDescriptor(t,n);e.enumerable&&(r[n]=e)})),Object.defineProperties(n,r)})),n},z=function n(t,r){if(null===r||"object"!==l.default(r))return r;if(r.constructor!==Object&&r.constructor!==Array)return r;if(r.constructor===Date||r.constructor===RegExp||r.constructor===Function||r.constructor===String||r.constructor===Number||r.constructor===Boolean)return new r.constructor(r);var e=t||new r.constructor;return Object.keys(r).forEach((function(t){var u=Object.getOwnPropertyDescriptor(r,t);void 0===e[t]&&(void 0===u.value?Object.defineProperty(e,t,u):e[t]=n(void 0,r[t]))})),e},G=function(n){return"".concat(n[0].toUpperCase()).concat(n.substr(1))},W=function(){},Z=W,J=function(n,t){return n-t},K=function(n){return new Promise((function(t){return setTimeout(t,n)}))},Q=K;n.addClass=function(n,t){if(n.namespaceURI===V){if(!B(n,t)){var r=n.getAttribute("class")||"";n.setAttribute("class","".concat(r," ").concat(t))}}else n.classList?n.classList.add(t):B(n,t)||(n.className+=" ".concat(t))},n.aggregate=function(n,t,r){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=e.getter,o=void 0===u?v:u,i=g(t),a=i?[t]:t,c=i?[r]:r,f=n.reduce((function(n,t){return a.map((function(r,e){return r(n[e],o(t))}))}),void 0===c?Array(a.length).fill(0):c);return i?f[0]:f},n.argSort=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.getter,e=void 0===r?v:r,u=t.comparator,o=void 0===u?J:u,i=t.ignoreNull,a=void 0!==i&&i;return n.map(a?function(n,t){return null===e(n)?void 0:[e(n),t]}:function(n,t){return[e(n),t]}).sort((function(n,t){return o(n[0],t[0])})).reduce((function(n,t){return t?(n.push(t[1]),n):n}),[])},n.array2dTranspose=function(n){for(var t=c.default(new Array(n[0].length).fill().map((function(){return[]}))),r=0;r<n.length;r++)for(var e=0;e<n[r].length;e++)t[e][r]=n[r][e];return t},n.assign=$,n.camelToConst=function(n){return n.split(/(?=[A-Z])/).join("_").toUpperCase()},n.capitalize=G,n.clamp=function(n,t,r){return n<t?t:n>r?r:n},n.clearArray=function(n){return n.splice(0,n.length),n},n.cloneEvent=H,n.createHtmlByTemplate=function(n){var t=document.createElement("div");return t.insertAdjacentHTML("beforeend",n),t.firstChild},n.createWorker=function(n){return new Worker(window.URL.createObjectURL(new Blob(["(".concat(n.toString(),")()")],{type:"text/javascript"})))},n.cubicIn=function(n){return n*n*n},n.cubicInOut=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},n.cubicOut=function(n){return--n*n*n+1},n.debounce=function(n,t){var r,e=function(){for(var e=arguments.length,u=new Array(e),o=0;o<e;o++)u[o]=arguments[o];var i=function(){r=null,n.apply(void 0,u)};clearTimeout(r),r=setTimeout(i,t)};return e.cancel=function(){clearTimeout(r)},e.now=function(){return n.apply(void 0,arguments)},e},n.decToRgb=function(n){return[n>>16,(n>>8)%256,n%256]},n.deepClone=function(n){return z(undefined,n)},n.diff=function(n,t){return n.map((function(n,r){return n-t[r]}))},n.extend=z,n.forEach=function(n){return function(t){return Array.prototype.forEach.call(t,n)}},n.forwardEvent=function(n,t){t.dispatchEvent(H(n))},n.hasClass=B,n.hexToDec=function(n){return parseInt(n.substr(1),16)},n.hexToRgbArray=_,n.hexToRgbaArray=U,n.identity=v,n.interpolateNumber=p,n.interpolateVector=function(n,t,r){return n.map((function(n,e){return p(n,t[e],r)}))},n.isArray=m,n.isClose=function(n,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6;return Math.abs(n-t)<Math.pow(10,-r)},n.isFunction=g,n.isHex=b,n.isNormFloat=y,n.isNormFloatArray=w,n.isNumber=A,n.isObject=function(n){return!!n&&n.constructor===Object},n.isParentOf=function(n,t){for(var r=n;r&&r!==t&&"HTML"!==r.tagName;)r=r.parentNode;return r===t},n.isPointHalfwayInRect=function(n,t){var r=d.default(n,2),e=r[0],u=r[1],o=d.default(t,4),i=o[0],a=o[1],c=o[2],f=o[3];return e>=i&&e<=a||u>=c&&u<=f},n.isPointInPolygon=function(){for(var n,t,r,e,u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=d.default(u,2),i=o[0],a=o[1],c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],f=!1,s=0,l=c.length-2;s<c.length;s+=2)n=c[s],t=c[s+1],r=c[l],t>a!=(e=c[l+1])>a&&i<(r-n)*(a-t)/(e-t)+n&&(f=!f),l=s;return f},n.isPointInRect=function(n,t){var r=d.default(n,2),e=r[0],u=r[1],o=d.default(t,4),i=o[0],a=o[1],c=o[2],f=o[3];return e>=i&&e<=a&&u>=c&&u<=f},n.isRgbArray=M,n.isRgbStr=function(n){return/rgb\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*\)/i.test(n)},n.isRgbaArray=O,n.isRgbaStr=function(n){return/rgba\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*\)/i.test(n)},n.isString=function(n){return"string"==typeof n||n instanceof String},n.isUint8=j,n.isUint8Array=x,n.iteratorToArray=function(n){var t,r=[],e=X(n);try{for(e.s();!(t=e.n()).done;){var u=t.value;r.push(u)}}catch(n){e.e(n)}finally{e.f()}return r},n.l1Dist=function(n,t){return n.length===t.length?n.reduce((function(n,r,e){return n+Math.abs(r-t[e])}),0):void 0},n.l1DistByDim=function(n){var t=Array(n).fill().map((function(n,t){return"s += Math.abs(v[".concat(t,"] - w[").concat(t,"]);")})).join(" ");return new Function("v","w","let s = 0; ".concat(t," return s;"))},n.l1PointDist=function(n,t,r,e){return Math.abs(n-r)+Math.abs(t-e)},n.l2Dist=function(n,t){return n.length===t.length?Math.sqrt(n.reduce((function(n,r,e){return n+Math.pow(r-t[e],2)}),0)):void 0},n.l2DistByDim=function(n){var t=Array(n).fill().map((function(n,t){return"s += Math.pow(v[".concat(t,"] - w[").concat(t,"], 2);")})).join(" ");return new Function("v","w","let s = 0; ".concat(t," return Math.sqrt(s);"))},n.l2Norm=P,n.l2PointDist=function(n,t,r,e){return Math.sqrt(Math.pow(n-r,2)+Math.pow(t-e,2))},n.lDist=function(n,t){if(Number.isNaN(+t))return function(t,r){return t.length===r.length?Math.pow(t.reduce((function(t,e,u){return t+Math.pow(Math.abs(e-r[u]),n)}),0),1/n):void 0};var r=Array(t).fill().map((function(n,t){return"s += Math.abs(v[".concat(t,"] - w[").concat(t,"]) ** l;")})).join(" ");return new Function("v","w","const l = ".concat(n,"; let s = 0; ").concat(r," return s ** (1 / l);"))},n.lPointDist=function(n){return function(t,r,e,u){return Math.pow(Math.pow(Math.abs(t-e),n)+Math.pow(Math.abs(r-u),n),1/n)}},n.lRectDist=function(n){return function(t,r){var e=r.minX-t.minX,u=r.minX-t.maxX,o=r.maxX-t.minX,i=r.maxX-t.maxX,a=e<0&&o>0||u<0&&i>0||e>0&&u<0||o>0&&i<0,c=r.minY-t.minY,f=r.minY-t.maxY,s=r.maxY-t.minY,l=r.maxY-t.maxY,d=c<0&&s>0||f<0&&l>0||c>0&&f<0||s>0&&l<0;if(a&&d)return 0;var h=Math.min(Math.abs(c),Math.abs(f),Math.abs(s),Math.abs(l));if(a)return h;var p=Math.min(Math.abs(e),Math.abs(u),Math.abs(o),Math.abs(i));return d?p:Math.pow(Math.pow(p,n)+Math.pow(h,n),1/n)}},n.linear=function(n){return n},n.map=function(n){return function(t){return Array.prototype.map.call(t,n)}},n.mapFilter=function(n,t){return function(r){for(var e=[],u=0;u<r.length;u++){var o=n(r[u],u);t(o,e.length)&&e.push(o)}return e}},n.max=T,n.maxNan=R,n.maxVector=function(n){switch(n.length){case 0:return[];case 1:return n[0];default:return n.reduce((function(n,t){return t.map((function(t,r){return n[r]>t?n[r]:t}))}),new Array(n[0].length).fill(-1/0))}},n.mean=function(n){return S(n)/n.length},n.meanNan=function(n){var t=0;return n.reduce((function(n,r){return r||0===r?++t&&n+r:n}),0)/t},n.meanVector=function(n){switch(n.length){case 0:return[];case 1:return n[0];default:return n.reduce((function(t,r){return r.map((function(r,e){return t[e]+r/n.length}))}),new Array(n[0].length).fill(0))}},n.median=N,n.medianVector=q,n.mergeMaps=function(n,t){return new Map(h.default.mark((function r(){return h.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(n,"t0",1);case 1:return r.delegateYield(t,"t1",2);case 2:case"end":return r.stop()}}),r)}))())},n.min=I,n.minNan=C,n.minVector=function(n){switch(n.length){case 0:return[];case 1:return n[0];default:return n.reduce((function(n,t){return t.map((function(t,r){return n[r]<t?n[r]:t}))}),new Array(n[0].length).fill(1/0))}},n.mod=function(n,t){return(n%t+n)%t},n.nextAnimationFrame=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(t){var r=0;!function e(){return requestAnimationFrame((function(){++r<n?e():t()}))}()}))},n.noop=Z,n.normalize=E,n.nthIndexOf=function(n,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,e=0,u=n.indexOf(t);e<r&&u>=0;)u=n.indexOf(t,u+1),e++;return u},n.pipe=function(){for(var n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];return function(n){return t.reduce((function(n,t){return t(n)}),n)}},n.quadIn=function(n){return n*n},n.quadInOut=function(n){return n<.5?2*n*n:(4-2*n)*n-1},n.quadOut=function(n){return n*(2-n)},n.quartIn=function(n){return n*n*n*n},n.quartInOut=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},n.quartOut=function(n){return 1- --n*n*n*n},n.quintIn=function(n){return n*n*n*n*n},n.quintInOut=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},n.quintOut=function(n){return 1+--n*n*n*n*n},n.randomString=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz";return Array.from({length:n},(function(){return t.charAt(Math.floor(Math.random()*t.length))})).join("")},n.range=function(n,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,e=r*Math.sign(t-n);return Number.isNaN(+t)?D(n):D(Math.ceil(Math.abs(t-n)/Math.abs(r)),(function(t){return n+t*e}))},n.rangeMap=D,n.removeAllChildren=function(n){for(;n.firstChild;)n.removeChild(n.firstChild)},n.removeClass=function(n,t){var r=new RegExp("(\\s|^)".concat(t,"(\\s|$)"));if(n.namespaceURI===V){var e=n.getAttribute("class")||"";n.setAttribute("class",e.replace(r," "))}else n.classList?n.classList.remove(t):B(n,t)&&(n.className=n.className.replace(r," "))},n.removeLastChild=function(n){n.removeChild(n.lastChild)},n.rgbStrToDec=function(n){return L(n).slice(0,3).map((function(n,t){return+n<<8*(2-t)})).reduce((function(n,t){return t+n}),0)},n.rgbStrToRgbArray=L,n.rgbToHex=function(n,t,r){var e=function(n){var t=n.toString(16);return 1===t.length?"0".concat(t):t};return"#".concat(e(n)).concat(e(t)).concat(e(r))},n.rgbaStrToRgbaArray=Y,n.some=function(n){return function(t){return Array.prototype.some.call(t,n)}},n.sortAsc=J,n.sortDesc=function(n,t){return t-n},n.sortPos=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.getter,e=void 0===r?v:r,u=t.comparator,o=void 0===u?J:u,i=t.ignoreNull,a=void 0!==i&&i;return Object.entries(n).map(a?function(n){var t=d.default(n,2),r=t[0],u=t[1];return null===e(u)?void 0:[r,e(u)]}:function(n){var t=d.default(n,2),r=t[0],u=t[1];return[r,e(u)]}).sort((function(n,t){return o(n[1],t[1])})).reduce((function(n,t,r){return t?(n[t[0]]=r,n):n}),new n.constructor)},n.sum=S,n.sumNan=F,n.sumVector=function(n){switch(n.length){case 0:return[];case 1:return n[0];default:return n.reduce((function(n,t){return t.map((function(t,r){return n[r]+t}))}),new Array(n[0].length).fill(0))}},n.throttle=function(n,t){var r=!1,e=function(){r||(n.apply(void 0,arguments),r=!0,setTimeout((function(){r=!1}),t))};return e.reset=function(){r=!1},e.now=function(){return n.apply(void 0,arguments)},e},n.throttleAndDebounce=function(n,t){var r,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=0;e=null===e?t:e;var o=function(){for(var t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];var a=function(){u>0&&(n.apply(void 0,o),u=0)};clearTimeout(r),r=setTimeout(a,e)},i=!1,a=function(){i?(u++,o.apply(void 0,arguments)):(n.apply(void 0,arguments),o.apply(void 0,arguments),i=!0,u=0,setTimeout((function(){i=!1}),t))};return a.reset=function(){i=!1},a.cancel=function(){clearTimeout(r)},a.now=function(){return n.apply(void 0,arguments)},a},n.timeout=Q,n.toRgbaArray=function(n,t){return O(n)?t&&!w(n)?t(n):n:M(n)?[].concat(c.default(t?E(n):n),[Math.pow(255,!t)]):b(n)?U(n,t):(console.warn("Only HEX, RGB, and RGBA are handled by this function. Returning white instead."),t?[1,1,1,1]:[255,255,255,255])},n.toVoid=W,n.unionIntegers=function(n,t){var r=[];return n.forEach((function(n){r[n]=!0})),t.forEach((function(n){r[n]=!0})),r.reduce((function(n,t,r){return t&&n.push(r),n}),[])},n.unique=function(n){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v,r=new Set,e=[],u=0;u<n.length;u++){var o=t(n[u]);r.has(o)||(r.add(o),e.push(o))}return e},n.update=function n(t,r){if(null===r||"object"!==l.default(r))return r;if(r.constructor!==Object&&r.constructor!==Array)return new r.constructor(r);var e=new t.constructor,u=!1;return Object.keys(r).forEach((function(o){var i=Object.getOwnPropertyDescriptor(r,o);void 0===t[o]?void 0===i.value?Object.defineProperty(e,o,i):e[o]=z(void 0,r[o]):e[o]=n(t[o],r[o]),u=u||e[o]!==t[o]})),(u=u||Object.keys(t).filter((function(n){return void 0===r[n]})).length)?e:t},n.version="0.30.0",n.wait=K,n.withConstructor=function(n){return function(t){return $({__proto__:{constructor:n}},t)}},n.withForwardedMethod=function(n,t){return function(r){return $(r,s.default({},n,(function(){for(var n=arguments.length,r=new Array(n),e=0;e<n;e++)r[e]=arguments[e];return t.apply(this,r)})))}},n.withProperty=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.initialValue,e=void 0===r?void 0:r,u=t.getter,o=t.setter,i=t.cloner,a=void 0===i?v:i,c=t.transformer,l=void 0===c?v:c,d=t.validator,h=void 0===d?function(){return!0}:d;return function(t){var r,i,c=e,d=u?function(){return u()}:function(){return a(c)},p=o?function(n){return o(n)}:function(n){var t=l(n);c=h(t)?t:c};return $(t,(r={},(i={})[n]=i[n]||{},i[n].get=function(){return d()},s.default(r,"set".concat(G(n)),(function(n){p(n)})),f.default(r,i),r))}},n.withReadOnlyProperty=function(n,t){return function(r){var e,u;return $(r,(e={},(u={})[n]=u[n]||{},u[n].get=function(){return t()},f.default(e,u),e))}},n.withStaticProperty=function(n,t){return function(r){var e,u;return $(r,(e={},(u={})[n]=u[n]||{},u[n].get=function(){return t},f.default(e,u),e))}},Object.defineProperty(n,"__esModule",{value:!0})})); |
{ | ||
"name": "@flekschas/utils", | ||
"version": "0.29.0", | ||
"version": "0.30.0", | ||
"description": "A set of utility functions I use across projects", | ||
@@ -31,2 +31,3 @@ "author": { | ||
"pretest": "npm run lint", | ||
"furz": "rollup -c ./rollup.test.config.js", | ||
"test": "rollup -c ./rollup.test.config.js | tape-run --render='tap-spec'", | ||
@@ -43,6 +44,6 @@ "watch": "rollup -cw" | ||
"@rollup/plugin-babel": "^5.2.2", | ||
"@rollup/plugin-commonjs": "^17.0.0", | ||
"@rollup/plugin-commonjs": "^20.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-multi-entry": "~4.0.0", | ||
"@rollup/plugin-node-resolve": "^11.1.0", | ||
"@rollup/plugin-multi-entry": "~4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.0.4", | ||
"eslint": "~7.18.0", | ||
@@ -64,3 +65,3 @@ "eslint-config-airbnb": "~18.2.1", | ||
"pretty-quick": "~3.1.0", | ||
"rollup": "~2.38.0", | ||
"rollup": "~2.56.3", | ||
"rollup-plugin-filesize": "~9.1.0", | ||
@@ -67,0 +68,0 @@ "rollup-plugin-terser": "~7.0.2", |
# A collection of handy utility functions | ||
[![NPM Version](https://img.shields.io/npm/v/@flekschas/utils.svg?style=flat-square&color=7f99ff)](https://npmjs.org/package/@flekschas/utils) | ||
[![Build Status](https://img.shields.io/github/workflow/status/flekschas/utils/build?color=a17fff&style=flat-square)](https://github.com/flekschas/utils/actions?query=workflow%3Abuild) | ||
[![Build Status](https://img.shields.io/github/actions/workflow/status/flekschas/utils/build.yml?branch=master&color=a17fff&style=flat-square)](https://github.com/flekschas/utils/actions?query=workflow%3Abuild) | ||
[![File Size](http://img.badgesize.io/https://unpkg.com/@flekschas/utils/dist/utils.min.js?compression=gzip&style=flat-square&color=e17fff)](https://bundlephobia.com/result?p=@flekschas/utils) | ||
@@ -6,0 +6,0 @@ [![Code Style Prettier](https://img.shields.io/badge/code%20style-prettier-ff7fe1.svg?style=flat-square)](https://github.com/prettier/prettier#readme) |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7562
318386
78