Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@flekschas/utils

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flekschas/utils - npm Package Compare versions

Comparing version 0.7.1 to 0.8.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## v0.8.0
- Add `removeAllChildren(node)` to _dom_
## v0.7.1

@@ -2,0 +6,0 @@

2

esm/animation.js

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
/**

@@ -3,0 +3,0 @@ * Cubic in and out easing function

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
/**

@@ -3,0 +3,0 @@ * Transpose a nested 2D array

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
const isHexStr = str => str[0] === '#';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
const XMLNS = 'http://www.w3.org/2000/svg';

@@ -58,2 +58,12 @@

/**
* Remove all children of a DOM node
* @param {object} node - DOM node whose children are to be removed
*/
const removeAllChildren = node => {
while (node.firstChild) {
node.removeChild(node.firstChild);
}
};
/**
* Remove a class from an HTML or SVG element.

@@ -76,2 +86,2 @@ * @param {object} element - HTML or SVG element.

export { addClass, hasClass, isParentOf, removeClass };
export { addClass, hasClass, isParentOf, removeAllChildren, removeClass };

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
/**

@@ -3,0 +3,0 @@ * Identity function

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
/**

@@ -3,0 +3,0 @@ * L distance between a pair of vectors

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
const mergeMaps = (map1, map2) =>

@@ -3,0 +3,0 @@ new Map(

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
/**

@@ -3,0 +3,0 @@ * Identity function

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
const assign = (target, ...sources) => {

@@ -3,0 +3,0 @@ sources.forEach(source => {

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
/**

@@ -3,0 +3,0 @@ * Create a worker from a function

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
const sortAsc = (a, b) => a - b;

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
const camelToConst = str =>

@@ -3,0 +3,0 @@ str

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
/**

@@ -3,0 +3,0 @@ * Debounce a function call.

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
/**

@@ -3,0 +3,0 @@ * Test if an object is a function

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
/**

@@ -3,0 +3,0 @@ * L distance between a pair of vectors

{
"name": "@flekschas/utils",
"version": "0.7.1",
"version": "0.8.0",
"description": "A set of utility functions I use across projects",

@@ -5,0 +5,0 @@ "author": {

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
(function (global, factory) {

@@ -62,2 +62,12 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

/**
* Remove all children of a DOM node
* @param {object} node - DOM node whose children are to be removed
*/
var removeAllChildren = function removeAllChildren(node) {
while (node.firstChild) {
node.removeChild(node.firstChild);
}
};
/**
* Remove a class from an HTML or SVG element.

@@ -84,2 +94,3 @@ * @param {object} element - HTML or SVG element.

exports.isParentOf = isParentOf;
exports.removeAllChildren = removeAllChildren;
exports.removeClass = removeClass;

@@ -86,0 +97,0 @@

@@ -1,1 +0,1 @@

!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports):"function"==typeof define&&define.amd?define(["exports"],s):s((e=e||self).utils=e.utils||{})}(this,(function(e){"use strict";var s="http://www.w3.org/2000/svg",t=function(e,t){if(e.namespaceURI===s){var a=e.getAttribute("class");return a&&!!a.match(new RegExp("(\\s|^)".concat(t,"(\\s|$)")))}return e.classList?e.classList.contains(t):!!e.className.match(new RegExp("(\\s|^)".concat(t,"(\\s|$)")))};e.addClass=function(e,a){if(e.namespaceURI===s){if(!t(e,a)){var c=e.getAttribute("class")||"";e.setAttribute("class","".concat(c," ").concat(a))}}else e.classList?e.classList.add(a):t(e,a)||(e.className+=" ".concat(a))},e.hasClass=t,e.isParentOf=function(e,s){for(var t=e;t&&t!==s&&"HTML"!==t.tagName;)t=t.parentNode;return t===s},e.removeClass=function(e,a){var c=new RegExp("(\\s|^)".concat(a,"(\\s|$)"));if(e.namespaceURI===s){var n=e.getAttribute("class")||"";e.setAttribute("class",n.replace(c," "))}else e.classList?e.classList.remove(a):t(e,a)&&(e.className=e.className.replace(c," "))},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports):"function"==typeof define&&define.amd?define(["exports"],s):s((e=e||self).utils=e.utils||{})}(this,(function(e){"use strict";var s="http://www.w3.org/2000/svg",t=function(e,t){if(e.namespaceURI===s){var a=e.getAttribute("class");return a&&!!a.match(new RegExp("(\\s|^)".concat(t,"(\\s|$)")))}return e.classList?e.classList.contains(t):!!e.className.match(new RegExp("(\\s|^)".concat(t,"(\\s|$)")))};e.addClass=function(e,a){if(e.namespaceURI===s){if(!t(e,a)){var c=e.getAttribute("class")||"";e.setAttribute("class","".concat(c," ").concat(a))}}else e.classList?e.classList.add(a):t(e,a)||(e.className+=" ".concat(a))},e.hasClass=t,e.isParentOf=function(e,s){for(var t=e;t&&t!==s&&"HTML"!==t.tagName;)t=t.parentNode;return t===s},e.removeAllChildren=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},e.removeClass=function(e,a){var c=new RegExp("(\\s|^)".concat(a,"(\\s|$)"));if(e.namespaceURI===s){var n=e.getAttribute("class")||"";e.setAttribute("class",n.replace(c," "))}else e.classList?e.classList.remove(a):t(e,a)&&(e.className=e.className.replace(c," "))},Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.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.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
/**

@@ -156,2 +156,12 @@ * Cubic in and out easing function

/**
* Remove all children of a DOM node
* @param {object} node - DOM node whose children are to be removed
*/
const removeAllChildren = node => {
while (node.firstChild) {
node.removeChild(node.firstChild);
}
};
/**
* Remove a class from an HTML or SVG element.

@@ -970,4 +980,4 @@ * @param {object} element - HTML or SVG element.

var version = "0.7.1";
var version = "0.8.0";
export { addClass, argSort, array2dTranspose, assign, camelToConst, capitalize, cloneEvent, createWorker, cubicInOut, debounce, deepClone, extend, forEach, forwardEvent, hasClass, hexStrToDec, identity, interpolateNumber, interpolateVector, isFunction, isHexStr, isParentOf, isPointHalfwayInRect, isPointInPolygon, isPointInRect, isRgbStr, isRgbaStr, iteratorToArray, l1Dist, l1PointDist, l2Dist, l2Norm, l2PointDist, lDist, lPointDist, map, mapFilter, max, mean, mergeMaps, min, mod, nextAnimationFrame, normalize, pipe, range, removeClass, rgbStrToDec, rgbToHex, some, sortAsc, sortDesc, sortPos, sum, throttle, throttleAndDebounce, toVoid, update, version, wait, withConstructor, withProperty, withReadOnlyProperty, withStaticProperty };
export { addClass, argSort, array2dTranspose, assign, camelToConst, capitalize, cloneEvent, createWorker, cubicInOut, debounce, deepClone, extend, forEach, forwardEvent, hasClass, hexStrToDec, identity, interpolateNumber, interpolateVector, isFunction, isHexStr, isParentOf, isPointHalfwayInRect, isPointInPolygon, isPointInRect, isRgbStr, isRgbaStr, iteratorToArray, l1Dist, l1PointDist, l2Dist, l2Norm, l2PointDist, lDist, lPointDist, map, mapFilter, max, mean, mergeMaps, min, mod, nextAnimationFrame, normalize, pipe, range, removeAllChildren, removeClass, rgbStrToDec, rgbToHex, some, sortAsc, sortDesc, sortPos, sum, throttle, throttleAndDebounce, toVoid, update, version, wait, withConstructor, withProperty, withReadOnlyProperty, withStaticProperty };

@@ -1,2 +0,2 @@

// @flekschas/utils v0.7.1 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.8.0 Copyright 2020 Fritz Lekschas
(function (global, factory) {

@@ -307,2 +307,12 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

/**
* Remove all children of a DOM node
* @param {object} node - DOM node whose children are to be removed
*/
var removeAllChildren = function removeAllChildren(node) {
while (node.firstChild) {
node.removeChild(node.firstChild);
}
};
/**
* Remove a class from an HTML or SVG element.

@@ -1258,3 +1268,3 @@ * @param {object} element - HTML or SVG element.

var version = "0.7.1";
var version = "0.8.0";

@@ -1307,2 +1317,3 @@ exports.addClass = addClass;

exports.range = range;
exports.removeAllChildren = removeAllChildren;
exports.removeClass = removeClass;

@@ -1309,0 +1320,0 @@ exports.rgbStrToDec = rgbStrToDec;

@@ -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="http://www.w3.org/2000/svg",a=function(t,n){if(t.namespaceURI===c){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|$)")))},f=function(t){var n=new t.constructor(t.type,t);return n.sourceUid=t.sourceUid,n.forwarded=t.forwarded,n},s=function(t){return t},l=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},p=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){o[n]=void 0===o[n]?t(void 0,e[n]):o[n]})),o},v=function(t){return"".concat(t[0].toUpperCase()).concat(t.substr(1))},d=function(t,n){return t-n},y=function(t){return Math.sqrt(t.reduce((function(t,n){return t+Math.pow(n,2)}),0))},h=function(t){return t.reduce((function(t,n){return t+n}),0)};t.addClass=function(t,n){if(t.namespaceURI===c){if(!a(t,n)){var r=t.getAttribute("class")||"";t.setAttribute("class","".concat(r," ").concat(n))}}else t.classList?t.classList.add(n):a(t,n)||(t.className+=" ".concat(n))},t.argSort=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.comparator,e=void 0===r?d:r,o=n.ignoreNull,u=void 0!==o&&o;return t.map(u?function(t,n){return null===t?void 0:[t,n]}:function(t,n){return[t,n]}).sort((function(t,n){return e(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=l,t.camelToConst=function(t){return t.split(/(?=[A-Z])/).join("_").toUpperCase()},t.capitalize=v,t.cloneEvent=f,t.createWorker=function(t){return new Worker(window.URL.createObjectURL(new Blob(["(".concat(t.toString(),")()")],{type:"text/javascript"})))},t.cubicInOut=function(t){return((t=2*Math.min(1,Math.max(0,t)))<=1?t*t*t:(t-=2)*t*t+2)/2},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 p(void 0,t)},t.extend=p,t.forEach=function(t){return function(n){return Array.prototype.forEach.call(n,t)}},t.forwardEvent=function(t,n){n.dispatchEvent(f(t))},t.hasClass=a,t.hexStrToDec=function(t){return parseInt(t.substr(1),16)},t.identity=s,t.interpolateNumber=n,t.interpolateVector=function(t,r,e){return t.map((function(t,o){return n(t,r[o],e)}))},t.isFunction=function(t){return!!(t&&t.constructor&&t.call&&t.apply)},t.isHexStr=function(t){return"#"===t[0]},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,p=f.length-2;l<f.length;l+=2)t=f[l],n=f[l+1],r=f[p],n>a!=(e=f[p+1])>a&&c<(r-t)*(a-n)/(e-n)+t&&(s=!s),p=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.isRgbStr=function(t){return"rgb("===t.substring(0,4)},t.isRgbaStr=function(t){return"rgba"===t.substring(0,4)},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.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.mean=function(t){return h(t)/t.length},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.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=function(t){var n=y(t);return t.map((function(t){return t/n}))},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.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.removeClass=function(t,n){var r=new RegExp("(\\s|^)".concat(n,"(\\s|$)"));if(t.namespaceURI===c){var e=t.getAttribute("class")||"";t.setAttribute("class",e.replace(r," "))}else t.classList?t.classList.remove(n):a(t,n)&&(t.className=t.className.replace(r," "))},t.rgbStrToDec=function(t){return t.match(/(\d+),\s*(\d+),\s*(\d+),?\s*([\d.]+)?/).slice(1,4).map((function(t,n){return+t<<8*(2-n)})).reduce((function(t,n){return n+t}),0)},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.some=function(t){return function(n){return Array.prototype.some.call(n,t)}},t.sortAsc=d,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.comparator,e=void 0===r?d:r,o=n.ignoreNull,u=void 0!==o&&o;return t.map(u?function(t,n){return null===t?void 0:[t,n]}:function(t,n){return[t,n]}).sort((function(t,n){return e(t[0],n[0])})).reduce((function(t,n,r){return n?(t[n[1]]=r,t):t}),[])},t.sum=h,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.toVoid=function(){},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.7.1",t.wait=function(t){return new Promise((function(n){return setTimeout(n,t)}))},t.withConstructor=function(t){return function(n){return l(n,{__proto__:{constructor:t}})}},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,c=n.setter,a=n.cloner,f=void 0===a?s:a,p=n.transformer,d=void 0===p?s:p,y=n.validator,h=void 0===y?function(){return!0}:y;return function(n){var r,a,s=u,p=i?function(){return i()}:function(){return f(s)},y=c?function(t){return c(t)}:function(t){var n=d(t);s=h(n)?n:s};return l(n,(r={},(a={})[t]=a[t]||{},a[t].get=function(){return p()},o(r,"set".concat(v(t)),(function(t){y(t)})),e(r,a),r))}},t.withReadOnlyProperty=function(t,n){return function(r){var o,u;return l(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 l(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="http://www.w3.org/2000/svg",a=function(t,n){if(t.namespaceURI===c){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|$)")))},f=function(t){var n=new t.constructor(t.type,t);return n.sourceUid=t.sourceUid,n.forwarded=t.forwarded,n},l=function(t){return t},s=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},p=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){o[n]=void 0===o[n]?t(void 0,e[n]):o[n]})),o},v=function(t){return"".concat(t[0].toUpperCase()).concat(t.substr(1))},d=function(t,n){return t-n},h=function(t){return Math.sqrt(t.reduce((function(t,n){return t+Math.pow(n,2)}),0))},y=function(t){return t.reduce((function(t,n){return t+n}),0)};t.addClass=function(t,n){if(t.namespaceURI===c){if(!a(t,n)){var r=t.getAttribute("class")||"";t.setAttribute("class","".concat(r," ").concat(n))}}else t.classList?t.classList.add(n):a(t,n)||(t.className+=" ".concat(n))},t.argSort=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.comparator,e=void 0===r?d:r,o=n.ignoreNull,u=void 0!==o&&o;return t.map(u?function(t,n){return null===t?void 0:[t,n]}:function(t,n){return[t,n]}).sort((function(t,n){return e(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=s,t.camelToConst=function(t){return t.split(/(?=[A-Z])/).join("_").toUpperCase()},t.capitalize=v,t.cloneEvent=f,t.createWorker=function(t){return new Worker(window.URL.createObjectURL(new Blob(["(".concat(t.toString(),")()")],{type:"text/javascript"})))},t.cubicInOut=function(t){return((t=2*Math.min(1,Math.max(0,t)))<=1?t*t*t:(t-=2)*t*t+2)/2},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 p(void 0,t)},t.extend=p,t.forEach=function(t){return function(n){return Array.prototype.forEach.call(n,t)}},t.forwardEvent=function(t,n){n.dispatchEvent(f(t))},t.hasClass=a,t.hexStrToDec=function(t){return parseInt(t.substr(1),16)},t.identity=l,t.interpolateNumber=n,t.interpolateVector=function(t,r,e){return t.map((function(t,o){return n(t,r[o],e)}))},t.isFunction=function(t){return!!(t&&t.constructor&&t.call&&t.apply)},t.isHexStr=function(t){return"#"===t[0]},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,p=f.length-2;s<f.length;s+=2)t=f[s],n=f[s+1],r=f[p],n>a!=(e=f[p+1])>a&&c<(r-t)*(a-n)/(e-n)+t&&(l=!l),p=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.isRgbStr=function(t){return"rgb("===t.substring(0,4)},t.isRgbaStr=function(t){return"rgba"===t.substring(0,4)},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=h,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.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.mean=function(t){return y(t)/t.length},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.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=function(t){var n=h(t);return t.map((function(t){return t/n}))},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.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===c){var e=t.getAttribute("class")||"";t.setAttribute("class",e.replace(r," "))}else t.classList?t.classList.remove(n):a(t,n)&&(t.className=t.className.replace(r," "))},t.rgbStrToDec=function(t){return t.match(/(\d+),\s*(\d+),\s*(\d+),?\s*([\d.]+)?/).slice(1,4).map((function(t,n){return+t<<8*(2-n)})).reduce((function(t,n){return n+t}),0)},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.some=function(t){return function(n){return Array.prototype.some.call(n,t)}},t.sortAsc=d,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.comparator,e=void 0===r?d:r,o=n.ignoreNull,u=void 0!==o&&o;return t.map(u?function(t,n){return null===t?void 0:[t,n]}:function(t,n){return[t,n]}).sort((function(t,n){return e(t[0],n[0])})).reduce((function(t,n,r){return n?(t[n[1]]=r,t):t}),[])},t.sum=y,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.toVoid=function(){},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.8.0",t.wait=function(t){return new Promise((function(n){return setTimeout(n,t)}))},t.withConstructor=function(t){return function(n){return s(n,{__proto__:{constructor:t}})}},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,c=n.setter,a=n.cloner,f=void 0===a?l:a,p=n.transformer,d=void 0===p?l:p,h=n.validator,y=void 0===h?function(){return!0}:h;return function(n){var r,a,l=u,p=i?function(){return i()}:function(){return f(l)},h=c?function(t){return c(t)}:function(t){var n=d(t);l=y(n)?n:l};return s(n,(r={},(a={})[t]=a[t]||{},a[t].get=function(){return p()},o(r,"set".concat(v(t)),(function(t){h(t)})),e(r,a),r))}},t.withReadOnlyProperty=function(t,n){return function(r){var o,u;return s(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 s(r,(o={},(u={})[t]=u[t]||{},u[t].get=function(){return n},e(o,u),o))}},Object.defineProperty(t,"__esModule",{value:!0})}));
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc