@daybrush/utils
Advanced tools
Comparing version 0.10.3 to 0.10.4
@@ -8,2 +8,3 @@ import { IArrayFormat, IObject } from "./types"; | ||
export declare function isFunction(value: any): value is (...args: any[]) => any; | ||
export declare function splitText(text: string, separator: string): string[]; | ||
export declare function splitSpace(text: string): string[]; | ||
@@ -10,0 +11,0 @@ export declare function splitComma(text: string): string[]; |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.10.3 | ||
@version 0.10.4 | ||
*/ | ||
@@ -386,3 +386,5 @@ /** | ||
function splitText(text, separator) { | ||
var texts = text.split(/(\s*,\s*|\(|\)|"|'|\\"|\\'|\s+)/g).filter(Boolean); | ||
var regexText = "(\\s*" + (separator || ",") + "\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)"; | ||
var regex = new RegExp(regexText, "g"); | ||
var texts = text.split(regex).filter(Boolean); | ||
var length = texts.length; | ||
@@ -439,3 +441,2 @@ var values = []; | ||
function splitSpace(text) { | ||
@@ -1013,3 +1014,3 @@ // divide comma(,) | ||
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_CHARACTER, cutHex, hexToRGBA, toFullHex, hslToRGBA, stringToRGBA, dot, isUndefined, isObject, isArray, isString, isFunction, splitSpace, splitComma, splitBracket, splitUnit, camelize, decamelize, toArray, now, findIndex, find, requestAnimationFrame, cancelAnimationFrame, $, 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_CHARACTER, cutHex, hexToRGBA, toFullHex, hslToRGBA, stringToRGBA, dot, isUndefined, isObject, isArray, isString, isFunction, splitText, splitSpace, splitComma, splitBracket, splitUnit, camelize, decamelize, toArray, now, findIndex, find, requestAnimationFrame, cancelAnimationFrame, $, hasClass, addClass, removeClass, fromCSS, addEvent, removeEvent }; | ||
//# sourceMappingURL=utils.esm.js.map |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.10.3 | ||
@version 0.10.4 | ||
*/ | ||
@@ -392,3 +392,5 @@ (function (global, factory) { | ||
function splitText(text, separator) { | ||
var texts = text.split(/(\s*,\s*|\(|\)|"|'|\\"|\\'|\s+)/g).filter(Boolean); | ||
var regexText = "(\\s*" + (separator || ",") + "\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)"; | ||
var regex = new RegExp(regexText, "g"); | ||
var texts = text.split(regex).filter(Boolean); | ||
var length = texts.length; | ||
@@ -445,3 +447,2 @@ var values = []; | ||
function splitSpace(text) { | ||
@@ -1053,2 +1054,3 @@ // divide comma(,) | ||
isFunction: isFunction, | ||
splitText: splitText, | ||
splitSpace: splitSpace, | ||
@@ -1055,0 +1057,0 @@ splitComma: splitComma, |
@@ -7,5 +7,5 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.10.3 | ||
@version 0.10.4 | ||
*/ | ||
!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";var s="rgb",f="rgba",c="hsl",l="hsla",n=[s,f,c,l],e="function",t="object",r="string",a="undefined",i=typeof window!==a,o=typeof document!==a&&document,u=["webkit","ms","moz","o"],m=function(n){if(!o)return"";var e=(o.body||o.documentElement).style,t=u.length;if(typeof e[n]!==a)return n;for(var r=0;r<t;++r){var i="-"+u[r]+"-"+n;if(typeof e[i]!==a)return i}return""},d=m("transform"),p=m("filter"),v=m("animation"),w=v.replace("animation","keyframes"),h=['"',"'",'\\"',"\\'"];function A(n,e,t,r){for(var i=t;i<r;++i){var a=e[i].trim();if(a===n)return i;var o=i;if("("===a?o=A(")",e,i+1,r):-1<h.indexOf(a)&&(o=A(a,e,i+1,r)),-1===o)break;i=o}return-1}function g(n,e){for(var t=n.split(/(\s*,\s*|\(|\)|"|'|\\"|\\'|\s+)/g).filter(Boolean),r=t.length,i=[],a=[],o=0;o<r;++o){var u=t[o].trim(),s=o;if("("===u)s=A(")",t,o+1,r);else{if(")"===u)throw new Error("invalid format");if(-1<h.indexOf(u))s=A(u,t,o+1,r);else if(u===e){a.length&&(i.push(a.join("")),a=[]);continue}}-1===s&&(s=r-1),a.push(t.slice(o,s+1).join("")),o=s}return a.length&&i.push(a.join("")),i}function y(n){return g(n,",")}function R(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 E(){return Date.now?Date.now():(new Date).getTime()}function F(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}var b=function(){var t=E(),n=i&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame);return n?n.bind(window):function(n){var e=E();return window.setTimeout(function(){n(e-t)},1e3/60)}}();function x(n){return n.replace("#","")}function N(n){var e=x(n),t=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),a=parseInt(e.substring(6,8),16)/255;return isNaN(a)&&(a=1),[t,r,i,a]}function C(n){var e=n.charAt(1),t=n.charAt(2),r=n.charAt(3),i=n.charAt(4);return["#",e,e,t,t,r,r,i,i].join("")}function S(n){var e=n[0],t=n[1],r=n[2];e<0&&(e+=360*Math.floor((Math.abs(e)+360)/360)),e%=360;var i,a=(1-Math.abs(2*r-1))*t,o=a*(1-Math.abs(e/60%2-1)),u=r-a/2;return e<60?i=[a,o,0]:e<120?i=[o,a,0]:e<180?i=[0,a,o]:e<240?i=[0,o,a]:e<300?i=[o,0,a]:e<360&&(i=[a,0,o]),[Math.round(255*(i[0]+u)),Math.round(255*(i[1]+u)),Math.round(255*(i[2]+u)),3<n.length?n[3]:1]}return{RGB:s,RGBA:f,HSL:c,HSLA:l,COLOR_MODELS:n,FUNCTION:e,PROPERTY:"property",ARRAY:"array",OBJECT:t,STRING:r,NUMBER:"number",UNDEFINED:a,IS_WINDOW:i,document:o,getCrossBrowserProperty:m,TRANSFORM:d,FILTER:p,ANIMATION:v,KEYFRAMES:w,OPEN_CLOSED_CHARACTER:h,cutHex:x,hexToRGBA:N,toFullHex:C,hslToRGBA:S,stringToRGBA:function(n){if("#"===n.charAt(0))return 4===n.length||5===n.length?N(C(n)):N(n);if(-1!==n.indexOf("(")){var e=R(n),t=e.prefix,r=e.value;if(!t||!r)return;var i=y(r),a=[],o=i.length;switch(t){case s:case f:for(var u=0;u<o;++u)a[u]=parseFloat(i[u]);return a;case c:case l:for(u=0;u<o;++u)-1!==i[u].indexOf("%")?a[u]=parseFloat(i[u])/100:a[u]=parseFloat(i[u]);return S(a)}}},dot:function(n,e,t,r){return(n*r+e*t)/(t+r)},isUndefined:function(n){return typeof n===a},isObject:function(n){return n&&typeof n===t},isArray:function(n){return Array.isArray(n)},isString:function(n){return typeof n===r},isFunction:function(n){return typeof n===e},splitSpace:function(n){return g(n,"")},splitComma:y,splitBracket:R,splitUnit:function(n){var e=/^([^\d|e|\-|\+]*)((?:\d|\.|-|e-|e\+)+)(\S*)$/g.exec(n);if(!e)return{prefix:"",unit:"",value:NaN};var t=e[1],r=e[2];return{prefix:t,unit:e[3],value:parseFloat(r)}},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:E,findIndex:F,find:function(n,e,t){var r=F(n,e);return-1<r?n[r]:t},requestAnimationFrame:b,cancelAnimationFrame:function(){var n=i&&(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame);return n?n.bind(window):function(n){clearTimeout(n)}}(),$:function(n,e){return e?o.querySelectorAll(n):o.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){if(n.classList)n.classList.remove(e);else{var t=new RegExp("(\\s|^)"+e+"(\\s|$)");n.className=n.className.replace(t," ")}},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),a=e.length,o=0;o<a;++o)r[e[o]]=i[e[o]];return r},addEvent:function(n,e,t,r){n.addEventListener(e,t,r)},removeEvent:function(n,e,t){n.removeEventListener(e,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";var s="rgb",f="rgba",c="hsl",l="hsla",n=[s,f,c,l],e="function",t="object",r="string",a="undefined",i=typeof window!==a,o=typeof document!==a&&document,u=["webkit","ms","moz","o"],m=function(n){if(!o)return"";var e=(o.body||o.documentElement).style,t=u.length;if(typeof e[n]!==a)return n;for(var r=0;r<t;++r){var i="-"+u[r]+"-"+n;if(typeof e[i]!==a)return i}return""},d=m("transform"),p=m("filter"),v=m("animation"),w=v.replace("animation","keyframes"),h=['"',"'",'\\"',"\\'"];function A(n,e,t,r){for(var i=t;i<r;++i){var a=e[i].trim();if(a===n)return i;var o=i;if("("===a?o=A(")",e,i+1,r):-1<h.indexOf(a)&&(o=A(a,e,i+1,r)),-1===o)break;i=o}return-1}function g(n,e){for(var t=new RegExp("(\\s*"+(e||",")+"\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)","g"),r=n.split(t).filter(Boolean),i=r.length,a=[],o=[],u=0;u<i;++u){var s=r[u].trim(),f=u;if("("===s)f=A(")",r,u+1,i);else{if(")"===s)throw new Error("invalid format");if(-1<h.indexOf(s))f=A(s,r,u+1,i);else if(s===e){o.length&&(a.push(o.join("")),o=[]);continue}}-1===f&&(f=i-1),o.push(r.slice(u,f+1).join("")),u=f}return o.length&&a.push(o.join("")),a}function y(n){return g(n,",")}function R(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 E(){return Date.now?Date.now():(new Date).getTime()}function x(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}var F=function(){var t=E(),n=i&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame);return n?n.bind(window):function(n){var e=E();return window.setTimeout(function(){n(e-t)},1e3/60)}}();function b(n){return n.replace("#","")}function N(n){var e=b(n),t=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),a=parseInt(e.substring(6,8),16)/255;return isNaN(a)&&(a=1),[t,r,i,a]}function C(n){var e=n.charAt(1),t=n.charAt(2),r=n.charAt(3),i=n.charAt(4);return["#",e,e,t,t,r,r,i,i].join("")}function S(n){var e=n[0],t=n[1],r=n[2];e<0&&(e+=360*Math.floor((Math.abs(e)+360)/360)),e%=360;var i,a=(1-Math.abs(2*r-1))*t,o=a*(1-Math.abs(e/60%2-1)),u=r-a/2;return e<60?i=[a,o,0]:e<120?i=[o,a,0]:e<180?i=[0,a,o]:e<240?i=[0,o,a]:e<300?i=[o,0,a]:e<360&&(i=[a,0,o]),[Math.round(255*(i[0]+u)),Math.round(255*(i[1]+u)),Math.round(255*(i[2]+u)),3<n.length?n[3]:1]}return{RGB:s,RGBA:f,HSL:c,HSLA:l,COLOR_MODELS:n,FUNCTION:e,PROPERTY:"property",ARRAY:"array",OBJECT:t,STRING:r,NUMBER:"number",UNDEFINED:a,IS_WINDOW:i,document:o,getCrossBrowserProperty:m,TRANSFORM:d,FILTER:p,ANIMATION:v,KEYFRAMES:w,OPEN_CLOSED_CHARACTER:h,cutHex:b,hexToRGBA:N,toFullHex:C,hslToRGBA:S,stringToRGBA:function(n){if("#"===n.charAt(0))return 4===n.length||5===n.length?N(C(n)):N(n);if(-1!==n.indexOf("(")){var e=R(n),t=e.prefix,r=e.value;if(!t||!r)return;var i=y(r),a=[],o=i.length;switch(t){case s:case f:for(var u=0;u<o;++u)a[u]=parseFloat(i[u]);return a;case c:case l:for(u=0;u<o;++u)-1!==i[u].indexOf("%")?a[u]=parseFloat(i[u])/100:a[u]=parseFloat(i[u]);return S(a)}}},dot:function(n,e,t,r){return(n*r+e*t)/(t+r)},isUndefined:function(n){return typeof n===a},isObject:function(n){return n&&typeof n===t},isArray:function(n){return Array.isArray(n)},isString:function(n){return typeof n===r},isFunction:function(n){return typeof n===e},splitText:g,splitSpace:function(n){return g(n,"")},splitComma:y,splitBracket:R,splitUnit:function(n){var e=/^([^\d|e|\-|\+]*)((?:\d|\.|-|e-|e\+)+)(\S*)$/g.exec(n);if(!e)return{prefix:"",unit:"",value:NaN};var t=e[1],r=e[2];return{prefix:t,unit:e[3],value:parseFloat(r)}},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:E,findIndex:x,find:function(n,e,t){var r=x(n,e);return-1<r?n[r]:t},requestAnimationFrame:F,cancelAnimationFrame:function(){var n=i&&(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame);return n?n.bind(window):function(n){clearTimeout(n)}}(),$:function(n,e){return e?o.querySelectorAll(n):o.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){if(n.classList)n.classList.remove(e);else{var t=new RegExp("(\\s|^)"+e+"(\\s|$)");n.className=n.className.replace(t," ")}},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),a=e.length,o=0;o<a;++o)r[e[o]]=i[e[o]];return r},addEvent:function(n,e,t,r){n.addEventListener(e,t,r)},removeEvent:function(n,e,t){n.removeEventListener(e,t)}}}); | ||
//# sourceMappingURL=utils.min.js.map |
{ | ||
"name": "@daybrush/utils", | ||
"version": "0.10.3", | ||
"version": "0.10.4", | ||
"description": "utils for daybrush", | ||
@@ -5,0 +5,0 @@ "main": "dist/utils.js", |
@@ -127,4 +127,6 @@ import { UNDEFINED, STRING, OBJECT, FUNCTION, IS_WINDOW, OPEN_CLOSED_CHARACTER } from "./consts"; | ||
} | ||
function splitText(text: string, separator: string) { | ||
const texts = text.split(/(\s*,\s*|\(|\)|"|'|\\"|\\'|\s+)/g).filter(Boolean); | ||
export function splitText(text: string, separator: string) { | ||
const regexText = `(\\s*${separator || ","}\\s*|\\(|\\)|"|'|\\\\"|\\\\'|\\s+)`; | ||
const regex = new RegExp(regexText, "g"); | ||
const texts = text.split(regex).filter(Boolean); | ||
const length = texts.length; | ||
@@ -131,0 +133,0 @@ const values = []; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
218887
2979