@daybrush/utils
Advanced tools
Comparing version 0.12.1 to 0.13.0
@@ -7,2 +7,3 @@ import { IArrayFormat, IObject } from "./types"; | ||
export declare function isString(value: any): value is string; | ||
export declare function isNumber(value: any): value is number; | ||
export declare function isFunction(value: any): value is (...args: any[]) => any; | ||
@@ -9,0 +10,0 @@ export declare function splitText(text: string, separator: string): string[]; |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.12.1 | ||
@version 0.13.0 | ||
*/ | ||
@@ -330,2 +330,5 @@ /** | ||
} | ||
function isNumber(value) { | ||
return typeof value === NUMBER; | ||
} | ||
/** | ||
@@ -1039,3 +1042,3 @@ * Check the type that the value is function. | ||
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, getKeys, sortOrders, $, 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, isNumber, isFunction, splitText, splitSpace, splitComma, splitBracket, splitUnit, camelize, decamelize, toArray, now, findIndex, find, requestAnimationFrame, cancelAnimationFrame, getKeys, sortOrders, $, hasClass, addClass, removeClass, fromCSS, addEvent, removeEvent }; | ||
//# sourceMappingURL=utils.esm.js.map |
@@ -7,3 +7,3 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.12.1 | ||
@version 0.13.0 | ||
*/ | ||
@@ -336,2 +336,5 @@ (function (global, factory) { | ||
} | ||
function isNumber(value) { | ||
return typeof value === NUMBER; | ||
} | ||
/** | ||
@@ -1078,2 +1081,3 @@ * Check the type that the value is function. | ||
isString: isString, | ||
isNumber: isNumber, | ||
isFunction: isFunction, | ||
@@ -1080,0 +1084,0 @@ splitText: splitText, |
@@ -7,5 +7,5 @@ /* | ||
repository: https://github.com/daybrush/utils | ||
@version 0.12.1 | ||
@version 0.13.0 | ||
*/ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.utils=e()}(this,function(){"use strict";function n(n){if(!u)return"";var e=(u.body||u.documentElement).style,t=d.length;if(typeof e[n]!=o)return n;for(var r=0;r<t;++r){var i="-"+d[r]+"-"+n;if(typeof e[i]!=o)return i}return""}var s="rgb",f="rgba",c="hsl",l="hsla",e=[s,f,c,l],t="function",r="object",i="string",o="undefined",a=typeof window!=o,u=typeof document!=o&&document,d=["webkit","ms","moz","o"],m=n("transform"),p=n("filter"),v=n("animation"),w=v.replace("animation","keyframes"),h=['"',"'",'\\"',"\\'"];function A(n,e,t,r){for(var i=t;i<r;++i){var o=e[i].trim();if(o===n)return i;var a=i;if("("===o?a=A(")",e,i+1,r):-1<h.indexOf(o)&&(a=A(o,e,i+1,r)),-1===a)break;i=a}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,o=[],a=[],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){a.length&&(o.push(a.join("")),a=[]);continue}}-1===f&&(f=i-1),a.push(r.slice(u,f+1).join("")),u=f}return a.length&&o.push(a.join("")),o}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 x(){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 E=function(){var t=x(),n=a&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame);return n?n.bind(window):function(n){var e=x();return window.setTimeout(function(){n(e-t)},1e3/60)}}();function F(n){return n.replace("#","")}function O(n){var e=F(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 N(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 C(n){var e,t=n[0],r=n[1],i=n[2];t<0&&(t+=360*Math.floor((Math.abs(t)+360)/360)),t%=360;var o=(1-Math.abs(2*i-1))*r,a=o*(1-Math.abs(t/60%2-1)),u=i-o/2,s=t<60?[o,a,0]:t<120?[a,o,0]:t<180?[0,o,a]:t<240?[0,a,o]:t<300?[a,0,o]:t<360?[o,0,a]:[0,0,0];return[Math.round(255*(s[0]+u)),Math.round(255*(s[1]+u)),Math.round(255*(s[2]+u)),null!==(e=n[3])&&void 0!==e?e:1]}return{RGB:s,RGBA:f,HSL:c,HSLA:l,COLOR_MODELS:e,FUNCTION:t,PROPERTY:"property",ARRAY:"array",OBJECT:r,STRING:i,NUMBER:"number",UNDEFINED:o,IS_WINDOW:a,document:u,getCrossBrowserProperty:n,TRANSFORM:m,FILTER:p,ANIMATION:v,KEYFRAMES:w,OPEN_CLOSED_CHARACTER:h,cutHex:F,hexToRGBA:O,toFullHex:N,hslToRGBA:C,stringToRGBA:function(n){if("#"===n.charAt(0))return 4===n.length||5===n.length?O(N(n)):O(n);if(-1!==n.indexOf("(")){var e=R(n),t=e.prefix,r=e.value;if(!t||!r)return;var i=y(r),o=[0,0,0,1],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 C(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==r},isArray:function(n){return Array.isArray(n)},isString:function(n){return typeof n==i},isFunction:function(n){return typeof n==t},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:x,findIndex:b,find:function(n,e,t){var r=b(n,e);return-1<r?n[r]:t},requestAnimationFrame:E,cancelAnimationFrame:function(){var n=a&&(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame);return n?n.bind(window):function(n){clearTimeout(n)}}(),getKeys:function(n){if(Object.keys)return Object.keys(n);var e=[];for(var t in e)e.push(t);return e},sortOrders:function(n,i){void 0===i&&(i=[]),n.sort(function(n,e){var t=i.indexOf(n),r=i.indexOf(e);return-1===r&&-1===t?0:-1===t?1:-1===r?-1:t-r})},$:function(n,e){return e?u.querySelectorAll(n):u.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 t;n.classList?n.classList.remove(e):(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";function n(n){if(!d)return"";var e=(d.body||d.documentElement).style,t=m.length;if(typeof e[n]!=a)return n;for(var r=0;r<t;++r){var i="-"+m[r]+"-"+n;if(typeof e[i]!=a)return i}return""}var s="rgb",f="rgba",c="hsl",l="hsla",e=[s,f,c,l],t="function",r="object",i="string",o="number",a="undefined",u=typeof window!=a,d=typeof document!=a&&document,m=["webkit","ms","moz","o"],p=n("transform"),v=n("filter"),w=n("animation"),h=w.replace("animation","keyframes"),A=['"',"'",'\\"',"\\'"];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;if("("===o?a=g(")",e,i+1,r):-1<A.indexOf(o)&&(a=g(o,e,i+1,r)),-1===a)break;i=a}return-1}function y(n,e){for(var t=new RegExp("(\\s*"+(e||",")+"\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)","g"),r=n.split(t).filter(Boolean),i=r.length,o=[],a=[],u=0;u<i;++u){var s=r[u].trim(),f=u;if("("===s)f=g(")",r,u+1,i);else{if(")"===s)throw new Error("invalid format");if(-1<A.indexOf(s))f=g(s,r,u+1,i);else if(s===e){a.length&&(o.push(a.join("")),a=[]);continue}}-1===f&&(f=i-1),a.push(r.slice(u,f+1).join("")),u=f}return a.length&&o.push(a.join("")),o}function R(n){return y(n,",")}function b(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 x(){return Date.now?Date.now():(new Date).getTime()}function E(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=x(),n=u&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame);return n?n.bind(window):function(n){var e=x();return window.setTimeout(function(){n(e-t)},1e3/60)}}();function O(n){return n.replace("#","")}function N(n){var e=O(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 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,t=n[0],r=n[1],i=n[2];t<0&&(t+=360*Math.floor((Math.abs(t)+360)/360)),t%=360;var o=(1-Math.abs(2*i-1))*r,a=o*(1-Math.abs(t/60%2-1)),u=i-o/2,s=t<60?[o,a,0]:t<120?[a,o,0]:t<180?[0,o,a]:t<240?[0,a,o]:t<300?[a,0,o]:t<360?[o,0,a]:[0,0,0];return[Math.round(255*(s[0]+u)),Math.round(255*(s[1]+u)),Math.round(255*(s[2]+u)),null!==(e=n[3])&&void 0!==e?e:1]}return{RGB:s,RGBA:f,HSL:c,HSLA:l,COLOR_MODELS:e,FUNCTION:t,PROPERTY:"property",ARRAY:"array",OBJECT:r,STRING:i,NUMBER:o,UNDEFINED:a,IS_WINDOW:u,document:d,getCrossBrowserProperty:n,TRANSFORM:p,FILTER:v,ANIMATION:w,KEYFRAMES:h,OPEN_CLOSED_CHARACTER:A,cutHex:O,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=b(n),t=e.prefix,r=e.value;if(!t||!r)return;var i=R(r),o=[0,0,0,1],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 S(o)}}},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==r},isArray:function(n){return Array.isArray(n)},isString:function(n){return typeof n==i},isNumber:function(n){return typeof n==o},isFunction:function(n){return typeof n==t},splitText:y,splitSpace:function(n){return y(n,"")},splitComma:R,splitBracket:b,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:x,findIndex:E,find:function(n,e,t){var r=E(n,e);return-1<r?n[r]:t},requestAnimationFrame:F,cancelAnimationFrame:function(){var n=u&&(window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame);return n?n.bind(window):function(n){clearTimeout(n)}}(),getKeys:function(n){if(Object.keys)return Object.keys(n);var e=[];for(var t in e)e.push(t);return e},sortOrders:function(n,i){void 0===i&&(i=[]),n.sort(function(n,e){var t=i.indexOf(n),r=i.indexOf(e);return-1===r&&-1===t?0:-1===t?1:-1===r?-1:t-r})},$:function(n,e){return e?d.querySelectorAll(n):d.querySelector(n)},hasClass:function(n,e){return n.classList?n.classList.contains(e):!!n.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))},addClass:function(n,e){n.classList?n.classList.add(e):n.className+=" "+e},removeClass:function(n,e){var t;n.classList?n.classList.remove(e):(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)}}}); | ||
//# sourceMappingURL=utils.min.js.map |
{ | ||
"name": "@daybrush/utils", | ||
"version": "0.12.1", | ||
"version": "0.13.0", | ||
"description": "utils for daybrush", | ||
@@ -5,0 +5,0 @@ "main": "dist/utils.js", |
@@ -1,2 +0,2 @@ | ||
import { UNDEFINED, STRING, OBJECT, FUNCTION, IS_WINDOW, OPEN_CLOSED_CHARACTER } from "./consts"; | ||
import { UNDEFINED, STRING, OBJECT, FUNCTION, IS_WINDOW, OPEN_CLOSED_CHARACTER, NUMBER } from "./consts"; | ||
import { IArrayFormat, IObject } from "./types"; | ||
@@ -89,2 +89,7 @@ /** | ||
} | ||
export function isNumber(value: any): value is number { | ||
return typeof value === NUMBER; | ||
} | ||
/** | ||
@@ -91,0 +96,0 @@ * Check the type that the value is function. |
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
227292
3058