@lntvow/utils 1.5.2 → 1.5.4
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 -0
- package/dist/index.d.ts +51 -31
- package/dist/index.mjs +75 -0
- package/package.json +9 -9
- package/README.md +0 -1
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js +0 -40
- package/dist/index.es.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function s(t){return t>10?s(10)+s(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const h=Object.prototype.toString,g=t=>h.call(t),u=t=>g(t)==="[object Date]",b=t=>g(t)==="[object RegExp]",f=t=>t!==null&&typeof t=="object",p=t=>t==null,d=Array.isArray,j=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);function c(t){const n=new WeakMap;function r(e){if(u(e))return new Date(e);if(b(e))return new RegExp(e);if(f(e)){if(n.has(e))return n.get(e);let i={};if(d(e)){i=[],n.set(e,i);for(let o=0;o<e.length;o++)i[o]=r(e[o]);return i}n.set(e,i);for(const o in e)j(e,o)&&(i[o]=r(e[o]));return i}else return e}return r(t)}function a(t,n){return d(t)?O(t,n):y(t,n)}function y(t,n){const r={},e=Object.keys(t),i=Object.keys(n);return e.forEach(o=>{p(n[o])?r[o]=c(t[o]):r[o]=f(t[o])&&f(n[o])?a(t[o],n[o]):c(n[o])}),i.forEach(o=>{p(r[o])&&(r[o]=c(n[o]))}),r}function O(t,n){return d(n)?[...c(t),...c(n)]:c(n)}function S(t,n=1e3){let r=null;return function(...e){r&&clearTimeout(r),r=setTimeout(()=>{t.apply(this,...e)},n)}}function w(t,n=1e3){let r=0;return function(...e){if(r)return r=Date.now(),t.apply(this,...e);{const i=Date.now();if(i-r>=n)return r=i,t.apply(this,...e)}}}exports.debounce=S;exports.deepClone=c;exports.deepMerge=a;exports.getRandomColor=l;exports.getRandomString=s;exports.throttle=w;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
declare type anyObj = Record<string, any>;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description 防抖函数
|
|
5
|
+
* @param target 目标函数
|
|
6
|
+
* @param wait 等待时间 默认 1000ms
|
|
7
|
+
* @example debounce(() => console.log('debounce'),500)
|
|
8
|
+
*/
|
|
9
|
+
export declare function debounce(target: Function, wait?: number): (...args: any[]) => void;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description 深拷贝
|
|
13
|
+
* @param target 拷贝对象
|
|
14
|
+
* @example deepClone({ name: 1, obj: { name: 1 }, arr: [1, 2, 3] }) => { name: 1, obj: { name: 1 }, arr: [1, 2, 3] }
|
|
15
|
+
*/
|
|
16
|
+
export declare function deepClone<T = any>(target: T): T;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @description 深度合并两对象
|
|
20
|
+
* @param template 模板对象 就是默认值
|
|
21
|
+
* @param source 源对象 就是用户传入的值
|
|
22
|
+
* @example deepMerge({ name: 1, obj: { name: '默认' }, arr: [1, 2, 3] }, { name: 1, obj: { name: '修改', age: '新增' }, test: 'test' }) => { name: 1, obj: { name: '修改', age: '新增' }, arr: [1, 2, 3], test: 'test' }
|
|
23
|
+
*/
|
|
24
|
+
export declare function deepMerge(template: anyObj, source: anyObj): any[] | anyObj;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @description 获取随机颜色
|
|
28
|
+
* @return {String} 随机颜色
|
|
29
|
+
*
|
|
30
|
+
* @example getRandomColor() => '#f36a38'
|
|
31
|
+
* */
|
|
32
|
+
export declare function getRandomColor(): string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @description 获取随机字符串
|
|
36
|
+
* @param {Number} number 长度
|
|
37
|
+
* @return {String} 随机字符串
|
|
38
|
+
*
|
|
39
|
+
* @example getRandomString(20) => 'tlw491y5ha357l59980n'
|
|
40
|
+
* */
|
|
41
|
+
export declare function getRandomString(number: number): string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @description 节流函数
|
|
45
|
+
* @param target 目标函数
|
|
46
|
+
* @param wait 等待时间 默认 1000ms
|
|
47
|
+
* @example throttle(() => console.log('throttle'),500)
|
|
48
|
+
*/
|
|
49
|
+
export declare function throttle(target: Function, wait?: number): (...args: any[]) => any;
|
|
50
|
+
|
|
51
|
+
export { }
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
function O() {
|
|
2
|
+
return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
|
|
3
|
+
}
|
|
4
|
+
function p(t) {
|
|
5
|
+
return t > 10 ? p(10) + p(t - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, t + 2);
|
|
6
|
+
}
|
|
7
|
+
const h = Object.prototype.toString, g = (t) => h.call(t), a = (t) => g(t) === "[object Date]", j = (t) => g(t) === "[object RegExp]", s = (t) => t !== null && typeof t == "object", d = (t) => t == null, f = Array.isArray, b = (t, n) => Object.prototype.hasOwnProperty.call(t, n);
|
|
8
|
+
function c(t) {
|
|
9
|
+
const n = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
function e(o) {
|
|
11
|
+
if (a(o))
|
|
12
|
+
return new Date(o);
|
|
13
|
+
if (j(o))
|
|
14
|
+
return new RegExp(o);
|
|
15
|
+
if (s(o)) {
|
|
16
|
+
if (n.has(o))
|
|
17
|
+
return n.get(o);
|
|
18
|
+
let i = {};
|
|
19
|
+
if (f(o)) {
|
|
20
|
+
i = [], n.set(o, i);
|
|
21
|
+
for (let r = 0; r < o.length; r++)
|
|
22
|
+
i[r] = e(o[r]);
|
|
23
|
+
return i;
|
|
24
|
+
}
|
|
25
|
+
n.set(o, i);
|
|
26
|
+
for (const r in o)
|
|
27
|
+
b(o, r) && (i[r] = e(o[r]));
|
|
28
|
+
return i;
|
|
29
|
+
} else
|
|
30
|
+
return o;
|
|
31
|
+
}
|
|
32
|
+
return e(t);
|
|
33
|
+
}
|
|
34
|
+
function u(t, n) {
|
|
35
|
+
return f(t) ? w(t, n) : l(t, n);
|
|
36
|
+
}
|
|
37
|
+
function l(t, n) {
|
|
38
|
+
const e = {}, o = Object.keys(t), i = Object.keys(n);
|
|
39
|
+
return o.forEach((r) => {
|
|
40
|
+
d(n[r]) ? e[r] = c(t[r]) : e[r] = s(t[r]) && s(n[r]) ? u(t[r], n[r]) : c(n[r]);
|
|
41
|
+
}), i.forEach((r) => {
|
|
42
|
+
d(e[r]) && (e[r] = c(n[r]));
|
|
43
|
+
}), e;
|
|
44
|
+
}
|
|
45
|
+
function w(t, n) {
|
|
46
|
+
return f(n) ? [...c(t), ...c(n)] : c(n);
|
|
47
|
+
}
|
|
48
|
+
function y(t, n = 1e3) {
|
|
49
|
+
let e = null;
|
|
50
|
+
return function(...o) {
|
|
51
|
+
e && clearTimeout(e), e = setTimeout(() => {
|
|
52
|
+
t.apply(this, ...o);
|
|
53
|
+
}, n);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function E(t, n = 1e3) {
|
|
57
|
+
let e = 0;
|
|
58
|
+
return function(...o) {
|
|
59
|
+
if (e)
|
|
60
|
+
return e = Date.now(), t.apply(this, ...o);
|
|
61
|
+
{
|
|
62
|
+
const i = Date.now();
|
|
63
|
+
if (i - e >= n)
|
|
64
|
+
return e = i, t.apply(this, ...o);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
y as debounce,
|
|
70
|
+
c as deepClone,
|
|
71
|
+
u as deepMerge,
|
|
72
|
+
O as getRandomColor,
|
|
73
|
+
p as getRandomString,
|
|
74
|
+
E as throttle
|
|
75
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lntvow/utils",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"description": "工具库",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
|
-
"main": "dist/index.cjs
|
|
12
|
-
"module": "dist/index.
|
|
11
|
+
"main": "dist/index.cjs",
|
|
12
|
+
"module": "dist/index.mjs",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@lntvow/eslint-config": "^
|
|
15
|
+
"@lntvow/eslint-config": "^7.1.12",
|
|
16
16
|
"bumpp": "^9.1.1",
|
|
17
17
|
"commitizen": "^4.3.0",
|
|
18
18
|
"cz-conventional-changelog": "^3.3.0",
|
|
19
|
-
"
|
|
19
|
+
"deepmerge": "^4.3.1",
|
|
20
20
|
"typescript": "^5.1.6",
|
|
21
|
-
"vite": "^4.
|
|
22
|
-
"vite-plugin-dts": "3.
|
|
23
|
-
"vitest": "^0.
|
|
21
|
+
"vite": "^4.4.4",
|
|
22
|
+
"vite-plugin-dts": "3.3.1",
|
|
23
|
+
"vitest": "^0.33.0"
|
|
24
24
|
},
|
|
25
25
|
"config": {
|
|
26
26
|
"commitizen": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"dev": "vite",
|
|
33
33
|
"test": "vitest",
|
|
34
|
-
"build": "vite build
|
|
34
|
+
"build": "vite build",
|
|
35
35
|
"commit": "git add . && git-cz && git push",
|
|
36
36
|
"release": "git add . && git commit -m release && bumpp package.json --commit --no-tag --push",
|
|
37
37
|
"rimraf": "rimraf ./node_modules/"
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# 工具库
|
package/dist/index.cjs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(){return`#${Math.random().toString(16).slice(2,8).padEnd(6,"0")}`}function i(t){return t>10?i(10)+i(t-10):Math.random().toString(36).padEnd(12,"0").slice(2,t+2)}const p=Object.prototype.toString,s=t=>p.call(t),d=t=>s(t)==="[object Date]",f=t=>s(t)==="[object RegExp]",y=t=>t!==null&&typeof t=="object",a=Array.isArray,S=(t,r)=>Object.prototype.hasOwnProperty.call(t,r);function j(t){const r=new WeakMap;function c(n){if(d(n))return new Date(n);if(f(n))return new RegExp(n);if(a(n)){const e=[];r.set(n,e);for(let o=0;o<n.length;o++)e[o]=c(n[o]);return e}if(y(n)){if(r.has(n))return r.get(n);const e={};r.set(n,e);for(const o in n)S(n,o)&&(e[o]=c(n[o]));return e}else return n}return c(t)}exports.deepClone=j;exports.getRandomColor=g;exports.getRandomString=i;
|
|
2
|
-
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/getRandom.ts","../src/util/type.ts","../src/deepClone.ts"],"sourcesContent":["/**\n * @description 获取随机颜色\n * @return {String} 随机颜色\n *\n * @example getRandomColor() => '#f36a38'\n * */\nexport function getRandomColor(): string {\n return `#${Math.random().toString(16).slice(2, 8).padEnd(6, '0')}`\n}\n\n/**\n * @description 获取随机字符串\n * @param {Number} number 长度\n * @return {String} 随机字符串\n *\n * @example getRandomString(20) => 'tlw491y5ha357l59980n'\n * */\nexport function getRandomString(number: number): string {\n return number > 10\n ? getRandomString(10) + getRandomString(number - 10)\n : Math.random()\n .toString(36)\n .padEnd(12, '0')\n .slice(2, number + 2)\n}\n","export const extend = Object.assign\n\nexport const objectToString = Object.prototype.toString\n\nexport const toTypeString = (value: unknown): string =>\n objectToString.call(value)\n\nexport const log = (...arg: unknown[]) =>\n console.log(\n `%c ${arg[0]}: `,\n 'padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;',\n arg.slice(1)\n )\n\nexport const warn = (msg: string) => console.warn(msg)\n\nexport const error = (msg: string) => console.error(msg)\n\nexport const isMap = (val: unknown): val is Map<any, any> =>\n toTypeString(val) === '[object Map]'\n\nexport const isSet = (val: unknown): val is Set<any> =>\n toTypeString(val) === '[object Set]'\n\nexport const isDate = (val: unknown): val is Date =>\n toTypeString(val) === '[object Date]'\n\nexport const isRegExp = (val: unknown): val is RegExp =>\n toTypeString(val) === '[object RegExp]'\n\nexport const isFunction = (val: unknown): val is Function =>\n typeof val === 'function'\n\nexport const isString = (val: unknown): val is string => typeof val === 'string'\n\nexport const isSymbol = (val: unknown): val is symbol => typeof val === 'symbol'\n\nexport const isObject = (val: unknown): val is Record<any, any> =>\n val !== null && typeof val === 'object'\n\nexport const isPromise = <T = any>(val: unknown): val is Promise<T> =>\n isObject(val) && isFunction(val.then) && isFunction(val.catch)\n\nexport const isUndef = (val: unknown): val is undefined => val === undefined\n\nexport const isNull = (val: unknown): val is null => val === null\n\nexport const isDef = (val: unknown): val is Exclude<typeof val, undefined> =>\n val !== undefined\n\nexport const isArray = Array.isArray\n\nexport const hasOwn = <T extends object, U extends keyof T>(\n target: T,\n key: U\n) => Object.prototype.hasOwnProperty.call(target, key)\n\nexport const hasChanged = (oldValue: unknown, newValue: unknown) =>\n oldValue !== newValue\n","import { hasOwn, isArray, isDate, isObject, isRegExp } from './util/type'\n\ntype Target = Record<string | symbol | number, any> | Array<any>\n\nexport function deepClone<T extends Target>(target: T): T {\n const map = new WeakMap()\n\n function _deepClone(value: any) {\n if (isDate(value)) return new Date(value)\n if (isRegExp(value)) return new RegExp(value)\n if (isArray(value)) {\n const clone: any[] = []\n map.set(value, clone)\n for (let i = 0; i < value.length; i++) clone[i] = _deepClone(value[i])\n\n return clone\n }\n if (isObject(value)) {\n // 取出 WeakMap 中缓存的 clone 对象\n if (map.has(value)) return map.get(value)\n const clone: Record<any, any> = {}\n // 设置缓存\n map.set(value, clone)\n for (const key in value)\n if (hasOwn(value, key)) clone[key] = _deepClone(value[key])\n\n return clone\n } else {\n return value\n }\n }\n\n return _deepClone(target)\n}\n"],"names":["getRandomColor","getRandomString","number","objectToString","toTypeString","value","isDate","val","isRegExp","isObject","isArray","hasOwn","target","key","deepClone","map","_deepClone","clone","i"],"mappings":"gFAMO,SAASA,GAAyB,CACvC,MAAO,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAG,CAAC,EAAE,OAAO,EAAG,GAAG,GACjE,CASO,SAASC,EAAgBC,EAAwB,CAC/C,OAAAA,EAAS,GACZD,EAAgB,EAAE,EAAIA,EAAgBC,EAAS,EAAE,EACjD,KAAK,OAAA,EACF,SAAS,EAAE,EACX,OAAO,GAAI,GAAG,EACd,MAAM,EAAGA,EAAS,CAAC,CAC5B,CCtBa,MAAAC,EAAiB,OAAO,UAAU,SAElCC,EAAgBC,GAC3BF,EAAe,KAAKE,CAAK,EAmBdC,EAAUC,GACrBH,EAAaG,CAAG,IAAM,gBAEXC,EAAYD,GACvBH,EAAaG,CAAG,IAAM,kBASXE,EAAYF,GACvBA,IAAQ,MAAQ,OAAOA,GAAQ,SAYpBG,EAAU,MAAM,QAEhBC,EAAS,CACpBC,EACAC,IACG,OAAO,UAAU,eAAe,KAAKD,EAAQC,CAAG,ECnD9C,SAASC,EAA4BF,EAAc,CAClD,MAAAG,MAAU,QAEhB,SAASC,EAAWX,EAAY,CAC9B,GAAIC,EAAOD,CAAK,EAAU,OAAA,IAAI,KAAKA,CAAK,EACxC,GAAIG,EAASH,CAAK,EAAU,OAAA,IAAI,OAAOA,CAAK,EACxC,GAAAK,EAAQL,CAAK,EAAG,CAClB,MAAMY,EAAe,CAAA,EACjBF,EAAA,IAAIV,EAAOY,CAAK,EACpB,QAASC,EAAI,EAAGA,EAAIb,EAAM,OAAQa,IAAKD,EAAMC,CAAC,EAAIF,EAAWX,EAAMa,CAAC,CAAC,EAE9D,OAAAD,EAEL,GAAAR,EAASJ,CAAK,EAAG,CAEf,GAAAU,EAAI,IAAIV,CAAK,EAAU,OAAAU,EAAI,IAAIV,CAAK,EACxC,MAAMY,EAA0B,CAAA,EAE5BF,EAAA,IAAIV,EAAOY,CAAK,EACpB,UAAWJ,KAAOR,EACZM,EAAON,EAAOQ,CAAG,IAAGI,EAAMJ,CAAG,EAAIG,EAAWX,EAAMQ,CAAG,CAAC,GAErD,OAAAI,MAEA,QAAAZ,CAEX,CAEA,OAAOW,EAAWJ,CAAM,CAC1B"}
|
package/dist/index.es.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
function a() {
|
|
2
|
-
return `#${Math.random().toString(16).slice(2, 8).padEnd(6, "0")}`;
|
|
3
|
-
}
|
|
4
|
-
function i(t) {
|
|
5
|
-
return t > 10 ? i(10) + i(t - 10) : Math.random().toString(36).padEnd(12, "0").slice(2, t + 2);
|
|
6
|
-
}
|
|
7
|
-
const p = Object.prototype.toString, s = (t) => p.call(t), f = (t) => s(t) === "[object Date]", g = (t) => s(t) === "[object RegExp]", d = (t) => t !== null && typeof t == "object", y = Array.isArray, j = (t, e) => Object.prototype.hasOwnProperty.call(t, e);
|
|
8
|
-
function h(t) {
|
|
9
|
-
const e = /* @__PURE__ */ new WeakMap();
|
|
10
|
-
function c(n) {
|
|
11
|
-
if (f(n))
|
|
12
|
-
return new Date(n);
|
|
13
|
-
if (g(n))
|
|
14
|
-
return new RegExp(n);
|
|
15
|
-
if (y(n)) {
|
|
16
|
-
const r = [];
|
|
17
|
-
e.set(n, r);
|
|
18
|
-
for (let o = 0; o < n.length; o++)
|
|
19
|
-
r[o] = c(n[o]);
|
|
20
|
-
return r;
|
|
21
|
-
}
|
|
22
|
-
if (d(n)) {
|
|
23
|
-
if (e.has(n))
|
|
24
|
-
return e.get(n);
|
|
25
|
-
const r = {};
|
|
26
|
-
e.set(n, r);
|
|
27
|
-
for (const o in n)
|
|
28
|
-
j(n, o) && (r[o] = c(n[o]));
|
|
29
|
-
return r;
|
|
30
|
-
} else
|
|
31
|
-
return n;
|
|
32
|
-
}
|
|
33
|
-
return c(t);
|
|
34
|
-
}
|
|
35
|
-
export {
|
|
36
|
-
h as deepClone,
|
|
37
|
-
a as getRandomColor,
|
|
38
|
-
i as getRandomString
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/getRandom.ts","../src/util/type.ts","../src/deepClone.ts"],"sourcesContent":["/**\n * @description 获取随机颜色\n * @return {String} 随机颜色\n *\n * @example getRandomColor() => '#f36a38'\n * */\nexport function getRandomColor(): string {\n return `#${Math.random().toString(16).slice(2, 8).padEnd(6, '0')}`\n}\n\n/**\n * @description 获取随机字符串\n * @param {Number} number 长度\n * @return {String} 随机字符串\n *\n * @example getRandomString(20) => 'tlw491y5ha357l59980n'\n * */\nexport function getRandomString(number: number): string {\n return number > 10\n ? getRandomString(10) + getRandomString(number - 10)\n : Math.random()\n .toString(36)\n .padEnd(12, '0')\n .slice(2, number + 2)\n}\n","export const extend = Object.assign\n\nexport const objectToString = Object.prototype.toString\n\nexport const toTypeString = (value: unknown): string =>\n objectToString.call(value)\n\nexport const log = (...arg: unknown[]) =>\n console.log(\n `%c ${arg[0]}: `,\n 'padding: 2px 1px; border-radius: 3px 3px 3px 3px; color: #fff; background: #000; font-weight: bold;',\n arg.slice(1)\n )\n\nexport const warn = (msg: string) => console.warn(msg)\n\nexport const error = (msg: string) => console.error(msg)\n\nexport const isMap = (val: unknown): val is Map<any, any> =>\n toTypeString(val) === '[object Map]'\n\nexport const isSet = (val: unknown): val is Set<any> =>\n toTypeString(val) === '[object Set]'\n\nexport const isDate = (val: unknown): val is Date =>\n toTypeString(val) === '[object Date]'\n\nexport const isRegExp = (val: unknown): val is RegExp =>\n toTypeString(val) === '[object RegExp]'\n\nexport const isFunction = (val: unknown): val is Function =>\n typeof val === 'function'\n\nexport const isString = (val: unknown): val is string => typeof val === 'string'\n\nexport const isSymbol = (val: unknown): val is symbol => typeof val === 'symbol'\n\nexport const isObject = (val: unknown): val is Record<any, any> =>\n val !== null && typeof val === 'object'\n\nexport const isPromise = <T = any>(val: unknown): val is Promise<T> =>\n isObject(val) && isFunction(val.then) && isFunction(val.catch)\n\nexport const isUndef = (val: unknown): val is undefined => val === undefined\n\nexport const isNull = (val: unknown): val is null => val === null\n\nexport const isDef = (val: unknown): val is Exclude<typeof val, undefined> =>\n val !== undefined\n\nexport const isArray = Array.isArray\n\nexport const hasOwn = <T extends object, U extends keyof T>(\n target: T,\n key: U\n) => Object.prototype.hasOwnProperty.call(target, key)\n\nexport const hasChanged = (oldValue: unknown, newValue: unknown) =>\n oldValue !== newValue\n","import { hasOwn, isArray, isDate, isObject, isRegExp } from './util/type'\n\ntype Target = Record<string | symbol | number, any> | Array<any>\n\nexport function deepClone<T extends Target>(target: T): T {\n const map = new WeakMap()\n\n function _deepClone(value: any) {\n if (isDate(value)) return new Date(value)\n if (isRegExp(value)) return new RegExp(value)\n if (isArray(value)) {\n const clone: any[] = []\n map.set(value, clone)\n for (let i = 0; i < value.length; i++) clone[i] = _deepClone(value[i])\n\n return clone\n }\n if (isObject(value)) {\n // 取出 WeakMap 中缓存的 clone 对象\n if (map.has(value)) return map.get(value)\n const clone: Record<any, any> = {}\n // 设置缓存\n map.set(value, clone)\n for (const key in value)\n if (hasOwn(value, key)) clone[key] = _deepClone(value[key])\n\n return clone\n } else {\n return value\n }\n }\n\n return _deepClone(target)\n}\n"],"names":["getRandomColor","getRandomString","number","objectToString","toTypeString","value","isDate","val","isRegExp","isObject","isArray","hasOwn","target","key","deepClone","map","_deepClone","clone","i"],"mappings":"AAMO,SAASA,IAAyB;AACvC,SAAO,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,EAAE,OAAO,GAAG,GAAG;AACjE;AASO,SAASC,EAAgBC,GAAwB;AAC/C,SAAAA,IAAS,KACZD,EAAgB,EAAE,IAAIA,EAAgBC,IAAS,EAAE,IACjD,KAAK,OAAA,EACF,SAAS,EAAE,EACX,OAAO,IAAI,GAAG,EACd,MAAM,GAAGA,IAAS,CAAC;AAC5B;ACtBa,MAAAC,IAAiB,OAAO,UAAU,UAElCC,IAAe,CAACC,MAC3BF,EAAe,KAAKE,CAAK,GAmBdC,IAAS,CAACC,MACrBH,EAAaG,CAAG,MAAM,iBAEXC,IAAW,CAACD,MACvBH,EAAaG,CAAG,MAAM,mBASXE,IAAW,CAACF,MACvBA,MAAQ,QAAQ,OAAOA,KAAQ,UAYpBG,IAAU,MAAM,SAEhBC,IAAS,CACpBC,GACAC,MACG,OAAO,UAAU,eAAe,KAAKD,GAAQC,CAAG;ACnD9C,SAASC,EAA4BF,GAAc;AAClD,QAAAG,wBAAU;AAEhB,WAASC,EAAWX,GAAY;AAC9B,QAAIC,EAAOD,CAAK;AAAU,aAAA,IAAI,KAAKA,CAAK;AACxC,QAAIG,EAASH,CAAK;AAAU,aAAA,IAAI,OAAOA,CAAK;AACxC,QAAAK,EAAQL,CAAK,GAAG;AAClB,YAAMY,IAAe,CAAA;AACjB,MAAAF,EAAA,IAAIV,GAAOY,CAAK;AACpB,eAASC,IAAI,GAAGA,IAAIb,EAAM,QAAQa;AAAK,QAAAD,EAAMC,CAAC,IAAIF,EAAWX,EAAMa,CAAC,CAAC;AAE9D,aAAAD;AAAA;AAEL,QAAAR,EAASJ,CAAK,GAAG;AAEf,UAAAU,EAAI,IAAIV,CAAK;AAAU,eAAAU,EAAI,IAAIV,CAAK;AACxC,YAAMY,IAA0B,CAAA;AAE5B,MAAAF,EAAA,IAAIV,GAAOY,CAAK;AACpB,iBAAWJ,KAAOR;AACZ,QAAAM,EAAON,GAAOQ,CAAG,MAAGI,EAAMJ,CAAG,IAAIG,EAAWX,EAAMQ,CAAG,CAAC;AAErD,aAAAI;AAAA;AAEA,aAAAZ;AAAA,EAEX;AAEA,SAAOW,EAAWJ,CAAM;AAC1B;"}
|