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

@daybrush/utils

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daybrush/utils - npm Package Compare versions

Comparing version 1.10.1 to 1.10.2

5

dist/utils.cjs.js

@@ -7,3 +7,3 @@ /*

repository: https://github.com/daybrush/utils
@version 1.10.1
@version 1.10.2
*/

@@ -1272,2 +1272,5 @@ 'use strict';

function $(selectors, multi) {
if (!doc) {
return multi ? [] : null;
}
return multi ? doc.querySelectorAll(selectors) : doc.querySelector(selectors);

@@ -1274,0 +1277,0 @@ }

@@ -7,3 +7,3 @@ /*

repository: https://github.com/daybrush/utils
@version 1.10.1
@version 1.10.2
*/

@@ -1268,2 +1268,5 @@ /**

function $(selectors, multi) {
if (!doc) {
return multi ? [] : null;
}
return multi ? doc.querySelectorAll(selectors) : doc.querySelector(selectors);

@@ -1270,0 +1273,0 @@ }

@@ -7,3 +7,3 @@ /*

repository: https://github.com/daybrush/utils
@version 1.10.1
@version 1.10.2
*/

@@ -1274,2 +1274,5 @@ (function (global, factory) {

function $(selectors, multi) {
if (!doc) {
return multi ? [] : null;
}
return multi ? doc.querySelectorAll(selectors) : doc.querySelector(selectors);

@@ -1276,0 +1279,0 @@ }

4

dist/utils.min.js

@@ -7,5 +7,5 @@ /*

repository: https://github.com/daybrush/utils
@version 1.10.1
@version 1.10.2
*/
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.utils=e()}(this,function(){"use strict";function n(n){if(l){var e=(l.body||l.documentElement).style,t=p.length;if(typeof e[n]!=o)return n;for(var r=0;r<t;++r){var i="-"+p[r]+"-"+n;if(typeof e[i]!=o)return i}}return""}var u="rgb",a="rgba",c="hsl",f="hsla",B=[u,a,c,f],e="function",t="object",r="string",i="number",o="undefined",s=typeof window!=o,l=typeof document!=o&&document,p=["webkit","ms","moz","o"],D=n("transform"),U=n("filter"),d=n("animation"),z=d.replace("animation","keyframes"),w=[{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:'\\"',close:'\\"'},{open:"\\'",close:"\\'"}],v=1e-7,m={cm:function(n){return 96*n/2.54},mm:function(n){return 96*n/254},in:function(n){return 96*n},pt:function(n){return 96*n/72},pc:function(n){return 96*n/6},"%":function(n,e){return n*e/100},vw:function(n,e){return n/100*(e=void 0===e?window.innerWidth:e)},vh:function(n,e){return n/100*(e=void 0===e?window.innerHeight:e)},vmax:function(n,e){return n/100*(e=void 0===e?Math.max(window.innerWidth,window.innerHeight):e)},vmin:function(n,e){return n/100*(e=void 0===e?Math.min(window.innerWidth,window.innerHeight):e)}};function h(n){return n&&typeof n==t}function g(n){return Array.isArray(n)}function A(n){return typeof n==r}function y(n){return typeof n==e}function S(n,e,t,r,i){if(b(n,e,t))return t;for(var o,u=n,a=e,c=r,f=i,s=t+1;s<c;++s){var l=function(n){var e,t,r=a[n].trim();return r!==u.close||b(u,a,n)?(e=n,-1===(e=(t=N(f,function(n){return n.open===r}))?S(t,a,n,c,f):e)?(o=n,"break"):void(o=n=e)):{value:n}}(s);if(s=o,"object"==typeof l)return l.value;if("break"===l)break}return-1}function b(n,e,t){return n.ignore?(e=e.slice(Math.max(t-3,0),t+3).join(""),new RegExp(n.ignore).exec(e)):null}function E(o,n){var n=A(n)?{separator:n}:n,e=n.separator,u=void 0===e?",":e,a=n.isSeparateFirst,c=n.isSeparateOnlyOpenClose,e=n.isSeparateOpenClose,f=void 0===e?c:e,e=n.openCloseCharacters,s=void 0===e?w:e,n=s.map(function(n){var e=n.open,n=n.close;return e===n?e:e+"|"+n}).join("|"),e=new RegExp("(\\s*"+u+"\\s*|"+n+"|\\s+)","g"),l=o.split(e).filter(Boolean),p=l.length,d=[],v=[];function m(){return v.length&&(d.push(v.join("")),v=[])}for(var h,t=function(n){var e=l[n].trim(),t=n,r=N(s,function(n){return n.open===e}),i=N(s,function(n){return n.close===e});if(r){if(-1!==(t=S(r,l,n,p,s))&&f)return m()&&a||(d.push(l.slice(n,t+1).join("")),n=t,a)?(h=n,"break"):(h=n,"continue")}else{if(i&&!b(i,l,n))return(r=function(){for(var n=0,e=0,t=arguments.length;e<t;e++)n+=arguments[e].length;for(var r=Array(n),i=0,e=0;e<t;e++)for(var o=arguments[e],u=0,a=o.length;u<a;u++,i++)r[i]=o[u];return r}(s)).splice(s.indexOf(i),1),{value:E(o,{separator:u,isSeparateFirst:a,isSeparateOnlyOpenClose:c,isSeparateOpenClose:f,openCloseCharacters:r})};if(i=e,!((""!==(r=u)&&" "!=r||""!==i&&" "!=i)&&i!==r||c))return m(),a?(h=n,"break"):(h=n,"continue")}v.push(l.slice(n,(t=-1===t?p-1:t)+1).join("")),h=n=t},r=0;r<p;++r){var i=t(r),r=h;if("object"==typeof i)return i.value;if("break"===i)break}return v.length&&d.push(v.join("")),d}function x(n){return E(n,",")}function R(n){n=/([^(]*)\(([\s\S]*)\)([\s\S]*)/g.exec(n);return!n||n.length<4?{}:{prefix:n[1],value:n[2],suffix:n[3]}}function C(n){var e,t,n=/^([^\d|e|\-|\+]*)((?:\d|\.|-|e-|e\+)+)(\S*)$/g.exec(n);return n?(e=n[1],t=n[2],{prefix:e,unit:n[3],value:parseFloat(t)}):{prefix:"",unit:"",value:NaN}}function M(){return Date.now?Date.now():(new Date).getTime()}function O(n,e,t){void 0===t&&(t=-1);for(var r=n.length,i=0;i<r;++i)if(e(n[i],i,n))return i;return t}function F(n,e,t){void 0===t&&(t=-1);for(var r=n.length-1;0<=r;--r)if(e(n[r],r,n))return r;return t}function N(n,e,t){e=O(n,e);return-1<e?n[e]:t}var _=function(){var t=M(),n=s&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame);return n?n.bind(window):function(n){var e=M();return setTimeout(function(){n(e-t)},1e3/60)}}();function I(n){return Object.keys(n)}function P(n,e,t){return Math.max(e,Math.min(n,t))}function T(n,r,i,e){return void 0===e&&(e=n[0]/n[1]),[[k(r[0],v),k(r[0]/e,v)],[k(r[1]*e,v),k(r[1],v)]].filter(function(n){return n.every(function(n,e){var e=r[e],t=k(e,v);return i?n<=e||n<=t:e<=n||t<=n})})[0]||n}function q(n){for(var e=n.length,t=0,r=e-1;0<=r;--r)t+=n[r];return e?t/e:0}function L(n,e){var t=e[0]-n[0],e=e[1]-n[1],n=Math.atan2(e,t);return 0<=n?n:n+2*Math.PI}function H(n){return[0,1].map(function(e){return q(n.map(function(n){return n[e]}))})}function k(n,e){var t;return e?(t=1/e,Math.round(n/e)/t):n}function G(n){return n.replace("#","")}function j(n){var n=G(n),e=parseInt(n.substring(0,2),16),t=parseInt(n.substring(2,4),16),r=parseInt(n.substring(4,6),16),n=parseInt(n.substring(6,8),16)/255;return[e,t,r,n=isNaN(n)?1:n]}function W(n){var e=n.charAt(1),t=n.charAt(2),r=n.charAt(3),n=n.charAt(4);return["#",e,e,t,t,r,r,n,n].join("")}function Y(n){var e=n[0],t=n[1],r=n[2],t=(e<0&&(e+=360*Math.floor((Math.abs(e)+360)/360)),e%=360,(1-Math.abs(2*r-1))*t),i=t*(1-Math.abs(e/60%2-1)),r=r-t/2,e=e<60?[t,i,0]:e<120?[i,t,0]:e<180?[0,t,i]:e<240?[0,i,t]:e<300?[i,0,t]:e<360?[t,0,i]:[0,0,0];return[Math.round(255*(e[0]+r)),Math.round(255*(e[1]+r)),Math.round(255*(e[2]+r)),null!=(t=n[3])?t:1]}return{RGB:u,RGBA:a,HSL:c,HSLA:f,COLOR_MODELS:B,FUNCTION:e,PROPERTY:"property",ARRAY:"array",OBJECT:t,STRING:r,NUMBER:i,UNDEFINED:o,IS_WINDOW:s,document:l,getCrossBrowserProperty:n,TRANSFORM:D,FILTER:U,ANIMATION:d,KEYFRAMES:z,OPEN_CLOSED_CHARACTERS:w,TINY_NUM:v,REVERSE_TINY_NUM:1e7,DEFAULT_UNIT_PRESETS:m,cutHex:G,hexToRGBA:j,toFullHex:W,hslToRGBA:Y,stringToRGBA:function(n){if("#"===n.charAt(0))return 4===n.length||5===n.length?j(W(n)):j(n);if(-1!==n.indexOf("(")){var n=R(n),e=n.prefix,n=n.value;if(!e||!n)return;var t=x(n),r=[0,0,0,1],i=t.length;switch(e){case u:case a:for(var o=0;o<i;++o)r[o]=parseFloat(t[o]);return r;case c:case f:for(o=0;o<i;++o)-1!==t[o].indexOf("%")?r[o]=parseFloat(t[o])/100:r[o]=parseFloat(t[o]);return Y(r)}}},dot:function(n,e,t,r){return(n*r+e*t)/(t+r)},isUndefined:function(n){return typeof n==o},isObject:h,isArray:g,isString:A,isNumber:function(n){return typeof n==i},isFunction:y,splitText:E,splitSpace:function(n){return E(n,"")},splitComma:x,splitBracket:R,splitUnit:C,camelize:function(n){return n.replace(/[\s-_]([a-z])/g,function(n,e){return e.toUpperCase()})},decamelize:function(n,r){return void 0===r&&(r="-"),n.replace(/([a-z])([A-Z])/g,function(n,e,t){return""+e+r+t.toLowerCase()})},toArray:function(n){return[].slice.call(n)},now:M,findIndex:O,findLastIndex:F,findLast:function(n,e,t){return-1<(e=F(n,e))?n[e]:t},find:N,requestAnimationFrame:_,cancelAnimationFrame:function(){var n=s&&(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame);return n?n.bind(window):function(n){clearTimeout(n)}}(),getKeys:I,getValues:function(e){return I(e).map(function(n){return e[n]})},getEntries:function(e){return I(e).map(function(n){return[n,e[n]]})},sortOrders:function(n,t){void 0===t&&(t=[]),n.sort(function(n,e){n=t.indexOf(n),e=t.indexOf(e);return-1===e&&-1===n?0:-1===n?1:-1===e?-1:n-e})},convertUnitSize:function(n,e){var t=(n=C(n)).value,n=n.unit;if(h(e)){var r=e[n];if(r){if(y(r))return r(t);if(m[n])return m[n](t,r)}}else if("%"===n)return t*e/100;return m[n]?m[n](t):t},between:P,checkBoundSize:T,calculateBoundSize:function(n,t,r,e){var i,o,u,a,c;return e?(i=n[0],o=n[1],u=(a=T(n,t,!1,e=!0===e?i/o:e))[0],a=a[1],c=(e=T(n,r,!0,e))[0],e=e[1],i<u||o<a?(i=u,o=a):(c<i||e<o)&&(i=c,o=e),[i,o]):n.map(function(n,e){return P(n,t[e],r[e])})},sum:function(n){for(var e=0,t=n.length-1;0<=t;--t)e+=n[t];return e},average:q,getRad:L,getCenterPoint:H,getShapeDirection:function(n){var e=L(t=H(n),n[0]),t=L(t,n[1]);return e<t&&t-e<Math.PI||t<e&&t-e<-Math.PI?1:-1},getDist:function(n,e){return Math.sqrt(Math.pow((e?e[0]:0)-n[0],2)+Math.pow((e?e[1]:0)-n[1],2))},throttle:k,throttleArray:function(t,r){return t.forEach(function(n,e){t[e]=k(t[e],r)}),t},counter:function(n){for(var e=[],t=0;t<n;++t)e.push(t);return e},replaceOnce:function(n,e,t){var r=!1;return n.replace(e,function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return r?n[0]:(r=!0,A(t)?t:t.apply(void 0,n))})},flat:function(n){return n.reduce(function(n,e){return n.concat(e)},[])},deepFlat:function t(n){return n.reduce(function(n,e){return g(e)?n.push.apply(n,t(e)):n.push(e),n},[])},$:function(n,e){return e?l.querySelectorAll(n):l.querySelector(n)},hasClass:function(n,e){return n.classList?n.classList.contains(e):!!n.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))},addClass:function(n,e){n.classList?n.classList.add(e):n.className+=" "+e},removeClass:function(n,e){n.classList?n.classList.remove(e):(e=new RegExp("(\\s|^)"+e+"(\\s|$)"),n.className=n.className.replace(e," "))},fromCSS:function(n,e){if(!n||!e||!e.length)return{};var t;if(n instanceof Element)t=n;else{if(!n.length)return{};t=n[0]}for(var r={},i=window.getComputedStyle(t),o=e.length,u=0;u<o;++u)r[e[u]]=i[e[u]];return r},addEvent:function(n,e,t,r){n.addEventListener(e,t,r)},removeEvent:function(n,e,t,r){n.removeEventListener(e,t,r)}}});
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.utils=e()}(this,function(){"use strict";function n(n){if(l){var e=(l.body||l.documentElement).style,t=p.length;if(typeof e[n]!=o)return n;for(var r=0;r<t;++r){var i="-"+p[r]+"-"+n;if(typeof e[i]!=o)return i}}return""}var u="rgb",a="rgba",c="hsl",f="hsla",B=[u,a,c,f],e="function",t="object",r="string",i="number",o="undefined",s=typeof window!=o,l=typeof document!=o&&document,p=["webkit","ms","moz","o"],D=n("transform"),U=n("filter"),d=n("animation"),z=d.replace("animation","keyframes"),w=[{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:'\\"',close:'\\"'},{open:"\\'",close:"\\'"}],v=1e-7,m={cm:function(n){return 96*n/2.54},mm:function(n){return 96*n/254},in:function(n){return 96*n},pt:function(n){return 96*n/72},pc:function(n){return 96*n/6},"%":function(n,e){return n*e/100},vw:function(n,e){return n/100*(e=void 0===e?window.innerWidth:e)},vh:function(n,e){return n/100*(e=void 0===e?window.innerHeight:e)},vmax:function(n,e){return n/100*(e=void 0===e?Math.max(window.innerWidth,window.innerHeight):e)},vmin:function(n,e){return n/100*(e=void 0===e?Math.min(window.innerWidth,window.innerHeight):e)}};function h(n){return n&&typeof n==t}function g(n){return Array.isArray(n)}function A(n){return typeof n==r}function y(n){return typeof n==e}function S(n,e,t,r,i){if(b(n,e,t))return t;for(var o,u=n,a=e,c=r,f=i,s=t+1;s<c;++s){var l=function(n){var e,t,r=a[n].trim();return r!==u.close||b(u,a,n)?(e=n,-1===(e=(t=N(f,function(n){return n.open===r}))?S(t,a,n,c,f):e)?(o=n,"break"):void(o=n=e)):{value:n}}(s);if(s=o,"object"==typeof l)return l.value;if("break"===l)break}return-1}function b(n,e,t){return n.ignore?(e=e.slice(Math.max(t-3,0),t+3).join(""),new RegExp(n.ignore).exec(e)):null}function E(o,n){var n=A(n)?{separator:n}:n,e=n.separator,u=void 0===e?",":e,a=n.isSeparateFirst,c=n.isSeparateOnlyOpenClose,e=n.isSeparateOpenClose,f=void 0===e?c:e,e=n.openCloseCharacters,s=void 0===e?w:e,n=s.map(function(n){var e=n.open,n=n.close;return e===n?e:e+"|"+n}).join("|"),e=new RegExp("(\\s*"+u+"\\s*|"+n+"|\\s+)","g"),l=o.split(e).filter(Boolean),p=l.length,d=[],v=[];function m(){return v.length&&(d.push(v.join("")),v=[])}for(var h,t=function(n){var e=l[n].trim(),t=n,r=N(s,function(n){return n.open===e}),i=N(s,function(n){return n.close===e});if(r){if(-1!==(t=S(r,l,n,p,s))&&f)return m()&&a||(d.push(l.slice(n,t+1).join("")),n=t,a)?(h=n,"break"):(h=n,"continue")}else{if(i&&!b(i,l,n))return(r=function(){for(var n=0,e=0,t=arguments.length;e<t;e++)n+=arguments[e].length;for(var r=Array(n),i=0,e=0;e<t;e++)for(var o=arguments[e],u=0,a=o.length;u<a;u++,i++)r[i]=o[u];return r}(s)).splice(s.indexOf(i),1),{value:E(o,{separator:u,isSeparateFirst:a,isSeparateOnlyOpenClose:c,isSeparateOpenClose:f,openCloseCharacters:r})};if(i=e,!((""!==(r=u)&&" "!=r||""!==i&&" "!=i)&&i!==r||c))return m(),a?(h=n,"break"):(h=n,"continue")}v.push(l.slice(n,(t=-1===t?p-1:t)+1).join("")),h=n=t},r=0;r<p;++r){var i=t(r),r=h;if("object"==typeof i)return i.value;if("break"===i)break}return v.length&&d.push(v.join("")),d}function x(n){return E(n,",")}function R(n){n=/([^(]*)\(([\s\S]*)\)([\s\S]*)/g.exec(n);return!n||n.length<4?{}:{prefix:n[1],value:n[2],suffix:n[3]}}function C(n){var e,t,n=/^([^\d|e|\-|\+]*)((?:\d|\.|-|e-|e\+)+)(\S*)$/g.exec(n);return n?(e=n[1],t=n[2],{prefix:e,unit:n[3],value:parseFloat(t)}):{prefix:"",unit:"",value:NaN}}function M(){return Date.now?Date.now():(new Date).getTime()}function O(n,e,t){void 0===t&&(t=-1);for(var r=n.length,i=0;i<r;++i)if(e(n[i],i,n))return i;return t}function F(n,e,t){void 0===t&&(t=-1);for(var r=n.length-1;0<=r;--r)if(e(n[r],r,n))return r;return t}function N(n,e,t){e=O(n,e);return-1<e?n[e]:t}var _=function(){var t=M(),n=s&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame);return n?n.bind(window):function(n){var e=M();return setTimeout(function(){n(e-t)},1e3/60)}}();function I(n){return Object.keys(n)}function P(n,e,t){return Math.max(e,Math.min(n,t))}function T(n,r,i,e){return void 0===e&&(e=n[0]/n[1]),[[k(r[0],v),k(r[0]/e,v)],[k(r[1]*e,v),k(r[1],v)]].filter(function(n){return n.every(function(n,e){var e=r[e],t=k(e,v);return i?n<=e||n<=t:e<=n||t<=n})})[0]||n}function q(n){for(var e=n.length,t=0,r=e-1;0<=r;--r)t+=n[r];return e?t/e:0}function L(n,e){var t=e[0]-n[0],e=e[1]-n[1],n=Math.atan2(e,t);return 0<=n?n:n+2*Math.PI}function H(n){return[0,1].map(function(e){return q(n.map(function(n){return n[e]}))})}function k(n,e){var t;return e?(t=1/e,Math.round(n/e)/t):n}function G(n){return n.replace("#","")}function j(n){var n=G(n),e=parseInt(n.substring(0,2),16),t=parseInt(n.substring(2,4),16),r=parseInt(n.substring(4,6),16),n=parseInt(n.substring(6,8),16)/255;return[e,t,r,n=isNaN(n)?1:n]}function W(n){var e=n.charAt(1),t=n.charAt(2),r=n.charAt(3),n=n.charAt(4);return["#",e,e,t,t,r,r,n,n].join("")}function Y(n){var e=n[0],t=n[1],r=n[2],t=(e<0&&(e+=360*Math.floor((Math.abs(e)+360)/360)),e%=360,(1-Math.abs(2*r-1))*t),i=t*(1-Math.abs(e/60%2-1)),r=r-t/2,e=e<60?[t,i,0]:e<120?[i,t,0]:e<180?[0,t,i]:e<240?[0,i,t]:e<300?[i,0,t]:e<360?[t,0,i]:[0,0,0];return[Math.round(255*(e[0]+r)),Math.round(255*(e[1]+r)),Math.round(255*(e[2]+r)),null!=(t=n[3])?t:1]}return{RGB:u,RGBA:a,HSL:c,HSLA:f,COLOR_MODELS:B,FUNCTION:e,PROPERTY:"property",ARRAY:"array",OBJECT:t,STRING:r,NUMBER:i,UNDEFINED:o,IS_WINDOW:s,document:l,getCrossBrowserProperty:n,TRANSFORM:D,FILTER:U,ANIMATION:d,KEYFRAMES:z,OPEN_CLOSED_CHARACTERS:w,TINY_NUM:v,REVERSE_TINY_NUM:1e7,DEFAULT_UNIT_PRESETS:m,cutHex:G,hexToRGBA:j,toFullHex:W,hslToRGBA:Y,stringToRGBA:function(n){if("#"===n.charAt(0))return 4===n.length||5===n.length?j(W(n)):j(n);if(-1!==n.indexOf("(")){var n=R(n),e=n.prefix,n=n.value;if(!e||!n)return;var t=x(n),r=[0,0,0,1],i=t.length;switch(e){case u:case a:for(var o=0;o<i;++o)r[o]=parseFloat(t[o]);return r;case c:case f:for(o=0;o<i;++o)-1!==t[o].indexOf("%")?r[o]=parseFloat(t[o])/100:r[o]=parseFloat(t[o]);return Y(r)}}},dot:function(n,e,t,r){return(n*r+e*t)/(t+r)},isUndefined:function(n){return typeof n==o},isObject:h,isArray:g,isString:A,isNumber:function(n){return typeof n==i},isFunction:y,splitText:E,splitSpace:function(n){return E(n,"")},splitComma:x,splitBracket:R,splitUnit:C,camelize:function(n){return n.replace(/[\s-_]([a-z])/g,function(n,e){return e.toUpperCase()})},decamelize:function(n,r){return void 0===r&&(r="-"),n.replace(/([a-z])([A-Z])/g,function(n,e,t){return""+e+r+t.toLowerCase()})},toArray:function(n){return[].slice.call(n)},now:M,findIndex:O,findLastIndex:F,findLast:function(n,e,t){return-1<(e=F(n,e))?n[e]:t},find:N,requestAnimationFrame:_,cancelAnimationFrame:function(){var n=s&&(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame);return n?n.bind(window):function(n){clearTimeout(n)}}(),getKeys:I,getValues:function(e){return I(e).map(function(n){return e[n]})},getEntries:function(e){return I(e).map(function(n){return[n,e[n]]})},sortOrders:function(n,t){void 0===t&&(t=[]),n.sort(function(n,e){n=t.indexOf(n),e=t.indexOf(e);return-1===e&&-1===n?0:-1===n?1:-1===e?-1:n-e})},convertUnitSize:function(n,e){var t=(n=C(n)).value,n=n.unit;if(h(e)){var r=e[n];if(r){if(y(r))return r(t);if(m[n])return m[n](t,r)}}else if("%"===n)return t*e/100;return m[n]?m[n](t):t},between:P,checkBoundSize:T,calculateBoundSize:function(n,t,r,e){var i,o,u,a,c;return e?(i=n[0],o=n[1],u=(a=T(n,t,!1,e=!0===e?i/o:e))[0],a=a[1],c=(e=T(n,r,!0,e))[0],e=e[1],i<u||o<a?(i=u,o=a):(c<i||e<o)&&(i=c,o=e),[i,o]):n.map(function(n,e){return P(n,t[e],r[e])})},sum:function(n){for(var e=0,t=n.length-1;0<=t;--t)e+=n[t];return e},average:q,getRad:L,getCenterPoint:H,getShapeDirection:function(n){var e=L(t=H(n),n[0]),t=L(t,n[1]);return e<t&&t-e<Math.PI||t<e&&t-e<-Math.PI?1:-1},getDist:function(n,e){return Math.sqrt(Math.pow((e?e[0]:0)-n[0],2)+Math.pow((e?e[1]:0)-n[1],2))},throttle:k,throttleArray:function(t,r){return t.forEach(function(n,e){t[e]=k(t[e],r)}),t},counter:function(n){for(var e=[],t=0;t<n;++t)e.push(t);return e},replaceOnce:function(n,e,t){var r=!1;return n.replace(e,function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return r?n[0]:(r=!0,A(t)?t:t.apply(void 0,n))})},flat:function(n){return n.reduce(function(n,e){return n.concat(e)},[])},deepFlat:function t(n){return n.reduce(function(n,e){return g(e)?n.push.apply(n,t(e)):n.push(e),n},[])},$:function(n,e){return l?e?l.querySelectorAll(n):l.querySelector(n):e?[]:null},hasClass:function(n,e){return n.classList?n.classList.contains(e):!!n.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))},addClass:function(n,e){n.classList?n.classList.add(e):n.className+=" "+e},removeClass:function(n,e){n.classList?n.classList.remove(e):(e=new RegExp("(\\s|^)"+e+"(\\s|$)"),n.className=n.className.replace(e," "))},fromCSS:function(n,e){if(!n||!e||!e.length)return{};var t;if(n instanceof Element)t=n;else{if(!n.length)return{};t=n[0]}for(var r={},i=window.getComputedStyle(t),o=e.length,u=0;u<o;++u)r[e[u]]=i[e[u]];return r},addEvent:function(n,e,t,r){n.addEventListener(e,t,r)},removeEvent:function(n,e,t,r){n.removeEventListener(e,t,r)}}});
//# sourceMappingURL=utils.min.js.map
{
"name": "@daybrush/utils",
"version": "1.10.1",
"version": "1.10.2",
"description": "utils for daybrush",

@@ -5,0 +5,0 @@ "main": "dist/utils.cjs.js",

@@ -33,2 +33,5 @@ import { document } from "./consts";

export function $<E extends Element = Element>(selectors: string, multi?: boolean): E | NodeListOf<E> | null {
if (!document) {
return multi ? [] as any : null;
}
return multi ? document.querySelectorAll<E>(selectors) : document.querySelector<E>(selectors);

@@ -35,0 +38,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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