Socket
Socket
Sign inDemoInstall

@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.0 to 1.10.1

234

dist/utils.cjs.js

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

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

@@ -18,3 +18,2 @@ 'use strict';

*/
/**

@@ -37,3 +36,2 @@ * get string "rgb"

*/
var RGBA = "rgba";

@@ -48,3 +46,2 @@ /**

*/
var HSL = "hsl";

@@ -59,3 +56,2 @@ /**

*/
var HSLA = "hsla";

@@ -70,3 +66,2 @@ /**

*/
var COLOR_MODELS = [RGB, RGBA, HSL, HSLA];

@@ -81,3 +76,2 @@ /**

*/
var FUNCTION = "function";

@@ -92,3 +86,2 @@ /**

*/
var PROPERTY = "property";

@@ -103,3 +96,2 @@ /**

*/
var ARRAY = "array";

@@ -114,3 +106,2 @@ /**

*/
var OBJECT = "object";

@@ -125,3 +116,2 @@ /**

*/
var STRING = "string";

@@ -136,3 +126,2 @@ /**

*/
var NUMBER = "number";

@@ -147,3 +136,2 @@ /**

*/
var UNDEFINED = "undefined";

@@ -159,3 +147,2 @@ /**

*/
var IS_WINDOW = typeof window !== UNDEFINED;

@@ -172,3 +159,2 @@ /**

*/
var doc = typeof document !== UNDEFINED && document; // FIXME: this type maybe false

@@ -179,3 +165,2 @@ var prefixes = ["webkit", "ms", "moz", "o"];

*/
/**

@@ -193,3 +178,2 @@ * Get a CSS property with a vendor prefix that supports cross browser.

*/
var getCrossBrowserProperty = /*#__PURE__*/function (property) {

@@ -199,13 +183,9 @@ if (!doc) {

}
var styles = (doc.body || doc.documentElement).style;
var length = prefixes.length;
if (typeof styles[property] !== UNDEFINED) {
return property;
}
for (var i = 0; i < length; ++i) {
var name = "-" + prefixes[i] + "-" + property;
if (typeof styles[name] !== UNDEFINED) {

@@ -215,3 +195,2 @@ return name;

}
return "";

@@ -227,3 +206,2 @@ };

*/
var TRANSFORM = /*#__PURE__*/getCrossBrowserProperty("transform");

@@ -238,3 +216,2 @@ /**

*/
var FILTER = /*#__PURE__*/getCrossBrowserProperty("filter");

@@ -249,3 +226,2 @@ /**

*/
var ANIMATION = /*#__PURE__*/getCrossBrowserProperty("animation");

@@ -260,3 +236,2 @@ /**

*/
var KEYFRAMES = /*#__PURE__*/ANIMATION.replace("animation", "keyframes");

@@ -304,3 +279,2 @@ var OPEN_CLOSED_CHARACTERS = [{

}
return pos / 100 * size;

@@ -312,3 +286,2 @@ },

}
return pos / 100 * size;

@@ -320,3 +293,2 @@ },

}
return pos / 100 * size;

@@ -328,3 +300,2 @@ },

}
return pos / 100 * size;

@@ -350,5 +321,3 @@ }

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;

@@ -361,3 +330,2 @@ }

*/
/**

@@ -377,3 +345,2 @@ * Returns the inner product of two numbers(`a1`, `a2`) by two criteria(`b1`, `b2`).

*/
function dot(a1, a2, b1, b2) {

@@ -395,3 +362,2 @@ return (a1 * b2 + a2 * b1) / (b1 + b2);

*/
function isUndefined(value) {

@@ -413,3 +379,2 @@ return typeof value === UNDEFINED;

*/
function isObject(value) {

@@ -431,3 +396,2 @@ return value && typeof value === OBJECT;

*/
function isArray(value) {

@@ -449,3 +413,2 @@ return Array.isArray(value);

*/
function isString(value) {

@@ -471,7 +434,5 @@ return typeof value === STRING;

*/
function isFunction(value) {
return typeof value === FUNCTION;
}
function isEqualSeparator(character, separator) {

@@ -482,13 +443,9 @@ var isCharacterSpace = character === "" || character == " ";

}
function findOpen(openCharacter, texts, index, length, openCloseCharacters) {
var isIgnore = findIgnore(openCharacter, texts, index);
if (!isIgnore) {
return findClose(openCharacter, texts, index + 1, length, openCloseCharacters);
}
return index;
}
function findIgnore(character, texts, index) {

@@ -498,11 +455,8 @@ if (!character.ignore) {

}
var otherText = texts.slice(Math.max(index - 3, 0), index + 3).join("");
return new RegExp(character.ignore).exec(otherText);
}
function findClose(closeCharacter, texts, index, length, openCloseCharacters) {
var _loop_1 = function (i) {
var character = texts[i].trim();
if (character === closeCharacter.close && !findIgnore(closeCharacter, texts, i)) {

@@ -513,5 +467,4 @@ return {

}
var nextIndex = i; // re open
var nextIndex = i;
// re open
var openCharacter = find(openCloseCharacters, function (_a) {

@@ -521,20 +474,14 @@ var open = _a.open;

});
if (openCharacter) {
nextIndex = findOpen(openCharacter, texts, i, length, openCloseCharacters);
}
if (nextIndex === -1) {
return out_i_1 = i, "break";
}
i = nextIndex;
out_i_1 = i;
};
var out_i_1;
for (var i = index; i < length; ++i) {
var state_1 = _loop_1(i);
i = out_i_1;

@@ -544,27 +491,22 @@ if (typeof state_1 === "object") return state_1.value;

}
return -1;
}
function splitText(text, splitOptions) {
var _a = isString(splitOptions) ? {
separator: splitOptions
} : splitOptions,
_b = _a.separator,
separator = _b === void 0 ? "," : _b,
isSeparateFirst = _a.isSeparateFirst,
isSeparateOnlyOpenClose = _a.isSeparateOnlyOpenClose,
_c = _a.isSeparateOpenClose,
isSeparateOpenClose = _c === void 0 ? isSeparateOnlyOpenClose : _c,
_d = _a.openCloseCharacters,
openCloseCharacters = _d === void 0 ? OPEN_CLOSED_CHARACTERS : _d;
separator: splitOptions
} : splitOptions,
_b = _a.separator,
separator = _b === void 0 ? "," : _b,
isSeparateFirst = _a.isSeparateFirst,
isSeparateOnlyOpenClose = _a.isSeparateOnlyOpenClose,
_c = _a.isSeparateOpenClose,
isSeparateOpenClose = _c === void 0 ? isSeparateOnlyOpenClose : _c,
_d = _a.openCloseCharacters,
openCloseCharacters = _d === void 0 ? OPEN_CLOSED_CHARACTERS : _d;
var openClosedText = openCloseCharacters.map(function (_a) {
var open = _a.open,
close = _a.close;
close = _a.close;
if (open === close) {
return open;
}
return open + "|" + close;

@@ -578,3 +520,2 @@ }).join("|");

var tempValues = [];
function resetTemp() {

@@ -586,6 +527,4 @@ if (tempValues.length) {

}
return false;
}
var _loop_2 = function (i) {

@@ -602,6 +541,4 @@ var character = texts[i].trim();

});
if (openCharacter) {
nextIndex = findOpen(openCharacter, texts, i, length, openCloseCharacters);
if (nextIndex !== -1 && isSeparateOpenClose) {

@@ -611,10 +548,7 @@ if (resetTemp() && isSeparateFirst) {

}
values.push(texts.slice(i, nextIndex + 1).join(""));
i = nextIndex;
if (isSeparateFirst) {
return out_i_2 = i, "break";
}
return out_i_2 = i, "continue";

@@ -624,3 +558,2 @@ }

var nextOpenCloseCharacters = __spreadArrays(openCloseCharacters);
nextOpenCloseCharacters.splice(openCloseCharacters.indexOf(closeCharacter), 1);

@@ -638,14 +571,10 @@ return {

resetTemp();
if (isSeparateFirst) {
return out_i_2 = i, "break";
}
return out_i_2 = i, "continue";
}
if (nextIndex === -1) {
nextIndex = length - 1;
}
tempValues.push(texts.slice(i, nextIndex + 1).join(""));

@@ -655,8 +584,5 @@ i = nextIndex;

};
var out_i_2;
for (var i = 0; i < length; ++i) {
var state_2 = _loop_2(i);
i = out_i_2;

@@ -666,7 +592,5 @@ if (typeof state_2 === "object") return state_2.value;

}
if (tempValues.length) {
values.push(tempValues.join(""));
}
return values;

@@ -687,3 +611,2 @@ }

*/
function splitSpace(text) {

@@ -706,3 +629,2 @@ // divide comma(space)

*/
function splitComma(text) {

@@ -726,6 +648,4 @@ // divide comma(,)

*/
function splitBracket(text) {
var matches = /([^(]*)\(([\s\S]*)\)([\s\S]*)/g.exec(text);
if (!matches || matches.length < 4) {

@@ -756,6 +676,4 @@ return {};

*/
function splitUnit(text) {
var matches = /^([^\d|e|\-|\+]*)((?:\d|\.|-|e-|e\+)+)(\S*)$/g.exec(text);
if (!matches) {

@@ -768,3 +686,2 @@ return {

}
var prefix = matches[1];

@@ -791,3 +708,2 @@ var value = matches[2];

*/
function camelize(str) {

@@ -810,3 +726,2 @@ return str.replace(/[\s-_]([a-z])/g, function (all, letter) {

*/
function decamelize(str, separator) {

@@ -816,3 +731,2 @@ if (separator === void 0) {

}
return str.replace(/([a-z])([A-Z])/g, function (all, letter, letter2) {

@@ -833,3 +747,2 @@ return "" + letter + separator + letter2.toLowerCase();

*/
function toArray(value) {

@@ -847,3 +760,2 @@ return [].slice.call(value);

*/
function now() {

@@ -864,3 +776,2 @@ return Date.now ? Date.now() : new Date().getTime();

*/
function findIndex(arr, callback, defaultIndex) {

@@ -870,5 +781,3 @@ if (defaultIndex === void 0) {

}
var length = arr.length;
for (var i = 0; i < length; ++i) {

@@ -879,3 +788,2 @@ if (callback(arr[i], i, arr)) {

}
return defaultIndex;

@@ -895,3 +803,2 @@ }

*/
function findLastIndex(arr, callback, defaultIndex) {

@@ -901,5 +808,3 @@ if (defaultIndex === void 0) {

}
var length = arr.length;
for (var i = length - 1; i >= 0; --i) {

@@ -910,3 +815,2 @@ if (callback(arr[i], i, arr)) {

}
return defaultIndex;

@@ -926,3 +830,2 @@ }

*/
function findLast(arr, callback, defalutValue) {

@@ -944,3 +847,2 @@ var index = findLastIndex(arr, callback);

*/
function find(arr, callback, defalutValue) {

@@ -963,3 +865,2 @@ var index = findIndex(arr, callback);

*/
var requestAnimationFrame = /*#__PURE__*/function () {

@@ -970,3 +871,3 @@ var firstTime = now();

var currTime = now();
var id = window.setTimeout(function () {
var id = setTimeout(function () {
callback(currTime - firstTime);

@@ -992,3 +893,2 @@ }, 1000 / 60);

*/
var cancelAnimationFrame = /*#__PURE__*/function () {

@@ -1004,3 +904,2 @@ var caf = IS_WINDOW && (window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.msCancelAnimationFrame);

*/
function getKeys(obj) {

@@ -1013,3 +912,2 @@ return Object.keys(obj);

*/
function getValues(obj) {

@@ -1025,3 +923,2 @@ var keys = getKeys(obj);

*/
function getEntries(obj) {

@@ -1037,3 +934,2 @@ var keys = getKeys(obj);

*/
function sortOrders(keys, orders) {

@@ -1043,19 +939,14 @@ if (orders === void 0) {

}
keys.sort(function (a, b) {
var index1 = orders.indexOf(a);
var index2 = orders.indexOf(b);
if (index2 === -1 && index1 === -1) {
return 0;
}
if (index1 === -1) {
return 1;
}
if (index2 === -1) {
return -1;
}
return index1 - index2;

@@ -1069,11 +960,8 @@ });

*/
function convertUnitSize(pos, size) {
var _a = splitUnit(pos),
value = _a.value,
unit = _a.unit;
value = _a.value,
unit = _a.unit;
if (isObject(size)) {
var sizeFunction = size[unit];
if (sizeFunction) {

@@ -1089,7 +977,5 @@ if (isFunction(sizeFunction)) {

}
if (DEFAULT_UNIT_PRESETS[unit]) {
return DEFAULT_UNIT_PRESETS[unit](value);
}
return value;

@@ -1102,3 +988,2 @@ }

*/
function between(value, min, max) {

@@ -1111,3 +996,2 @@ return Math.max(min, Math.min(value, max));

}
return [[throttle(compareSize[0], TINY_NUM), throttle(compareSize[0] / ratio, TINY_NUM)], [throttle(compareSize[1] * ratio, TINY_NUM), throttle(compareSize[1], TINY_NUM)]].filter(function (size) {

@@ -1126,3 +1010,2 @@ return size.every(function (value, i) {

*/
function calculateBoundSize(size, minSize, maxSize, keepRatio) {

@@ -1134,15 +1017,12 @@ if (!keepRatio) {

}
var width = size[0],
height = size[1];
var ratio = keepRatio === true ? width / height : keepRatio; // width : height = minWidth : minHeight;
height = size[1];
var ratio = keepRatio === true ? width / height : keepRatio;
// width : height = minWidth : minHeight;
var _a = checkBoundSize(size, minSize, false, ratio),
minWidth = _a[0],
minHeight = _a[1];
minWidth = _a[0],
minHeight = _a[1];
var _b = checkBoundSize(size, maxSize, true, ratio),
maxWidth = _b[0],
maxHeight = _b[1];
maxWidth = _b[0],
maxHeight = _b[1];
if (width < minWidth || height < minHeight) {

@@ -1155,3 +1035,2 @@ width = minWidth;

}
return [width, height];

@@ -1164,11 +1043,8 @@ }

*/
function sum(nums) {
var length = nums.length;
var total = 0;
for (var i = length - 1; i >= 0; --i) {
total += nums[i];
}
return total;

@@ -1181,11 +1057,8 @@ }

*/
function average(nums) {
var length = nums.length;
var total = 0;
for (var i = length - 1; i >= 0; --i) {
total += nums[i];
}
return length ? total / length : 0;

@@ -1198,3 +1071,2 @@ }

*/
function getRad(pos1, pos2) {

@@ -1211,3 +1083,2 @@ var distX = pos2[0] - pos1[0];

*/
function getCenterPoint(points) {

@@ -1225,3 +1096,2 @@ return [0, 1].map(function (i) {

*/
function getShapeDirection(points) {

@@ -1238,3 +1108,2 @@ var center = getCenterPoint(points);

*/
function getDist(a, b) {

@@ -1248,3 +1117,2 @@ return Math.sqrt(Math.pow((b ? b[0] : 0) - a[0], 2) + Math.pow((b ? b[1] : 0) - a[1], 2));

*/
function throttle(num, unit) {

@@ -1254,3 +1122,2 @@ if (!unit) {

}
var reverseUnit = 1 / unit;

@@ -1264,3 +1131,2 @@ return Math.round(num / unit) / reverseUnit;

*/
function throttleArray(nums, unit) {

@@ -1276,10 +1142,7 @@ nums.forEach(function (_, i) {

*/
function counter(num) {
var nums = [];
for (var i = 0; i < num; ++i) {
nums.push(i);
}
return nums;

@@ -1291,3 +1154,2 @@ }

*/
function replaceOnce(text, fromText, toText) {

@@ -1297,11 +1159,8 @@ var isOnce = false;

var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (isOnce) {
return args[0];
}
isOnce = true;

@@ -1315,3 +1174,2 @@ return isString(toText) ? toText : toText.apply(void 0, args);

*/
function flat(arr) {

@@ -1326,3 +1184,2 @@ return arr.reduce(function (prev, cur) {

*/
function deepFlat(arr) {

@@ -1335,3 +1192,2 @@ return arr.reduce(function (prev, cur) {

}
return prev;

@@ -1345,3 +1201,2 @@ }, []);

*/
/**

@@ -1357,3 +1212,2 @@ * Remove the # from the hex color.

*/
function cutHex(hex) {

@@ -1375,3 +1229,2 @@ return hex.replace("#", "");

*/
function hexToRGBA(hex) {

@@ -1383,7 +1236,5 @@ var h = cutHex(hex);

var a = parseInt(h.substring(6, 8), 16) / 255;
if (isNaN(a)) {
a = 1;
}
return [r, g, b, a];

@@ -1402,3 +1253,2 @@ }

*/
function toFullHex(h) {

@@ -1423,14 +1273,10 @@ var r = h.charAt(1);

*/
function hslToRGBA(hsl) {
var _a;
var h = hsl[0];
var s = hsl[1];
var l = hsl[2];
if (h < 0) {
h += Math.floor((Math.abs(h) + 360) / 360) * 360;
}
h %= 360;

@@ -1441,3 +1287,2 @@ var c = (1 - Math.abs(2 * l - 1)) * s;

var rgb;
if (h < 60) {

@@ -1458,3 +1303,2 @@ rgb = [c, x, 0];

}
return [Math.round((rgb[0] + m) * 255), Math.round((rgb[1] + m) * 255), Math.round((rgb[2] + m) * 255), (_a = hsl[3]) !== null && _a !== void 0 ? _a : 1];

@@ -1474,3 +1318,2 @@ }

*/
function stringToRGBA(color) {

@@ -1486,13 +1329,10 @@ if (color.charAt(0) === "#") {

var _a = splitBracket(color),
prefix = _a.prefix,
value = _a.value;
prefix = _a.prefix,
value = _a.value;
if (!prefix || !value) {
return undefined;
}
var arr = splitComma(value);
var colorArr = [0, 0, 0, 1];
var length = arr.length;
switch (prefix) {

@@ -1504,5 +1344,3 @@ case RGB:

}
return colorArr;
case HSL:

@@ -1516,9 +1354,7 @@ case HSLA:

}
} // hsl, hsla to rgba
}
// hsl, hsla to rgba
return hslToRGBA(colorArr);
}
}
return undefined;

@@ -1531,3 +1367,2 @@ }

*/
/**

@@ -1544,3 +1379,2 @@ * Checks if the specified class value exists in the element's class attribute.

*/
function $(selectors, multi) {

@@ -1560,3 +1394,2 @@ return multi ? doc.querySelectorAll(selectors) : doc.querySelector(selectors);

*/
function hasClass(element, className) {

@@ -1566,3 +1399,2 @@ if (element.classList) {

}
return !!element.className.match(new RegExp("(\\s|^)" + className + "(\\s|$)"));

@@ -1580,3 +1412,2 @@ }

*/
function addClass(element, className) {

@@ -1599,3 +1430,2 @@ if (element.classList) {

*/
function removeClass(element, className) {

@@ -1620,3 +1450,2 @@ if (element.classList) {

*/
function fromCSS(elements, properties) {

@@ -1626,5 +1455,3 @@ if (!elements || !properties || !properties.length) {

}
var element;
if (elements instanceof Element) {

@@ -1637,11 +1464,8 @@ element = elements;

}
var cssObject = {};
var styles = window.getComputedStyle(element);
var length = properties.length;
for (var i = 0; i < length; ++i) {
cssObject[properties[i]] = styles[properties[i]];
}
return cssObject;

@@ -1663,3 +1487,2 @@ }

*/
function addEvent(el, type, listener, options) {

@@ -1683,3 +1506,2 @@ el.addEventListener(type, listener, options);

*/
function removeEvent(el, type, listener, options) {

@@ -1686,0 +1508,0 @@ el.removeEventListener(type, listener, options);

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

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

@@ -14,3 +14,2 @@ /**

*/
/**

@@ -33,3 +32,2 @@ * get string "rgb"

*/
var RGBA = "rgba";

@@ -44,3 +42,2 @@ /**

*/
var HSL = "hsl";

@@ -55,3 +52,2 @@ /**

*/
var HSLA = "hsla";

@@ -66,3 +62,2 @@ /**

*/
var COLOR_MODELS = [RGB, RGBA, HSL, HSLA];

@@ -77,3 +72,2 @@ /**

*/
var FUNCTION = "function";

@@ -88,3 +82,2 @@ /**

*/
var PROPERTY = "property";

@@ -99,3 +92,2 @@ /**

*/
var ARRAY = "array";

@@ -110,3 +102,2 @@ /**

*/
var OBJECT = "object";

@@ -121,3 +112,2 @@ /**

*/
var STRING = "string";

@@ -132,3 +122,2 @@ /**

*/
var NUMBER = "number";

@@ -143,3 +132,2 @@ /**

*/
var UNDEFINED = "undefined";

@@ -155,3 +143,2 @@ /**

*/
var IS_WINDOW = typeof window !== UNDEFINED;

@@ -168,3 +155,2 @@ /**

*/
var doc = typeof document !== UNDEFINED && document; // FIXME: this type maybe false

@@ -175,3 +161,2 @@ var prefixes = ["webkit", "ms", "moz", "o"];

*/
/**

@@ -189,3 +174,2 @@ * Get a CSS property with a vendor prefix that supports cross browser.

*/
var getCrossBrowserProperty = /*#__PURE__*/function (property) {

@@ -195,13 +179,9 @@ if (!doc) {

}
var styles = (doc.body || doc.documentElement).style;
var length = prefixes.length;
if (typeof styles[property] !== UNDEFINED) {
return property;
}
for (var i = 0; i < length; ++i) {
var name = "-" + prefixes[i] + "-" + property;
if (typeof styles[name] !== UNDEFINED) {

@@ -211,3 +191,2 @@ return name;

}
return "";

@@ -223,3 +202,2 @@ };

*/
var TRANSFORM = /*#__PURE__*/getCrossBrowserProperty("transform");

@@ -234,3 +212,2 @@ /**

*/
var FILTER = /*#__PURE__*/getCrossBrowserProperty("filter");

@@ -245,3 +222,2 @@ /**

*/
var ANIMATION = /*#__PURE__*/getCrossBrowserProperty("animation");

@@ -256,3 +232,2 @@ /**

*/
var KEYFRAMES = /*#__PURE__*/ANIMATION.replace("animation", "keyframes");

@@ -300,3 +275,2 @@ var OPEN_CLOSED_CHARACTERS = [{

}
return pos / 100 * size;

@@ -308,3 +282,2 @@ },

}
return pos / 100 * size;

@@ -316,3 +289,2 @@ },

}
return pos / 100 * size;

@@ -324,3 +296,2 @@ },

}
return pos / 100 * size;

@@ -346,5 +317,3 @@ }

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;

@@ -357,3 +326,2 @@ }

*/
/**

@@ -373,3 +341,2 @@ * Returns the inner product of two numbers(`a1`, `a2`) by two criteria(`b1`, `b2`).

*/
function dot(a1, a2, b1, b2) {

@@ -391,3 +358,2 @@ return (a1 * b2 + a2 * b1) / (b1 + b2);

*/
function isUndefined(value) {

@@ -409,3 +375,2 @@ return typeof value === UNDEFINED;

*/
function isObject(value) {

@@ -427,3 +392,2 @@ return value && typeof value === OBJECT;

*/
function isArray(value) {

@@ -445,3 +409,2 @@ return Array.isArray(value);

*/
function isString(value) {

@@ -467,7 +430,5 @@ return typeof value === STRING;

*/
function isFunction(value) {
return typeof value === FUNCTION;
}
function isEqualSeparator(character, separator) {

@@ -478,13 +439,9 @@ var isCharacterSpace = character === "" || character == " ";

}
function findOpen(openCharacter, texts, index, length, openCloseCharacters) {
var isIgnore = findIgnore(openCharacter, texts, index);
if (!isIgnore) {
return findClose(openCharacter, texts, index + 1, length, openCloseCharacters);
}
return index;
}
function findIgnore(character, texts, index) {

@@ -494,11 +451,8 @@ if (!character.ignore) {

}
var otherText = texts.slice(Math.max(index - 3, 0), index + 3).join("");
return new RegExp(character.ignore).exec(otherText);
}
function findClose(closeCharacter, texts, index, length, openCloseCharacters) {
var _loop_1 = function (i) {
var character = texts[i].trim();
if (character === closeCharacter.close && !findIgnore(closeCharacter, texts, i)) {

@@ -509,5 +463,4 @@ return {

}
var nextIndex = i; // re open
var nextIndex = i;
// re open
var openCharacter = find(openCloseCharacters, function (_a) {

@@ -517,20 +470,14 @@ var open = _a.open;

});
if (openCharacter) {
nextIndex = findOpen(openCharacter, texts, i, length, openCloseCharacters);
}
if (nextIndex === -1) {
return out_i_1 = i, "break";
}
i = nextIndex;
out_i_1 = i;
};
var out_i_1;
for (var i = index; i < length; ++i) {
var state_1 = _loop_1(i);
i = out_i_1;

@@ -540,27 +487,22 @@ if (typeof state_1 === "object") return state_1.value;

}
return -1;
}
function splitText(text, splitOptions) {
var _a = isString(splitOptions) ? {
separator: splitOptions
} : splitOptions,
_b = _a.separator,
separator = _b === void 0 ? "," : _b,
isSeparateFirst = _a.isSeparateFirst,
isSeparateOnlyOpenClose = _a.isSeparateOnlyOpenClose,
_c = _a.isSeparateOpenClose,
isSeparateOpenClose = _c === void 0 ? isSeparateOnlyOpenClose : _c,
_d = _a.openCloseCharacters,
openCloseCharacters = _d === void 0 ? OPEN_CLOSED_CHARACTERS : _d;
separator: splitOptions
} : splitOptions,
_b = _a.separator,
separator = _b === void 0 ? "," : _b,
isSeparateFirst = _a.isSeparateFirst,
isSeparateOnlyOpenClose = _a.isSeparateOnlyOpenClose,
_c = _a.isSeparateOpenClose,
isSeparateOpenClose = _c === void 0 ? isSeparateOnlyOpenClose : _c,
_d = _a.openCloseCharacters,
openCloseCharacters = _d === void 0 ? OPEN_CLOSED_CHARACTERS : _d;
var openClosedText = openCloseCharacters.map(function (_a) {
var open = _a.open,
close = _a.close;
close = _a.close;
if (open === close) {
return open;
}
return open + "|" + close;

@@ -574,3 +516,2 @@ }).join("|");

var tempValues = [];
function resetTemp() {

@@ -582,6 +523,4 @@ if (tempValues.length) {

}
return false;
}
var _loop_2 = function (i) {

@@ -598,6 +537,4 @@ var character = texts[i].trim();

});
if (openCharacter) {
nextIndex = findOpen(openCharacter, texts, i, length, openCloseCharacters);
if (nextIndex !== -1 && isSeparateOpenClose) {

@@ -607,10 +544,7 @@ if (resetTemp() && isSeparateFirst) {

}
values.push(texts.slice(i, nextIndex + 1).join(""));
i = nextIndex;
if (isSeparateFirst) {
return out_i_2 = i, "break";
}
return out_i_2 = i, "continue";

@@ -620,3 +554,2 @@ }

var nextOpenCloseCharacters = __spreadArrays(openCloseCharacters);
nextOpenCloseCharacters.splice(openCloseCharacters.indexOf(closeCharacter), 1);

@@ -634,14 +567,10 @@ return {

resetTemp();
if (isSeparateFirst) {
return out_i_2 = i, "break";
}
return out_i_2 = i, "continue";
}
if (nextIndex === -1) {
nextIndex = length - 1;
}
tempValues.push(texts.slice(i, nextIndex + 1).join(""));

@@ -651,8 +580,5 @@ i = nextIndex;

};
var out_i_2;
for (var i = 0; i < length; ++i) {
var state_2 = _loop_2(i);
i = out_i_2;

@@ -662,7 +588,5 @@ if (typeof state_2 === "object") return state_2.value;

}
if (tempValues.length) {
values.push(tempValues.join(""));
}
return values;

@@ -683,3 +607,2 @@ }

*/
function splitSpace(text) {

@@ -702,3 +625,2 @@ // divide comma(space)

*/
function splitComma(text) {

@@ -722,6 +644,4 @@ // divide comma(,)

*/
function splitBracket(text) {
var matches = /([^(]*)\(([\s\S]*)\)([\s\S]*)/g.exec(text);
if (!matches || matches.length < 4) {

@@ -752,6 +672,4 @@ return {};

*/
function splitUnit(text) {
var matches = /^([^\d|e|\-|\+]*)((?:\d|\.|-|e-|e\+)+)(\S*)$/g.exec(text);
if (!matches) {

@@ -764,3 +682,2 @@ return {

}
var prefix = matches[1];

@@ -787,3 +704,2 @@ var value = matches[2];

*/
function camelize(str) {

@@ -806,3 +722,2 @@ return str.replace(/[\s-_]([a-z])/g, function (all, letter) {

*/
function decamelize(str, separator) {

@@ -812,3 +727,2 @@ if (separator === void 0) {

}
return str.replace(/([a-z])([A-Z])/g, function (all, letter, letter2) {

@@ -829,3 +743,2 @@ return "" + letter + separator + letter2.toLowerCase();

*/
function toArray(value) {

@@ -843,3 +756,2 @@ return [].slice.call(value);

*/
function now() {

@@ -860,3 +772,2 @@ return Date.now ? Date.now() : new Date().getTime();

*/
function findIndex(arr, callback, defaultIndex) {

@@ -866,5 +777,3 @@ if (defaultIndex === void 0) {

}
var length = arr.length;
for (var i = 0; i < length; ++i) {

@@ -875,3 +784,2 @@ if (callback(arr[i], i, arr)) {

}
return defaultIndex;

@@ -891,3 +799,2 @@ }

*/
function findLastIndex(arr, callback, defaultIndex) {

@@ -897,5 +804,3 @@ if (defaultIndex === void 0) {

}
var length = arr.length;
for (var i = length - 1; i >= 0; --i) {

@@ -906,3 +811,2 @@ if (callback(arr[i], i, arr)) {

}
return defaultIndex;

@@ -922,3 +826,2 @@ }

*/
function findLast(arr, callback, defalutValue) {

@@ -940,3 +843,2 @@ var index = findLastIndex(arr, callback);

*/
function find(arr, callback, defalutValue) {

@@ -959,3 +861,2 @@ var index = findIndex(arr, callback);

*/
var requestAnimationFrame = /*#__PURE__*/function () {

@@ -966,3 +867,3 @@ var firstTime = now();

var currTime = now();
var id = window.setTimeout(function () {
var id = setTimeout(function () {
callback(currTime - firstTime);

@@ -988,3 +889,2 @@ }, 1000 / 60);

*/
var cancelAnimationFrame = /*#__PURE__*/function () {

@@ -1000,3 +900,2 @@ var caf = IS_WINDOW && (window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.msCancelAnimationFrame);

*/
function getKeys(obj) {

@@ -1009,3 +908,2 @@ return Object.keys(obj);

*/
function getValues(obj) {

@@ -1021,3 +919,2 @@ var keys = getKeys(obj);

*/
function getEntries(obj) {

@@ -1033,3 +930,2 @@ var keys = getKeys(obj);

*/
function sortOrders(keys, orders) {

@@ -1039,19 +935,14 @@ if (orders === void 0) {

}
keys.sort(function (a, b) {
var index1 = orders.indexOf(a);
var index2 = orders.indexOf(b);
if (index2 === -1 && index1 === -1) {
return 0;
}
if (index1 === -1) {
return 1;
}
if (index2 === -1) {
return -1;
}
return index1 - index2;

@@ -1065,11 +956,8 @@ });

*/
function convertUnitSize(pos, size) {
var _a = splitUnit(pos),
value = _a.value,
unit = _a.unit;
value = _a.value,
unit = _a.unit;
if (isObject(size)) {
var sizeFunction = size[unit];
if (sizeFunction) {

@@ -1085,7 +973,5 @@ if (isFunction(sizeFunction)) {

}
if (DEFAULT_UNIT_PRESETS[unit]) {
return DEFAULT_UNIT_PRESETS[unit](value);
}
return value;

@@ -1098,3 +984,2 @@ }

*/
function between(value, min, max) {

@@ -1107,3 +992,2 @@ return Math.max(min, Math.min(value, max));

}
return [[throttle(compareSize[0], TINY_NUM), throttle(compareSize[0] / ratio, TINY_NUM)], [throttle(compareSize[1] * ratio, TINY_NUM), throttle(compareSize[1], TINY_NUM)]].filter(function (size) {

@@ -1122,3 +1006,2 @@ return size.every(function (value, i) {

*/
function calculateBoundSize(size, minSize, maxSize, keepRatio) {

@@ -1130,15 +1013,12 @@ if (!keepRatio) {

}
var width = size[0],
height = size[1];
var ratio = keepRatio === true ? width / height : keepRatio; // width : height = minWidth : minHeight;
height = size[1];
var ratio = keepRatio === true ? width / height : keepRatio;
// width : height = minWidth : minHeight;
var _a = checkBoundSize(size, minSize, false, ratio),
minWidth = _a[0],
minHeight = _a[1];
minWidth = _a[0],
minHeight = _a[1];
var _b = checkBoundSize(size, maxSize, true, ratio),
maxWidth = _b[0],
maxHeight = _b[1];
maxWidth = _b[0],
maxHeight = _b[1];
if (width < minWidth || height < minHeight) {

@@ -1151,3 +1031,2 @@ width = minWidth;

}
return [width, height];

@@ -1160,11 +1039,8 @@ }

*/
function sum(nums) {
var length = nums.length;
var total = 0;
for (var i = length - 1; i >= 0; --i) {
total += nums[i];
}
return total;

@@ -1177,11 +1053,8 @@ }

*/
function average(nums) {
var length = nums.length;
var total = 0;
for (var i = length - 1; i >= 0; --i) {
total += nums[i];
}
return length ? total / length : 0;

@@ -1194,3 +1067,2 @@ }

*/
function getRad(pos1, pos2) {

@@ -1207,3 +1079,2 @@ var distX = pos2[0] - pos1[0];

*/
function getCenterPoint(points) {

@@ -1221,3 +1092,2 @@ return [0, 1].map(function (i) {

*/
function getShapeDirection(points) {

@@ -1234,3 +1104,2 @@ var center = getCenterPoint(points);

*/
function getDist(a, b) {

@@ -1244,3 +1113,2 @@ return Math.sqrt(Math.pow((b ? b[0] : 0) - a[0], 2) + Math.pow((b ? b[1] : 0) - a[1], 2));

*/
function throttle(num, unit) {

@@ -1250,3 +1118,2 @@ if (!unit) {

}
var reverseUnit = 1 / unit;

@@ -1260,3 +1127,2 @@ return Math.round(num / unit) / reverseUnit;

*/
function throttleArray(nums, unit) {

@@ -1272,10 +1138,7 @@ nums.forEach(function (_, i) {

*/
function counter(num) {
var nums = [];
for (var i = 0; i < num; ++i) {
nums.push(i);
}
return nums;

@@ -1287,3 +1150,2 @@ }

*/
function replaceOnce(text, fromText, toText) {

@@ -1293,11 +1155,8 @@ var isOnce = false;

var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (isOnce) {
return args[0];
}
isOnce = true;

@@ -1311,3 +1170,2 @@ return isString(toText) ? toText : toText.apply(void 0, args);

*/
function flat(arr) {

@@ -1322,3 +1180,2 @@ return arr.reduce(function (prev, cur) {

*/
function deepFlat(arr) {

@@ -1331,3 +1188,2 @@ return arr.reduce(function (prev, cur) {

}
return prev;

@@ -1341,3 +1197,2 @@ }, []);

*/
/**

@@ -1353,3 +1208,2 @@ * Remove the # from the hex color.

*/
function cutHex(hex) {

@@ -1371,3 +1225,2 @@ return hex.replace("#", "");

*/
function hexToRGBA(hex) {

@@ -1379,7 +1232,5 @@ var h = cutHex(hex);

var a = parseInt(h.substring(6, 8), 16) / 255;
if (isNaN(a)) {
a = 1;
}
return [r, g, b, a];

@@ -1398,3 +1249,2 @@ }

*/
function toFullHex(h) {

@@ -1419,14 +1269,10 @@ var r = h.charAt(1);

*/
function hslToRGBA(hsl) {
var _a;
var h = hsl[0];
var s = hsl[1];
var l = hsl[2];
if (h < 0) {
h += Math.floor((Math.abs(h) + 360) / 360) * 360;
}
h %= 360;

@@ -1437,3 +1283,2 @@ var c = (1 - Math.abs(2 * l - 1)) * s;

var rgb;
if (h < 60) {

@@ -1454,3 +1299,2 @@ rgb = [c, x, 0];

}
return [Math.round((rgb[0] + m) * 255), Math.round((rgb[1] + m) * 255), Math.round((rgb[2] + m) * 255), (_a = hsl[3]) !== null && _a !== void 0 ? _a : 1];

@@ -1470,3 +1314,2 @@ }

*/
function stringToRGBA(color) {

@@ -1482,13 +1325,10 @@ if (color.charAt(0) === "#") {

var _a = splitBracket(color),
prefix = _a.prefix,
value = _a.value;
prefix = _a.prefix,
value = _a.value;
if (!prefix || !value) {
return undefined;
}
var arr = splitComma(value);
var colorArr = [0, 0, 0, 1];
var length = arr.length;
switch (prefix) {

@@ -1500,5 +1340,3 @@ case RGB:

}
return colorArr;
case HSL:

@@ -1512,9 +1350,7 @@ case HSLA:

}
} // hsl, hsla to rgba
}
// hsl, hsla to rgba
return hslToRGBA(colorArr);
}
}
return undefined;

@@ -1527,3 +1363,2 @@ }

*/
/**

@@ -1540,3 +1375,2 @@ * Checks if the specified class value exists in the element's class attribute.

*/
function $(selectors, multi) {

@@ -1556,3 +1390,2 @@ return multi ? doc.querySelectorAll(selectors) : doc.querySelector(selectors);

*/
function hasClass(element, className) {

@@ -1562,3 +1395,2 @@ if (element.classList) {

}
return !!element.className.match(new RegExp("(\\s|^)" + className + "(\\s|$)"));

@@ -1576,3 +1408,2 @@ }

*/
function addClass(element, className) {

@@ -1595,3 +1426,2 @@ if (element.classList) {

*/
function removeClass(element, className) {

@@ -1616,3 +1446,2 @@ if (element.classList) {

*/
function fromCSS(elements, properties) {

@@ -1622,5 +1451,3 @@ if (!elements || !properties || !properties.length) {

}
var element;
if (elements instanceof Element) {

@@ -1633,11 +1460,8 @@ element = elements;

}
var cssObject = {};
var styles = window.getComputedStyle(element);
var length = properties.length;
for (var i = 0; i < length; ++i) {
cssObject[properties[i]] = styles[properties[i]];
}
return cssObject;

@@ -1659,3 +1483,2 @@ }

*/
function addEvent(el, type, listener, options) {

@@ -1679,3 +1502,2 @@ el.addEventListener(type, listener, options);

*/
function removeEvent(el, type, listener, options) {

@@ -1682,0 +1504,0 @@ el.removeEventListener(type, listener, options);

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

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

@@ -20,3 +20,2 @@ (function (global, factory) {

*/
/**

@@ -39,3 +38,2 @@ * get string "rgb"

*/
var RGBA = "rgba";

@@ -50,3 +48,2 @@ /**

*/
var HSL = "hsl";

@@ -61,3 +58,2 @@ /**

*/
var HSLA = "hsla";

@@ -72,3 +68,2 @@ /**

*/
var COLOR_MODELS = [RGB, RGBA, HSL, HSLA];

@@ -83,3 +78,2 @@ /**

*/
var FUNCTION = "function";

@@ -94,3 +88,2 @@ /**

*/
var PROPERTY = "property";

@@ -105,3 +98,2 @@ /**

*/
var ARRAY = "array";

@@ -116,3 +108,2 @@ /**

*/
var OBJECT = "object";

@@ -127,3 +118,2 @@ /**

*/
var STRING = "string";

@@ -138,3 +128,2 @@ /**

*/
var NUMBER = "number";

@@ -149,3 +138,2 @@ /**

*/
var UNDEFINED = "undefined";

@@ -161,3 +149,2 @@ /**

*/
var IS_WINDOW = typeof window !== UNDEFINED;

@@ -174,3 +161,2 @@ /**

*/
var doc = typeof document !== UNDEFINED && document; // FIXME: this type maybe false

@@ -181,3 +167,2 @@ var prefixes = ["webkit", "ms", "moz", "o"];

*/
/**

@@ -195,3 +180,2 @@ * Get a CSS property with a vendor prefix that supports cross browser.

*/
var getCrossBrowserProperty = /*#__PURE__*/function (property) {

@@ -201,13 +185,9 @@ if (!doc) {

}
var styles = (doc.body || doc.documentElement).style;
var length = prefixes.length;
if (typeof styles[property] !== UNDEFINED) {
return property;
}
for (var i = 0; i < length; ++i) {
var name = "-" + prefixes[i] + "-" + property;
if (typeof styles[name] !== UNDEFINED) {

@@ -217,3 +197,2 @@ return name;

}
return "";

@@ -229,3 +208,2 @@ };

*/
var TRANSFORM = /*#__PURE__*/getCrossBrowserProperty("transform");

@@ -240,3 +218,2 @@ /**

*/
var FILTER = /*#__PURE__*/getCrossBrowserProperty("filter");

@@ -251,3 +228,2 @@ /**

*/
var ANIMATION = /*#__PURE__*/getCrossBrowserProperty("animation");

@@ -262,3 +238,2 @@ /**

*/
var KEYFRAMES = /*#__PURE__*/ANIMATION.replace("animation", "keyframes");

@@ -306,3 +281,2 @@ var OPEN_CLOSED_CHARACTERS = [{

}
return pos / 100 * size;

@@ -314,3 +288,2 @@ },

}
return pos / 100 * size;

@@ -322,3 +295,2 @@ },

}
return pos / 100 * size;

@@ -330,3 +302,2 @@ },

}
return pos / 100 * size;

@@ -352,5 +323,3 @@ }

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;

@@ -363,3 +332,2 @@ }

*/
/**

@@ -379,3 +347,2 @@ * Returns the inner product of two numbers(`a1`, `a2`) by two criteria(`b1`, `b2`).

*/
function dot(a1, a2, b1, b2) {

@@ -397,3 +364,2 @@ return (a1 * b2 + a2 * b1) / (b1 + b2);

*/
function isUndefined(value) {

@@ -415,3 +381,2 @@ return typeof value === UNDEFINED;

*/
function isObject(value) {

@@ -433,3 +398,2 @@ return value && typeof value === OBJECT;

*/
function isArray(value) {

@@ -451,3 +415,2 @@ return Array.isArray(value);

*/
function isString(value) {

@@ -473,7 +436,5 @@ return typeof value === STRING;

*/
function isFunction(value) {
return typeof value === FUNCTION;
}
function isEqualSeparator(character, separator) {

@@ -484,13 +445,9 @@ var isCharacterSpace = character === "" || character == " ";

}
function findOpen(openCharacter, texts, index, length, openCloseCharacters) {
var isIgnore = findIgnore(openCharacter, texts, index);
if (!isIgnore) {
return findClose(openCharacter, texts, index + 1, length, openCloseCharacters);
}
return index;
}
function findIgnore(character, texts, index) {

@@ -500,11 +457,8 @@ if (!character.ignore) {

}
var otherText = texts.slice(Math.max(index - 3, 0), index + 3).join("");
return new RegExp(character.ignore).exec(otherText);
}
function findClose(closeCharacter, texts, index, length, openCloseCharacters) {
var _loop_1 = function (i) {
var character = texts[i].trim();
if (character === closeCharacter.close && !findIgnore(closeCharacter, texts, i)) {

@@ -515,5 +469,4 @@ return {

}
var nextIndex = i; // re open
var nextIndex = i;
// re open
var openCharacter = find(openCloseCharacters, function (_a) {

@@ -523,20 +476,14 @@ var open = _a.open;

});
if (openCharacter) {
nextIndex = findOpen(openCharacter, texts, i, length, openCloseCharacters);
}
if (nextIndex === -1) {
return out_i_1 = i, "break";
}
i = nextIndex;
out_i_1 = i;
};
var out_i_1;
for (var i = index; i < length; ++i) {
var state_1 = _loop_1(i);
i = out_i_1;

@@ -546,27 +493,22 @@ if (typeof state_1 === "object") return state_1.value;

}
return -1;
}
function splitText(text, splitOptions) {
var _a = isString(splitOptions) ? {
separator: splitOptions
} : splitOptions,
_b = _a.separator,
separator = _b === void 0 ? "," : _b,
isSeparateFirst = _a.isSeparateFirst,
isSeparateOnlyOpenClose = _a.isSeparateOnlyOpenClose,
_c = _a.isSeparateOpenClose,
isSeparateOpenClose = _c === void 0 ? isSeparateOnlyOpenClose : _c,
_d = _a.openCloseCharacters,
openCloseCharacters = _d === void 0 ? OPEN_CLOSED_CHARACTERS : _d;
separator: splitOptions
} : splitOptions,
_b = _a.separator,
separator = _b === void 0 ? "," : _b,
isSeparateFirst = _a.isSeparateFirst,
isSeparateOnlyOpenClose = _a.isSeparateOnlyOpenClose,
_c = _a.isSeparateOpenClose,
isSeparateOpenClose = _c === void 0 ? isSeparateOnlyOpenClose : _c,
_d = _a.openCloseCharacters,
openCloseCharacters = _d === void 0 ? OPEN_CLOSED_CHARACTERS : _d;
var openClosedText = openCloseCharacters.map(function (_a) {
var open = _a.open,
close = _a.close;
close = _a.close;
if (open === close) {
return open;
}
return open + "|" + close;

@@ -580,3 +522,2 @@ }).join("|");

var tempValues = [];
function resetTemp() {

@@ -588,6 +529,4 @@ if (tempValues.length) {

}
return false;
}
var _loop_2 = function (i) {

@@ -604,6 +543,4 @@ var character = texts[i].trim();

});
if (openCharacter) {
nextIndex = findOpen(openCharacter, texts, i, length, openCloseCharacters);
if (nextIndex !== -1 && isSeparateOpenClose) {

@@ -613,10 +550,7 @@ if (resetTemp() && isSeparateFirst) {

}
values.push(texts.slice(i, nextIndex + 1).join(""));
i = nextIndex;
if (isSeparateFirst) {
return out_i_2 = i, "break";
}
return out_i_2 = i, "continue";

@@ -626,3 +560,2 @@ }

var nextOpenCloseCharacters = __spreadArrays(openCloseCharacters);
nextOpenCloseCharacters.splice(openCloseCharacters.indexOf(closeCharacter), 1);

@@ -640,14 +573,10 @@ return {

resetTemp();
if (isSeparateFirst) {
return out_i_2 = i, "break";
}
return out_i_2 = i, "continue";
}
if (nextIndex === -1) {
nextIndex = length - 1;
}
tempValues.push(texts.slice(i, nextIndex + 1).join(""));

@@ -657,8 +586,5 @@ i = nextIndex;

};
var out_i_2;
for (var i = 0; i < length; ++i) {
var state_2 = _loop_2(i);
i = out_i_2;

@@ -668,7 +594,5 @@ if (typeof state_2 === "object") return state_2.value;

}
if (tempValues.length) {
values.push(tempValues.join(""));
}
return values;

@@ -689,3 +613,2 @@ }

*/
function splitSpace(text) {

@@ -708,3 +631,2 @@ // divide comma(space)

*/
function splitComma(text) {

@@ -728,6 +650,4 @@ // divide comma(,)

*/
function splitBracket(text) {
var matches = /([^(]*)\(([\s\S]*)\)([\s\S]*)/g.exec(text);
if (!matches || matches.length < 4) {

@@ -758,6 +678,4 @@ return {};

*/
function splitUnit(text) {
var matches = /^([^\d|e|\-|\+]*)((?:\d|\.|-|e-|e\+)+)(\S*)$/g.exec(text);
if (!matches) {

@@ -770,3 +688,2 @@ return {

}
var prefix = matches[1];

@@ -793,3 +710,2 @@ var value = matches[2];

*/
function camelize(str) {

@@ -812,3 +728,2 @@ return str.replace(/[\s-_]([a-z])/g, function (all, letter) {

*/
function decamelize(str, separator) {

@@ -818,3 +733,2 @@ if (separator === void 0) {

}
return str.replace(/([a-z])([A-Z])/g, function (all, letter, letter2) {

@@ -835,3 +749,2 @@ return "" + letter + separator + letter2.toLowerCase();

*/
function toArray(value) {

@@ -849,3 +762,2 @@ return [].slice.call(value);

*/
function now() {

@@ -866,3 +778,2 @@ return Date.now ? Date.now() : new Date().getTime();

*/
function findIndex(arr, callback, defaultIndex) {

@@ -872,5 +783,3 @@ if (defaultIndex === void 0) {

}
var length = arr.length;
for (var i = 0; i < length; ++i) {

@@ -881,3 +790,2 @@ if (callback(arr[i], i, arr)) {

}
return defaultIndex;

@@ -897,3 +805,2 @@ }

*/
function findLastIndex(arr, callback, defaultIndex) {

@@ -903,5 +810,3 @@ if (defaultIndex === void 0) {

}
var length = arr.length;
for (var i = length - 1; i >= 0; --i) {

@@ -912,3 +817,2 @@ if (callback(arr[i], i, arr)) {

}
return defaultIndex;

@@ -928,3 +832,2 @@ }

*/
function findLast(arr, callback, defalutValue) {

@@ -946,3 +849,2 @@ var index = findLastIndex(arr, callback);

*/
function find(arr, callback, defalutValue) {

@@ -965,3 +867,2 @@ var index = findIndex(arr, callback);

*/
var requestAnimationFrame = /*#__PURE__*/function () {

@@ -972,3 +873,3 @@ var firstTime = now();

var currTime = now();
var id = window.setTimeout(function () {
var id = setTimeout(function () {
callback(currTime - firstTime);

@@ -994,3 +895,2 @@ }, 1000 / 60);

*/
var cancelAnimationFrame = /*#__PURE__*/function () {

@@ -1006,3 +906,2 @@ var caf = IS_WINDOW && (window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.msCancelAnimationFrame);

*/
function getKeys(obj) {

@@ -1015,3 +914,2 @@ return Object.keys(obj);

*/
function getValues(obj) {

@@ -1027,3 +925,2 @@ var keys = getKeys(obj);

*/
function getEntries(obj) {

@@ -1039,3 +936,2 @@ var keys = getKeys(obj);

*/
function sortOrders(keys, orders) {

@@ -1045,19 +941,14 @@ if (orders === void 0) {

}
keys.sort(function (a, b) {
var index1 = orders.indexOf(a);
var index2 = orders.indexOf(b);
if (index2 === -1 && index1 === -1) {
return 0;
}
if (index1 === -1) {
return 1;
}
if (index2 === -1) {
return -1;
}
return index1 - index2;

@@ -1071,11 +962,8 @@ });

*/
function convertUnitSize(pos, size) {
var _a = splitUnit(pos),
value = _a.value,
unit = _a.unit;
value = _a.value,
unit = _a.unit;
if (isObject(size)) {
var sizeFunction = size[unit];
if (sizeFunction) {

@@ -1091,7 +979,5 @@ if (isFunction(sizeFunction)) {

}
if (DEFAULT_UNIT_PRESETS[unit]) {
return DEFAULT_UNIT_PRESETS[unit](value);
}
return value;

@@ -1104,3 +990,2 @@ }

*/
function between(value, min, max) {

@@ -1113,3 +998,2 @@ return Math.max(min, Math.min(value, max));

}
return [[throttle(compareSize[0], TINY_NUM), throttle(compareSize[0] / ratio, TINY_NUM)], [throttle(compareSize[1] * ratio, TINY_NUM), throttle(compareSize[1], TINY_NUM)]].filter(function (size) {

@@ -1128,3 +1012,2 @@ return size.every(function (value, i) {

*/
function calculateBoundSize(size, minSize, maxSize, keepRatio) {

@@ -1136,15 +1019,12 @@ if (!keepRatio) {

}
var width = size[0],
height = size[1];
var ratio = keepRatio === true ? width / height : keepRatio; // width : height = minWidth : minHeight;
height = size[1];
var ratio = keepRatio === true ? width / height : keepRatio;
// width : height = minWidth : minHeight;
var _a = checkBoundSize(size, minSize, false, ratio),
minWidth = _a[0],
minHeight = _a[1];
minWidth = _a[0],
minHeight = _a[1];
var _b = checkBoundSize(size, maxSize, true, ratio),
maxWidth = _b[0],
maxHeight = _b[1];
maxWidth = _b[0],
maxHeight = _b[1];
if (width < minWidth || height < minHeight) {

@@ -1157,3 +1037,2 @@ width = minWidth;

}
return [width, height];

@@ -1166,11 +1045,8 @@ }

*/
function sum(nums) {
var length = nums.length;
var total = 0;
for (var i = length - 1; i >= 0; --i) {
total += nums[i];
}
return total;

@@ -1183,11 +1059,8 @@ }

*/
function average(nums) {
var length = nums.length;
var total = 0;
for (var i = length - 1; i >= 0; --i) {
total += nums[i];
}
return length ? total / length : 0;

@@ -1200,3 +1073,2 @@ }

*/
function getRad(pos1, pos2) {

@@ -1213,3 +1085,2 @@ var distX = pos2[0] - pos1[0];

*/
function getCenterPoint(points) {

@@ -1227,3 +1098,2 @@ return [0, 1].map(function (i) {

*/
function getShapeDirection(points) {

@@ -1240,3 +1110,2 @@ var center = getCenterPoint(points);

*/
function getDist(a, b) {

@@ -1250,3 +1119,2 @@ return Math.sqrt(Math.pow((b ? b[0] : 0) - a[0], 2) + Math.pow((b ? b[1] : 0) - a[1], 2));

*/
function throttle(num, unit) {

@@ -1256,3 +1124,2 @@ if (!unit) {

}
var reverseUnit = 1 / unit;

@@ -1266,3 +1133,2 @@ return Math.round(num / unit) / reverseUnit;

*/
function throttleArray(nums, unit) {

@@ -1278,10 +1144,7 @@ nums.forEach(function (_, i) {

*/
function counter(num) {
var nums = [];
for (var i = 0; i < num; ++i) {
nums.push(i);
}
return nums;

@@ -1293,3 +1156,2 @@ }

*/
function replaceOnce(text, fromText, toText) {

@@ -1299,11 +1161,8 @@ var isOnce = false;

var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (isOnce) {
return args[0];
}
isOnce = true;

@@ -1317,3 +1176,2 @@ return isString(toText) ? toText : toText.apply(void 0, args);

*/
function flat(arr) {

@@ -1328,3 +1186,2 @@ return arr.reduce(function (prev, cur) {

*/
function deepFlat(arr) {

@@ -1337,3 +1194,2 @@ return arr.reduce(function (prev, cur) {

}
return prev;

@@ -1347,3 +1203,2 @@ }, []);

*/
/**

@@ -1359,3 +1214,2 @@ * Remove the # from the hex color.

*/
function cutHex(hex) {

@@ -1377,3 +1231,2 @@ return hex.replace("#", "");

*/
function hexToRGBA(hex) {

@@ -1385,7 +1238,5 @@ var h = cutHex(hex);

var a = parseInt(h.substring(6, 8), 16) / 255;
if (isNaN(a)) {
a = 1;
}
return [r, g, b, a];

@@ -1404,3 +1255,2 @@ }

*/
function toFullHex(h) {

@@ -1425,14 +1275,10 @@ var r = h.charAt(1);

*/
function hslToRGBA(hsl) {
var _a;
var h = hsl[0];
var s = hsl[1];
var l = hsl[2];
if (h < 0) {
h += Math.floor((Math.abs(h) + 360) / 360) * 360;
}
h %= 360;

@@ -1443,3 +1289,2 @@ var c = (1 - Math.abs(2 * l - 1)) * s;

var rgb;
if (h < 60) {

@@ -1460,3 +1305,2 @@ rgb = [c, x, 0];

}
return [Math.round((rgb[0] + m) * 255), Math.round((rgb[1] + m) * 255), Math.round((rgb[2] + m) * 255), (_a = hsl[3]) !== null && _a !== void 0 ? _a : 1];

@@ -1476,3 +1320,2 @@ }

*/
function stringToRGBA(color) {

@@ -1488,13 +1331,10 @@ if (color.charAt(0) === "#") {

var _a = splitBracket(color),
prefix = _a.prefix,
value = _a.value;
prefix = _a.prefix,
value = _a.value;
if (!prefix || !value) {
return undefined;
}
var arr = splitComma(value);
var colorArr = [0, 0, 0, 1];
var length = arr.length;
switch (prefix) {

@@ -1506,5 +1346,3 @@ case RGB:

}
return colorArr;
case HSL:

@@ -1518,9 +1356,7 @@ case HSLA:

}
} // hsl, hsla to rgba
}
// hsl, hsla to rgba
return hslToRGBA(colorArr);
}
}
return undefined;

@@ -1533,3 +1369,2 @@ }

*/
/**

@@ -1546,3 +1381,2 @@ * Checks if the specified class value exists in the element's class attribute.

*/
function $(selectors, multi) {

@@ -1562,3 +1396,2 @@ return multi ? doc.querySelectorAll(selectors) : doc.querySelector(selectors);

*/
function hasClass(element, className) {

@@ -1568,3 +1401,2 @@ if (element.classList) {

}
return !!element.className.match(new RegExp("(\\s|^)" + className + "(\\s|$)"));

@@ -1582,3 +1414,2 @@ }

*/
function addClass(element, className) {

@@ -1601,3 +1432,2 @@ if (element.classList) {

*/
function removeClass(element, className) {

@@ -1622,3 +1452,2 @@ if (element.classList) {

*/
function fromCSS(elements, properties) {

@@ -1628,5 +1457,3 @@ if (!elements || !properties || !properties.length) {

}
var element;
if (elements instanceof Element) {

@@ -1639,11 +1466,8 @@ element = elements;

}
var cssObject = {};
var styles = window.getComputedStyle(element);
var length = properties.length;
for (var i = 0; i < length; ++i) {
cssObject[properties[i]] = styles[properties[i]];
}
return cssObject;

@@ -1665,3 +1489,2 @@ }

*/
function addEvent(el, type, listener, options) {

@@ -1685,3 +1508,2 @@ el.addEventListener(type, listener, options);

*/
function removeEvent(el, type, listener, options) {

@@ -1688,0 +1510,0 @@ el.removeEventListener(type, listener, options);

4

dist/utils.min.js

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

repository: https://github.com/daybrush/utils
@version 1.10.0
@version 1.10.1
*/
!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=d.length;if(typeof e[n]!=u)return n;for(var t=0;t<r;++t){var i="-"+d[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,d=["webkit","ms","moz","o"],v=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 Array.isArray(n)}function x(n){return typeof n===i}function R(n){return typeof n===r}function C(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=j(a,function(n){return n.open===e});if(t&&(r=C(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 O(c,n){var e=x(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,d=void 0===i?S:i,o=d.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"),v=c.split(u).filter(Boolean),m=v.length,h=[],w=[];function g(){return w.length&&(h.push(w.join("")),w=[])}for(var A,a=function(n){var e,r,t=v[n].trim(),i=n,o=j(d,function(n){return n.open===t}),u=j(d,function(n){return n.close===t});if(o){if(-1!==(i=C(o,v,n,m,d))&&p)return g()&&s?(A=n,"break"):(h.push(v.slice(n,i+1).join("")),n=i,s?(A=n,"break"):(A=n,"continue"))}else{if(u&&!M(u,v,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}(d);return a.splice(d.indexOf(u),1),{value:O(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(v.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 F(n){return O(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 I(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 T(){return Date.now?Date.now():(new Date).getTime()}function L(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 k(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 j(n,e,r){var t=L(n,e);return-1<t?n[t]:r}var B=function(){var r=T(),n=a&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame);return n?n.bind(window):function(n){var e=T();return window.setTimeout(function(){n(e-r)},1e3/60)}}();function D(n){return Object.keys(n)}function U(n,e,r){return Math.max(e,Math.min(n,r))}function z(n,i,o,e){return void 0===e&&(e=n[0]/n[1]),[[H(i[0],g),H(i[0]/e,g)],[H(i[1]*e,g),H(i[1],g)]].filter(function(n){return n.every(function(n,e){var r=i[e],t=H(r,g);return o?n<=r||n<=t:r<=n||t<=n})})[0]||n}function _(n){for(var e=n.length,r=0,t=e-1;0<=t;--t)r+=n[t];return e?r/e:0}function P(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 q(n){return[0,1].map(function(e){return _(n.map(function(n){return n[e]}))})}function H(n,e){if(!e)return n;var r=1/e;return Math.round(n/e)/r}function G(n){return n.replace("#","")}function W(n){var e=G(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 Y(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 $(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:v,FILTER:m,ANIMATION:h,KEYFRAMES:w,OPEN_CLOSED_CHARACTERS:S,TINY_NUM:g,REVERSE_TINY_NUM:A,DEFAULT_UNIT_PRESETS:y,cutHex:G,hexToRGBA:W,toFullHex:Y,hslToRGBA:$,stringToRGBA:function(n){if("#"===n.charAt(0))return 4===n.length||5===n.length?W(Y(n)):W(n);if(-1!==n.indexOf("(")){var e=N(n),r=e.prefix,t=e.value;if(!r||!t)return;var i=F(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 $(o)}}},dot:function(n,e,r,t){return(n*t+e*r)/(r+t)},isUndefined:function(n){return typeof n==u},isObject:b,isArray:E,isString:x,isNumber:function(n){return typeof n==o},isFunction:R,splitText:O,splitSpace:function(n){return O(n,"")},splitComma:F,splitBracket:N,splitUnit:I,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:T,findIndex:L,findLastIndex:k,findLast:function(n,e,r){var t=k(n,e);return-1<t?n[t]:r},find:j,requestAnimationFrame:B,cancelAnimationFrame:function(){var n=a&&(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame);return n?n.bind(window):function(n){clearTimeout(n)}}(),getKeys:D,getValues:function(e){return D(e).map(function(n){return e[n]})},getEntries:function(e){return D(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=I(n),t=r.value,i=r.unit;if(b(e)){var o=e[i];if(o){if(R(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:U,checkBoundSize:z,calculateBoundSize:function(n,r,t,e){if(!e)return n.map(function(n,e){return U(n,r[e],t[e])});var i=n[0],o=n[1],u=!0===e?i/o:e,a=z(n,r,!1,u),c=a[0],f=a[1],s=z(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:_,getRad:P,getCenterPoint:q,getShapeDirection:function(n){var e=q(n),r=P(e,n[0]),t=P(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:H,throttleArray:function(r,t){return r.forEach(function(n,e){r[e]=H(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,x(r)?r:r.apply(void 0,n))})},flat:function(n){return n.reduce(function(n,e){return n.concat(e)},[])},deepFlat:function r(n){return n.reduce(function(n,e){return E(e)?n.push.apply(n,r(e)):n.push(e),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)}}});
!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)}}});
//# sourceMappingURL=utils.min.js.map
{
"name": "@daybrush/utils",
"version": "1.10.0",
"version": "1.10.1",
"description": "utils for daybrush",

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

@@ -534,2 +534,3 @@ import {

const firstTime = now();
const raf = IS_WINDOW

@@ -541,6 +542,7 @@ && (window.requestAnimationFrame || (window as any).webkitRequestAnimationFrame

const currTime = now();
const id = window.setTimeout(() => {
const id = setTimeout(() => {
callback(currTime - firstTime);
}, 1000 / 60);
return id;
return id as any as number;
});

@@ -547,0 +549,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