@lntvow/utils 2.2.8 → 2.2.9
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.mjs +26 -57
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function M(...e){return e.reduce((t,n)=>function(...r){return n(t(...r))})}function F(...e){return e.reduce((t,n)=>function(...r){return t(n(...r))})}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function M(...e){return e.reduce((t,n)=>function(...r){return n(t(...r))})}function F(...e){return e.reduce((t,n)=>function(...r){return t(n(...r))})}function R(e,t=500){let n=null;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,r)},t)}}const O=Object.prototype.toString,f=e=>O.call(e);let m=null;function P(e){p(e)&&(m=e)}const U=(e,...t)=>{const n=t.length===0?"":t.length===1?t[0]:t;console.log(`%c ${e} `,"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",n),m&&m(e,n)},I=(...e)=>console.warn(...e),Z=(...e)=>console.error(...e),x=e=>f(e)==="[object Map]",j=e=>f(e)==="[object Set]",C=e=>f(e)==="[object Date]",A=e=>f(e)==="[object RegExp]",p=e=>typeof e=="function",L=e=>typeof e=="number",N=e=>typeof e=="string",D=e=>typeof e=="symbol",a=e=>e!==null&&typeof e=="object",T=e=>a(e)&&p(e.then)&&p(e.catch),c=e=>e==null,v=e=>e===void 0,z=e=>e===null,W=e=>e!=null,_=e=>typeof e=="boolean",l=Array.isArray,h=(e,t)=>Object.hasOwn(e,t),q=(e,t)=>e!==t;function b(e){const t=new WeakMap;function n(r){if(C(r))return new Date(r);if(A(r))return new RegExp(r);if(a(r)){if(t.has(r))return t.get(r);let o={};if(l(r)){o=[],t.set(r,o);for(let i=0;i<r.length;i++)o[i]=n(r[i]);return o}t.set(r,o);for(const i in r)h(r,i)&&(o[i]=n(r[i]));return o}else return r}return n(e)}function s(e,t,n){return l(e)?K(e,t,n):B(e,t,n)}function B(e,t,n){const r=u(t,n);return Object.keys(e).forEach(i=>{c(t[i])?r[i]=u(e[i],n):r[i]=a(e[i])&&a(t[i])?s(e[i],t[i],n):u(t[i],n)}),r}function K(e,t,n){if(l(t)){const r=u(t,n);return r.push(...u(e,n)),r}else return u(e,n)}function u(e,t){const{clone:n=!0}=t||{};return n?b(e):e}class w extends Error{constructor(t){super(t),this.name="LntvowError"}}function E(e,t){throw new w(`[${e}] ${t}`)}function G(e,t){if(process.env.NODE_ENV!=="production"){const n=N(e)?new w(`[${e}] ${t}`):e;console.warn(n)}}function Q(e,t){const{decode:n}=s({decode:!0},t||{}),r={};e.startsWith("?")&&(e=e.slice(1)),e.includes("?")&&(e=e.slice(e.indexOf("?")+1));const o=e.split("&").filter(Boolean);for(const i of o){const[g,d]=i.split("=");r[g]=n?decodeURIComponent(d):d}return r}function S(e,t){const{encode:n}=s({encode:!0},t||{}),r=[];for(const o in e){const i=e[o];r.push(`${o}=${n?encodeURIComponent(i):i}`)}return r.join("&")}function V(e,t,n){const r=s({encode:!0},n||{}),o=S(t,r);return e.includes("?")?e.endsWith("?")||e.endsWith("&")?`${e}${o}`:`${e}&${o}`:`${e}?${o}`}const X={parse:Q,stringify:S,appendQueryString:V};function H(e,t=500){let n=null;return function(...r){if(c(n))return n=Date.now(),e.apply(this,r);{const o=Date.now();if(o-n>=t)return n=o,e.apply(this,r)}}}function J(e){return/^-?\d{1,3}\.\d{6}$/.test(e)}function Y(e){return!c(e)&&/^[\dA-Za-z\u4E00-\u9FA5]+$/.test(e)}function k(e){return!c(e)&&/^[A-Za-z\u4E00-\u9FA5]+$/.test(e)}function ee(e){return!c(e)&&/^[\d!"#$%&'()*+,./:;<=>?@A-Z[\\\]^_`{|}~]+$/.test(e)}function te(e){return/^[\dA-Z_]+$/.test(e)}function $(e){return l(e)?e:[e]}function ne(e,t){const n=b(e);return $(t).forEach(o=>{h(n,o)&&delete n[o]}),n}function re(e,t){const n={};return $(t).forEach(o=>{h(e,o)&&(n[o]=e[o])}),n}function oe(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function ie(e=0,t=1e9){return Math.random()*(t-e)+e}function se(e=0,t=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(t-e+1))+Math.floor(e)}function ue(){let e=["130","131","132","133","134","135","136","137","138","139"];return e=[...e,"145","146","147","149"],e=[...e,"150","151","152","153","155","156","157","158","159"],e=[...e,"166","167"],e=[...e,"170","171","172","173","174","175","176","177","178"],e=[...e,"180","181","182","183","184","185","186","187","188","189"],e=[...e,"190","191","192","195","196","197","198","199"],e[Math.floor(Math.random()*e.length)]+Math.floor(Math.random()*1e8).toString().padStart(8,"0")}function ce(e,t={}){const{lowerCase:n,upperCase:r,number:o}=s({lowerCase:!0,upperCase:!0,number:!0},t);n||r||o||E("getRandomString","lowerCase upperCase number 至少需要一个参数为true");let i="";n&&(i+="abcdefghijklmnopqrstuvwxyz"),r&&(i+="ABCDEFGHIJKLMNOPQRSTUVWXYZ"),o&&(i+="0123456789");let g="";for(let d=0;d<e;d++){const y=Math.floor(Math.random()*i.length);g+=i.charAt(y)}return g}function de(e){return/^\d+$/.test(e)}function ae(e){return/^[\u4E00-\u9FA5]+$/.test(e)}function fe(e){return/^[A-Za-z]+$/.test(e)}function le(e){return/^[A-Z]+$/.test(e)}function ge(e){return/^[\dA-Z]+$/.test(e)}function pe(e){return/^[\dA-Z\u4E00-\u9FA5]+$/.test(e)}function he(e){return/^[a-z]+$/.test(e)}function me(e){return/^[\da-z]+$/.test(e)}function be(e){return/^[\da-z\u4E00-\u9FA5]+$/.test(e)}function $e(e,t={}){const{integer:n}=s({integer:!0},t);return n?/^-?(0|[1-9]\d*)(\.\d+)?$/.test(e):/^-?(0|[1-9]\d*)\.\d+$/.test(e)}function Oe(e,t={}){const{integer:n}=s({integer:!0},t);return n?/^[1-9]\d*\.?\d*|^0\.\d*[1-9]\d*$/.test(e):/^[1-9]\d*\.\d*|^0\.\d*[1-9]\d*$/.test(e)}function Ce(e,t={}){const{integer:n}=s({integer:!0},t);return n?/^-[1-9]\d*\.?\d*|^-0\.\d*[1-9]\d*$/.test(e):/^-[1-9]\d*\.\d*|^-0\.\d*[1-9]\d*$/.test(e)}function Ae(e,t={}){const{integer:n}=s({integer:!0},t);return n?/^(0|[1-9]\d*)(\.\d+)?$/.test(e):/^(0|[1-9]\d*)\.\d+$/.test(e)}function Ne(e,t={}){const{integer:n}=s({integer:!0},t);return n?/^(-?0(\.0+)?|-(0|[1-9]\d*)(\.\d+)?)$/.test(e):/^(-?0\.0+|-(0|[1-9]\d*)\.\d+)$/.test(e)}function we(e){return/^-?(0|[1-9]\d*)$/.test(e)}function Ee(e){return/^[1-9]\d*$/.test(e)}function Se(e){return/^(0|[1-9]\d*)$/.test(e)}function ye(e){return/^-([1-9]\d*)$/.test(e)}function Me(e){return/^(0|-(0|[1-9]\d*))$/.test(e)}function Fe(e){return/^(?:(?:\+|00)86)?1(?:(?:3\d)|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8\d)|(?:9[0-25-9]))\d{8}$/.test(e)}function Re(e){return/^([\w-])+@([\w-])+(\.[\w-])+/.test(e)}function Pe(e){return e===""}exports.castArray=$;exports.compose=M;exports.composeRight=F;exports.debounce=R;exports.debugWarn=G;exports.deepClone=b;exports.deepMerge=s;exports.error=Z;exports.excludeProperties=ne;exports.extractProperties=re;exports.getRandomColor=oe;exports.getRandomFloat=ie;exports.getRandomInteger=se;exports.getRandomPhoneNumber=ue;exports.getRandomString=ce;exports.hasChanged=q;exports.hasOwn=h;exports.initLog=P;exports.isArray=l;exports.isBoolean=_;exports.isChinese=ae;exports.isDate=C;exports.isDef=W;exports.isEmail=Re;exports.isEmptyString=Pe;exports.isEnglishAphabet=fe;exports.isFloat=$e;exports.isFunction=p;exports.isInteger=we;exports.isLowerCase=he;exports.isLowerCaseAndNumber=me;exports.isLowerCaseAndNumberAndChinese=be;exports.isMap=x;exports.isMobilePhone=Fe;exports.isNegativeFloat=Ce;exports.isNegativeFloatOrZero=Ne;exports.isNegativeInteger=ye;exports.isNegativeIntegerOrZero=Me;exports.isNull=z;exports.isNumber=L;exports.isNumberOrNumberString=de;exports.isObject=a;exports.isPositiveFloat=Oe;exports.isPositiveFloatOrZero=Ae;exports.isPositiveInteger=Ee;exports.isPositiveIntegerOrZero=Se;exports.isPromise=T;exports.isRegExp=A;exports.isSet=j;exports.isString=N;exports.isSymbol=D;exports.isUndef=c;exports.isUndefined=v;exports.isUpperCase=le;exports.isUpperCaseAndNumber=ge;exports.isUpperCaseAndNumberAndChinese=pe;exports.log=U;exports.objectToString=O;exports.qs=X;exports.throttle=H;exports.throwError=E;exports.toTypeString=f;exports.validatorChineseOrEnglish=k;exports.validatorChineseOrEnglishOrNumber=Y;exports.validatorLatitudeOrLongitude=J;exports.validatorUppercaseOrNumbersOrSpecial=ee;exports.validatorUppercaseOrNumbersOrUnderline=te;exports.warn=I;
|
package/dist/index.mjs
CHANGED
|
@@ -18,23 +18,23 @@ function I(t, n = 500) {
|
|
|
18
18
|
}
|
|
19
19
|
const C = Object.prototype.toString, l = (t) => C.call(t);
|
|
20
20
|
let p = null;
|
|
21
|
-
function
|
|
21
|
+
function U(t) {
|
|
22
22
|
h(t) && (p = t);
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const P = (t, ...n) => {
|
|
25
25
|
const e = n.length === 0 ? "" : n.length === 1 ? n[0] : n;
|
|
26
26
|
console.log(
|
|
27
27
|
`%c ${t} `,
|
|
28
28
|
"padding: 2px; border-radius: 3px; color: #fff; background: #000; font-weight: bold;",
|
|
29
29
|
e
|
|
30
30
|
), p && p(t, e);
|
|
31
|
-
}, L = (...t) => console.warn(...t), D = (...t) => console.error(...t), z = (t) => l(t) === "[object Map]", T = (t) => l(t) === "[object Set]",
|
|
31
|
+
}, L = (...t) => console.warn(...t), D = (...t) => console.error(...t), z = (t) => l(t) === "[object Map]", T = (t) => l(t) === "[object Set]", O = (t) => l(t) === "[object Date]", N = (t) => l(t) === "[object RegExp]", h = (t) => typeof t == "function", W = (t) => typeof t == "number", y = (t) => typeof t == "string", _ = (t) => typeof t == "symbol", a = (t) => t !== null && typeof t == "object", q = (t) => a(t) && h(t.then) && h(t.catch), d = (t) => t == null, B = (t) => t === void 0, K = (t) => t === null, G = (t) => t != null, Q = (t) => typeof t == "boolean", g = Array.isArray, $ = (t, n) => Object.hasOwn(t, n), V = (t, n) => t !== n;
|
|
32
32
|
function m(t) {
|
|
33
33
|
const n = /* @__PURE__ */ new WeakMap();
|
|
34
34
|
function e(r) {
|
|
35
|
-
if (N(r))
|
|
36
|
-
return new Date(r);
|
|
37
35
|
if (O(r))
|
|
36
|
+
return new Date(r);
|
|
37
|
+
if (N(r))
|
|
38
38
|
return new RegExp(r);
|
|
39
39
|
if (a(r)) {
|
|
40
40
|
if (n.has(r))
|
|
@@ -99,7 +99,7 @@ function F(t, n) {
|
|
|
99
99
|
}
|
|
100
100
|
return r;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function w(t, n) {
|
|
103
103
|
const { encode: e } = s({ encode: !0 }, n || {}), r = [];
|
|
104
104
|
for (const o in t) {
|
|
105
105
|
const i = t[o];
|
|
@@ -108,12 +108,12 @@ function A(t, n) {
|
|
|
108
108
|
return r.join("&");
|
|
109
109
|
}
|
|
110
110
|
function R(t, n, e) {
|
|
111
|
-
const r = s({ encode: !0 }, e || {}), o =
|
|
111
|
+
const r = s({ encode: !0 }, e || {}), o = w(n, r);
|
|
112
112
|
return t.includes("?") ? t.endsWith("?") || t.endsWith("&") ? `${t}${o}` : `${t}&${o}` : `${t}?${o}`;
|
|
113
113
|
}
|
|
114
114
|
const H = {
|
|
115
115
|
parse: F,
|
|
116
|
-
stringify:
|
|
116
|
+
stringify: w,
|
|
117
117
|
appendQueryString: R
|
|
118
118
|
};
|
|
119
119
|
function J(t, n = 500) {
|
|
@@ -143,18 +143,18 @@ function tt(t) {
|
|
|
143
143
|
function nt(t) {
|
|
144
144
|
return /^[\dA-Z_]+$/.test(t);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function A(t) {
|
|
147
147
|
return g(t) ? t : [t];
|
|
148
148
|
}
|
|
149
149
|
function et(t, n) {
|
|
150
150
|
const e = m(t);
|
|
151
|
-
return
|
|
151
|
+
return A(n).forEach((o) => {
|
|
152
152
|
$(e, o) && delete e[o];
|
|
153
153
|
}), e;
|
|
154
154
|
}
|
|
155
155
|
function rt(t, n) {
|
|
156
156
|
const e = {};
|
|
157
|
-
return
|
|
157
|
+
return A(n).forEach((o) => {
|
|
158
158
|
$(t, o) && (e[o] = t[o]);
|
|
159
159
|
}), e;
|
|
160
160
|
}
|
|
@@ -168,39 +168,8 @@ function st(t = 0, n = Number.MAX_SAFE_INTEGER) {
|
|
|
168
168
|
return Math.floor(Math.random() * (n - t + 1)) + Math.floor(t);
|
|
169
169
|
}
|
|
170
170
|
function ut() {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"131",
|
|
174
|
-
"132",
|
|
175
|
-
"133",
|
|
176
|
-
"134",
|
|
177
|
-
"135",
|
|
178
|
-
"136",
|
|
179
|
-
"137",
|
|
180
|
-
"138",
|
|
181
|
-
"139",
|
|
182
|
-
"150",
|
|
183
|
-
"151",
|
|
184
|
-
"152",
|
|
185
|
-
"153",
|
|
186
|
-
"154",
|
|
187
|
-
"155",
|
|
188
|
-
"156",
|
|
189
|
-
"157",
|
|
190
|
-
"158",
|
|
191
|
-
"159",
|
|
192
|
-
"180",
|
|
193
|
-
"181",
|
|
194
|
-
"182",
|
|
195
|
-
"183",
|
|
196
|
-
"184",
|
|
197
|
-
"185",
|
|
198
|
-
"186",
|
|
199
|
-
"187",
|
|
200
|
-
"188",
|
|
201
|
-
"189"
|
|
202
|
-
], n = t[Math.floor(Math.random() * t.length)], e = Math.floor(Math.random() * 1e9).toString().padStart(8, "0");
|
|
203
|
-
return n + e;
|
|
171
|
+
let t = ["130", "131", "132", "133", "134", "135", "136", "137", "138", "139"];
|
|
172
|
+
return t = [...t, "145", "146", "147", "149"], t = [...t, "150", "151", "152", "153", "155", "156", "157", "158", "159"], t = [...t, "166", "167"], t = [...t, "170", "171", "172", "173", "174", "175", "176", "177", "178"], t = [...t, "180", "181", "182", "183", "184", "185", "186", "187", "188", "189"], t = [...t, "190", "191", "192", "195", "196", "197", "198", "199"], t[Math.floor(Math.random() * t.length)] + Math.floor(Math.random() * 1e8).toString().padStart(8, "0");
|
|
204
173
|
}
|
|
205
174
|
function ct(t, n = {}) {
|
|
206
175
|
const { lowerCase: e, upperCase: r, number: o } = s({ lowerCase: !0, upperCase: !0, number: !0 }, n);
|
|
@@ -245,11 +214,11 @@ function bt(t, n = {}) {
|
|
|
245
214
|
const { integer: e } = s({ integer: !0 }, n);
|
|
246
215
|
return e ? /^-?(0|[1-9]\d*)(\.\d+)?$/.test(t) : /^-?(0|[1-9]\d*)\.\d+$/.test(t);
|
|
247
216
|
}
|
|
248
|
-
function
|
|
217
|
+
function wt(t, n = {}) {
|
|
249
218
|
const { integer: e } = s({ integer: !0 }, n);
|
|
250
219
|
return e ? /^[1-9]\d*\.?\d*|^0\.\d*[1-9]\d*$/.test(t) : /^[1-9]\d*\.\d*|^0\.\d*[1-9]\d*$/.test(t);
|
|
251
220
|
}
|
|
252
|
-
function
|
|
221
|
+
function At(t, n = {}) {
|
|
253
222
|
const { integer: e } = s({ integer: !0 }, n);
|
|
254
223
|
return e ? /^-[1-9]\d*\.?\d*|^-0\.\d*[1-9]\d*$/.test(t) : /^-[1-9]\d*\.\d*|^-0\.\d*[1-9]\d*$/.test(t);
|
|
255
224
|
}
|
|
@@ -261,10 +230,10 @@ function Ct(t, n = {}) {
|
|
|
261
230
|
const { integer: e } = s({ integer: !0 }, n);
|
|
262
231
|
return e ? /^(-?0(\.0+)?|-(0|[1-9]\d*)(\.\d+)?)$/.test(t) : /^(-?0\.0+|-(0|[1-9]\d*)\.\d+)$/.test(t);
|
|
263
232
|
}
|
|
264
|
-
function
|
|
233
|
+
function Ot(t) {
|
|
265
234
|
return /^-?(0|[1-9]\d*)$/.test(t);
|
|
266
235
|
}
|
|
267
|
-
function
|
|
236
|
+
function Nt(t) {
|
|
268
237
|
return /^[1-9]\d*$/.test(t);
|
|
269
238
|
}
|
|
270
239
|
function yt(t) {
|
|
@@ -288,7 +257,7 @@ function Rt(t) {
|
|
|
288
257
|
return t === "";
|
|
289
258
|
}
|
|
290
259
|
export {
|
|
291
|
-
|
|
260
|
+
A as castArray,
|
|
292
261
|
Z as compose,
|
|
293
262
|
j as composeRight,
|
|
294
263
|
I as debounce,
|
|
@@ -305,24 +274,24 @@ export {
|
|
|
305
274
|
ct as getRandomString,
|
|
306
275
|
V as hasChanged,
|
|
307
276
|
$ as hasOwn,
|
|
308
|
-
|
|
277
|
+
U as initLog,
|
|
309
278
|
g as isArray,
|
|
310
279
|
Q as isBoolean,
|
|
311
280
|
ft as isChinese,
|
|
312
|
-
|
|
281
|
+
O as isDate,
|
|
313
282
|
G as isDef,
|
|
314
283
|
Ft as isEmail,
|
|
315
284
|
Rt as isEmptyString,
|
|
316
285
|
at as isEnglishAphabet,
|
|
317
286
|
bt as isFloat,
|
|
318
287
|
h as isFunction,
|
|
319
|
-
|
|
288
|
+
Ot as isInteger,
|
|
320
289
|
ht as isLowerCase,
|
|
321
290
|
$t as isLowerCaseAndNumber,
|
|
322
291
|
mt as isLowerCaseAndNumberAndChinese,
|
|
323
292
|
z as isMap,
|
|
324
293
|
xt as isMobilePhone,
|
|
325
|
-
|
|
294
|
+
At as isNegativeFloat,
|
|
326
295
|
Ct as isNegativeFloatOrZero,
|
|
327
296
|
Mt as isNegativeInteger,
|
|
328
297
|
St as isNegativeIntegerOrZero,
|
|
@@ -330,12 +299,12 @@ export {
|
|
|
330
299
|
W as isNumber,
|
|
331
300
|
dt as isNumberOrNumberString,
|
|
332
301
|
a as isObject,
|
|
333
|
-
|
|
302
|
+
wt as isPositiveFloat,
|
|
334
303
|
Et as isPositiveFloatOrZero,
|
|
335
|
-
|
|
304
|
+
Nt as isPositiveInteger,
|
|
336
305
|
yt as isPositiveIntegerOrZero,
|
|
337
306
|
q as isPromise,
|
|
338
|
-
|
|
307
|
+
N as isRegExp,
|
|
339
308
|
T as isSet,
|
|
340
309
|
y as isString,
|
|
341
310
|
_ as isSymbol,
|
|
@@ -344,7 +313,7 @@ export {
|
|
|
344
313
|
lt as isUpperCase,
|
|
345
314
|
gt as isUpperCaseAndNumber,
|
|
346
315
|
pt as isUpperCaseAndNumberAndChinese,
|
|
347
|
-
|
|
316
|
+
P as log,
|
|
348
317
|
C as objectToString,
|
|
349
318
|
H as qs,
|
|
350
319
|
J as throttle,
|