@lntvow/utils 1.8.21 → 1.8.23
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 +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +26 -22
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function S(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function l(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function S(){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,f=t=>a.call(t),w=(...t)=>console.log(`%c ${t[0]} `,"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",t.slice(1).length>0?t.slice(1):""),A=(...t)=>console.warn(...t),E=(...t)=>console.error(...t),C=t=>f(t)==="[object Map]",$=t=>f(t)==="[object Set]",g=t=>f(t)==="[object Date]",h=t=>f(t)==="[object RegExp]",p=t=>typeof t=="function",j=t=>typeof t=="string",M=t=>typeof t=="symbol",u=t=>t!==null&&typeof t=="object",U=t=>u(t)&&p(t.then)&&p(t.catch),c=t=>t==null,P=t=>t===void 0,b=t=>t===null;function N(t){return t!=null}function R(t){return typeof t=="boolean"}const d=Array.isArray,m=(t,e)=>Object.hasOwn(t,e),D=(t,e)=>t!==e;function O(t){const e=new WeakMap;function r(n){if(g(n))return new Date(n);if(h(n))return new RegExp(n);if(u(n)){if(e.has(n))return e.get(n);let s={};if(d(n)){s=[],e.set(n,s);for(let i=0;i<n.length;i++)s[i]=r(n[i]);return s}e.set(n,s);for(const i in n)m(n,i)&&(s[i]=r(n[i]));return s}else return n}return r(t)}function y(t,e,r){return d(t)?Z(t,e,r):T(t,e,r)}function T(t,e,r){const n=o(e,r);return Object.keys(t).forEach(i=>{c(e[i])?n[i]=o(t[i],r):n[i]=u(t[i])&&u(e[i])?y(t[i],e[i],r):o(e[i],r)}),n}function Z(t,e,r){if(d(e)){const n=o(e,r);return n.push(...o(t,r)),n}else return o(t,r)}function o(t,e){const{isDeepClone:r=!0}=e||{};return r?O(t):t}function x(t,e=1e3){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{t.apply(this,n)},e)}}function F(t,e=1e3){let r=null;return function(...n){if(b(r))return r=Date.now(),t.apply(this,n);{const s=Date.now();if(s-r>=e)return r=s,t.apply(this,n)}}}function L(...t){return t.reduce((e,r)=>function(...n){return r(e(...n))})}function I(...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 _(t){return/^([\w-])+@([\w-])+(.[\w-])+/.test(t)}function B(t){return/^[A-Z]+$/.test(t)}function K(t){return!c(t)&&/^[a-z]+$/.test(t)}function W(t){return/^\d+$/.test(t)}function q(t){return/^-?\d{1,3}\.\d{6}$/.test(t)}function G(t){return t===""}function H(t){return!c(t)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(t)}function J(t){return!c(t)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(t)}function Q(t){return!c(t)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(t)}function V(t){return/^[\dA-Z_]+$/.test(t)}function X(t){return/^[1-9]\d*$/.test(t)}function Y(t){return/^\d+$/.test(t)}function k(t){return/^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(t)}function v(t){return Array.isArray(t)?t:[t]}exports.castArray=v;exports.compose=L;exports.composeRight=I;exports.debounce=x;exports.deepClone=O;exports.deepMerge=y;exports.error=E;exports.getRandomColor=S;exports.getRandomString=l;exports.hasChanged=D;exports.hasOwn=m;exports.isArray=d;exports.isBoolean=R;exports.isChineseOrEnglish=J;exports.isChineseOrEnglishOrNumber=H;exports.isDate=g;exports.isDef=N;exports.isEmail=_;exports.isEmptyString=G;exports.isFunction=p;exports.isLatitudeOrLongitude=q;exports.isLowerCase=K;exports.isMap=C;exports.isMobilePhone=z;exports.isNull=b;exports.isNumber=W;exports.isObject=u;exports.isPositiveFloat=k;exports.isPositiveInt=X;exports.isPositiveIntAndZero=Y;exports.isPromise=U;exports.isRegExp=h;exports.isSet=$;exports.isString=j;exports.isSymbol=M;exports.isUndef=c;exports.isUndefined=P;exports.isUpperCase=B;exports.isUppercaseOrNumbersOrSpecial=Q;exports.isUppercaseOrNumbersOrUnderline=V;exports.log=w;exports.objectToString=a;exports.throttle=F;exports.toTypeString=f;exports.warn=A;
|
package/dist/index.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ export declare function isChineseOrEnglishOrNumber(value: string): boolean;
|
|
|
79
79
|
|
|
80
80
|
export declare const isDate: (val: unknown) => val is Date;
|
|
81
81
|
|
|
82
|
-
export declare function isDef<T>(
|
|
82
|
+
export declare function isDef<T>(val: T): val is NonNullable<T>;
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* @description 校验邮箱
|
|
@@ -129,6 +129,11 @@ export declare function isPositiveFloat(value: string): boolean;
|
|
|
129
129
|
*/
|
|
130
130
|
export declare function isPositiveInt(value: string): boolean;
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* @description 校验大于0的整数
|
|
134
|
+
*/
|
|
135
|
+
export declare function isPositiveIntAndZero(value: string): boolean;
|
|
136
|
+
|
|
132
137
|
export declare const isPromise: <T = any>(val: unknown) => val is Promise<T>;
|
|
133
138
|
|
|
134
139
|
export declare const isRegExp: (val: unknown) => val is RegExp;
|
package/dist/index.mjs
CHANGED
|
@@ -4,22 +4,22 @@ function A() {
|
|
|
4
4
|
function p(n) {
|
|
5
5
|
return n > 10 ? p(10) + p(n - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, n + 2);
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const g = Object.prototype.toString, f = (n) => g.call(n), E = (...n) => console.log(
|
|
8
8
|
`%c ${n[0]} `,
|
|
9
9
|
"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
|
|
10
10
|
n.slice(1).length > 0 ? n.slice(1) : ""
|
|
11
|
-
), S = (...n) => console.warn(...n), j = (...n) => console.error(...n), C = (n) => f(n) === "[object Map]", M = (n) => f(n) === "[object Set]",
|
|
12
|
-
function
|
|
11
|
+
), S = (...n) => console.warn(...n), j = (...n) => console.error(...n), C = (n) => f(n) === "[object Map]", M = (n) => f(n) === "[object Set]", a = (n) => f(n) === "[object Date]", h = (n) => f(n) === "[object RegExp]", l = (n) => typeof n == "function", D = (n) => typeof n == "string", x = (n) => typeof n == "symbol", u = (n) => n !== null && typeof n == "object", R = (n) => u(n) && l(n.then) && l(n.catch), c = (n) => n == null, U = (n) => n === void 0, b = (n) => n === null;
|
|
12
|
+
function Z(n) {
|
|
13
13
|
return n != null;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function N(n) {
|
|
16
16
|
return typeof n == "boolean";
|
|
17
17
|
}
|
|
18
|
-
const d = Array.isArray, y = (n, e) => Object.hasOwn(n, e),
|
|
18
|
+
const d = Array.isArray, y = (n, e) => Object.hasOwn(n, e), P = (n, e) => n !== e;
|
|
19
19
|
function m(n) {
|
|
20
20
|
const e = /* @__PURE__ */ new WeakMap();
|
|
21
21
|
function r(t) {
|
|
22
|
-
if (
|
|
22
|
+
if (a(t))
|
|
23
23
|
return new Date(t);
|
|
24
24
|
if (h(t))
|
|
25
25
|
return new RegExp(t);
|
|
@@ -62,7 +62,7 @@ function s(n, e) {
|
|
|
62
62
|
const { isDeepClone: r = !0 } = e || {};
|
|
63
63
|
return r ? m(n) : n;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function F(n, e = 1e3) {
|
|
66
66
|
let r = null;
|
|
67
67
|
return function(...t) {
|
|
68
68
|
r && clearTimeout(r), r = setTimeout(() => {
|
|
@@ -97,13 +97,13 @@ function _(n) {
|
|
|
97
97
|
n
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function I(n) {
|
|
101
101
|
return /^([\w-])+@([\w-])+(.[\w-])+/.test(n);
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function K(n) {
|
|
104
104
|
return /^[A-Z]+$/.test(n);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function B(n) {
|
|
107
107
|
return !c(n) && /^[a-z]+$/.test(n);
|
|
108
108
|
}
|
|
109
109
|
function W(n) {
|
|
@@ -131,41 +131,45 @@ function X(n) {
|
|
|
131
131
|
return /^[1-9]\d*$/.test(n);
|
|
132
132
|
}
|
|
133
133
|
function Y(n) {
|
|
134
|
-
return
|
|
134
|
+
return /^\d+$/.test(n);
|
|
135
135
|
}
|
|
136
136
|
function k(n) {
|
|
137
|
+
return /^(0*[1-9]+\d*\.?\d*|0+\.\d*[1-9]+\d*)$/.test(n);
|
|
138
|
+
}
|
|
139
|
+
function v(n) {
|
|
137
140
|
return Array.isArray(n) ? n : [n];
|
|
138
141
|
}
|
|
139
142
|
export {
|
|
140
|
-
|
|
143
|
+
v as castArray,
|
|
141
144
|
z as compose,
|
|
142
145
|
L as composeRight,
|
|
143
|
-
|
|
146
|
+
F as debounce,
|
|
144
147
|
m as deepClone,
|
|
145
148
|
w as deepMerge,
|
|
146
149
|
j as error,
|
|
147
150
|
A as getRandomColor,
|
|
148
151
|
p as getRandomString,
|
|
149
|
-
|
|
152
|
+
P as hasChanged,
|
|
150
153
|
y as hasOwn,
|
|
151
154
|
d as isArray,
|
|
152
|
-
|
|
155
|
+
N as isBoolean,
|
|
153
156
|
J as isChineseOrEnglish,
|
|
154
157
|
H as isChineseOrEnglishOrNumber,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
a as isDate,
|
|
159
|
+
Z as isDef,
|
|
160
|
+
I as isEmail,
|
|
158
161
|
G as isEmptyString,
|
|
159
162
|
l as isFunction,
|
|
160
163
|
q as isLatitudeOrLongitude,
|
|
161
|
-
|
|
164
|
+
B as isLowerCase,
|
|
162
165
|
C as isMap,
|
|
163
166
|
_ as isMobilePhone,
|
|
164
167
|
b as isNull,
|
|
165
168
|
W as isNumber,
|
|
166
169
|
u as isObject,
|
|
167
|
-
|
|
170
|
+
k as isPositiveFloat,
|
|
168
171
|
X as isPositiveInt,
|
|
172
|
+
Y as isPositiveIntAndZero,
|
|
169
173
|
R as isPromise,
|
|
170
174
|
h as isRegExp,
|
|
171
175
|
M as isSet,
|
|
@@ -173,11 +177,11 @@ export {
|
|
|
173
177
|
x as isSymbol,
|
|
174
178
|
c as isUndef,
|
|
175
179
|
U as isUndefined,
|
|
176
|
-
|
|
180
|
+
K as isUpperCase,
|
|
177
181
|
Q as isUppercaseOrNumbersOrSpecial,
|
|
178
182
|
V as isUppercaseOrNumbersOrUnderline,
|
|
179
183
|
E as log,
|
|
180
|
-
|
|
184
|
+
g as objectToString,
|
|
181
185
|
T as throttle,
|
|
182
186
|
f as toTypeString,
|
|
183
187
|
S as warn
|