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.6.0 to 0.7.0

array/package.json

4

CHANGELOG.md

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

## v0.7.0
- Add `array2dTranspose()` to _array_
## v0.6.0

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

2

esm/animation.js

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

// @flekschas/utils v0.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.0 Copyright 2020 Fritz Lekschas
/**

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

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

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

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

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

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

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

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

// @flekschas/utils v0.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.0 Copyright 2020 Fritz Lekschas
/**

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

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

// @flekschas/utils v0.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.0 Copyright 2020 Fritz Lekschas
/**

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

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

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

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

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

// @flekschas/utils v0.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.0 Copyright 2020 Fritz Lekschas
/**

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

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

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

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

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

// @flekschas/utils v0.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.0 Copyright 2020 Fritz Lekschas
/**

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

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

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

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

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

// @flekschas/utils v0.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.0 Copyright 2020 Fritz Lekschas
const camelToConst = str =>

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

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

// @flekschas/utils v0.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.0 Copyright 2020 Fritz Lekschas
/**

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

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

// @flekschas/utils v0.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.0 Copyright 2020 Fritz Lekschas
/**

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

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

// @flekschas/utils v0.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.0 Copyright 2020 Fritz Lekschas
/**

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

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

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

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

// @flekschas/utils v0.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.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.6.0 Copyright 2020 Fritz Lekschas
// @flekschas/utils v0.7.0 Copyright 2020 Fritz Lekschas
/**

@@ -950,4 +950,4 @@ * Cubic in and out easing function

var version = "0.6.0";
var version = "0.7.0";
export { addClass, argSort, 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 };

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

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

@@ -1216,3 +1216,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

var version = "0.6.0";
var version = "0.7.0";

@@ -1219,0 +1219,0 @@ exports.addClass = addClass;

@@ -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},r="http://www.w3.org/2000/svg",e=function(t,n){if(t.namespaceURI===r){var e=t.getAttribute("class");return e&&!!e.match(new RegExp("(\\s|^)".concat(n,"(\\s|$)")))}return t.classList?t.classList.contains(n):!!t.className.match(new RegExp("(\\s|^)".concat(n,"(\\s|$)")))},o=function(t){var n=new t.constructor(t.type,t);return n.sourceUid=t.sourceUid,n.forwarded=t.forwarded,n};function u(t){return(u="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 i(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 c(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function a(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")}()}var f=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},l=function t(n,r){if(null===r||"object"!==u(r))return r;if(r.constructor!==Object&&r.constructor!==Array)return r;if(r.constructor===Date||r.constructor===RegExp||r.constructor===Function||r.constructor===String||r.constructor===Number||r.constructor===Boolean)return new r.constructor(r);var e=n||new r.constructor;return Object.keys(r).forEach((function(n){e[n]=void 0===e[n]?t(void 0,r[n]):e[n]})),e},p=function(t){return"".concat(t[0].toUpperCase()).concat(t.substr(1))},v=function(t,n){return t-n},d=function(t){return Math.sqrt(t.reduce((function(t,n){return t+Math.pow(n,2)}),0))},m=function(t){return t.reduce((function(t,n){return t+n}),0)};t.addClass=function(t,n){if(t.namespaceURI===r){if(!e(t,n)){var o=t.getAttribute("class")||"";t.setAttribute("class","".concat(o," ").concat(n))}}else t.classList?t.classList.add(n):e(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?v: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.assign=s,t.camelToConst=function(t){return t.split(/(?=[A-Z])/).join("_").toUpperCase()},t.capitalize=p,t.cloneEvent=o,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 l(void 0,t)},t.extend=l,t.forEach=function(t){return function(n){return Array.prototype.forEach.call(n,t)}},t.forwardEvent=function(t,n){n.dispatchEvent(o(t))},t.hasClass=e,t.hexStrToDec=function(t){return parseInt(t.substr(1),16)},t.identity=f,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=a(t,2),e=r[0],o=r[1],u=a(n,4),i=u[0],c=u[1],f=u[2],s=u[3];return e>=i&&e<=c||o>=f&&o<=s},t.isPointInPolygon=function(){for(var t,n,r,e,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],u=a(o,2),i=u[0],c=u[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>c!=(e=f[p+1])>c&&i<(r-t)*(c-n)/(e-n)+t&&(s=!s),p=l;return s},t.isPointInRect=function(t,n){var r=a(t,2),e=r[0],o=r[1],u=a(n,4),i=u[0],c=u[1],f=u[2],s=u[3];return e>=i&&e<=c&&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=d,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 m(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=d(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 o=new RegExp("(\\s|^)".concat(n,"(\\s|$)"));if(t.namespaceURI===r){var u=t.getAttribute("class")||"";t.setAttribute("class",u.replace(o," "))}else t.classList?t.classList.remove(n):e(t,n)&&(t.className=t.className.replace(o," "))},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=v,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?v: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=m,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,r){if(null===r||"object"!==u(r))return r;if(r.constructor!==Object&&r.constructor!==Array)return new r.constructor(r);var e=new n.constructor,o=!1;return Object.keys(r).forEach((function(u){e[u]=t(n[u],r[u]),o=o||e[u]!==n[u]})),(o=o||Object.keys(n).filter((function(t){return void 0===r[t]})).length)?e:n},t.version="0.6.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,e=void 0===r?void 0:r,o=n.getter,u=n.setter,a=n.cloner,l=void 0===a?f:a,v=n.transformer,d=void 0===v?f:v,m=n.validator,h=void 0===m?function(){return!0}:m;return function(n){var r,a,f=e,v=o?function(){return o()}:function(){return l(f)},m=u?function(t){return u(t)}:function(t){var n=d(t);f=h(n)?n:f};return s(n,(r={},(a={})[t]=a[t]||{},a[t].get=function(){return v()},c(r,"set".concat(p(t)),(function(t){m(t)})),i(r,a),r))}},t.withReadOnlyProperty=function(t,n){return function(r){var e,o;return s(r,(e={},(o={})[t]=o[t]||{},o[t].get=function(){return n()},i(e,o),e))}},t.withStaticProperty=function(t,n){return function(r){var e,o;return s(r,(e={},(o={})[t]=o[t]||{},o[t].get=function(){return n},i(e,o),e))}},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},r="http://www.w3.org/2000/svg",e=function(t,n){if(t.namespaceURI===r){var e=t.getAttribute("class");return e&&!!e.match(new RegExp("(\\s|^)".concat(n,"(\\s|$)")))}return t.classList?t.classList.contains(n):!!t.className.match(new RegExp("(\\s|^)".concat(n,"(\\s|$)")))},o=function(t){var n=new t.constructor(t.type,t);return n.sourceUid=t.sourceUid,n.forwarded=t.forwarded,n};function u(t){return(u="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 i(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 c(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function a(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")}()}var f=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},l=function t(n,r){if(null===r||"object"!==u(r))return r;if(r.constructor!==Object&&r.constructor!==Array)return r;if(r.constructor===Date||r.constructor===RegExp||r.constructor===Function||r.constructor===String||r.constructor===Number||r.constructor===Boolean)return new r.constructor(r);var e=n||new r.constructor;return Object.keys(r).forEach((function(n){e[n]=void 0===e[n]?t(void 0,r[n]):e[n]})),e},p=function(t){return"".concat(t[0].toUpperCase()).concat(t.substr(1))},v=function(t,n){return t-n},d=function(t){return Math.sqrt(t.reduce((function(t,n){return t+Math.pow(n,2)}),0))},m=function(t){return t.reduce((function(t,n){return t+n}),0)};t.addClass=function(t,n){if(t.namespaceURI===r){if(!e(t,n)){var o=t.getAttribute("class")||"";t.setAttribute("class","".concat(o," ").concat(n))}}else t.classList?t.classList.add(n):e(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?v: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.assign=s,t.camelToConst=function(t){return t.split(/(?=[A-Z])/).join("_").toUpperCase()},t.capitalize=p,t.cloneEvent=o,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 l(void 0,t)},t.extend=l,t.forEach=function(t){return function(n){return Array.prototype.forEach.call(n,t)}},t.forwardEvent=function(t,n){n.dispatchEvent(o(t))},t.hasClass=e,t.hexStrToDec=function(t){return parseInt(t.substr(1),16)},t.identity=f,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=a(t,2),e=r[0],o=r[1],u=a(n,4),i=u[0],c=u[1],f=u[2],s=u[3];return e>=i&&e<=c||o>=f&&o<=s},t.isPointInPolygon=function(){for(var t,n,r,e,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],u=a(o,2),i=u[0],c=u[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>c!=(e=f[p+1])>c&&i<(r-t)*(c-n)/(e-n)+t&&(s=!s),p=l;return s},t.isPointInRect=function(t,n){var r=a(t,2),e=r[0],o=r[1],u=a(n,4),i=u[0],c=u[1],f=u[2],s=u[3];return e>=i&&e<=c&&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=d,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 m(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=d(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 o=new RegExp("(\\s|^)".concat(n,"(\\s|$)"));if(t.namespaceURI===r){var u=t.getAttribute("class")||"";t.setAttribute("class",u.replace(o," "))}else t.classList?t.classList.remove(n):e(t,n)&&(t.className=t.className.replace(o," "))},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=v,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?v: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=m,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,r){if(null===r||"object"!==u(r))return r;if(r.constructor!==Object&&r.constructor!==Array)return new r.constructor(r);var e=new n.constructor,o=!1;return Object.keys(r).forEach((function(u){e[u]=t(n[u],r[u]),o=o||e[u]!==n[u]})),(o=o||Object.keys(n).filter((function(t){return void 0===r[t]})).length)?e:n},t.version="0.7.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,e=void 0===r?void 0:r,o=n.getter,u=n.setter,a=n.cloner,l=void 0===a?f:a,v=n.transformer,d=void 0===v?f:v,m=n.validator,h=void 0===m?function(){return!0}:m;return function(n){var r,a,f=e,v=o?function(){return o()}:function(){return l(f)},m=u?function(t){return u(t)}:function(t){var n=d(t);f=h(n)?n:f};return s(n,(r={},(a={})[t]=a[t]||{},a[t].get=function(){return v()},c(r,"set".concat(p(t)),(function(t){m(t)})),i(r,a),r))}},t.withReadOnlyProperty=function(t,n){return function(r){var e,o;return s(r,(e={},(o={})[t]=o[t]||{},o[t].get=function(){return n()},i(e,o),e))}},t.withStaticProperty=function(t,n){return function(r){var e,o;return s(r,(e={},(o={})[t]=o[t]||{},o[t].get=function(){return n},i(e,o),e))}},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