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.7.1 to 1.8.0

2

declaration/utils.d.ts

@@ -37,2 +37,4 @@ import { IArrayFormat, IObject, SplitOptions } from "./types";

export declare function getKeys(obj: IObject<any>): string[];
export declare function getValues(obj: IObject<any>): any[];
export declare function getEntries(obj: IObject<any>): [string, any][];
export declare function sortOrders(keys: Array<string | number>, orders?: Array<string | number>): void;

@@ -39,0 +41,0 @@ export declare function convertUnitSize(pos: string, size: number | IObject<((pos: number) => number) | number>): number;

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

repository: https://github.com/daybrush/utils
@version 1.7.1
@version 1.8.0
*/

@@ -304,2 +304,24 @@ /**

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
return r;
}
/**

@@ -555,3 +577,14 @@ * @namespace

} else if (closeCharacter && !findIgnore(closeCharacter, texts, i)) {
throw new Error("invalid format: " + closeCharacter.close);
var nextOpenCloseCharacters = __spreadArrays(openCloseCharacters);
nextOpenCloseCharacters.splice(openCloseCharacters.indexOf(closeCharacter), 1);
return {
value: splitText(text, {
separator: separator,
isSeparateFirst: isSeparateFirst,
isSeparateOnlyOpenClose: isSeparateOnlyOpenClose,
isSeparateOpenClose: isSeparateOpenClose,
openCloseCharacters: nextOpenCloseCharacters
})
};
} else if (isEqualSeparator(character, separator) && !isSeparateOnlyOpenClose) {

@@ -582,2 +615,3 @@ resetTemp();

i = out_i_2;
if (typeof state_2 === "object") return state_2.value;
if (state_2 === "break") break;

@@ -903,13 +937,25 @@ }

function getKeys(obj) {
if (Object.keys) {
return Object.keys(obj);
}
return Object.keys(obj);
}
/**
* @function
* @memberof Utils
*/
var keys = [];
function getValues(obj) {
var keys = getKeys(obj);
return keys.map(function (key) {
return obj[key];
});
}
/**
* @function
* @memberof Utils
*/
for (var name in keys) {
keys.push(name);
}
return keys;
function getEntries(obj) {
var keys = getKeys(obj);
return keys.map(function (key) {
return [key, obj[key]];
});
}

@@ -1499,3 +1545,3 @@ /**

export { RGB, RGBA, HSL, HSLA, COLOR_MODELS, FUNCTION, PROPERTY, ARRAY, OBJECT, STRING, NUMBER, UNDEFINED, IS_WINDOW, doc as document, getCrossBrowserProperty, TRANSFORM, FILTER, ANIMATION, KEYFRAMES, OPEN_CLOSED_CHARACTERS, TINY_NUM, REVERSE_TINY_NUM, DEFAULT_UNIT_PRESETS, cutHex, hexToRGBA, toFullHex, hslToRGBA, stringToRGBA, dot, isUndefined, isObject, isArray, isString, isNumber, isFunction, splitText, splitSpace, splitComma, splitBracket, splitUnit, camelize, decamelize, toArray, now, findIndex, findLastIndex, findLast, find, requestAnimationFrame, cancelAnimationFrame, getKeys, sortOrders, convertUnitSize, between, checkBoundSize, calculateBoundSize, sum, average, getRad, getCenterPoint, getShapeDirection, getDist, throttle, throttleArray, counter, replaceOnce, $, hasClass, addClass, removeClass, fromCSS, addEvent, removeEvent };
export { RGB, RGBA, HSL, HSLA, COLOR_MODELS, FUNCTION, PROPERTY, ARRAY, OBJECT, STRING, NUMBER, UNDEFINED, IS_WINDOW, doc as document, getCrossBrowserProperty, TRANSFORM, FILTER, ANIMATION, KEYFRAMES, OPEN_CLOSED_CHARACTERS, TINY_NUM, REVERSE_TINY_NUM, DEFAULT_UNIT_PRESETS, cutHex, hexToRGBA, toFullHex, hslToRGBA, stringToRGBA, dot, isUndefined, isObject, isArray, isString, isNumber, isFunction, splitText, splitSpace, splitComma, splitBracket, splitUnit, camelize, decamelize, toArray, now, findIndex, findLastIndex, findLast, find, requestAnimationFrame, cancelAnimationFrame, getKeys, getValues, getEntries, sortOrders, convertUnitSize, between, checkBoundSize, calculateBoundSize, sum, average, getRad, getCenterPoint, getShapeDirection, getDist, throttle, throttleArray, counter, replaceOnce, $, hasClass, addClass, removeClass, fromCSS, addEvent, removeEvent };
//# sourceMappingURL=utils.esm.js.map

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

repository: https://github.com/daybrush/utils
@version 1.7.1
@version 1.8.0
*/

@@ -310,2 +310,24 @@ (function (global, factory) {

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
return r;
}
/**

@@ -561,3 +583,14 @@ * @namespace

} else if (closeCharacter && !findIgnore(closeCharacter, texts, i)) {
throw new Error("invalid format: " + closeCharacter.close);
var nextOpenCloseCharacters = __spreadArrays(openCloseCharacters);
nextOpenCloseCharacters.splice(openCloseCharacters.indexOf(closeCharacter), 1);
return {
value: splitText(text, {
separator: separator,
isSeparateFirst: isSeparateFirst,
isSeparateOnlyOpenClose: isSeparateOnlyOpenClose,
isSeparateOpenClose: isSeparateOpenClose,
openCloseCharacters: nextOpenCloseCharacters
})
};
} else if (isEqualSeparator(character, separator) && !isSeparateOnlyOpenClose) {

@@ -588,2 +621,3 @@ resetTemp();

i = out_i_2;
if (typeof state_2 === "object") return state_2.value;
if (state_2 === "break") break;

@@ -909,13 +943,25 @@ }

function getKeys(obj) {
if (Object.keys) {
return Object.keys(obj);
}
return Object.keys(obj);
}
/**
* @function
* @memberof Utils
*/
var keys = [];
function getValues(obj) {
var keys = getKeys(obj);
return keys.map(function (key) {
return obj[key];
});
}
/**
* @function
* @memberof Utils
*/
for (var name in keys) {
keys.push(name);
}
return keys;
function getEntries(obj) {
var keys = getKeys(obj);
return keys.map(function (key) {
return [key, obj[key]];
});
}

@@ -1559,2 +1605,4 @@ /**

getKeys: getKeys,
getValues: getValues,
getEntries: getEntries,
sortOrders: sortOrders,

@@ -1561,0 +1609,0 @@ convertUnitSize: convertUnitSize,

4

dist/utils.min.js

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

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

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

@@ -184,3 +184,3 @@ import {

splitOptions: string | SplitOptions,
) {
): string[] {
const {

@@ -241,3 +241,15 @@ separator = ",",

} else if (closeCharacter && !findIgnore(closeCharacter, texts, i)) {
throw new Error(`invalid format: ${closeCharacter.close}`);
const nextOpenCloseCharacters = [...openCloseCharacters];
nextOpenCloseCharacters.splice(openCloseCharacters.indexOf(closeCharacter), 1);
return splitText(
text,
{
separator,
isSeparateFirst,
isSeparateOnlyOpenClose,
isSeparateOpenClose,
openCloseCharacters: nextOpenCloseCharacters,
});
} else if (isEqualSeparator(character, separator) && !isSeparateOnlyOpenClose) {

@@ -557,2 +569,3 @@ resetTemp();

})();
/**

@@ -563,10 +576,3 @@ * @function

export function getKeys(obj: IObject<any>): string[] {
if (Object.keys) {
return Object.keys(obj);
}
const keys: string[] = [];
for (const name in keys) {
keys.push(name);
}
return keys;
return Object.keys(obj);
}

@@ -578,2 +584,21 @@

*/
export function getValues(obj: IObject<any>): any[] {
const keys = getKeys(obj);
return keys.map(key => obj[key]);
}
/**
* @function
* @memberof Utils
*/
export function getEntries(obj: IObject<any>): [string, any][] {
const keys = getKeys(obj);
return keys.map(key => [key, obj[key]]);
}
/**
* @function
* @memberof Utils
*/
export function sortOrders(keys: Array<string | number>, orders: Array<string | number> = []) {

@@ -580,0 +605,0 @@ keys.sort((a, b) => {

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