@lntvow/utils 1.8.22 → 1.8.24
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 +3 -3
- package/dist/index.mjs +7 -7
- 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(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=
|
|
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=500){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{t.apply(this,n)},e)}}function F(t,e=500){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
|
@@ -19,7 +19,7 @@ export declare function composeRight(...fns: ((...args: any[]) => any)[]): (...a
|
|
|
19
19
|
/**
|
|
20
20
|
* @description 防抖函数
|
|
21
21
|
* @param target 目标函数
|
|
22
|
-
* @param wait 等待时间 默认
|
|
22
|
+
* @param wait 等待时间 默认 500ms
|
|
23
23
|
* @example debounce(() => console.log('debounce'), 500)
|
|
24
24
|
*/
|
|
25
25
|
export declare function debounce(target: Function, wait?: number): (...args: any[]) => void;
|
|
@@ -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 校验邮箱
|
|
@@ -178,7 +178,7 @@ declare interface Options {
|
|
|
178
178
|
/**
|
|
179
179
|
* @description 节流函数
|
|
180
180
|
* @param target 目标函数
|
|
181
|
-
* @param wait 等待时间 默认
|
|
181
|
+
* @param wait 等待时间 默认 500ms
|
|
182
182
|
* @example throttle(() => console.log('hello world'), 500)
|
|
183
183
|
*/
|
|
184
184
|
export declare function throttle(target: Function, wait?: number): (...args: any[]) => any;
|
package/dist/index.mjs
CHANGED
|
@@ -4,11 +4,11 @@ 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]",
|
|
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
12
|
function Z(n) {
|
|
13
13
|
return n != null;
|
|
14
14
|
}
|
|
@@ -19,7 +19,7 @@ const d = Array.isArray, y = (n, e) => Object.hasOwn(n, e), P = (n, e) => n !==
|
|
|
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 F(n, e =
|
|
65
|
+
function F(n, e = 500) {
|
|
66
66
|
let r = null;
|
|
67
67
|
return function(...t) {
|
|
68
68
|
r && clearTimeout(r), r = setTimeout(() => {
|
|
@@ -70,7 +70,7 @@ function F(n, e = 1e3) {
|
|
|
70
70
|
}, e);
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function T(n, e =
|
|
73
|
+
function T(n, e = 500) {
|
|
74
74
|
let r = null;
|
|
75
75
|
return function(...t) {
|
|
76
76
|
if (b(r))
|
|
@@ -155,7 +155,7 @@ export {
|
|
|
155
155
|
N as isBoolean,
|
|
156
156
|
J as isChineseOrEnglish,
|
|
157
157
|
H as isChineseOrEnglishOrNumber,
|
|
158
|
-
|
|
158
|
+
a as isDate,
|
|
159
159
|
Z as isDef,
|
|
160
160
|
I as isEmail,
|
|
161
161
|
G as isEmptyString,
|
|
@@ -181,7 +181,7 @@ export {
|
|
|
181
181
|
Q as isUppercaseOrNumbersOrSpecial,
|
|
182
182
|
V as isUppercaseOrNumbersOrUnderline,
|
|
183
183
|
E as log,
|
|
184
|
-
|
|
184
|
+
g as objectToString,
|
|
185
185
|
T as throttle,
|
|
186
186
|
f as toTypeString,
|
|
187
187
|
S as warn
|