@lntvow/utils 1.7.14 → 1.8.1

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 p(t){return t>10?p(10)+p(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const l=Object.prototype.toString,f=t=>l.call(t),w=(...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)),x=(...t)=>console.warn(...t),M=(...t)=>console.error(...t),O=t=>f(t)==="[object Map]",R=t=>f(t)==="[object Set]",d=t=>f(t)==="[object Date]",a=t=>f(t)==="[object RegExp]",g=t=>typeof t=="function",D=t=>typeof t=="string",C=t=>typeof t=="symbol",s=t=>t!==null&&typeof t=="object",E=t=>s(t)&&g(t.then)&&g(t.catch),h=t=>t==null,b=t=>t===null;function T(t){return t!=null}const u=Array.isArray,y=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),A=(t,n)=>t!==n;function S(t){const n=new WeakMap;function e(o){if(d(o))return new Date(o);if(a(o))return new RegExp(o);if(s(o)){if(n.has(o))return n.get(o);let i={};if(u(o)){i=[],n.set(o,i);for(let r=0;r<o.length;r++)i[r]=e(o[r]);return i}n.set(o,i);for(const r in o)y(o,r)&&(i[r]=e(o[r]));return i}else return o}return e(t)}function m(t,n,e){return u(t)?F(t,n,e):P(t,n,e)}function P(t,n,e){const o=c(n,e);return Object.keys(t).forEach(r=>{h(n[r])?o[r]=c(t[r],e):o[r]=s(t[r])&&s(n[r])?m(t[r],n[r],e):c(n[r],e)}),o}function F(t,n,e){return u(n)?c(t,e).concat(c(n,e)):c(n,e)}function c(t,n){const{isDeepClone:e=!0}=n||{};return e?S(t):t}function K(t,n=1e3){let e=null;return function(...o){e&&clearTimeout(e),e=setTimeout(()=>{t.apply(this,...o)},n)}}function N(t,n=1e3){let e=null;return function(...o){if(b(e))return e=Date.now(),t.apply(this,...o);{const i=Date.now();if(i-e>=n)return e=i,t.apply(this,...o)}}}function U(...t){return t.reduce((n,e)=>function(...o){return e(n(...o))})}function $(...t){return t.reduce((n,e)=>function(...o){return n(e(...o))})}exports.compose=U;exports.composeRight=$;exports.debounce=K;exports.deepClone=S;exports.deepMerge=m;exports.error=M;exports.getRandomColor=j;exports.getRandomString=p;exports.hasChanged=A;exports.hasOwn=y;exports.isArray=u;exports.isDate=d;exports.isDef=T;exports.isFunction=g;exports.isMap=O;exports.isNull=b;exports.isObject=s;exports.isPromise=E;exports.isRegExp=a;exports.isSet=R;exports.isString=D;exports.isSymbol=C;exports.isUndef=h;exports.log=w;exports.objectToString=l;exports.throttle=N;exports.toTypeString=f;exports.warn=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function j(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function g(t){return t>10?g(10)+g(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const p=Object.prototype.toString,f=t=>p.call(t),w=(...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)),x=(...t)=>console.warn(...t),M=(...t)=>console.error(...t),O=t=>f(t)==="[object Map]",R=t=>f(t)==="[object Set]",d=t=>f(t)==="[object Date]",a=t=>f(t)==="[object RegExp]",l=t=>typeof t=="function",D=t=>typeof t=="string",C=t=>typeof t=="symbol",c=t=>t!==null&&typeof t=="object",E=t=>c(t)&&l(t.then)&&l(t.catch),h=t=>t==null,b=t=>t===null;function T(t){return t!=null}const u=Array.isArray,S=(t,e)=>Object.hasOwn(t,e),A=(t,e)=>t!==e;function m(t){const e=new WeakMap;function o(n){if(d(n))return new Date(n);if(a(n))return new RegExp(n);if(c(n)){if(e.has(n))return e.get(n);let i={};if(u(n)){i=[],e.set(n,i);for(let r=0;r<n.length;r++)i[r]=o(n[r]);return i}e.set(n,i);for(const r in n)S(n,r)&&(i[r]=o(n[r]));return i}else return n}return o(t)}function y(t,e,o){return u(t)?F(t,e,o):P(t,e,o)}function P(t,e,o){const n=s(e,o);return Object.keys(t).forEach(r=>{h(e[r])?n[r]=s(t[r],o):n[r]=c(t[r])&&c(e[r])?y(t[r],e[r],o):s(e[r],o)}),n}function F(t,e,o){if(u(e)){const n=s(e,o);return n.push(...s(t,o)),n}else return s(t,o)}function s(t,e){const{isDeepClone:o=!0}=e||{};return o?m(t):t}function K(t,e=1e3){let o=null;return function(...n){o&&clearTimeout(o),o=setTimeout(()=>{t.apply(this,...n)},e)}}function N(t,e=1e3){let o=null;return function(...n){if(b(o))return o=Date.now(),t.apply(this,...n);{const i=Date.now();if(i-o>=e)return o=i,t.apply(this,...n)}}}function U(...t){return t.reduce((e,o)=>function(...n){return o(e(...n))})}function $(...t){return t.reduce((e,o)=>function(...n){return e(o(...n))})}exports.compose=U;exports.composeRight=$;exports.debounce=K;exports.deepClone=m;exports.deepMerge=y;exports.error=M;exports.getRandomColor=j;exports.getRandomString=g;exports.hasChanged=A;exports.hasOwn=S;exports.isArray=u;exports.isDate=d;exports.isDef=T;exports.isFunction=l;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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- function S() {
1
+ function m() {
2
2
  return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
3
3
  }
4
4
  function p(n) {
@@ -8,94 +8,98 @@ const d = Object.prototype.toString, f = (n) => d.call(n), D = (...n) => console
8
8
  `%c ${n[0]}: `,
9
9
  "padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",
10
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]", a = (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), h = (n) => n == null, b = (n) => n === null;
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
12
  function K(n) {
13
13
  return n != null;
14
14
  }
15
- const u = Array.isArray, y = (n, t) => Object.prototype.hasOwnProperty.call(n, t), P = (n, t) => n !== t;
16
- function j(n) {
17
- const t = /* @__PURE__ */ new WeakMap();
18
- function o(e) {
19
- if (g(e))
20
- return new Date(e);
21
- if (a(e))
22
- return new RegExp(e);
23
- if (s(e)) {
24
- if (t.has(e))
25
- return t.get(e);
15
+ const u = Array.isArray, j = (n, e) => Object.hasOwn(n, e), $ = (n, e) => n !== e;
16
+ function w(n) {
17
+ const e = /* @__PURE__ */ new WeakMap();
18
+ function o(t) {
19
+ if (g(t))
20
+ return new Date(t);
21
+ if (h(t))
22
+ return new RegExp(t);
23
+ if (s(t)) {
24
+ if (e.has(t))
25
+ return e.get(t);
26
26
  let c = {};
27
- if (u(e)) {
28
- c = [], t.set(e, c);
29
- for (let r = 0; r < e.length; r++)
30
- c[r] = o(e[r]);
27
+ if (u(t)) {
28
+ c = [], e.set(t, c);
29
+ for (let r = 0; r < t.length; r++)
30
+ c[r] = o(t[r]);
31
31
  return c;
32
32
  }
33
- t.set(e, c);
34
- for (const r in e)
35
- y(e, r) && (c[r] = o(e[r]));
33
+ e.set(t, c);
34
+ for (const r in t)
35
+ j(t, r) && (c[r] = o(t[r]));
36
36
  return c;
37
37
  } else
38
- return e;
38
+ return t;
39
39
  }
40
40
  return o(n);
41
41
  }
42
- function w(n, t, o) {
43
- return u(n) ? x(n, t, o) : m(n, t, o);
42
+ function y(n, e, o) {
43
+ return u(n) ? S(n, e, o) : x(n, e, o);
44
44
  }
45
- function m(n, t, o) {
46
- const e = i(t, o);
45
+ function x(n, e, o) {
46
+ const t = i(e, o);
47
47
  return Object.keys(n).forEach((r) => {
48
- h(t[r]) ? e[r] = i(n[r], o) : e[r] = s(n[r]) && s(t[r]) ? w(n[r], t[r], o) : i(t[r], o);
49
- }), e;
48
+ a(e[r]) ? t[r] = i(n[r], o) : t[r] = s(n[r]) && s(e[r]) ? y(n[r], e[r], o) : i(e[r], o);
49
+ }), t;
50
50
  }
51
- function x(n, t, o) {
52
- return u(t) ? i(n, o).concat(i(t, o)) : i(t, o);
51
+ function S(n, e, o) {
52
+ if (u(e)) {
53
+ const t = i(e, o);
54
+ return t.push(...i(n, o)), t;
55
+ } else
56
+ return i(n, o);
53
57
  }
54
- function i(n, t) {
55
- const { isDeepClone: o = !0 } = t || {};
56
- return o ? j(n) : n;
58
+ function i(n, e) {
59
+ const { isDeepClone: o = !0 } = e || {};
60
+ return o ? w(n) : n;
57
61
  }
58
- function $(n, t = 1e3) {
62
+ function F(n, e = 1e3) {
59
63
  let o = null;
60
- return function(...e) {
64
+ return function(...t) {
61
65
  o && clearTimeout(o), o = setTimeout(() => {
62
- n.apply(this, ...e);
63
- }, t);
66
+ n.apply(this, ...t);
67
+ }, e);
64
68
  };
65
69
  }
66
- function F(n, t = 1e3) {
70
+ function N(n, e = 1e3) {
67
71
  let o = null;
68
- return function(...e) {
72
+ return function(...t) {
69
73
  if (b(o))
70
- return o = Date.now(), n.apply(this, ...e);
74
+ return o = Date.now(), n.apply(this, ...t);
71
75
  {
72
76
  const c = Date.now();
73
- if (c - o >= t)
74
- return o = c, n.apply(this, ...e);
77
+ if (c - o >= e)
78
+ return o = c, n.apply(this, ...t);
75
79
  }
76
80
  };
77
81
  }
78
- function N(...n) {
79
- return n.reduce((t, o) => function(...e) {
80
- return o(t(...e));
82
+ function P(...n) {
83
+ return n.reduce((e, o) => function(...t) {
84
+ return o(e(...t));
81
85
  });
82
86
  }
83
87
  function U(...n) {
84
- return n.reduce((t, o) => function(...e) {
85
- return t(o(...e));
88
+ return n.reduce((e, o) => function(...t) {
89
+ return e(o(...t));
86
90
  });
87
91
  }
88
92
  export {
89
- N as compose,
93
+ P as compose,
90
94
  U as composeRight,
91
- $ as debounce,
92
- j as deepClone,
93
- w as deepMerge,
95
+ F as debounce,
96
+ w as deepClone,
97
+ y as deepMerge,
94
98
  O as error,
95
- S as getRandomColor,
99
+ m as getRandomColor,
96
100
  p as getRandomString,
97
- P as hasChanged,
98
- y as hasOwn,
101
+ $ as hasChanged,
102
+ j as hasOwn,
99
103
  u as isArray,
100
104
  g as isDate,
101
105
  K as isDef,
@@ -104,14 +108,14 @@ export {
104
108
  b as isNull,
105
109
  s as isObject,
106
110
  A as isPromise,
107
- a as isRegExp,
111
+ h as isRegExp,
108
112
  R as isSet,
109
113
  C as isString,
110
114
  T as isSymbol,
111
- h as isUndef,
115
+ a as isUndef,
112
116
  D as log,
113
117
  d as objectToString,
114
- F as throttle,
118
+ N as throttle,
115
119
  f as toTypeString,
116
120
  M as warn
117
121
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "1.7.14",
3
+ "version": "1.8.1",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -21,16 +21,14 @@
21
21
  "typescript": "^5.0.4",
22
22
  "vite": "^4.4.4",
23
23
  "vite-plugin-dts": "3.3.1",
24
- "vitest": "^0.33.0"
24
+ "vitest": "^0.33.0",
25
+ "vconsole": "^3.15.1"
25
26
  },
26
27
  "config": {
27
28
  "commitizen": {
28
29
  "path": "node_modules/cz-conventional-changelog"
29
30
  }
30
31
  },
31
- "dependencies": {
32
- "vconsole": "^3.15.1"
33
- },
34
32
  "scripts": {
35
33
  "dev": "vite",
36
34
  "test": "vitest",