@hairy/utils 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +2 -2
- package/index.d.ts +1 -1
- package/index.esm.js +2 -2
- package/index.iife.js +2 -2
- package/index.iife.min.js +1 -1
- package/package.json +2 -2
package/index.cjs.js
CHANGED
|
@@ -86,14 +86,14 @@ const weexPlatform = isWeex && WXEnvironment.platform.toLowerCase();
|
|
|
86
86
|
const UA = isBrowser && window.navigator.userAgent.toLowerCase();
|
|
87
87
|
const isIE = UA && /msie|trident/.test(UA);
|
|
88
88
|
const isIE9 = UA && UA.indexOf("msie 9.0") > 0;
|
|
89
|
-
const isIE11 = navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
|
|
89
|
+
const isIE11 = isBrowser && navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
|
|
90
90
|
const isEdge = UA && UA.indexOf("edge/") > 0;
|
|
91
91
|
const isAndroid = UA && UA.indexOf("android") > 0 || weexPlatform === "android";
|
|
92
92
|
const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA) || weexPlatform === "ios";
|
|
93
93
|
const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
|
|
94
94
|
const isPhantomJS = UA && /phantomjs/.test(UA);
|
|
95
95
|
const isFF = typeof UA == "string" && UA.match(/firefox\/(\d+)/);
|
|
96
|
-
const isMobile = navigator.userAgent.toLowerCase().includes("mobile");
|
|
96
|
+
const isMobile = isBrowser && navigator.userAgent.toLowerCase().includes("mobile");
|
|
97
97
|
|
|
98
98
|
const analyUnit = (size, unit = "px") => {
|
|
99
99
|
return lodash.isString(size) && /\D/g.test(size) ? size : size + unit;
|
package/index.d.ts
CHANGED
|
@@ -140,7 +140,7 @@ declare type DeepReplace<T, K = unknown, V = unknown> = {
|
|
|
140
140
|
[P in keyof T]: K extends P ? V : DeepReplace<T[P], K, V>;
|
|
141
141
|
};
|
|
142
142
|
declare type Option<L extends Key = 'label', V extends Key = 'value', C extends Key = 'children'> = {
|
|
143
|
-
[P in L]:
|
|
143
|
+
[P in L]: string;
|
|
144
144
|
} & {
|
|
145
145
|
[P in V]: LooseNumber;
|
|
146
146
|
} & {
|
package/index.esm.js
CHANGED
|
@@ -78,14 +78,14 @@ const weexPlatform = isWeex && WXEnvironment.platform.toLowerCase();
|
|
|
78
78
|
const UA = isBrowser && window.navigator.userAgent.toLowerCase();
|
|
79
79
|
const isIE = UA && /msie|trident/.test(UA);
|
|
80
80
|
const isIE9 = UA && UA.indexOf("msie 9.0") > 0;
|
|
81
|
-
const isIE11 = navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
|
|
81
|
+
const isIE11 = isBrowser && navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
|
|
82
82
|
const isEdge = UA && UA.indexOf("edge/") > 0;
|
|
83
83
|
const isAndroid = UA && UA.indexOf("android") > 0 || weexPlatform === "android";
|
|
84
84
|
const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA) || weexPlatform === "ios";
|
|
85
85
|
const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
|
|
86
86
|
const isPhantomJS = UA && /phantomjs/.test(UA);
|
|
87
87
|
const isFF = typeof UA == "string" && UA.match(/firefox\/(\d+)/);
|
|
88
|
-
const isMobile = navigator.userAgent.toLowerCase().includes("mobile");
|
|
88
|
+
const isMobile = isBrowser && navigator.userAgent.toLowerCase().includes("mobile");
|
|
89
89
|
|
|
90
90
|
const analyUnit = (size, unit = "px") => {
|
|
91
91
|
return isString(size) && /\D/g.test(size) ? size : size + unit;
|
package/index.iife.js
CHANGED
|
@@ -82,14 +82,14 @@
|
|
|
82
82
|
const UA = isBrowser && window.navigator.userAgent.toLowerCase();
|
|
83
83
|
const isIE = UA && /msie|trident/.test(UA);
|
|
84
84
|
const isIE9 = UA && UA.indexOf("msie 9.0") > 0;
|
|
85
|
-
const isIE11 = navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
|
|
85
|
+
const isIE11 = isBrowser && navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
|
|
86
86
|
const isEdge = UA && UA.indexOf("edge/") > 0;
|
|
87
87
|
const isAndroid = UA && UA.indexOf("android") > 0 || weexPlatform === "android";
|
|
88
88
|
const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA) || weexPlatform === "ios";
|
|
89
89
|
const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
|
|
90
90
|
const isPhantomJS = UA && /phantomjs/.test(UA);
|
|
91
91
|
const isFF = typeof UA == "string" && UA.match(/firefox\/(\d+)/);
|
|
92
|
-
const isMobile = navigator.userAgent.toLowerCase().includes("mobile");
|
|
92
|
+
const isMobile = isBrowser && navigator.userAgent.toLowerCase().includes("mobile");
|
|
93
93
|
|
|
94
94
|
const analyUnit = (size, unit = "px") => {
|
|
95
95
|
return lodash.isString(size) && /\D/g.test(size) ? size : size + unit;
|
package/index.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r,t){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(r);const a=(e,r,t)=>{t=Math.max(Math.min(Number(t),1),0);const i=parseInt(e.slice(1,3),16),o=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16),n=parseInt(r.slice(1,3),16),s=parseInt(r.slice(3,5),16),l=parseInt(r.slice(5,7),16);let c=Math.round(i*(1-t)+n*t),p=Math.round(o*(1-t)+s*t),f=Math.round(a*(1-t)+l*t);return c=("0"+(c||0).toString(16)).slice(-2),p=("0"+(p||0).toString(16)).slice(-2),f=("0"+(f||0).toString(16)).slice(-2),"#"+c+p+f},n=(e,r)=>{const t="rgba("+parseInt("0x"+e.slice(1,3))+","+parseInt("0x"+e.slice(3,5))+","+parseInt("0x"+e.slice(5,7))+","+r+")";return{red:parseInt("0x"+e.slice(1,3)),green:parseInt("0x"+e.slice(3,5)),blue:parseInt("0x"+e.slice(5,7)),rgba:t}},s="undefined"!=typeof window,l="undefined"!=typeof WXEnvironment&&!!WXEnvironment.platform,c=l&&WXEnvironment.platform.toLowerCase(),p=s&&window.navigator.userAgent.toLowerCase(),f=p&&/msie|trident/.test(p),d=p&&p.indexOf("msie 9.0")>0,m=navigator.userAgent.includes("Trident")&&navigator.userAgent.includes("rv:11.0"),g=p&&p.indexOf("edge/")>0,u=p&&p.indexOf("android")>0||"android"===c,y=p&&/iphone|ipad|ipod|ios/.test(p)||"ios"===c,h=p&&/chrome\/\d+/.test(p)&&!g,b=p&&/phantomjs/.test(p),w="string"==typeof p&&p.match(/firefox\/(\d+)/),C=navigator.userAgent.toLowerCase().includes("mobile"),j=(e,r="px")=>t.isString(e)&&/\D/g.test(e)?e:e+r,x="undefined"!=typeof window,O=(e,r,i=!1)=>{i&&t.forIn(e,((o,a)=>{t.isObject(o)&&(e[a]=O(e[a],r,i))}));const o=t.pickBy(e,(e=>!r.includes(e)));return Array.isArray(e)?Object.values(o):o};e.UA=p,e.analySize=(e,r)=>"string"==typeof e||"number"==typeof e?{width:j(e,r),height:j(e,r)}:Array.isArray(e)?{width:j(e[0],r),height:j(e[1],r)}:"object"==typeof e?{width:j(e.width,r),height:j(e.height,r)}:{width:"",height:""},e.analyUnit=j,e.assert=(e,...r)=>(e||console.warn(...r),e),e.awaitPromise=(e=1e3)=>new Promise((r=>setTimeout(r,e))),e.blendColor=a,e.capitalizeCamelCase=e=>{let r=t.camelCase(e);return r=r.slice(0,1).toLocaleUpperCase()+r.slice(1),r},e.checkedTypeof=e=>Object.prototype.toString.call(e).slice(8,-1),e.formDataToObject=e=>Object.fromEntries(e.entries()),e.formatClearHtml=e=>e.replace(/<[!/]*[^<>]*>/gi,""),e.formatCoverPhone=e=>e.replace(/^(\d{3})\d{4}(\d{4})$/,"$1****$2"),e.formatInteger=e=>e.replace(/^(0+)|\D+/g,""),e.formatPrice=e=>e.replace(/^[^\d+]/,"").replace(/[^\d,.{|}]/g,"").replace(".","$#$").replace(/\./g,"").replace("$#$",".").replace(/\.{2,}/g,".").replace(/^(-)*(\d+)\.(\d\d).*$/,"$1$2.$3"),e.formatThousandBitSeparator=(e,r=",")=>{if(""===e)return"";const t=String(e).split(".");for(let e=0;e<t.length;e++)t[e]=t[e].replace(new RegExp("(\\d)(?=(\\d{3})+$)","ig"),`$1${r||""}`);return t.join(".")},e.formatUnix=(e,r="YYYY-MM-DD HH:mm:ss")=>o.default.unix(e).format(r),e.fuseThemeColor=e=>({"primaryColorLight-2":a("#ffffff",e,.8),"primaryColorLight-4":a("#ffffff",e,.6),"primaryColorLight-6":a("#ffffff",e,.4),"primaryColorLight-8":a("#ffffff",e,.2),"primaryColorDark-2":a("#000000",e,.8),"primaryColorDark-4":a("#000000",e,.6),"primaryColorDark-6":a("#000000",e,.4),"primaryColorDark-8":a("#000000",e,.2),"primaryColorOpacity-2":n(e,.8).rgba,"primaryColorOpacity-4":n(e,.6).rgba,"primaryColorOpacity-6":n(e,.4).rgba,"primaryColorOpacity-8":n(e,.2).rgba}),e.generateArray=(e,r)=>(e=Number(e),r=(r=Number(r))>e?r:e,[...new Array(r+1).keys()].slice(e)),e.hexToRgba=n,e.isAndroid=u,e.isBrowser=s,e.isChrome=h,e.isClient=x,e.isEdge=g,e.isFF=w,e.isFormData=e=>t.isObject(e)&&e instanceof FormData,e.isIE=f,e.isIE11=m,e.isIE9=d,e.isIOS=y,e.isMobile=C,e.isPhantomJS=b,e.isWeex=l,e.isWindow=e=>"undefined"!=typeof window&&"[object Window]"===toString.call(e),e.noop=()=>{},e.objectFlat=(e,r=1)=>{const i=(e,r=1)=>{let o={};for(const[a,n]of Object.entries(e))t.isPlainObject(n)?o={...o,...r>0?i(n,r-1):n}:o[a]=n;return o};return i(e,r)},e.objectToFormData=e=>{const r=new FormData;for(const[t,i]of Object.entries(e))r.append(t,i);return r},e.pickByParams=O,e.prefixZero=(e,r=2)=>(new Array(r).join("0")+e).slice(-r),e.urlParamsAnaly=(e,r)=>{const t=Object.keys(r).map((e=>`${e}=${r[e]}`));return t.length>0&&(e+="?"+t.join("&")),e},e.weexPlatform=c,Object.defineProperty(e,"__esModule",{value:!0})}(this.hairyUtils=this.hairyUtils||{},dayjs,_);
|
|
1
|
+
!function(e,r,t){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(r);const a=(e,r,t)=>{t=Math.max(Math.min(Number(t),1),0);const i=parseInt(e.slice(1,3),16),o=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16),n=parseInt(r.slice(1,3),16),s=parseInt(r.slice(3,5),16),l=parseInt(r.slice(5,7),16);let c=Math.round(i*(1-t)+n*t),p=Math.round(o*(1-t)+s*t),f=Math.round(a*(1-t)+l*t);return c=("0"+(c||0).toString(16)).slice(-2),p=("0"+(p||0).toString(16)).slice(-2),f=("0"+(f||0).toString(16)).slice(-2),"#"+c+p+f},n=(e,r)=>{const t="rgba("+parseInt("0x"+e.slice(1,3))+","+parseInt("0x"+e.slice(3,5))+","+parseInt("0x"+e.slice(5,7))+","+r+")";return{red:parseInt("0x"+e.slice(1,3)),green:parseInt("0x"+e.slice(3,5)),blue:parseInt("0x"+e.slice(5,7)),rgba:t}},s="undefined"!=typeof window,l="undefined"!=typeof WXEnvironment&&!!WXEnvironment.platform,c=l&&WXEnvironment.platform.toLowerCase(),p=s&&window.navigator.userAgent.toLowerCase(),f=p&&/msie|trident/.test(p),d=p&&p.indexOf("msie 9.0")>0,m=s&&navigator.userAgent.includes("Trident")&&navigator.userAgent.includes("rv:11.0"),g=p&&p.indexOf("edge/")>0,u=p&&p.indexOf("android")>0||"android"===c,y=p&&/iphone|ipad|ipod|ios/.test(p)||"ios"===c,h=p&&/chrome\/\d+/.test(p)&&!g,b=p&&/phantomjs/.test(p),w="string"==typeof p&&p.match(/firefox\/(\d+)/),C=s&&navigator.userAgent.toLowerCase().includes("mobile"),j=(e,r="px")=>t.isString(e)&&/\D/g.test(e)?e:e+r,x="undefined"!=typeof window,O=(e,r,i=!1)=>{i&&t.forIn(e,((o,a)=>{t.isObject(o)&&(e[a]=O(e[a],r,i))}));const o=t.pickBy(e,(e=>!r.includes(e)));return Array.isArray(e)?Object.values(o):o};e.UA=p,e.analySize=(e,r)=>"string"==typeof e||"number"==typeof e?{width:j(e,r),height:j(e,r)}:Array.isArray(e)?{width:j(e[0],r),height:j(e[1],r)}:"object"==typeof e?{width:j(e.width,r),height:j(e.height,r)}:{width:"",height:""},e.analyUnit=j,e.assert=(e,...r)=>(e||console.warn(...r),e),e.awaitPromise=(e=1e3)=>new Promise((r=>setTimeout(r,e))),e.blendColor=a,e.capitalizeCamelCase=e=>{let r=t.camelCase(e);return r=r.slice(0,1).toLocaleUpperCase()+r.slice(1),r},e.checkedTypeof=e=>Object.prototype.toString.call(e).slice(8,-1),e.formDataToObject=e=>Object.fromEntries(e.entries()),e.formatClearHtml=e=>e.replace(/<[!/]*[^<>]*>/gi,""),e.formatCoverPhone=e=>e.replace(/^(\d{3})\d{4}(\d{4})$/,"$1****$2"),e.formatInteger=e=>e.replace(/^(0+)|\D+/g,""),e.formatPrice=e=>e.replace(/^[^\d+]/,"").replace(/[^\d,.{|}]/g,"").replace(".","$#$").replace(/\./g,"").replace("$#$",".").replace(/\.{2,}/g,".").replace(/^(-)*(\d+)\.(\d\d).*$/,"$1$2.$3"),e.formatThousandBitSeparator=(e,r=",")=>{if(""===e)return"";const t=String(e).split(".");for(let e=0;e<t.length;e++)t[e]=t[e].replace(new RegExp("(\\d)(?=(\\d{3})+$)","ig"),`$1${r||""}`);return t.join(".")},e.formatUnix=(e,r="YYYY-MM-DD HH:mm:ss")=>o.default.unix(e).format(r),e.fuseThemeColor=e=>({"primaryColorLight-2":a("#ffffff",e,.8),"primaryColorLight-4":a("#ffffff",e,.6),"primaryColorLight-6":a("#ffffff",e,.4),"primaryColorLight-8":a("#ffffff",e,.2),"primaryColorDark-2":a("#000000",e,.8),"primaryColorDark-4":a("#000000",e,.6),"primaryColorDark-6":a("#000000",e,.4),"primaryColorDark-8":a("#000000",e,.2),"primaryColorOpacity-2":n(e,.8).rgba,"primaryColorOpacity-4":n(e,.6).rgba,"primaryColorOpacity-6":n(e,.4).rgba,"primaryColorOpacity-8":n(e,.2).rgba}),e.generateArray=(e,r)=>(e=Number(e),r=(r=Number(r))>e?r:e,[...new Array(r+1).keys()].slice(e)),e.hexToRgba=n,e.isAndroid=u,e.isBrowser=s,e.isChrome=h,e.isClient=x,e.isEdge=g,e.isFF=w,e.isFormData=e=>t.isObject(e)&&e instanceof FormData,e.isIE=f,e.isIE11=m,e.isIE9=d,e.isIOS=y,e.isMobile=C,e.isPhantomJS=b,e.isWeex=l,e.isWindow=e=>"undefined"!=typeof window&&"[object Window]"===toString.call(e),e.noop=()=>{},e.objectFlat=(e,r=1)=>{const i=(e,r=1)=>{let o={};for(const[a,n]of Object.entries(e))t.isPlainObject(n)?o={...o,...r>0?i(n,r-1):n}:o[a]=n;return o};return i(e,r)},e.objectToFormData=e=>{const r=new FormData;for(const[t,i]of Object.entries(e))r.append(t,i);return r},e.pickByParams=O,e.prefixZero=(e,r=2)=>(new Array(r).join("0")+e).slice(-r),e.urlParamsAnaly=(e,r)=>{const t=Object.keys(r).map((e=>`${e}=${r[e]}`));return t.length>0&&(e+="?"+t.join("&")),e},e.weexPlatform=c,Object.defineProperty(e,"__esModule",{value:!0})}(this.hairyUtils=this.hairyUtils||{},dayjs,_);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hairy/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"dayjs": "^1.10.6",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"./*": "./*"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "3bdb75dc5cd49def822404c98aac6d64bec825eb",
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
}
|