@daybrush/utils
Advanced tools
Comparing version 0.10.4 to 0.10.5
@@ -8,4 +8,4 @@ export interface IArrayFormat<T> { | ||
} | ||
export interface IEventMap extends ElementEventMap, HTMLElementEventMap, SVGElementEventMap, HTMLMediaElementEventMap, HTMLBodyElementEventMap, HTMLVideoElementEventMap { | ||
export interface IEventMap extends ElementEventMap, HTMLElementEventMap, SVGElementEventMap, HTMLMediaElementEventMap, HTMLBodyElementEventMap { | ||
[name: string]: Event; | ||
} |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.10.4 | ||
@version 0.10.5 | ||
*/ | ||
@@ -10,0 +10,0 @@ /** |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.10.4 | ||
@version 0.10.5 | ||
*/ | ||
@@ -10,0 +10,0 @@ (function (global, factory) { |
@@ -7,5 +7,5 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.10.4 | ||
@version 0.10.5 | ||
*/ | ||
!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.4", | ||
"version": "0.10.5", | ||
"description": "utils for daybrush", | ||
@@ -86,5 +86,5 @@ "main": "dist/utils.js", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.3" | ||
"typescript": "^3.9.5" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -19,4 +19,4 @@ | ||
export interface IEventMap extends ElementEventMap, | ||
HTMLElementEventMap, SVGElementEventMap, HTMLMediaElementEventMap, HTMLBodyElementEventMap, HTMLVideoElementEventMap { | ||
HTMLElementEventMap, SVGElementEventMap, HTMLMediaElementEventMap, HTMLBodyElementEventMap { | ||
[name: string]: Event; | ||
} |
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
218917