@lntvow/utils 1.8.2 → 1.8.3

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function j(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function l(n){return n>10?l(10)+l(n-10):Math.random().toString(36).padEnd(12,"0").slice(2,n+2)}const p=Object.prototype.toString,f=n=>p.call(n),w=(...n)=>console.log(`%c ${n[0]}: `,"padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",n.slice(1)),x=(...n)=>console.warn(...n),M=(...n)=>console.error(...n),O=n=>f(n)==="[object Map]",R=n=>f(n)==="[object Set]",d=n=>f(n)==="[object Date]",a=n=>f(n)==="[object RegExp]",g=n=>typeof n=="function",D=n=>typeof n=="string",C=n=>typeof n=="symbol",c=n=>n!==null&&typeof n=="object",E=n=>c(n)&&g(n.then)&&g(n.catch),h=n=>n==null,b=n=>n===null;function T(n){return n!=null}function A(n){return typeof n=="boolean"}const u=Array.isArray,S=(n,e)=>Object.hasOwn(n,e),P=(n,e)=>n!==e;function y(n){const e=new WeakMap;function o(t){if(d(t))return new Date(t);if(a(t))return new RegExp(t);if(c(t)){if(e.has(t))return e.get(t);let i={};if(u(t)){i=[],e.set(t,i);for(let r=0;r<t.length;r++)i[r]=o(t[r]);return i}e.set(t,i);for(const r in t)S(t,r)&&(i[r]=o(t[r]));return i}else return t}return o(n)}function m(n,e,o){return u(n)?F(n,e,o):B(n,e,o)}function B(n,e,o){const t=s(e,o);return Object.keys(n).forEach(r=>{h(e[r])?t[r]=s(n[r],o):t[r]=c(n[r])&&c(e[r])?m(n[r],e[r],o):s(e[r],o)}),t}function F(n,e,o){if(u(e)){const t=s(e,o);return t.push(...s(n,o)),t}else return s(n,o)}function s(n,e){const{isDeepClone:o=!0}=e||{};return o?y(n):n}function K(n,e=1e3){let o=null;return function(...t){o&&clearTimeout(o),o=setTimeout(()=>{n.apply(this,...t)},e)}}function N(n,e=1e3){let o=null;return function(...t){if(b(o))return o=Date.now(),n.apply(this,...t);{const i=Date.now();if(i-o>=e)return o=i,n.apply(this,...t)}}}function U(...n){return n.reduce((e,o)=>function(...t){return o(e(...t))})}function $(...n){return n.reduce((e,o)=>function(...t){return e(o(...t))})}exports.compose=U;exports.composeRight=$;exports.debounce=K;exports.deepClone=y;exports.deepMerge=m;exports.error=M;exports.getRandomColor=j;exports.getRandomString=l;exports.hasChanged=P;exports.hasOwn=S;exports.isArray=u;exports.isBoolean=A;exports.isDate=d;exports.isDef=T;exports.isFunction=g;exports.isMap=O;exports.isNull=b;exports.isObject=c;exports.isPromise=E;exports.isRegExp=a;exports.isSet=R;exports.isString=D;exports.isSymbol=C;exports.isUndef=h;exports.log=w;exports.objectToString=p;exports.throttle=N;exports.toTypeString=f;exports.warn=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function w(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function l(t){return t>10?l(10)+l(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const a=Object.prototype.toString,u=t=>a.call(t),y=(...t)=>console.log(`%c ${t[0]}: `,"padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",t.slice(1)),C=(...t)=>console.warn(...t),E=(...t)=>console.error(...t),j=t=>u(t)==="[object Map]",A=t=>u(t)==="[object Set]",p=t=>u(t)==="[object Date]",g=t=>u(t)==="[object RegExp]",d=t=>typeof t=="function",$=t=>typeof t=="string",x=t=>typeof t=="symbol",c=t=>t!==null&&typeof t=="object",M=t=>c(t)&&d(t.then)&&d(t.catch),h=t=>t==null,b=t=>t===null;function R(t){return t!=null}function D(t){return typeof t=="boolean"}const f=Array.isArray,m=(t,e)=>Object.hasOwn(t,e),P=(t,e)=>t!==e;function O(t){const e=new WeakMap;function r(n){if(p(n))return new Date(n);if(g(n))return new RegExp(n);if(c(n)){if(e.has(n))return e.get(n);let o={};if(f(n)){o=[],e.set(n,o);for(let i=0;i<n.length;i++)o[i]=r(n[i]);return o}e.set(n,o);for(const i in n)m(n,i)&&(o[i]=r(n[i]));return o}else return n}return r(t)}function S(t,e,r){return f(t)?N(t,e,r):T(t,e,r)}function T(t,e,r){const n=s(e,r);return Object.keys(t).forEach(i=>{h(e[i])?n[i]=s(t[i],r):n[i]=c(t[i])&&c(e[i])?S(t[i],e[i],r):s(e[i],r)}),n}function N(t,e,r){if(f(e)){const n=s(e,r);return n.push(...s(t,r)),n}else return s(t,r)}function s(t,e){const{isDeepClone:r=!0}=e||{};return r?O(t):t}function F(t,e=1e3){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{t.apply(this,...n)},e)}}function L(t,e=1e3){let r=null;return function(...n){if(b(r))return r=Date.now(),t.apply(this,...n);{const o=Date.now();if(o-r>=e)return r=o,t.apply(this,...n)}}}function U(...t){return t.reduce((e,r)=>function(...n){return r(e(...n))})}function Z(...t){return t.reduce((e,r)=>function(...n){return e(r(...n))})}function z(t){return/^(?:(?:\+|00)86)?1(?:(?:3\d)|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8\d)|(?:9[1589]))\d{8}$/.test(t)}function B(t){return/^([\w-])+@([\w-])+(.[\w-])+/.test(t)}function I(t){return/^[A-Z]+$/.test(t)}function K(t){return/^[a-z]+$/.test(t)}function W(t){return/^\d+$/.test(t)}function _(t){return/^-?\d{1,3}\.\d{6}$/.test(t)}function q(t){return/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function G(t){return/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function H(t){return/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function J(t){return/^[\d!#$%&*@A-Z^]+$/.test(t)}function Q(t){return/^[1-9]\d*$/.test(t)}function V(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}exports.compose=U;exports.composeRight=Z;exports.debounce=F;exports.deepClone=O;exports.deepMerge=S;exports.error=E;exports.getRandomColor=w;exports.getRandomString=l;exports.hasChanged=P;exports.hasOwn=m;exports.isAlphanumericText=q;exports.isArray=f;exports.isBoolean=D;exports.isChineseOrEnglish=G;exports.isChineseOrEnglishOrNumber=H;exports.isDate=p;exports.isDef=R;exports.isEmail=B;exports.isFunction=d;exports.isLatitudeOrLongitude=_;exports.isLowerCase=K;exports.isMap=j;exports.isMobilePhone=z;exports.isNull=b;exports.isNumber=W;exports.isObject=c;exports.isPositiveFloat=V;exports.isPositiveInt=Q;exports.isPromise=M;exports.isRegExp=g;exports.isSet=A;exports.isString=$;exports.isSymbol=x;exports.isUndef=h;exports.isUpperCase=I;exports.isUppercaseOrNumbersOrSpecial=J;exports.log=y;exports.objectToString=a;exports.throttle=L;exports.toTypeString=u;exports.warn=C;
package/dist/index.d.ts CHANGED
@@ -61,22 +61,72 @@ export declare const hasChanged: (oldValue: unknown, newValue: unknown) => boole
61
61
 
62
62
  export declare const hasOwn: <T extends object, U extends keyof T>(target: T, key: U) => boolean;
63
63
 
64
+ /**
65
+ * @description 校验中英文、数字
66
+ */
67
+ export declare function isAlphanumericText(value: string): boolean;
68
+
64
69
  export declare const isArray: (arg: any) => arg is any[];
65
70
 
66
71
  export declare function isBoolean(val: unknown): val is boolean;
67
72
 
73
+ /**
74
+ * @description 校验中英文
75
+ */
76
+ export declare function isChineseOrEnglish(value: string): boolean;
77
+
78
+ /**
79
+ * @description 校验中文、字母、数字
80
+ */
81
+ export declare function isChineseOrEnglishOrNumber(value: string): boolean;
82
+
68
83
  export declare const isDate: (val: unknown) => val is Date;
69
84
 
70
85
  export declare function isDef<T>(v: T): v is NonNullable<T>;
71
86
 
87
+ /**
88
+ * @description 校验邮箱
89
+ */
90
+ export declare function isEmail(value: string): boolean;
91
+
72
92
  export declare const isFunction: (val: unknown) => val is Function;
73
93
 
94
+ /**
95
+ * @description 校验经纬度
96
+ */
97
+ export declare function isLatitudeOrLongitude(value: string): boolean;
98
+
99
+ /**
100
+ * @description 校验小写字母
101
+ */
102
+ export declare function isLowerCase(value: string): boolean;
103
+
74
104
  export declare const isMap: (val: unknown) => val is Map<any, any>;
75
105
 
106
+ /**
107
+ * @description 校验手机号
108
+ */
109
+ export declare function isMobilePhone(value: string): boolean;
110
+
76
111
  export declare const isNull: (val: unknown) => val is null;
77
112
 
113
+ /**
114
+ * @description 校验校验数字
115
+ */
116
+ export declare function isNumber(value: string): boolean;
117
+
78
118
  export declare const isObject: (val: unknown) => val is Record<any, any>;
79
119
 
120
+ /**
121
+ * @description 校验正浮点数
122
+ */
123
+ export declare function isPositiveFloat(value: string): boolean;
124
+
125
+ /**
126
+ * @description 校验正整数
127
+ */
128
+ export declare function isPositiveInt(value: string): boolean;
129
+
80
130
  export declare const isPromise: <T = any>(val: unknown) => val is Promise<T>;
81
131
 
82
132
  export declare const isRegExp: (val: unknown) => val is RegExp;
@@ -89,6 +139,16 @@ export declare const isSymbol: (val: unknown) => val is symbol;
89
139
 
90
140
  export declare const isUndef: (val: unknown) => val is null | undefined;
91
141
 
142
+ /**
143
+ * @description 校验大写字母
144
+ */
145
+ export declare function isUpperCase(value: string): boolean;
146
+
147
+ /**
148
+ * @description 校验大写字母、数字、特殊字符
149
+ */
150
+ export declare function isUppercaseOrNumbersOrSpecial(value: string): boolean;
151
+
92
152
  export declare const log: (...arg: unknown[]) => void;
93
153
 
94
154
  export declare const objectToString: () => string;
package/dist/index.mjs CHANGED
@@ -1,125 +1,175 @@
1
- function m() {
1
+ function A() {
2
2
  return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
3
3
  }
4
- function p(n) {
5
- return n > 10 ? p(10) + p(n - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, n + 2);
4
+ function d(t) {
5
+ return t > 10 ? d(10) + d(t - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, t + 2);
6
6
  }
7
- const d = Object.prototype.toString, f = (n) => d.call(n), D = (...n) => console.log(
8
- `%c ${n[0]}: `,
7
+ const l = Object.prototype.toString, u = (t) => l.call(t), E = (...t) => console.log(
8
+ `%c ${t[0]}: `,
9
9
  "padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",
10
- n.slice(1)
11
- ), M = (...n) => console.warn(...n), O = (...n) => console.error(...n), E = (n) => f(n) === "[object Map]", R = (n) => f(n) === "[object Set]", g = (n) => f(n) === "[object Date]", h = (n) => f(n) === "[object RegExp]", l = (n) => typeof n == "function", C = (n) => typeof n == "string", T = (n) => typeof n == "symbol", s = (n) => n !== null && typeof n == "object", A = (n) => s(n) && l(n.then) && l(n.catch), a = (n) => n == null, b = (n) => n === null;
12
- function K(n) {
13
- return n != null;
10
+ t.slice(1)
11
+ ), j = (...t) => console.warn(...t), x = (...t) => console.error(...t), S = (t) => u(t) === "[object Map]", C = (t) => u(t) === "[object Set]", a = (t) => u(t) === "[object Date]", g = (t) => u(t) === "[object RegExp]", p = (t) => typeof t == "function", M = (t) => typeof t == "string", D = (t) => typeof t == "symbol", c = (t) => t !== null && typeof t == "object", R = (t) => c(t) && p(t.then) && p(t.catch), h = (t) => t == null, b = (t) => t === null;
12
+ function F(t) {
13
+ return t != null;
14
14
  }
15
- function $(n) {
16
- return typeof n == "boolean";
15
+ function T(t) {
16
+ return typeof t == "boolean";
17
17
  }
18
- const u = Array.isArray, y = (n, e) => Object.hasOwn(n, e), B = (n, e) => n !== e;
19
- function j(n) {
18
+ const f = Array.isArray, w = (t, e) => Object.hasOwn(t, e), Z = (t, e) => t !== e;
19
+ function m(t) {
20
20
  const e = /* @__PURE__ */ new WeakMap();
21
- function o(t) {
22
- if (g(t))
23
- return new Date(t);
24
- if (h(t))
25
- return new RegExp(t);
26
- if (s(t)) {
27
- if (e.has(t))
28
- return e.get(t);
29
- let c = {};
30
- if (u(t)) {
31
- c = [], e.set(t, c);
32
- for (let r = 0; r < t.length; r++)
33
- c[r] = o(t[r]);
34
- return c;
21
+ function r(n) {
22
+ if (a(n))
23
+ return new Date(n);
24
+ if (g(n))
25
+ return new RegExp(n);
26
+ if (c(n)) {
27
+ if (e.has(n))
28
+ return e.get(n);
29
+ let i = {};
30
+ if (f(n)) {
31
+ i = [], e.set(n, i);
32
+ for (let o = 0; o < n.length; o++)
33
+ i[o] = r(n[o]);
34
+ return i;
35
35
  }
36
- e.set(t, c);
37
- for (const r in t)
38
- y(t, r) && (c[r] = o(t[r]));
39
- return c;
36
+ e.set(n, i);
37
+ for (const o in n)
38
+ w(n, o) && (i[o] = r(n[o]));
39
+ return i;
40
40
  } else
41
- return t;
41
+ return n;
42
42
  }
43
- return o(n);
43
+ return r(t);
44
44
  }
45
- function w(n, e, o) {
46
- return u(n) ? S(n, e, o) : x(n, e, o);
45
+ function $(t, e, r) {
46
+ return f(t) ? y(t, e, r) : O(t, e, r);
47
47
  }
48
- function x(n, e, o) {
49
- const t = i(e, o);
50
- return Object.keys(n).forEach((r) => {
51
- a(e[r]) ? t[r] = i(n[r], o) : t[r] = s(n[r]) && s(e[r]) ? w(n[r], e[r], o) : i(e[r], o);
52
- }), t;
48
+ function O(t, e, r) {
49
+ const n = s(e, r);
50
+ return Object.keys(t).forEach((o) => {
51
+ h(e[o]) ? n[o] = s(t[o], r) : n[o] = c(t[o]) && c(e[o]) ? $(t[o], e[o], r) : s(e[o], r);
52
+ }), n;
53
53
  }
54
- function S(n, e, o) {
55
- if (u(e)) {
56
- const t = i(e, o);
57
- return t.push(...i(n, o)), t;
54
+ function y(t, e, r) {
55
+ if (f(e)) {
56
+ const n = s(e, r);
57
+ return n.push(...s(t, r)), n;
58
58
  } else
59
- return i(n, o);
59
+ return s(t, r);
60
60
  }
61
- function i(n, e) {
62
- const { isDeepClone: o = !0 } = e || {};
63
- return o ? j(n) : n;
61
+ function s(t, e) {
62
+ const { isDeepClone: r = !0 } = e || {};
63
+ return r ? m(t) : t;
64
64
  }
65
- function F(n, e = 1e3) {
66
- let o = null;
67
- return function(...t) {
68
- o && clearTimeout(o), o = setTimeout(() => {
69
- n.apply(this, ...t);
65
+ function z(t, e = 1e3) {
66
+ let r = null;
67
+ return function(...n) {
68
+ r && clearTimeout(r), r = setTimeout(() => {
69
+ t.apply(this, ...n);
70
70
  }, e);
71
71
  };
72
72
  }
73
- function N(n, e = 1e3) {
74
- let o = null;
75
- return function(...t) {
76
- if (b(o))
77
- return o = Date.now(), n.apply(this, ...t);
73
+ function N(t, e = 1e3) {
74
+ let r = null;
75
+ return function(...n) {
76
+ if (b(r))
77
+ return r = Date.now(), t.apply(this, ...n);
78
78
  {
79
- const c = Date.now();
80
- if (c - o >= e)
81
- return o = c, n.apply(this, ...t);
79
+ const i = Date.now();
80
+ if (i - r >= e)
81
+ return r = i, t.apply(this, ...n);
82
82
  }
83
83
  };
84
84
  }
85
- function P(...n) {
86
- return n.reduce((e, o) => function(...t) {
87
- return o(e(...t));
85
+ function P(...t) {
86
+ return t.reduce((e, r) => function(...n) {
87
+ return r(e(...n));
88
88
  });
89
89
  }
90
- function U(...n) {
91
- return n.reduce((e, o) => function(...t) {
92
- return e(o(...t));
90
+ function L(...t) {
91
+ return t.reduce((e, r) => function(...n) {
92
+ return e(r(...n));
93
93
  });
94
94
  }
95
+ function U(t) {
96
+ return /^(?:(?:\+|00)86)?1(?:(?:3\d)|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8\d)|(?:9[1589]))\d{8}$/.test(
97
+ t
98
+ );
99
+ }
100
+ function K(t) {
101
+ return /^([\w-])+@([\w-])+(.[\w-])+/.test(t);
102
+ }
103
+ function B(t) {
104
+ return /^[A-Z]+$/.test(t);
105
+ }
106
+ function I(t) {
107
+ return /^[a-z]+$/.test(t);
108
+ }
109
+ function W(t) {
110
+ return /^\d+$/.test(t);
111
+ }
112
+ function _(t) {
113
+ return /^-?\d{1,3}\.\d{6}$/.test(t);
114
+ }
115
+ function q(t) {
116
+ return /^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t);
117
+ }
118
+ function G(t) {
119
+ return /^[A-Za-z\u4E00-\u9FA5]+$/.test(t);
120
+ }
121
+ function H(t) {
122
+ return /^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t);
123
+ }
124
+ function J(t) {
125
+ return /^[\d!#$%&*@A-Z^]+$/.test(t);
126
+ }
127
+ function Q(t) {
128
+ return /^[1-9]\d*$/.test(t);
129
+ }
130
+ function V(t) {
131
+ return /^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t);
132
+ }
95
133
  export {
96
134
  P as compose,
97
- U as composeRight,
98
- F as debounce,
99
- j as deepClone,
100
- w as deepMerge,
101
- O as error,
102
- m as getRandomColor,
103
- p as getRandomString,
104
- B as hasChanged,
105
- y as hasOwn,
106
- u as isArray,
107
- $ as isBoolean,
108
- g as isDate,
109
- K as isDef,
110
- l as isFunction,
111
- E as isMap,
135
+ L as composeRight,
136
+ z as debounce,
137
+ m as deepClone,
138
+ $ as deepMerge,
139
+ x as error,
140
+ A as getRandomColor,
141
+ d as getRandomString,
142
+ Z as hasChanged,
143
+ w as hasOwn,
144
+ q as isAlphanumericText,
145
+ f as isArray,
146
+ T as isBoolean,
147
+ G as isChineseOrEnglish,
148
+ H as isChineseOrEnglishOrNumber,
149
+ a as isDate,
150
+ F as isDef,
151
+ K as isEmail,
152
+ p as isFunction,
153
+ _ as isLatitudeOrLongitude,
154
+ I as isLowerCase,
155
+ S as isMap,
156
+ U as isMobilePhone,
112
157
  b as isNull,
113
- s as isObject,
114
- A as isPromise,
115
- h as isRegExp,
116
- R as isSet,
117
- C as isString,
118
- T as isSymbol,
119
- a as isUndef,
120
- D as log,
121
- d as objectToString,
158
+ W as isNumber,
159
+ c as isObject,
160
+ V as isPositiveFloat,
161
+ Q as isPositiveInt,
162
+ R as isPromise,
163
+ g as isRegExp,
164
+ C as isSet,
165
+ M as isString,
166
+ D as isSymbol,
167
+ h as isUndef,
168
+ B as isUpperCase,
169
+ J as isUppercaseOrNumbersOrSpecial,
170
+ E as log,
171
+ l as objectToString,
122
172
  N as throttle,
123
- f as toTypeString,
124
- M as warn
173
+ u as toTypeString,
174
+ j as warn
125
175
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -24,11 +24,6 @@
24
24
  "vitest": "^0.33.0",
25
25
  "vconsole": "^3.15.1"
26
26
  },
27
- "config": {
28
- "commitizen": {
29
- "path": "node_modules/cz-conventional-changelog"
30
- }
31
- },
32
27
  "scripts": {
33
28
  "dev": "vite",
34
29
  "test": "vitest",