@flekschas/utils
Advanced tools
Comparing version 0.21.0 to 0.22.0
@@ -0,1 +1,5 @@ | ||
## v0.22.0 | ||
- Add `median` and `medianVector` to _vector_ | ||
## v0.21.0 | ||
@@ -2,0 +6,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/* eslint no-param-reassign:0 */ | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Identity function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Test if a variable is an array |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
const XMLNS = 'http://www.w3.org/2000/svg'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Identity function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * L distance between a pair of vectors |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
const mergeMaps = (map1, map2) => | ||
@@ -3,0 +3,0 @@ new Map( |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Identity function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
const assign = (target, ...sources) => { | ||
@@ -3,0 +3,0 @@ sources.forEach(source => { |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Create a worker from a function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Identity function |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
const camelToConst = str => | ||
@@ -3,0 +3,0 @@ str |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Debounce a function call. |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -3,0 +3,0 @@ * Test if a variable is an array |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/** | ||
@@ -228,2 +228,17 @@ * Identity function | ||
/** | ||
* Get the median of a vector | ||
* | ||
* @param {array} v - Numerical vector | ||
* @return {number} The median | ||
*/ | ||
const median = v => v[Math.floor(v.length / 2)]; | ||
/** | ||
* Get the median vector | ||
* @param {array} m - Array of vectors | ||
* @return {array} The median vector | ||
*/ | ||
const medianVector = median; | ||
/** | ||
* Get the minimum number of a vector | ||
@@ -321,2 +336,2 @@ * | ||
export { aggregate, diff, l1Dist, l1DistByDim, l2Dist, l2DistByDim, 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, median, medianVector, min, minVector, mod, normalize, range, sum, sumVector }; |
{ | ||
"name": "@flekschas/utils", | ||
"version": "0.21.0", | ||
"version": "0.22.0", | ||
"description": "A set of utility functions I use across projects", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -247,2 +247,19 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
/** | ||
* Get the median of a vector | ||
* | ||
* @param {array} v - Numerical vector | ||
* @return {number} The median | ||
*/ | ||
var median = function median(v) { | ||
return v[Math.floor(v.length / 2)]; | ||
}; | ||
/** | ||
* Get the median vector | ||
* @param {array} m - Array of vectors | ||
* @return {array} The median vector | ||
*/ | ||
var medianVector = median; | ||
/** | ||
* Get the minimum number of a vector | ||
@@ -369,2 +386,4 @@ * | ||
exports.meanVector = meanVector; | ||
exports.median = median; | ||
exports.medianVector = medianVector; | ||
exports.min = min; | ||
@@ -371,0 +390,0 @@ exports.minVector = minVector; |
@@ -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},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"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=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})})); | ||
!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[Math.floor(n.length/2)]},c=u,i=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"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=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 i(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.median=u,n.medianVector=c,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=i,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.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
/* eslint no-param-reassign:0 */ | ||
@@ -519,2 +519,17 @@ | ||
/** | ||
* Get the median of a vector | ||
* | ||
* @param {array} v - Numerical vector | ||
* @return {number} The median | ||
*/ | ||
const median = v => v[Math.floor(v.length / 2)]; | ||
/** | ||
* Get the median vector | ||
* @param {array} m - Array of vectors | ||
* @return {array} The median vector | ||
*/ | ||
const medianVector = median; | ||
/** | ||
* Get the minimum number of a vector | ||
@@ -1590,4 +1605,4 @@ * | ||
var version = "0.21.0"; | ||
var version = "0.22.0"; | ||
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, 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, 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, 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, maxVector, mean, meanVector, median, medianVector, 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 }; |
23
utils.js
@@ -1,2 +0,2 @@ | ||
// @flekschas/utils v0.21.0 Copyright 2020 Fritz Lekschas | ||
// @flekschas/utils v0.22.0 Copyright 2020 Fritz Lekschas | ||
(function (global, factory) { | ||
@@ -703,2 +703,19 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
/** | ||
* Get the median of a vector | ||
* | ||
* @param {array} v - Numerical vector | ||
* @return {number} The median | ||
*/ | ||
var median = function median(v) { | ||
return v[Math.floor(v.length / 2)]; | ||
}; | ||
/** | ||
* Get the median vector | ||
* @param {array} m - Array of vectors | ||
* @return {array} The median vector | ||
*/ | ||
var medianVector = median; | ||
/** | ||
* Get the minimum number of a vector | ||
@@ -1908,3 +1925,3 @@ * | ||
var version = "0.21.0"; | ||
var version = "0.22.0"; | ||
@@ -1975,2 +1992,4 @@ exports.addClass = addClass; | ||
exports.meanVector = meanVector; | ||
exports.median = median; | ||
exports.medianVector = medianVector; | ||
exports.mergeMaps = mergeMaps; | ||
@@ -1977,0 +1996,0 @@ exports.min = min; |
@@ -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=Array.isArray,f=function(t){return!!(t&&t.constructor&&t.call&&t.apply)},s=function(t){return/(^#[0-9A-Fa-f]{6}$)|(^#[0-9A-Fa-f]{3}$)/i.test(t)},l=function(t){return p(t)&&t>=0&&t<=1},d=function(t){return Array.isArray(t)&&t.every(l)},p=function(t){return"number"==typeof t},h=function(t){return 3===t.length&&(d(t)||y(t))},v=function(t){return 4===t.length&&(d(t)||y(t)||y(t.slice(0,3))&&l(t[3]))},m=function(t){return Number.isInteger(t)&&t>=0&&t<=255},y=function(t){return Array.isArray(t)&&t.every(m)},g=function(t){return Math.sqrt(t.reduce((function(t,n){return t+Math.pow(n,2)}),0))},b=function(t){var n=g(t);return t.map((function(t){return t/n}))},w=function(t){return t.reduce((function(t,n){return t+n}),0)},A=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)}))},M=function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return[].concat(i(A(t,n)),[Math.pow(255,!n)])},O=function(t){return t.match(/[\d.]+/g).slice(0,4).map((function(t){return+t}))},j=O,x="http://www.w3.org/2000/svg",S=function(t,n){if(t.namespaceURI===x){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|$)")))},R=function(t){var n=new t.constructor(t.type,t);return n.sourceUid=t.sourceUid,n.forwarded=t.forwarded,n},P=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},D=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===x){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=f(n),a=i?[n]:n,s=i?[r]:r,l=t.reduce((function(t,n){return a.map((function(r,e){return r(t[e],u(n))}))}),void 0===s?Array(a.length).fill(0):s);return i?l[0]:l},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=P,t.camelToConst=function(t){return t.split(/(?=[A-Z])/).join("_").toUpperCase()},t.capitalize=D,t.clearArray=function(t){return t.splice(0,t.length),t},t.cloneEvent=R,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.diff=function(t,n){return t.map((function(t,r){return t-n[r]}))},t.extend=T,t.forEach=function(t){return function(n){return Array.prototype.forEach.call(n,t)}},t.forwardEvent=function(t,n){n.dispatchEvent(R(t))},t.hasClass=S,t.hexToDec=function(t){return parseInt(t.substr(1),16)},t.hexToRgbArray=A,t.hexToRgbaArray=M,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.isArray=a,t.isClose=function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6;return Math.abs(t-n)<Math.pow(10,-r)},t.isFunction=f,t.isHex=s,t.isNormFloat=l,t.isNormFloatArray=d,t.isNumber=p,t.isObject=function(t){return!!t&&t.constructor===Object},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],s=i[3];return e>=c&&e<=a||o>=f&&o<=s},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]:[],s=!1,l=0,d=f.length-2;l<f.length;l+=2)t=f[l],n=f[l+1],r=f[d],n>a!=(e=f[d+1])>a&&c<(r-t)*(a-n)/(e-n)+t&&(s=!s),d=l;return s},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],s=i[3];return e>=c&&e<=a&&o>=f&&o<=s},t.isRgbArray=h,t.isRgbStr=function(t){return/rgb\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*\)/i.test(t)},t.isRgbaArray=v,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=m,t.isUint8Array=y,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.l1DistByDim=function(t){var n=Array(t).fill().map((function(t,n){return"s += Math.abs(v[".concat(n,"] - w[").concat(n,"]);")})).join(" ");return new Function("v","w","let s = 0; ".concat(n," return s;"))},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.l2DistByDim=function(t){var n=Array(t).fill().map((function(t,n){return"s += Math.pow(v[".concat(n,"] - w[").concat(n,"], 2);")})).join(" ");return new Function("v","w","let s = 0; ".concat(n," return Math.sqrt(s);"))},t.l2Norm=g,t.l2PointDist=function(t,n,r,e){return Math.sqrt(Math.pow(t-r,2)+Math.pow(n-e,2))},t.lDist=function(t,n){if(Number.isNaN(+n))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};var r=Array(n).fill().map((function(t,n){return"s += Math.abs(v[".concat(n,"] - w[").concat(n,"]) ** l;")})).join(" ");return new Function("v","w","const l = ".concat(t,"; let s = 0; ").concat(r," return s ** (1 / l);"))},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.lRectDist=function(t){return function(n,r){var e=r.minX-n.minX,o=r.minX-n.maxX,u=r.maxX-n.minX,i=r.maxX-n.maxX,c=e<0&&u>0||o<0&&i>0||e>0&&o<0||u>0&&i<0,a=r.minY-n.minY,f=r.minY-n.maxY,s=r.maxY-n.minY,l=r.maxY-n.maxY,d=a<0&&s>0||f<0&&l>0||a>0&&f<0||s>0&&l<0;if(c&&d)return 0;var p=Math.min(Math.abs(a),Math.abs(f),Math.abs(s),Math.abs(l));if(c)return p;var h=Math.min(Math.abs(e),Math.abs(o),Math.abs(u),Math.abs(i));return d?h:Math.pow(Math.pow(h,t)+Math.pow(p,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 w(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=b,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===x){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=w,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 v(t)?n&&!d(t)?n(t):t:h(t)?[].concat(i(n?b(t):t),[Math.pow(255,!n)]):s(t)?M(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.21.0",t.wait=function(t){return new Promise((function(n){return setTimeout(n,t)}))},t.withConstructor=function(t){return function(n){return P(n,{__proto__:{constructor:t}})}},t.withForwardedMethod=function(t,n){return function(r){return P(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,s=void 0===f?c:f,l=n.transformer,d=void 0===l?c:l,p=n.validator,h=void 0===p?function(){return!0}:p;return function(n){var r,c,f=u,l=i?function(){return i()}:function(){return s(f)},p=a?function(t){return a(t)}:function(t){var n=d(t);f=h(n)?n:f};return P(n,(r={},(c={})[t]=c[t]||{},c[t].get=function(){return l()},o(r,"set".concat(D(t)),(function(t){p(t)})),e(r,c),r))}},t.withReadOnlyProperty=function(t,n){return function(r){var o,u;return P(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 P(r,(o={},(u={})[t]=u[t]||{},u[t].get=function(){return n},e(o,u),o))}},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!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=Array.isArray,f=function(t){return!!(t&&t.constructor&&t.call&&t.apply)},s=function(t){return/(^#[0-9A-Fa-f]{6}$)|(^#[0-9A-Fa-f]{3}$)/i.test(t)},l=function(t){return h(t)&&t>=0&&t<=1},d=function(t){return Array.isArray(t)&&t.every(l)},h=function(t){return"number"==typeof t},p=function(t){return 3===t.length&&(d(t)||y(t))},v=function(t){return 4===t.length&&(d(t)||y(t)||y(t.slice(0,3))&&l(t[3]))},m=function(t){return Number.isInteger(t)&&t>=0&&t<=255},y=function(t){return Array.isArray(t)&&t.every(m)},g=function(t){return Math.sqrt(t.reduce((function(t,n){return t+Math.pow(n,2)}),0))},b=function(t){return t[Math.floor(t.length/2)]},w=b,A=function(t){var n=g(t);return t.map((function(t){return t/n}))},M=function(t){return t.reduce((function(t,n){return t+n}),0)},O=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)}))},j=function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return[].concat(i(O(t,n)),[Math.pow(255,!n)])},x=function(t){return t.match(/[\d.]+/g).slice(0,4).map((function(t){return+t}))},S=x,R="http://www.w3.org/2000/svg",P=function(t,n){if(t.namespaceURI===R){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|$)")))},T=function(t){var n=new t.constructor(t.type,t);return n.sourceUid=t.sourceUid,n.forwarded=t.forwarded,n},D=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},I=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},N=function(t){return"".concat(t[0].toUpperCase()).concat(t.substr(1))},C=function(t,n){return t-n};t.addClass=function(t,n){if(t.namespaceURI===R){if(!P(t,n)){var r=t.getAttribute("class")||"";t.setAttribute("class","".concat(r," ").concat(n))}}else t.classList?t.classList.add(n):P(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=f(n),a=i?[n]:n,s=i?[r]:r,l=t.reduce((function(t,n){return a.map((function(r,e){return r(t[e],u(n))}))}),void 0===s?Array(a.length).fill(0):s);return i?l[0]:l},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?C: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=D,t.camelToConst=function(t){return t.split(/(?=[A-Z])/).join("_").toUpperCase()},t.capitalize=N,t.clearArray=function(t){return t.splice(0,t.length),t},t.cloneEvent=T,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 I(void 0,t)},t.diff=function(t,n){return t.map((function(t,r){return t-n[r]}))},t.extend=I,t.forEach=function(t){return function(n){return Array.prototype.forEach.call(n,t)}},t.forwardEvent=function(t,n){n.dispatchEvent(T(t))},t.hasClass=P,t.hexToDec=function(t){return parseInt(t.substr(1),16)},t.hexToRgbArray=O,t.hexToRgbaArray=j,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.isArray=a,t.isClose=function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6;return Math.abs(t-n)<Math.pow(10,-r)},t.isFunction=f,t.isHex=s,t.isNormFloat=l,t.isNormFloatArray=d,t.isNumber=h,t.isObject=function(t){return!!t&&t.constructor===Object},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],s=i[3];return e>=c&&e<=a||o>=f&&o<=s},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]:[],s=!1,l=0,d=f.length-2;l<f.length;l+=2)t=f[l],n=f[l+1],r=f[d],n>a!=(e=f[d+1])>a&&c<(r-t)*(a-n)/(e-n)+t&&(s=!s),d=l;return s},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],s=i[3];return e>=c&&e<=a&&o>=f&&o<=s},t.isRgbArray=p,t.isRgbStr=function(t){return/rgb\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*\)/i.test(t)},t.isRgbaArray=v,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=m,t.isUint8Array=y,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.l1DistByDim=function(t){var n=Array(t).fill().map((function(t,n){return"s += Math.abs(v[".concat(n,"] - w[").concat(n,"]);")})).join(" ");return new Function("v","w","let s = 0; ".concat(n," return s;"))},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.l2DistByDim=function(t){var n=Array(t).fill().map((function(t,n){return"s += Math.pow(v[".concat(n,"] - w[").concat(n,"], 2);")})).join(" ");return new Function("v","w","let s = 0; ".concat(n," return Math.sqrt(s);"))},t.l2Norm=g,t.l2PointDist=function(t,n,r,e){return Math.sqrt(Math.pow(t-r,2)+Math.pow(n-e,2))},t.lDist=function(t,n){if(Number.isNaN(+n))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};var r=Array(n).fill().map((function(t,n){return"s += Math.abs(v[".concat(n,"] - w[").concat(n,"]) ** l;")})).join(" ");return new Function("v","w","const l = ".concat(t,"; let s = 0; ").concat(r," return s ** (1 / l);"))},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.lRectDist=function(t){return function(n,r){var e=r.minX-n.minX,o=r.minX-n.maxX,u=r.maxX-n.minX,i=r.maxX-n.maxX,c=e<0&&u>0||o<0&&i>0||e>0&&o<0||u>0&&i<0,a=r.minY-n.minY,f=r.minY-n.maxY,s=r.maxY-n.minY,l=r.maxY-n.maxY,d=a<0&&s>0||f<0&&l>0||a>0&&f<0||s>0&&l<0;if(c&&d)return 0;var h=Math.min(Math.abs(a),Math.abs(f),Math.abs(s),Math.abs(l));if(c)return h;var p=Math.min(Math.abs(e),Math.abs(o),Math.abs(u),Math.abs(i));return d?p:Math.pow(Math.pow(p,t)+Math.pow(h,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 M(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.median=b,t.medianVector=w,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=A,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===R){var e=t.getAttribute("class")||"";t.setAttribute("class",e.replace(r," "))}else t.classList?t.classList.remove(n):P(t,n)&&(t.className=t.className.replace(r," "))},t.removeLastChild=function(t){t.removeChild(t.lastChild)},t.rgbStrToDec=function(t){return x(t).slice(0,3).map((function(t,n){return+t<<8*(2-n)})).reduce((function(t,n){return n+t}),0)},t.rgbStrToRgbArray=x,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=S,t.some=function(t){return function(n){return Array.prototype.some.call(n,t)}},t.sortAsc=C,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?C: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=M,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 v(t)?n&&!d(t)?n(t):t:p(t)?[].concat(i(n?A(t):t),[Math.pow(255,!n)]):s(t)?j(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.22.0",t.wait=function(t){return new Promise((function(n){return setTimeout(n,t)}))},t.withConstructor=function(t){return function(n){return D(n,{__proto__:{constructor:t}})}},t.withForwardedMethod=function(t,n){return function(r){return D(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,s=void 0===f?c:f,l=n.transformer,d=void 0===l?c:l,h=n.validator,p=void 0===h?function(){return!0}:h;return function(n){var r,c,f=u,l=i?function(){return i()}:function(){return s(f)},h=a?function(t){return a(t)}:function(t){var n=d(t);f=p(n)?n:f};return D(n,(r={},(c={})[t]=c[t]||{},c[t].get=function(){return l()},o(r,"set".concat(N(t)),(function(t){h(t)})),e(r,c),r))}},t.withReadOnlyProperty=function(t,n){return function(r){var o,u;return D(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 D(r,(o={},(u={})[t]=u[t]||{},u[t].get=function(){return n},e(o,u),o))}},Object.defineProperty(t,"__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
286993
7149