@lntvow/utils 1.8.1 → 1.8.2
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 +2 -0
- package/dist/index.mjs +14 -10
- package/package.json +1 -1
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
|
|
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;
|
package/dist/index.d.ts
CHANGED
|
@@ -63,6 +63,8 @@ export declare const hasOwn: <T extends object, U extends keyof T>(target: T, ke
|
|
|
63
63
|
|
|
64
64
|
export declare const isArray: (arg: any) => arg is any[];
|
|
65
65
|
|
|
66
|
+
export declare function isBoolean(val: unknown): val is boolean;
|
|
67
|
+
|
|
66
68
|
export declare const isDate: (val: unknown) => val is Date;
|
|
67
69
|
|
|
68
70
|
export declare function isDef<T>(v: T): v is NonNullable<T>;
|
package/dist/index.mjs
CHANGED
|
@@ -12,8 +12,11 @@ const d = Object.prototype.toString, f = (n) => d.call(n), D = (...n) => console
|
|
|
12
12
|
function K(n) {
|
|
13
13
|
return n != null;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
function $(n) {
|
|
16
|
+
return typeof n == "boolean";
|
|
17
|
+
}
|
|
18
|
+
const u = Array.isArray, y = (n, e) => Object.hasOwn(n, e), B = (n, e) => n !== e;
|
|
19
|
+
function j(n) {
|
|
17
20
|
const e = /* @__PURE__ */ new WeakMap();
|
|
18
21
|
function o(t) {
|
|
19
22
|
if (g(t))
|
|
@@ -32,20 +35,20 @@ function w(n) {
|
|
|
32
35
|
}
|
|
33
36
|
e.set(t, c);
|
|
34
37
|
for (const r in t)
|
|
35
|
-
|
|
38
|
+
y(t, r) && (c[r] = o(t[r]));
|
|
36
39
|
return c;
|
|
37
40
|
} else
|
|
38
41
|
return t;
|
|
39
42
|
}
|
|
40
43
|
return o(n);
|
|
41
44
|
}
|
|
42
|
-
function
|
|
45
|
+
function w(n, e, o) {
|
|
43
46
|
return u(n) ? S(n, e, o) : x(n, e, o);
|
|
44
47
|
}
|
|
45
48
|
function x(n, e, o) {
|
|
46
49
|
const t = i(e, o);
|
|
47
50
|
return Object.keys(n).forEach((r) => {
|
|
48
|
-
a(e[r]) ? t[r] = i(n[r], o) : t[r] = s(n[r]) && s(e[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);
|
|
49
52
|
}), t;
|
|
50
53
|
}
|
|
51
54
|
function S(n, e, o) {
|
|
@@ -57,7 +60,7 @@ function S(n, e, o) {
|
|
|
57
60
|
}
|
|
58
61
|
function i(n, e) {
|
|
59
62
|
const { isDeepClone: o = !0 } = e || {};
|
|
60
|
-
return o ?
|
|
63
|
+
return o ? j(n) : n;
|
|
61
64
|
}
|
|
62
65
|
function F(n, e = 1e3) {
|
|
63
66
|
let o = null;
|
|
@@ -93,14 +96,15 @@ export {
|
|
|
93
96
|
P as compose,
|
|
94
97
|
U as composeRight,
|
|
95
98
|
F as debounce,
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
j as deepClone,
|
|
100
|
+
w as deepMerge,
|
|
98
101
|
O as error,
|
|
99
102
|
m as getRandomColor,
|
|
100
103
|
p as getRandomString,
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
B as hasChanged,
|
|
105
|
+
y as hasOwn,
|
|
103
106
|
u as isArray,
|
|
107
|
+
$ as isBoolean,
|
|
104
108
|
g as isDate,
|
|
105
109
|
K as isDef,
|
|
106
110
|
l as isFunction,
|