@daybrush/utils
Advanced tools
Comparing version 0.10.2 to 0.10.3
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.10.2 | ||
@version 0.10.3 | ||
*/ | ||
@@ -359,6 +359,2 @@ /** | ||
function throwInvalidFormatError() { | ||
throw new Error("Invalid Format"); | ||
} | ||
function findClosed(closedCharacter, texts, index, length) { | ||
@@ -381,3 +377,3 @@ for (var i = index; i < length; ++i) { | ||
if (nextIndex === -1) { | ||
throwInvalidFormatError(); | ||
break; | ||
} | ||
@@ -417,7 +413,6 @@ | ||
if (nextIndex === -1) { | ||
throwInvalidFormatError(); | ||
} else { | ||
tempValues.push(texts.slice(i, nextIndex + 1).join("")); | ||
nextIndex = length - 1; | ||
} | ||
tempValues.push(texts.slice(i, nextIndex + 1).join("")); | ||
i = nextIndex; | ||
@@ -424,0 +419,0 @@ } |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.10.2 | ||
@version 0.10.3 | ||
*/ | ||
@@ -365,6 +365,2 @@ (function (global, factory) { | ||
function throwInvalidFormatError() { | ||
throw new Error("Invalid Format"); | ||
} | ||
function findClosed(closedCharacter, texts, index, length) { | ||
@@ -387,3 +383,3 @@ for (var i = index; i < length; ++i) { | ||
if (nextIndex === -1) { | ||
throwInvalidFormatError(); | ||
break; | ||
} | ||
@@ -423,7 +419,6 @@ | ||
if (nextIndex === -1) { | ||
throwInvalidFormatError(); | ||
} else { | ||
tempValues.push(texts.slice(i, nextIndex + 1).join("")); | ||
nextIndex = length - 1; | ||
} | ||
tempValues.push(texts.slice(i, nextIndex + 1).join("")); | ||
i = nextIndex; | ||
@@ -430,0 +425,0 @@ } |
@@ -7,5 +7,5 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.10.2 | ||
@version 0.10.3 | ||
*/ | ||
!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",o="undefined",i=typeof window!==o,a=typeof document!==o&&document,u=["webkit","ms","moz","o"],m=function(n){if(!a)return"";var e=(a.body||a.documentElement).style,t=u.length;if(typeof e[n]!==o)return n;for(var r=0;r<t;++r){var i="-"+u[r]+"-"+n;if(typeof e[i]!==o)return i}return""},d=m("transform"),p=m("filter"),v=m("animation"),w=v.replace("animation","keyframes"),h=['"',"'",'\\"',"\\'"];function A(){throw new Error("Invalid Format")}function g(n,e,t,r){for(var i=t;i<r;++i){var o=e[i].trim();if(o===n)return i;var a=i;"("===o?a=g(")",e,i+1,r):-1<h.indexOf(o)&&(a=g(o,e,i+1,r)),-1===a&&A(),i=a}return-1}function y(n,e){for(var t=n.split(/(\s*,\s*|\(|\)|"|'|\\"|\\'|\s+)/g).filter(Boolean),r=t.length,i=[],o=[],a=0;a<r;++a){var u=t[a].trim(),s=a;if("("===u)s=g(")",t,a+1,r);else{if(")"===u)throw new Error("invalid format");if(-1<h.indexOf(u))s=g(u,t,a+1,r);else if(u===e){o.length&&(i.push(o.join("")),o=[]);continue}}-1===s?A():o.push(t.slice(a,s+1).join("")),a=s}return o.length&&i.push(o.join("")),i}function R(n){return y(n,",")}function E(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(){return Date.now?Date.now():(new Date).getTime()}function b(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 x=function(){var t=F(),n=i&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame);return n?n.bind(window):function(n){var e=F();return window.setTimeout(function(){n(e-t)},1e3/60)}}();function N(n){return n.replace("#","")}function C(n){var e=N(n),t=parseInt(e.substring(0,2),16),r=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),[t,r,i,o]}function S(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 O(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,o=(1-Math.abs(2*r-1))*t,a=o*(1-Math.abs(e/60%2-1)),u=r-o/2;return e<60?i=[o,a,0]:e<120?i=[a,o,0]:e<180?i=[0,o,a]:e<240?i=[0,a,o]:e<300?i=[a,0,o]:e<360&&(i=[o,0,a]),[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:o,IS_WINDOW:i,document:a,getCrossBrowserProperty:m,TRANSFORM:d,FILTER:p,ANIMATION:v,KEYFRAMES:w,OPEN_CLOSED_CHARACTER:h,cutHex:N,hexToRGBA:C,toFullHex:S,hslToRGBA:O,stringToRGBA:function(n){if("#"===n.charAt(0))return 4===n.length||5===n.length?C(S(n)):C(n);if(-1!==n.indexOf("(")){var e=E(n),t=e.prefix,r=e.value;if(!t||!r)return;var i=R(r),o=[],a=i.length;switch(t){case s:case f:for(var u=0;u<a;++u)o[u]=parseFloat(i[u]);return o;case c:case l:for(u=0;u<a;++u)-1!==i[u].indexOf("%")?o[u]=parseFloat(i[u])/100:o[u]=parseFloat(i[u]);return O(o)}}},dot:function(n,e,t,r){return(n*r+e*t)/(t+r)},isUndefined:function(n){return typeof n===o},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 y(n,"")},splitComma:R,splitBracket:E,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:F,findIndex:b,find:function(n,e,t){var r=b(n,e);return-1<r?n[r]:t},requestAnimationFrame:x,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?a.querySelectorAll(n):a.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),o=e.length,a=0;a<o;++a)r[e[a]]=i[e[a]];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=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)}}}); | ||
//# sourceMappingURL=utils.min.js.map |
{ | ||
"name": "@daybrush/utils", | ||
"version": "0.10.2", | ||
"version": "0.10.3", | ||
"description": "utils for daybrush", | ||
@@ -5,0 +5,0 @@ "main": "dist/utils.js", |
@@ -107,5 +107,2 @@ import { UNDEFINED, STRING, OBJECT, FUNCTION, IS_WINDOW, OPEN_CLOSED_CHARACTER } from "./consts"; | ||
function throwInvalidFormatError() { | ||
throw new Error("Invalid Format"); | ||
} | ||
function findClosed(closedCharacter: string, texts: string[], index: number, length: number) { | ||
@@ -125,3 +122,3 @@ for (let i = index; i < length; ++i) { | ||
if (nextIndex === -1) { | ||
throwInvalidFormatError(); | ||
break; | ||
} | ||
@@ -157,6 +154,5 @@ i = nextIndex; | ||
if (nextIndex === -1) { | ||
throwInvalidFormatError(); | ||
} else { | ||
tempValues.push(texts.slice(i, nextIndex + 1).join("")); | ||
nextIndex = length - 1; | ||
} | ||
tempValues.push(texts.slice(i, nextIndex + 1).join("")); | ||
i = nextIndex; | ||
@@ -163,0 +159,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
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
217764
2971