@lntvow/utils 1.7.8 → 1.7.10

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"});const m=require("vconsole");function O(){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 S=Object.prototype.toString,a=t=>S.call(t),D=(...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),E=t=>a(t)==="[object Map]",R=t=>a(t)==="[object Set]",b=t=>a(t)==="[object Date]",h=t=>a(t)==="[object RegExp]",p=t=>typeof t=="function",T=t=>typeof t=="string",N=t=>typeof t=="symbol",l=t=>t!==null&&typeof t=="object",A=t=>l(t)&&p(t.then)&&p(t.catch),w=t=>t==null,y=t=>t===null;function I(t){return t!=null}const f=Array.isArray,j=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),P=(t,n)=>t!==n;function C(t){const n=new WeakMap;function e(o){if(b(o))return new Date(o);if(h(o))return new RegExp(o);if(l(o)){if(n.has(o))return n.get(o);let i={};if(f(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)j(o,r)&&(i[r]=e(o[r]));return i}else return o}return e(t)}function u(t,n,e){return f(t)?K(t,n,e):F(t,n,e)}function F(t,n,e){const o=c(n,e);return Object.keys(t).forEach(r=>{w(n[r])?o[r]=c(t[r],e):o[r]=l(t[r])&&l(n[r])?u(t[r],n[r],e):c(n[r],e)}),o}function K(t,n,e){return f(n)?c(t,e).concat(c(n,e)):c(n,e)}function c(t,n){const{isDeepClone:e=!0}=n||{};return e?C(t):t}function L(t,n=1e3){let e=null;return function(...o){e&&clearTimeout(e),e=setTimeout(()=>{t.apply(this,...o)},n)}}function U(t,n=1e3){let e=null;return function(...o){if(y(e))return e=Date.now(),t.apply(this,...o);{const i=Date.now();if(i-e>=n)return e=i,t.apply(this,...o)}}}let s={name:"LNTVOW_CONSOLE",time:3600,count:20};function V(t){s=u(s,t||{});const n=localStorage.getItem(s.name);if(!n)return;Date.now()-Number(n)>=1e3*s.time?localStorage.removeItem(s.name):new m}let d=0;function W(){d++,d>=s.count&&!localStorage.getItem(s.name)&&(localStorage.setItem(s.name,Date.now().toString()),new m)}const _={initConsole:V,showConsole:W};exports.debounce=L;exports.deepClone=C;exports.deepMerge=u;exports.error=M;exports.getRandomColor=O;exports.getRandomString=g;exports.hasChanged=P;exports.hasOwn=j;exports.isArray=f;exports.isDate=b;exports.isDef=I;exports.isFunction=p;exports.isMap=E;exports.isNull=y;exports.isObject=l;exports.isPromise=A;exports.isRegExp=h;exports.isSet=R;exports.isString=T;exports.isSymbol=N;exports.isUndef=w;exports.log=D;exports.nConsole=_;exports.objectToString=S;exports.throttle=U;exports.toTypeString=a;exports.warn=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("vconsole");function O(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function u(t){return t>10?u(10)+u(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const S=Object.prototype.toString,f=t=>S.call(t),D=(...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),R=t=>f(t)==="[object Map]",E=t=>f(t)==="[object Set]",h=t=>f(t)==="[object Date]",b=t=>f(t)==="[object RegExp]",g=t=>typeof t=="function",T=t=>typeof t=="string",N=t=>typeof t=="symbol",l=t=>t!==null&&typeof t=="object",A=t=>l(t)&&g(t.then)&&g(t.catch),w=t=>t==null,y=t=>t===null;function I(t){return t!=null}const a=Array.isArray,j=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),P=(t,n)=>t!==n;function C(t){const n=new WeakMap;function e(o){if(h(o))return new Date(o);if(b(o))return new RegExp(o);if(l(o)){if(n.has(o))return n.get(o);let i={};if(a(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)j(o,r)&&(i[r]=e(o[r]));return i}else return o}return e(t)}function p(t,n,e){return a(t)?K(t,n,e):F(t,n,e)}function F(t,n,e){const o=s(n,e);return Object.keys(t).forEach(r=>{w(n[r])?o[r]=s(t[r],e):o[r]=l(t[r])&&l(n[r])?p(t[r],n[r],e):s(n[r],e)}),o}function K(t,n,e){return a(n)?s(t,e).concat(s(n,e)):s(n,e)}function s(t,n){const{isDeepClone:e=!0}=n||{};return e?C(t):t}function L(t,n=1e3){let e=null;return function(...o){e&&clearTimeout(e),e=setTimeout(()=>{t.apply(this,...o)},n)}}function U(t,n=1e3){let e=null;return function(...o){if(y(e))return e=Date.now(),t.apply(this,...o);{const i=Date.now();if(i-e>=n)return e=i,t.apply(this,...o)}}}let c={name:"LNTVOW_CONSOLE",time:3600,count:20};function V(t){c=p(c,t||{});const n=localStorage.getItem(c.name);if(!n)return;Date.now()-Number(n)>=1e3*c.time?localStorage.removeItem(c.name):new m}let d=0;function W(){d++,d>=c.count&&!localStorage.getItem(c.name)&&(localStorage.setItem(c.name,Date.now().toString()),new m)}const _={initConsole:V,showConsole:W};function $(...t){return t.reduce((n,e)=>function(...o){return e(n(...o))})}function q(...t){return t.reduce((n,e)=>function(...o){return n(e(...o))})}exports.compose=$;exports.composeRight=q;exports.debounce=L;exports.deepClone=C;exports.deepMerge=p;exports.error=M;exports.getRandomColor=O;exports.getRandomString=u;exports.hasChanged=P;exports.hasOwn=j;exports.isArray=a;exports.isDate=h;exports.isDef=I;exports.isFunction=g;exports.isMap=R;exports.isNull=y;exports.isObject=l;exports.isPromise=A;exports.isRegExp=b;exports.isSet=E;exports.isString=T;exports.isSymbol=N;exports.isUndef=w;exports.log=D;exports.nConsole=_;exports.objectToString=S;exports.throttle=U;exports.toTypeString=f;exports.warn=x;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,19 @@
1
1
  export declare type AnyObj = Record<string, any>;
2
2
 
3
+ /**
4
+ * @description compose
5
+ * @param fns 任意函数
6
+ * @url https://lntvow.vercel.app/web/javascript/compose.html
7
+ */
8
+ export declare function compose(...fns: ((...args: any[]) => any)[]): (...args: any[]) => any;
9
+
10
+ /**
11
+ * @description compose 从右到左
12
+ * @param fns 任意函数
13
+ * @url https://lntvow.vercel.app/web/javascript/compose.html
14
+ */
15
+ export declare function composeRight(...fns: ((...args: any[]) => any)[]): (...args: any[]) => any;
16
+
3
17
  /**
4
18
  * @description 防抖函数
5
19
  * @param target 目标函数
package/dist/index.mjs CHANGED
@@ -2,18 +2,18 @@ import m from "vconsole";
2
2
  function R() {
3
3
  return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
4
4
  }
5
- function p(t) {
6
- return t > 10 ? p(10) + p(t - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, t + 2);
5
+ function a(t) {
6
+ return t > 10 ? a(10) + a(t - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, t + 2);
7
7
  }
8
8
  const h = Object.prototype.toString, l = (t) => h.call(t), T = (...t) => console.log(
9
9
  `%c ${t[0]}: `,
10
10
  "padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;",
11
11
  t.slice(1)
12
- ), I = (t) => console.warn(t), N = (t) => console.error(t), A = (t) => l(t) === "[object Map]", K = (t) => l(t) === "[object Set]", b = (t) => l(t) === "[object Date]", w = (t) => l(t) === "[object RegExp]", g = (t) => typeof t == "function", L = (t) => typeof t == "string", P = (t) => typeof t == "symbol", f = (t) => t !== null && typeof t == "object", V = (t) => f(t) && g(t.then) && g(t.catch), S = (t) => t == null, y = (t) => t === null;
12
+ ), I = (t) => console.warn(t), N = (t) => console.error(t), A = (t) => l(t) === "[object Map]", K = (t) => l(t) === "[object Set]", b = (t) => l(t) === "[object Date]", w = (t) => l(t) === "[object RegExp]", p = (t) => typeof t == "function", L = (t) => typeof t == "string", P = (t) => typeof t == "symbol", f = (t) => t !== null && typeof t == "object", V = (t) => f(t) && p(t.then) && p(t.catch), S = (t) => t == null, y = (t) => t === null;
13
13
  function W(t) {
14
14
  return t != null;
15
15
  }
16
- const a = Array.isArray, j = (t, n) => Object.prototype.hasOwnProperty.call(t, n), _ = (t, n) => t !== n;
16
+ const u = Array.isArray, j = (t, n) => Object.prototype.hasOwnProperty.call(t, n), _ = (t, n) => t !== n;
17
17
  function O(t) {
18
18
  const n = /* @__PURE__ */ new WeakMap();
19
19
  function e(o) {
@@ -24,24 +24,24 @@ function O(t) {
24
24
  if (f(o)) {
25
25
  if (n.has(o))
26
26
  return n.get(o);
27
- let i = {};
28
- if (a(o)) {
29
- i = [], n.set(o, i);
27
+ let c = {};
28
+ if (u(o)) {
29
+ c = [], n.set(o, c);
30
30
  for (let r = 0; r < o.length; r++)
31
- i[r] = e(o[r]);
32
- return i;
31
+ c[r] = e(o[r]);
32
+ return c;
33
33
  }
34
- n.set(o, i);
34
+ n.set(o, c);
35
35
  for (const r in o)
36
- j(o, r) && (i[r] = e(o[r]));
37
- return i;
36
+ j(o, r) && (c[r] = e(o[r]));
37
+ return c;
38
38
  } else
39
39
  return o;
40
40
  }
41
41
  return e(t);
42
42
  }
43
43
  function d(t, n, e) {
44
- return a(t) ? C(t, n, e) : x(t, n, e);
44
+ return u(t) ? C(t, n, e) : x(t, n, e);
45
45
  }
46
46
  function x(t, n, e) {
47
47
  const o = s(n, e);
@@ -50,7 +50,7 @@ function x(t, n, e) {
50
50
  }), o;
51
51
  }
52
52
  function C(t, n, e) {
53
- return a(n) ? s(t, e).concat(s(n, e)) : s(n, e);
53
+ return u(n) ? s(t, e).concat(s(n, e)) : s(n, e);
54
54
  }
55
55
  function s(t, n) {
56
56
  const { isDeepClone: e = !0 } = n || {};
@@ -70,45 +70,57 @@ function F(t, n = 1e3) {
70
70
  if (y(e))
71
71
  return e = Date.now(), t.apply(this, ...o);
72
72
  {
73
- const i = Date.now();
74
- if (i - e >= n)
75
- return e = i, t.apply(this, ...o);
73
+ const c = Date.now();
74
+ if (c - e >= n)
75
+ return e = c, t.apply(this, ...o);
76
76
  }
77
77
  };
78
78
  }
79
- let c = {
79
+ let i = {
80
80
  name: "LNTVOW_CONSOLE",
81
81
  time: 3600,
82
82
  count: 20
83
83
  };
84
84
  function D(t) {
85
- c = d(c, t || {});
86
- const n = localStorage.getItem(c.name);
85
+ i = d(i, t || {});
86
+ const n = localStorage.getItem(i.name);
87
87
  if (!n)
88
88
  return;
89
- Date.now() - Number(n) >= 1e3 * c.time ? localStorage.removeItem(c.name) : new m();
89
+ Date.now() - Number(n) >= 1e3 * i.time ? localStorage.removeItem(i.name) : new m();
90
90
  }
91
- let u = 0;
91
+ let g = 0;
92
92
  function E() {
93
- u++, u >= c.count && !localStorage.getItem(c.name) && (localStorage.setItem(c.name, Date.now().toString()), new m());
93
+ g++, g >= i.count && !localStorage.getItem(i.name) && (localStorage.setItem(i.name, Date.now().toString()), new m());
94
94
  }
95
95
  const U = {
96
96
  initConsole: D,
97
97
  showConsole: E
98
98
  };
99
+ function q(...t) {
100
+ return t.reduce((n, e) => function(...o) {
101
+ return e(n(...o));
102
+ });
103
+ }
104
+ function z(...t) {
105
+ return t.reduce((n, e) => function(...o) {
106
+ return n(e(...o));
107
+ });
108
+ }
99
109
  export {
110
+ q as compose,
111
+ z as composeRight,
100
112
  $ as debounce,
101
113
  O as deepClone,
102
114
  d as deepMerge,
103
115
  N as error,
104
116
  R as getRandomColor,
105
- p as getRandomString,
117
+ a as getRandomString,
106
118
  _ as hasChanged,
107
119
  j as hasOwn,
108
- a as isArray,
120
+ u as isArray,
109
121
  b as isDate,
110
122
  W as isDef,
111
- g as isFunction,
123
+ p as isFunction,
112
124
  A as isMap,
113
125
  y as isNull,
114
126
  f as isObject,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/utils",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "description": "工具库",
5
5
  "type": "module",
6
6
  "license": "MIT",