@flekschas/utils
Advanced tools
Comparing version 0.18.0 to 0.19.0
@@ -0,1 +1,7 @@ | ||
## v0.19.0 | ||
- Add `diff()`, `l1DistByDim`, `l2DistByDim` to _vector_ | ||
- Add `dim` parameter to `lDist` to work like `l1DistByDim` and `l2DistByDim` | ||
- Improve `isClose()` | ||
## v0.18.0 | ||
@@ -2,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/* eslint no-param-reassign:0 */ | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Identity function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Test if an object is a function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Store the values of an iterator in an array. |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
const XMLNS = 'http://www.w3.org/2000/svg'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 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.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Identity function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * L distance between a pair of vectors |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
const mergeMaps = (map1, map2) => | ||
@@ -3,0 +3,0 @@ new Map( |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -18,4 +18,4 @@ * Identity function | ||
const isClose = (a, b, precision = 6) => | ||
Math.round(Math.abs(a - b) * 10 ** precision) === 0; | ||
Math.abs(a - b) < 10 ** -precision; | ||
export { identity, isClose }; |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
const assign = (target, ...sources) => { | ||
@@ -3,0 +3,0 @@ sources.forEach(source => { |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Create a worker from a function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Identity function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
const camelToConst = str => | ||
@@ -3,0 +3,0 @@ str |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Debounce a function call. |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Test if an object is a function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -45,18 +45,41 @@ * Identity function | ||
/** | ||
* Get the difference of two vectoe | ||
* @param {array} v - Numerical vectors | ||
* @param {array} w - Numerical vectors | ||
* @return {array} Difference vector | ||
*/ | ||
const diff = (v, w) => v.map((x, i) => x - w[i]); | ||
/** | ||
* L distance between a pair of vectors | ||
* | ||
* @param {array} l - Defines the Lp space | ||
* @param {number} dim - Dimension of the input data (Optional) | ||
*/ | ||
const lDist = l => | ||
/** | ||
* L distance function | ||
* @param {array} v - First vector | ||
* @param {array} w - Second vector | ||
* @return {array} L distance | ||
*/ | ||
(v, w) => | ||
v.length === w.length | ||
? v.reduce((sum, x, i) => sum + Math.abs(x - w[i]) ** l, 0) ** (1 / l) | ||
: undefined; | ||
const lDist = (l, dim) => { | ||
if (Number.isNaN(+dim)) { | ||
/** | ||
* L distance function | ||
* @param {array} v - First vector | ||
* @param {array} w - Second vector | ||
* @return {array} L distance | ||
*/ | ||
return (v, w) => | ||
v.length === w.length | ||
? v.reduce((sum, x, i) => sum + Math.abs(x - w[i]) ** l, 0) ** (1 / l) | ||
: undefined; | ||
} | ||
const body = Array(dim) | ||
.fill() | ||
.map((_, i) => `s += Math.abs(v[${i}] - w[${i}]) ** l;`) | ||
.join(' '); | ||
// eslint-disable-next-line no-new-func | ||
return new Function( | ||
'v', | ||
'w', | ||
`const l = ${l}; let s = 0; ${body} return s ** (1 / l);` | ||
); | ||
}; | ||
/** | ||
@@ -78,2 +101,20 @@ * L1 distance between a pair of vectors | ||
/** | ||
* Creates a l1 distance function tailored to the dimension of the data | ||
* | ||
* @description | ||
* This is identical but faster than `l1Dist(v, w)` | ||
* | ||
* @param {number} dim - Dimension of the input data | ||
* @return {function} A function with the same signature as `l1Dist` | ||
*/ | ||
const l1DistByDim = dim => { | ||
const body = Array(dim) | ||
.fill() | ||
.map((_, i) => `s += Math.abs(v[${i}] - w[${i}]);`) | ||
.join(' '); | ||
// eslint-disable-next-line no-new-func | ||
return new Function('v', 'w', `let s = 0; ${body} return s;`); | ||
}; | ||
/** | ||
* L2 distance between a pair of vectors | ||
@@ -94,2 +135,24 @@ * | ||
/** | ||
* Creates a l2 distance function tailored to the dimension of the data | ||
* | ||
* @description | ||
* This is identical but faster than `l2Dist(v, w)` | ||
* | ||
* @param {number} dim - Dimension of the input data | ||
* @return {function} A function with the same signature as `l2Dist` | ||
*/ | ||
const l2DistByDim = dim => { | ||
const body = Array(dim) | ||
.fill() | ||
.map((_, i) => `d = v[${i}] - w[${i}]; s += d * d;`) | ||
.join(' '); | ||
// eslint-disable-next-line no-new-func | ||
return new Function( | ||
'v', | ||
'w', | ||
`let s = 0; let d; ${body} return Math.sqrt(s);` | ||
); | ||
}; | ||
/** | ||
* Vector L2 norm | ||
@@ -259,2 +322,2 @@ * | ||
export { aggregate, l1Dist, l2Dist, l2Norm, lDist, max, maxVector, mean, meanVector, min, minVector, mod, normalize, range, sum, sumVector }; | ||
export { aggregate, diff, l1Dist, l1DistByDim, l2Dist, l2DistByDim, l2Norm, lDist, max, maxVector, mean, meanVector, min, minVector, mod, normalize, range, sum, sumVector }; |
{ | ||
"name": "@flekschas/utils", | ||
"version": "0.18.0", | ||
"version": "0.19.0", | ||
"description": "A set of utility functions I use across projects", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -27,3 +27,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6; | ||
return Math.round(Math.abs(a - b) * Math.pow(10, precision)) === 0; | ||
return Math.abs(a - b) < Math.pow(10, -precision); | ||
}; | ||
@@ -30,0 +30,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).utils=e.utils||{})}(this,(function(e){"use strict";e.identity=function(e){return e},e.isClose=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6;return 0===Math.round(Math.abs(e-t)*Math.pow(10,n))},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).utils=e.utils||{})}(this,(function(e){"use strict";e.identity=function(e){return e},e.isClose=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6;return Math.abs(e-t)<Math.pow(10,-n)},Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -51,9 +51,22 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
/** | ||
* Get the difference of two vectoe | ||
* @param {array} v - Numerical vectors | ||
* @param {array} w - Numerical vectors | ||
* @return {array} Difference vector | ||
*/ | ||
var diff = function diff(v, w) { | ||
return v.map(function (x, i) { | ||
return x - w[i]; | ||
}); | ||
}; | ||
/** | ||
* L distance between a pair of vectors | ||
* | ||
* @param {array} l - Defines the Lp space | ||
* @param {number} dim - Dimension of the input data (Optional) | ||
*/ | ||
var lDist = function lDist(l) { | ||
return ( | ||
var lDist = function lDist(l, dim) { | ||
if (Number.isNaN(+dim)) { | ||
/** | ||
@@ -65,8 +78,14 @@ * L distance function | ||
*/ | ||
function (v, w) { | ||
return function (v, w) { | ||
return v.length === w.length ? Math.pow(v.reduce(function (sum, x, i) { | ||
return sum + Math.pow(Math.abs(x - w[i]), l); | ||
}, 0), 1 / l) : undefined; | ||
} | ||
); | ||
}; | ||
} | ||
var body = Array(dim).fill().map(function (_, i) { | ||
return "s += Math.abs(v[".concat(i, "] - w[").concat(i, "]) ** l;"); | ||
}).join(' '); // eslint-disable-next-line no-new-func | ||
return new Function('v', 'w', "const l = ".concat(l, "; let s = 0; ").concat(body, " return s ** (1 / l);")); | ||
}; | ||
@@ -90,2 +109,19 @@ /** | ||
/** | ||
* Creates a l1 distance function tailored to the dimension of the data | ||
* | ||
* @description | ||
* This is identical but faster than `l1Dist(v, w)` | ||
* | ||
* @param {number} dim - Dimension of the input data | ||
* @return {function} A function with the same signature as `l1Dist` | ||
*/ | ||
var l1DistByDim = function l1DistByDim(dim) { | ||
var body = Array(dim).fill().map(function (_, i) { | ||
return "s += Math.abs(v[".concat(i, "] - w[").concat(i, "]);"); | ||
}).join(' '); // eslint-disable-next-line no-new-func | ||
return new Function('v', 'w', "let s = 0; ".concat(body, " return s;")); | ||
}; | ||
/** | ||
* L2 distance between a pair of vectors | ||
@@ -107,2 +143,19 @@ * | ||
/** | ||
* Creates a l2 distance function tailored to the dimension of the data | ||
* | ||
* @description | ||
* This is identical but faster than `l2Dist(v, w)` | ||
* | ||
* @param {number} dim - Dimension of the input data | ||
* @return {function} A function with the same signature as `l2Dist` | ||
*/ | ||
var l2DistByDim = function l2DistByDim(dim) { | ||
var body = Array(dim).fill().map(function (_, i) { | ||
return "d = v[".concat(i, "] - w[").concat(i, "]; s += d * d;"); | ||
}).join(' '); // eslint-disable-next-line no-new-func | ||
return new Function('v', 'w', "let s = 0; let d; ".concat(body, " return Math.sqrt(s);")); | ||
}; | ||
/** | ||
* Vector L2 norm | ||
@@ -302,4 +355,7 @@ * | ||
exports.aggregate = aggregate; | ||
exports.diff = diff; | ||
exports.l1Dist = l1Dist; | ||
exports.l1DistByDim = l1DistByDim; | ||
exports.l2Dist = l2Dist; | ||
exports.l2DistByDim = l2DistByDim; | ||
exports.l2Norm = l2Norm; | ||
@@ -306,0 +362,0 @@ exports.lDist = lDist; |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).utils=n.utils||{})}(this,(function(n){"use strict";var t=function(n){return n},e=function(n){return!!(n&&n.constructor&&n.call&&n.apply)},r=function(n){return Math.sqrt(n.reduce((function(n,t){return n+Math.pow(t,2)}),0))},u=function(n){return n.reduce((function(n,t){return n+t}),0)};n.aggregate=function(n,r,u){var c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=c.getter,o=void 0===i?t:i,f=e(r),a=f?[r]:r,l=f?[u]:u,d=n.reduce((function(n,t){return a.map((function(e,r){return e(n[r],o(t))}))}),void 0===l?Array(a.length).fill(0):l);return f?d[0]:d},n.l1Dist=function(n,t){return n.length===t.length?n.reduce((function(n,e,r){return n+Math.abs(e-t[r])}),0):void 0},n.l2Dist=function(n,t){return n.length===t.length?Math.sqrt(n.reduce((function(n,e,r){return n+Math.pow(e-t[r],2)}),0)):void 0},n.l2Norm=r,n.lDist=function(n){return function(t,e){return t.length===e.length?Math.pow(t.reduce((function(t,r,u){return t+Math.pow(Math.abs(r-e[u]),n)}),0),1/n):void 0}},n.max=function(n){return n.reduce((function(n,t){return n>t?n:t}),-1/0)},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,e){return n[e]>t?n[e]:t}))}),new Array(n[0].length).fill(-1/0))}},n.mean=function(n){return u(n)/n.length},n.meanVector=function(n){switch(n.length){case 0:return[];case 1:return n[0];default:return n.reduce((function(t,e){return e.map((function(e,r){return t[r]+e/n.length}))}),new Array(n[0].length).fill(0))}},n.min=function(n){return n.reduce((function(n,t){return n<t?n:t}),1/0)},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,e){return n[e]<t?n[e]:t}))}),new Array(n[0].length).fill(1/0))}},n.mod=function(n,t){return(n%t+n)%t},n.normalize=function(n){var t=r(n);return n.map((function(n){return n/t}))},n.range=function(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Array(Math.ceil((t-n)/e)).fill().map((function(t,r){return n+r*e}))},n.sum=u,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,e){return n[e]+t}))}),new Array(n[0].length).fill(0))}},Object.defineProperty(n,"__esModule",{value:!0})})); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).utils=n.utils||{})}(this,(function(n){"use strict";var t=function(n){return n},r=function(n){return!!(n&&n.constructor&&n.call&&n.apply)},e=function(n){return Math.sqrt(n.reduce((function(n,t){return n+Math.pow(t,2)}),0))},u=function(n){return n.reduce((function(n,t){return n+t}),0)};n.aggregate=function(n,e,u){var c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=c.getter,o=void 0===i?t:i,a=r(e),f=a?[e]:e,l=a?[u]:u,s=n.reduce((function(n,t){return f.map((function(r,e){return r(n[e],o(t))}))}),void 0===l?Array(f.length).fill(0):l);return a?s[0]:s},n.diff=function(n,t){return n.map((function(n,r){return n-t[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.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"d = v[".concat(t,"] - w[").concat(t,"]; s += d * d;")})).join(" ");return new Function("v","w","let s = 0; let d; ".concat(t," return Math.sqrt(s);"))},n.l2Norm=e,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.max=function(n){return n.reduce((function(n,t){return n>t?n:t}),-1/0)},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 u(n)/n.length},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.min=function(n){return n.reduce((function(n,t){return n<t?n:t}),1/0)},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.normalize=function(n){var t=e(n);return n.map((function(n){return n/t}))},n.range=function(n,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Array(Math.ceil((t-n)/r)).fill().map((function(t,e){return n+e*r}))},n.sum=u,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))}},Object.defineProperty(n,"__esModule",{value:!0})})); |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
/* eslint no-param-reassign:0 */ | ||
@@ -152,3 +152,3 @@ | ||
const isClose = (a, b, precision = 6) => | ||
Math.round(Math.abs(a - b) * 10 ** precision) === 0; | ||
Math.abs(a - b) < 10 ** -precision; | ||
@@ -329,18 +329,41 @@ /** | ||
/** | ||
* Get the difference of two vectoe | ||
* @param {array} v - Numerical vectors | ||
* @param {array} w - Numerical vectors | ||
* @return {array} Difference vector | ||
*/ | ||
const diff = (v, w) => v.map((x, i) => x - w[i]); | ||
/** | ||
* L distance between a pair of vectors | ||
* | ||
* @param {array} l - Defines the Lp space | ||
* @param {number} dim - Dimension of the input data (Optional) | ||
*/ | ||
const lDist = l => | ||
/** | ||
* L distance function | ||
* @param {array} v - First vector | ||
* @param {array} w - Second vector | ||
* @return {array} L distance | ||
*/ | ||
(v, w) => | ||
v.length === w.length | ||
? v.reduce((sum, x, i) => sum + Math.abs(x - w[i]) ** l, 0) ** (1 / l) | ||
: undefined; | ||
const lDist = (l, dim) => { | ||
if (Number.isNaN(+dim)) { | ||
/** | ||
* L distance function | ||
* @param {array} v - First vector | ||
* @param {array} w - Second vector | ||
* @return {array} L distance | ||
*/ | ||
return (v, w) => | ||
v.length === w.length | ||
? v.reduce((sum, x, i) => sum + Math.abs(x - w[i]) ** l, 0) ** (1 / l) | ||
: undefined; | ||
} | ||
const body = Array(dim) | ||
.fill() | ||
.map((_, i) => `s += Math.abs(v[${i}] - w[${i}]) ** l;`) | ||
.join(' '); | ||
// eslint-disable-next-line no-new-func | ||
return new Function( | ||
'v', | ||
'w', | ||
`const l = ${l}; let s = 0; ${body} return s ** (1 / l);` | ||
); | ||
}; | ||
/** | ||
@@ -362,2 +385,20 @@ * L1 distance between a pair of vectors | ||
/** | ||
* Creates a l1 distance function tailored to the dimension of the data | ||
* | ||
* @description | ||
* This is identical but faster than `l1Dist(v, w)` | ||
* | ||
* @param {number} dim - Dimension of the input data | ||
* @return {function} A function with the same signature as `l1Dist` | ||
*/ | ||
const l1DistByDim = dim => { | ||
const body = Array(dim) | ||
.fill() | ||
.map((_, i) => `s += Math.abs(v[${i}] - w[${i}]);`) | ||
.join(' '); | ||
// eslint-disable-next-line no-new-func | ||
return new Function('v', 'w', `let s = 0; ${body} return s;`); | ||
}; | ||
/** | ||
* L2 distance between a pair of vectors | ||
@@ -378,2 +419,24 @@ * | ||
/** | ||
* Creates a l2 distance function tailored to the dimension of the data | ||
* | ||
* @description | ||
* This is identical but faster than `l2Dist(v, w)` | ||
* | ||
* @param {number} dim - Dimension of the input data | ||
* @return {function} A function with the same signature as `l2Dist` | ||
*/ | ||
const l2DistByDim = dim => { | ||
const body = Array(dim) | ||
.fill() | ||
.map((_, i) => `d = v[${i}] - w[${i}]; s += d * d;`) | ||
.join(' '); | ||
// eslint-disable-next-line no-new-func | ||
return new Function( | ||
'v', | ||
'w', | ||
`let s = 0; let d; ${body} return Math.sqrt(s);` | ||
); | ||
}; | ||
/** | ||
* Vector L2 norm | ||
@@ -1458,4 +1521,4 @@ * | ||
var version = "0.18.0"; | ||
var version = "0.19.0"; | ||
export { addClass, aggregate, argSort, array2dTranspose, assign, camelToConst, capitalize, clearArray, cloneEvent, createHtmlByTemplate, createWorker, cubicIn, cubicInOut, cubicOut, debounce, deepClone, extend, forEach, forwardEvent, hasClass, hexToDec, hexToRgbArray, hexToRgbaArray, identity, interpolateNumber, interpolateVector, isClose, isFunction, isHex, isNormFloat, isNormFloatArray, isNumber, isParentOf, isPointHalfwayInRect, isPointInPolygon, isPointInRect, isRgbArray, isRgbStr, isRgbaArray, isRgbaStr, isString, isUint8, isUint8Array, iteratorToArray, l1Dist, l1PointDist, l2Dist, l2Norm, l2PointDist, lDist, lPointDist, linear, map, mapFilter, max, maxVector, mean, meanVector, mergeMaps, min, minVector, mod, nextAnimationFrame, normalize, pipe, quadIn, quadInOut, quadOut, quartIn, quartInOut, quartOut, quintIn, quintInOut, quintOut, randomString, range, removeAllChildren, removeClass, removeLastChild, rgbStrToDec, rgbStrToRgbArray, rgbToHex, rgbaStrToRgbaArray, some, sortAsc, sortDesc, sortPos, sum, sumVector, throttle, throttleAndDebounce, toRgbaArray, toVoid, unique, update, version, wait, withConstructor, withForwardedMethod, withProperty, withReadOnlyProperty, withStaticProperty }; | ||
export { addClass, aggregate, argSort, array2dTranspose, assign, camelToConst, capitalize, clearArray, cloneEvent, createHtmlByTemplate, createWorker, cubicIn, cubicInOut, cubicOut, debounce, deepClone, diff, extend, forEach, forwardEvent, hasClass, hexToDec, hexToRgbArray, hexToRgbaArray, identity, interpolateNumber, interpolateVector, isClose, isFunction, isHex, isNormFloat, isNormFloatArray, isNumber, isParentOf, isPointHalfwayInRect, isPointInPolygon, isPointInRect, isRgbArray, isRgbStr, isRgbaArray, isRgbaStr, isString, isUint8, isUint8Array, iteratorToArray, l1Dist, l1DistByDim, l1PointDist, l2Dist, l2DistByDim, l2Norm, l2PointDist, lDist, lPointDist, linear, map, mapFilter, max, maxVector, mean, meanVector, mergeMaps, min, minVector, mod, nextAnimationFrame, normalize, pipe, quadIn, quadInOut, quadOut, quartIn, quartInOut, quartOut, quintIn, quintInOut, quintOut, randomString, range, removeAllChildren, removeClass, removeLastChild, rgbStrToDec, rgbStrToRgbArray, rgbToHex, rgbaStrToRgbaArray, some, sortAsc, sortDesc, sortPos, sum, sumVector, throttle, throttleAndDebounce, toRgbaArray, toVoid, unique, update, version, wait, withConstructor, withForwardedMethod, withProperty, withReadOnlyProperty, withStaticProperty }; |
72
utils.js
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.18.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.19.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -303,3 +303,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
var precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6; | ||
return Math.round(Math.abs(a - b) * Math.pow(10, precision)) === 0; | ||
return Math.abs(a - b) < Math.pow(10, -precision); | ||
}; | ||
@@ -498,9 +498,22 @@ | ||
/** | ||
* Get the difference of two vectoe | ||
* @param {array} v - Numerical vectors | ||
* @param {array} w - Numerical vectors | ||
* @return {array} Difference vector | ||
*/ | ||
var diff = function diff(v, w) { | ||
return v.map(function (x, i) { | ||
return x - w[i]; | ||
}); | ||
}; | ||
/** | ||
* L distance between a pair of vectors | ||
* | ||
* @param {array} l - Defines the Lp space | ||
* @param {number} dim - Dimension of the input data (Optional) | ||
*/ | ||
var lDist = function lDist(l) { | ||
return ( | ||
var lDist = function lDist(l, dim) { | ||
if (Number.isNaN(+dim)) { | ||
/** | ||
@@ -512,8 +525,14 @@ * L distance function | ||
*/ | ||
function (v, w) { | ||
return function (v, w) { | ||
return v.length === w.length ? Math.pow(v.reduce(function (sum, x, i) { | ||
return sum + Math.pow(Math.abs(x - w[i]), l); | ||
}, 0), 1 / l) : undefined; | ||
} | ||
); | ||
}; | ||
} | ||
var body = Array(dim).fill().map(function (_, i) { | ||
return "s += Math.abs(v[".concat(i, "] - w[").concat(i, "]) ** l;"); | ||
}).join(' '); // eslint-disable-next-line no-new-func | ||
return new Function('v', 'w', "const l = ".concat(l, "; let s = 0; ").concat(body, " return s ** (1 / l);")); | ||
}; | ||
@@ -537,2 +556,19 @@ /** | ||
/** | ||
* Creates a l1 distance function tailored to the dimension of the data | ||
* | ||
* @description | ||
* This is identical but faster than `l1Dist(v, w)` | ||
* | ||
* @param {number} dim - Dimension of the input data | ||
* @return {function} A function with the same signature as `l1Dist` | ||
*/ | ||
var l1DistByDim = function l1DistByDim(dim) { | ||
var body = Array(dim).fill().map(function (_, i) { | ||
return "s += Math.abs(v[".concat(i, "] - w[").concat(i, "]);"); | ||
}).join(' '); // eslint-disable-next-line no-new-func | ||
return new Function('v', 'w', "let s = 0; ".concat(body, " return s;")); | ||
}; | ||
/** | ||
* L2 distance between a pair of vectors | ||
@@ -554,2 +590,19 @@ * | ||
/** | ||
* Creates a l2 distance function tailored to the dimension of the data | ||
* | ||
* @description | ||
* This is identical but faster than `l2Dist(v, w)` | ||
* | ||
* @param {number} dim - Dimension of the input data | ||
* @return {function} A function with the same signature as `l2Dist` | ||
*/ | ||
var l2DistByDim = function l2DistByDim(dim) { | ||
var body = Array(dim).fill().map(function (_, i) { | ||
return "d = v[".concat(i, "] - w[").concat(i, "]; s += d * d;"); | ||
}).join(' '); // eslint-disable-next-line no-new-func | ||
return new Function('v', 'w', "let s = 0; let d; ".concat(body, " return Math.sqrt(s);")); | ||
}; | ||
/** | ||
* Vector L2 norm | ||
@@ -1804,3 +1857,3 @@ * | ||
var version = "0.18.0"; | ||
var version = "0.19.0"; | ||
@@ -1823,2 +1876,3 @@ exports.addClass = addClass; | ||
exports.deepClone = deepClone; | ||
exports.diff = diff; | ||
exports.extend = extend; | ||
@@ -1853,4 +1907,6 @@ exports.forEach = forEach; | ||
exports.l1Dist = l1Dist; | ||
exports.l1DistByDim = l1DistByDim; | ||
exports.l1PointDist = l1PointDist; | ||
exports.l2Dist = l2Dist; | ||
exports.l2DistByDim = l2DistByDim; | ||
exports.l2Norm = l2Norm; | ||
@@ -1857,0 +1913,0 @@ exports.l2PointDist = l2PointDist; |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).utils={})}(this,(function(t){"use strict";var n=function(t,n,r){return t*(1-(r=Math.min(1,Math.max(0,r))))+n*r};function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function e(t,n){for(var r in n){(u=n[r]).configurable=u.enumerable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(t,r,u)}if(Object.getOwnPropertySymbols)for(var e=Object.getOwnPropertySymbols(n),o=0;o<e.length;o++){var u,i=e[o];(u=n[i]).configurable=u.enumerable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(t,i,u)}return t}function o(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function u(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if(!(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)))return;var r=[],e=!0,o=!1,u=void 0;try{for(var i,c=t[Symbol.iterator]();!(e=(i=c.next()).done)&&(r.push(i.value),!n||r.length!==n);e=!0);}catch(t){o=!0,u=t}finally{try{e||null==c.return||c.return()}finally{if(o)throw u}}return r}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function i(t){return function(t){if(Array.isArray(t)){for(var n=0,r=new Array(t.length);n<t.length;n++)r[n]=t[n];return r}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var c=function(t){return t},a=function(t){return!!(t&&t.constructor&&t.call&&t.apply)},f=function(t){return/(^#[0-9A-Fa-f]{6}$)|(^#[0-9A-Fa-f]{3}$)/i.test(t)},l=function(t){return d(t)&&t>=0&&t<=1},s=function(t){return Array.isArray(t)&&t.every(l)},d=function(t){return"number"==typeof t},p=function(t){return 3===t.length&&(s(t)||g(t))},h=function(t){return 4===t.length&&(s(t)||g(t)||g(t.slice(0,3))&&l(t[3]))},v=function(t){return Number.isInteger(t)&&t>=0&&t<=255},g=function(t){return Array.isArray(t)&&t.every(v)},y=function(t){return Math.sqrt(t.reduce((function(t,n){return t+Math.pow(n,2)}),0))},m=function(t){var n=y(t);return t.map((function(t){return t/n}))},b=function(t){return t.reduce((function(t,n){return t+n}),0)},w=function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(t,n,r,e){return"#".concat(n).concat(n).concat(r).concat(r).concat(e).concat(e)})).substring(1).match(/.{2}/g).map((function(t){return parseInt(t,16)/Math.pow(255,n)}))},A=function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return[].concat(i(w(t,n)),[Math.pow(255,!n)])},O=function(t){return t.match(/[\d.]+/g).slice(0,4).map((function(t){return+t}))},j=O,M="http://www.w3.org/2000/svg",S=function(t,n){if(t.namespaceURI===M){var r=t.getAttribute("class");return r&&!!r.match(new RegExp("(\\s|^)".concat(n,"(\\s|$)")))}return t.classList?t.classList.contains(n):!!t.className.match(new RegExp("(\\s|^)".concat(n,"(\\s|$)")))},P=function(t){var n=new t.constructor(t.type,t);return n.sourceUid=t.sourceUid,n.forwarded=t.forwarded,n},R=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return r.forEach((function(n){var r=Object.keys(n).reduce((function(t,r){return t[r]=Object.getOwnPropertyDescriptor(n,r),t}),{});Object.getOwnPropertySymbols(n).forEach((function(t){var e=Object.getOwnPropertyDescriptor(n,t);e.enumerable&&(r[t]=e)})),Object.defineProperties(t,r)})),t},T=function t(n,e){if(null===e||"object"!==r(e))return e;if(e.constructor!==Object&&e.constructor!==Array)return e;if(e.constructor===Date||e.constructor===RegExp||e.constructor===Function||e.constructor===String||e.constructor===Number||e.constructor===Boolean)return new e.constructor(e);var o=n||new e.constructor;return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);void 0===o[n]&&(void 0===r.value?Object.defineProperty(o,n,r):o[n]=t(void 0,e[n]))})),o},x=function(t){return"".concat(t[0].toUpperCase()).concat(t.substr(1))},I=function(t,n){return t-n};t.addClass=function(t,n){if(t.namespaceURI===M){if(!S(t,n)){var r=t.getAttribute("class")||"";t.setAttribute("class","".concat(r," ").concat(n))}}else t.classList?t.classList.add(n):S(t,n)||(t.className+=" ".concat(n))},t.aggregate=function(t,n,r){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=e.getter,u=void 0===o?c:o,i=a(n),f=i?[n]:n,l=i?[r]:r,s=t.reduce((function(t,n){return f.map((function(r,e){return r(t[e],u(n))}))}),void 0===l?Array(f.length).fill(0):l);return i?s[0]:s},t.argSort=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.getter,e=void 0===r?c:r,o=n.comparator,u=void 0===o?I:o,i=n.ignoreNull,a=void 0!==i&&i;return t.map(a?function(t,n){return null===e(t)?void 0:[e(t),n]}:function(t,n){return[e(t),n]}).sort((function(t,n){return u(t[0],n[0])})).reduce((function(t,n){return n?(t.push(n[1]),t):t}),[])},t.array2dTranspose=function(t){for(var n=i(new Array(t[0].length).fill().map((function(){return[]}))),r=0;r<t.length;r++)for(var e=0;e<t[r].length;e++)n[e][r]=t[r][e];return n},t.assign=R,t.camelToConst=function(t){return t.split(/(?=[A-Z])/).join("_").toUpperCase()},t.capitalize=x,t.clearArray=function(t){return t.splice(0,t.length),t},t.cloneEvent=P,t.createHtmlByTemplate=function(t){var n=document.createElement("div");return n.insertAdjacentHTML("beforeend",t),n.firstChild},t.createWorker=function(t){return new Worker(window.URL.createObjectURL(new Blob(["(".concat(t.toString(),")()")],{type:"text/javascript"})))},t.cubicIn=function(t){return t*t*t},t.cubicInOut=function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},t.cubicOut=function(t){return--t*t*t+1},t.debounce=function(t,n){var r,e=function(){for(var e=arguments.length,o=new Array(e),u=0;u<e;u++)o[u]=arguments[u];var i=function(){r=null,t.apply(void 0,o)};clearTimeout(r),r=setTimeout(i,n)};return e.cancel=function(){clearTimeout(r)},e.now=function(){return t.apply(void 0,arguments)},e},t.deepClone=function(t){return T(void 0,t)},t.extend=T,t.forEach=function(t){return function(n){return Array.prototype.forEach.call(n,t)}},t.forwardEvent=function(t,n){n.dispatchEvent(P(t))},t.hasClass=S,t.hexToDec=function(t){return parseInt(t.substr(1),16)},t.hexToRgbArray=w,t.hexToRgbaArray=A,t.identity=c,t.interpolateNumber=n,t.interpolateVector=function(t,r,e){return t.map((function(t,o){return n(t,r[o],e)}))},t.isClose=function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6;return 0===Math.round(Math.abs(t-n)*Math.pow(10,r))},t.isFunction=a,t.isHex=f,t.isNormFloat=l,t.isNormFloatArray=s,t.isNumber=d,t.isParentOf=function(t,n){for(var r=t;r&&r!==n&&"HTML"!==r.tagName;)r=r.parentNode;return r===n},t.isPointHalfwayInRect=function(t,n){var r=u(t,2),e=r[0],o=r[1],i=u(n,4),c=i[0],a=i[1],f=i[2],l=i[3];return e>=c&&e<=a||o>=f&&o<=l},t.isPointInPolygon=function(){for(var t,n,r,e,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=u(o,2),c=i[0],a=i[1],f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],l=!1,s=0,d=f.length-2;s<f.length;s+=2)t=f[s],n=f[s+1],r=f[d],n>a!=(e=f[d+1])>a&&c<(r-t)*(a-n)/(e-n)+t&&(l=!l),d=s;return l},t.isPointInRect=function(t,n){var r=u(t,2),e=r[0],o=r[1],i=u(n,4),c=i[0],a=i[1],f=i[2],l=i[3];return e>=c&&e<=a&&o>=f&&o<=l},t.isRgbArray=p,t.isRgbStr=function(t){return/rgb\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*\)/i.test(t)},t.isRgbaArray=h,t.isRgbaStr=function(t){return/rgba\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*\)/i.test(t)},t.isString=function(t){return"string"==typeof t||t instanceof String},t.isUint8=v,t.isUint8Array=g,t.iteratorToArray=function(t){var n=[],r=!0,e=!1,o=void 0;try{for(var u,i=t[Symbol.iterator]();!(r=(u=i.next()).done);r=!0){var c=u.value;n.push(c)}}catch(t){e=!0,o=t}finally{try{r||null==i.return||i.return()}finally{if(e)throw o}}return n},t.l1Dist=function(t,n){return t.length===n.length?t.reduce((function(t,r,e){return t+Math.abs(r-n[e])}),0):void 0},t.l1PointDist=function(t,n,r,e){return Math.abs(t-r)+Math.abs(n-e)},t.l2Dist=function(t,n){return t.length===n.length?Math.sqrt(t.reduce((function(t,r,e){return t+Math.pow(r-n[e],2)}),0)):void 0},t.l2Norm=y,t.l2PointDist=function(t,n,r,e){return Math.sqrt(Math.pow(t-r,2)+Math.pow(n-e,2))},t.lDist=function(t){return function(n,r){return n.length===r.length?Math.pow(n.reduce((function(n,e,o){return n+Math.pow(Math.abs(e-r[o]),t)}),0),1/t):void 0}},t.lPointDist=function(t){return function(n,r,e,o){return Math.pow(Math.pow(Math.abs(n-e),t)+Math.pow(Math.abs(r-o),t),1/t)}},t.linear=function(t){return t},t.map=function(t){return function(n){return Array.prototype.map.call(n,t)}},t.mapFilter=function(t,n){return function(r){for(var e=[],o=0;o<r.length;o++){var u=t(r[o],o);n(u,e.length)&&e.push(u)}return e}},t.max=function(t){return t.reduce((function(t,n){return t>n?t:n}),-1/0)},t.maxVector=function(t){switch(t.length){case 0:return[];case 1:return t[0];default:return t.reduce((function(t,n){return n.map((function(n,r){return t[r]>n?t[r]:n}))}),new Array(t[0].length).fill(-1/0))}},t.mean=function(t){return b(t)/t.length},t.meanVector=function(t){switch(t.length){case 0:return[];case 1:return t[0];default:return t.reduce((function(n,r){return r.map((function(r,e){return n[e]+r/t.length}))}),new Array(t[0].length).fill(0))}},t.mergeMaps=function(t,n){return new Map(regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(t,"t0",1);case 1:return r.delegateYield(n,"t1",2);case 2:case"end":return r.stop()}}),r)}))())},t.min=function(t){return t.reduce((function(t,n){return t<n?t:n}),1/0)},t.minVector=function(t){switch(t.length){case 0:return[];case 1:return t[0];default:return t.reduce((function(t,n){return n.map((function(n,r){return t[r]<n?t[r]:n}))}),new Array(t[0].length).fill(1/0))}},t.mod=function(t,n){return(t%n+t)%n},t.nextAnimationFrame=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(n){var r=0;!function e(){return requestAnimationFrame((function(){++r<t?e():n()}))}()}))},t.normalize=m,t.pipe=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(function(t){return n.reduce((function(t,n){return n(t)}),t)})},t.quadIn=function(t){return t*t},t.quadInOut=function(t){return t<.5?2*t*t:(4-2*t)*t-1},t.quadOut=function(t){return t*(2-t)},t.quartIn=function(t){return t*t*t*t},t.quartInOut=function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},t.quartOut=function(t){return 1- --t*t*t*t},t.quintIn=function(t){return t*t*t*t*t},t.quintInOut=function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t},t.quintOut=function(t){return 1+--t*t*t*t*t},t.randomString=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz";return Array(t).join().split(",").map((function(){return n.charAt(Math.floor(Math.random()*n.length))})).join("")},t.range=function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Array(Math.ceil((n-t)/r)).fill().map((function(n,e){return t+e*r}))},t.removeAllChildren=function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},t.removeClass=function(t,n){var r=new RegExp("(\\s|^)".concat(n,"(\\s|$)"));if(t.namespaceURI===M){var e=t.getAttribute("class")||"";t.setAttribute("class",e.replace(r," "))}else t.classList?t.classList.remove(n):S(t,n)&&(t.className=t.className.replace(r," "))},t.removeLastChild=function(t){t.removeChild(t.lastChild)},t.rgbStrToDec=function(t){return O(t).slice(0,3).map((function(t,n){return+t<<8*(2-n)})).reduce((function(t,n){return n+t}),0)},t.rgbStrToRgbArray=O,t.rgbToHex=function(t,n,r){var e=function(t){var n=t.toString(16);return 1===n.length?"0".concat(n):n};return"#".concat(e(t)).concat(e(n)).concat(e(r))},t.rgbaStrToRgbaArray=j,t.some=function(t){return function(n){return Array.prototype.some.call(n,t)}},t.sortAsc=I,t.sortDesc=function(t,n){return n-t},t.sortPos=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.getter,e=void 0===r?c:r,o=n.comparator,i=void 0===o?I:o,a=n.ignoreNull,f=void 0!==a&&a;return Object.entries(t).map(f?function(t){var n=u(t,2),r=n[0],o=n[1];return null===e(o)?void 0:[r,e(o)]}:function(t){var n=u(t,2),r=n[0],o=n[1];return[r,e(o)]}).sort((function(t,n){return i(t[1],n[1])})).reduce((function(t,n,r){return n?(t[n[0]]=r,t):t}),new t.constructor)},t.sum=b,t.sumVector=function(t){switch(t.length){case 0:return[];case 1:return t[0];default:return t.reduce((function(t,n){return n.map((function(n,r){return t[r]+n}))}),new Array(t[0].length).fill(0))}},t.throttle=function(t,n){var r=!1,e=function(){r||(t.apply(void 0,arguments),r=!0,setTimeout((function(){r=!1}),n))};return e.reset=function(){r=!1},e.now=function(){return t.apply(void 0,arguments)},e},t.throttleAndDebounce=function(t,n){var r,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=0;e=null===e?n:e;var u=function(){for(var n=arguments.length,u=new Array(n),i=0;i<n;i++)u[i]=arguments[i];var c=function(){o>0&&(t.apply(void 0,u),o=0)};clearTimeout(r),r=setTimeout(c,e)},i=!1,c=function(){i?(o++,u.apply(void 0,arguments)):(t.apply(void 0,arguments),u.apply(void 0,arguments),i=!0,o=0,setTimeout((function(){i=!1}),n))};return c.reset=function(){i=!1},c.cancel=function(){clearTimeout(r)},c.now=function(){return t.apply(void 0,arguments)},c},t.toRgbaArray=function(t,n){return h(t)?n&&!s(t)?n(t):t:p(t)?[].concat(i(n?m(t):t),[Math.pow(255,!n)]):f(t)?A(t,n):(console.warn("Only HEX, RGB, and RGBA are handled by this function. Returning white instead."),n?[1,1,1,1]:[255,255,255,255])},t.toVoid=function(){},t.unique=function(t){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c,r=new Set,e=[],o=0;o<t.length;o++){var u=n(t[o]);r.has(u)||(r.add(u),e.push(u))}return e},t.update=function t(n,e){if(null===e||"object"!==r(e))return e;if(e.constructor!==Object&&e.constructor!==Array)return new e.constructor(e);var o=new n.constructor,u=!1;return Object.keys(e).forEach((function(r){o[r]=t(n[r],e[r]),u=u||o[r]!==n[r]})),(u=u||Object.keys(n).filter((function(t){return void 0===e[t]})).length)?o:n},t.version="0.18.0",t.wait=function(t){return new Promise((function(n){return setTimeout(n,t)}))},t.withConstructor=function(t){return function(n){return R(n,{__proto__:{constructor:t}})}},t.withForwardedMethod=function(t,n){return function(r){return R(r,o({},t,(function(){for(var t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return n.apply(this,r)})))}},t.withProperty=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.initialValue,u=void 0===r?void 0:r,i=n.getter,a=n.setter,f=n.cloner,l=void 0===f?c:f,s=n.transformer,d=void 0===s?c:s,p=n.validator,h=void 0===p?function(){return!0}:p;return function(n){var r,c,f=u,s=i?function(){return i()}:function(){return l(f)},p=a?function(t){return a(t)}:function(t){var n=d(t);f=h(n)?n:f};return R(n,(r={},(c={})[t]=c[t]||{},c[t].get=function(){return s()},o(r,"set".concat(x(t)),(function(t){p(t)})),e(r,c),r))}},t.withReadOnlyProperty=function(t,n){return function(r){var o,u;return R(r,(o={},(u={})[t]=u[t]||{},u[t].get=function(){return n()},e(o,u),o))}},t.withStaticProperty=function(t,n){return function(r){var o,u;return R(r,(o={},(u={})[t]=u[t]||{},u[t].get=function(){return n},e(o,u),o))}},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).utils={})}(this,(function(n){"use strict";var t=function(n,t,r){return n*(1-(r=Math.min(1,Math.max(0,r))))+t*r};function r(n){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function e(n,t){for(var r in t){(u=t[r]).configurable=u.enumerable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(n,r,u)}if(Object.getOwnPropertySymbols)for(var e=Object.getOwnPropertySymbols(t),o=0;o<e.length;o++){var u,i=e[o];(u=t[i]).configurable=u.enumerable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(n,i,u)}return n}function o(n,t,r){return t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r,n}function u(n,t){return function(n){if(Array.isArray(n))return n}(n)||function(n,t){if(!(Symbol.iterator in Object(n)||"[object Arguments]"===Object.prototype.toString.call(n)))return;var r=[],e=!0,o=!1,u=void 0;try{for(var i,c=n[Symbol.iterator]();!(e=(i=c.next()).done)&&(r.push(i.value),!t||r.length!==t);e=!0);}catch(n){o=!0,u=n}finally{try{e||null==c.return||c.return()}finally{if(o)throw u}}return r}(n,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function i(n){return function(n){if(Array.isArray(n)){for(var t=0,r=new Array(n.length);t<n.length;t++)r[t]=n[t];return r}}(n)||function(n){if(Symbol.iterator in Object(n)||"[object Arguments]"===Object.prototype.toString.call(n))return Array.from(n)}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var c=function(n){return n},a=function(n){return!!(n&&n.constructor&&n.call&&n.apply)},f=function(n){return/(^#[0-9A-Fa-f]{6}$)|(^#[0-9A-Fa-f]{3}$)/i.test(n)},l=function(n){return d(n)&&n>=0&&n<=1},s=function(n){return Array.isArray(n)&&n.every(l)},d=function(n){return"number"==typeof n},p=function(n){return 3===n.length&&(s(n)||g(n))},v=function(n){return 4===n.length&&(s(n)||g(n)||g(n.slice(0,3))&&l(n[3]))},h=function(n){return Number.isInteger(n)&&n>=0&&n<=255},g=function(n){return Array.isArray(n)&&n.every(h)},y=function(n){return Math.sqrt(n.reduce((function(n,t){return n+Math.pow(t,2)}),0))},m=function(n){var t=y(n);return n.map((function(n){return n/t}))},b=function(n){return n.reduce((function(n,t){return n+t}),0)},w=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)}))},A=function(n){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return[].concat(i(w(n,t)),[Math.pow(255,!t)])},O=function(n){return n.match(/[\d.]+/g).slice(0,4).map((function(n){return+n}))},j=O,M="http://www.w3.org/2000/svg",S=function(n,t){if(n.namespaceURI===M){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|$)")))},P=function(n){var t=new n.constructor(n.type,n);return t.sourceUid=n.sourceUid,t.forwarded=n.forwarded,t},R=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},T=function n(t,e){if(null===e||"object"!==r(e))return e;if(e.constructor!==Object&&e.constructor!==Array)return e;if(e.constructor===Date||e.constructor===RegExp||e.constructor===Function||e.constructor===String||e.constructor===Number||e.constructor===Boolean)return new e.constructor(e);var o=t||new e.constructor;return Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);void 0===o[t]&&(void 0===r.value?Object.defineProperty(o,t,r):o[t]=n(void 0,e[t]))})),o},x=function(n){return"".concat(n[0].toUpperCase()).concat(n.substr(1))},I=function(n,t){return n-t};n.addClass=function(n,t){if(n.namespaceURI===M){if(!S(n,t)){var r=n.getAttribute("class")||"";n.setAttribute("class","".concat(r," ").concat(t))}}else n.classList?n.classList.add(t):S(n,t)||(n.className+=" ".concat(t))},n.aggregate=function(n,t,r){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=e.getter,u=void 0===o?c:o,i=a(t),f=i?[t]:t,l=i?[r]:r,s=n.reduce((function(n,t){return f.map((function(r,e){return r(n[e],u(t))}))}),void 0===l?Array(f.length).fill(0):l);return i?s[0]:s},n.argSort=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.getter,e=void 0===r?c:r,o=t.comparator,u=void 0===o?I:o,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 u(n[0],t[0])})).reduce((function(n,t){return t?(n.push(t[1]),n):n}),[])},n.array2dTranspose=function(n){for(var t=i(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=R,n.camelToConst=function(n){return n.split(/(?=[A-Z])/).join("_").toUpperCase()},n.capitalize=x,n.clearArray=function(n){return n.splice(0,n.length),n},n.cloneEvent=P,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,o=new Array(e),u=0;u<e;u++)o[u]=arguments[u];var i=function(){r=null,n.apply(void 0,o)};clearTimeout(r),r=setTimeout(i,t)};return e.cancel=function(){clearTimeout(r)},e.now=function(){return n.apply(void 0,arguments)},e},n.deepClone=function(n){return T(void 0,n)},n.diff=function(n,t){return n.map((function(n,r){return n-t[r]}))},n.extend=T,n.forEach=function(n){return function(t){return Array.prototype.forEach.call(t,n)}},n.forwardEvent=function(n,t){t.dispatchEvent(P(n))},n.hasClass=S,n.hexToDec=function(n){return parseInt(n.substr(1),16)},n.hexToRgbArray=w,n.hexToRgbaArray=A,n.identity=c,n.interpolateNumber=t,n.interpolateVector=function(n,r,e){return n.map((function(n,o){return t(n,r[o],e)}))},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=a,n.isHex=f,n.isNormFloat=l,n.isNormFloatArray=s,n.isNumber=d,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=u(n,2),e=r[0],o=r[1],i=u(t,4),c=i[0],a=i[1],f=i[2],l=i[3];return e>=c&&e<=a||o>=f&&o<=l},n.isPointInPolygon=function(){for(var n,t,r,e,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=u(o,2),c=i[0],a=i[1],f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],l=!1,s=0,d=f.length-2;s<f.length;s+=2)n=f[s],t=f[s+1],r=f[d],t>a!=(e=f[d+1])>a&&c<(r-n)*(a-t)/(e-t)+n&&(l=!l),d=s;return l},n.isPointInRect=function(n,t){var r=u(n,2),e=r[0],o=r[1],i=u(t,4),c=i[0],a=i[1],f=i[2],l=i[3];return e>=c&&e<=a&&o>=f&&o<=l},n.isRgbArray=p,n.isRgbStr=function(n){return/rgb\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*\)/i.test(n)},n.isRgbaArray=v,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=h,n.isUint8Array=g,n.iteratorToArray=function(n){var t=[],r=!0,e=!1,o=void 0;try{for(var u,i=n[Symbol.iterator]();!(r=(u=i.next()).done);r=!0){var c=u.value;t.push(c)}}catch(n){e=!0,o=n}finally{try{r||null==i.return||i.return()}finally{if(e)throw o}}return t},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"d = v[".concat(t,"] - w[").concat(t,"]; s += d * d;")})).join(" ");return new Function("v","w","let s = 0; let d; ".concat(t," return Math.sqrt(s);"))},n.l2Norm=y,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,o){return t+Math.pow(Math.abs(e-r[o]),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,o){return Math.pow(Math.pow(Math.abs(t-e),n)+Math.pow(Math.abs(r-o),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=[],o=0;o<r.length;o++){var u=n(r[o],o);t(u,e.length)&&e.push(u)}return e}},n.max=function(n){return n.reduce((function(n,t){return n>t?n:t}),-1/0)},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 b(n)/n.length},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.mergeMaps=function(n,t){return new Map(regeneratorRuntime.mark((function r(){return regeneratorRuntime.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=function(n){return n.reduce((function(n,t){return n<t?n:t}),1/0)},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.normalize=m,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;return Array(Math.ceil((t-n)/r)).fill().map((function(t,e){return n+e*r}))},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===M){var e=n.getAttribute("class")||"";n.setAttribute("class",e.replace(r," "))}else n.classList?n.classList.remove(t):S(n,t)&&(n.className=n.className.replace(r," "))},n.removeLastChild=function(n){n.removeChild(n.lastChild)},n.rgbStrToDec=function(n){return O(n).slice(0,3).map((function(n,t){return+n<<8*(2-t)})).reduce((function(n,t){return t+n}),0)},n.rgbStrToRgbArray=O,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=j,n.some=function(n){return function(t){return Array.prototype.some.call(t,n)}},n.sortAsc=I,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?c:r,o=t.comparator,i=void 0===o?I:o,a=t.ignoreNull,f=void 0!==a&&a;return Object.entries(n).map(f?function(n){var t=u(n,2),r=t[0],o=t[1];return null===e(o)?void 0:[r,e(o)]}:function(n){var t=u(n,2),r=t[0],o=t[1];return[r,e(o)]}).sort((function(n,t){return i(n[1],t[1])})).reduce((function(n,t,r){return t?(n[t[0]]=r,n):n}),new n.constructor)},n.sum=b,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,o=0;e=null===e?t:e;var u=function(){for(var t=arguments.length,u=new Array(t),i=0;i<t;i++)u[i]=arguments[i];var c=function(){o>0&&(n.apply(void 0,u),o=0)};clearTimeout(r),r=setTimeout(c,e)},i=!1,c=function(){i?(o++,u.apply(void 0,arguments)):(n.apply(void 0,arguments),u.apply(void 0,arguments),i=!0,o=0,setTimeout((function(){i=!1}),t))};return c.reset=function(){i=!1},c.cancel=function(){clearTimeout(r)},c.now=function(){return n.apply(void 0,arguments)},c},n.toRgbaArray=function(n,t){return v(n)?t&&!s(n)?t(n):n:p(n)?[].concat(i(t?m(n):n),[Math.pow(255,!t)]):f(n)?A(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=function(){},n.unique=function(n){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c,r=new Set,e=[],o=0;o<n.length;o++){var u=t(n[o]);r.has(u)||(r.add(u),e.push(u))}return e},n.update=function n(t,e){if(null===e||"object"!==r(e))return e;if(e.constructor!==Object&&e.constructor!==Array)return new e.constructor(e);var o=new t.constructor,u=!1;return Object.keys(e).forEach((function(r){o[r]=n(t[r],e[r]),u=u||o[r]!==t[r]})),(u=u||Object.keys(t).filter((function(n){return void 0===e[n]})).length)?o:t},n.version="0.19.0",n.wait=function(n){return new Promise((function(t){return setTimeout(t,n)}))},n.withConstructor=function(n){return function(t){return R(t,{__proto__:{constructor:n}})}},n.withForwardedMethod=function(n,t){return function(r){return R(r,o({},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,u=void 0===r?void 0:r,i=t.getter,a=t.setter,f=t.cloner,l=void 0===f?c:f,s=t.transformer,d=void 0===s?c:s,p=t.validator,v=void 0===p?function(){return!0}:p;return function(t){var r,c,f=u,s=i?function(){return i()}:function(){return l(f)},p=a?function(n){return a(n)}:function(n){var t=d(n);f=v(t)?t:f};return R(t,(r={},(c={})[n]=c[n]||{},c[n].get=function(){return s()},o(r,"set".concat(x(n)),(function(n){p(n)})),e(r,c),r))}},n.withReadOnlyProperty=function(n,t){return function(r){var o,u;return R(r,(o={},(u={})[n]=u[n]||{},u[n].get=function(){return t()},e(o,u),o))}},n.withStaticProperty=function(n,t){return function(r){var o,u;return R(r,(o={},(u={})[n]=u[n]||{},u[n].get=function(){return t},e(o,u),o))}},Object.defineProperty(n,"__esModule",{value:!0})})); |
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
275538
6846