@vope/utils 1.0.2 → 1.1.0

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.
Files changed (45) hide show
  1. package/cjs/clamp.js +14 -0
  2. package/cjs/classnames.js +22 -0
  3. package/cjs/compare/version.js +21 -0
  4. package/cjs/compare/{value.js → weak-equal.js} +6 -6
  5. package/cjs/encoding.js +65 -0
  6. package/cjs/index.js +25 -5
  7. package/cjs/is/class.js +1 -2
  8. package/cjs/memory/basic.js +148 -0
  9. package/cjs/memory/list.js +20 -0
  10. package/cjs/memory/power.js +19 -0
  11. package/cjs/once.js +15 -0
  12. package/cjs/power/decon.js +31 -0
  13. package/cjs/union.js +25 -0
  14. package/cjs/url/join.js +1 -2
  15. package/lib/clamp.js +12 -0
  16. package/lib/classnames.js +20 -0
  17. package/lib/compare/version.js +19 -0
  18. package/lib/compare/{value.js → weak-equal.js} +6 -6
  19. package/lib/encoding.js +63 -0
  20. package/lib/index.js +13 -3
  21. package/lib/is/class.js +2 -1
  22. package/lib/memory/basic.js +142 -0
  23. package/lib/memory/list.js +14 -0
  24. package/lib/memory/power.js +13 -0
  25. package/lib/once.js +13 -0
  26. package/lib/power/decon.js +29 -0
  27. package/lib/union.js +22 -0
  28. package/lib/url/join.js +2 -1
  29. package/package.json +7 -5
  30. package/types/clamp.d.ts +5 -0
  31. package/types/classnames.d.ts +7 -0
  32. package/types/compare/version.d.ts +6 -0
  33. package/types/compare/weak-equal.d.ts +5 -0
  34. package/types/encoding.d.ts +16 -0
  35. package/types/index.d.ts +13 -3
  36. package/types/is/class.d.ts +2 -1
  37. package/types/memory/basic.d.ts +63 -0
  38. package/types/memory/list.d.ts +8 -0
  39. package/types/memory/power.d.ts +8 -0
  40. package/types/memory/type.d.ts +11 -0
  41. package/types/once.d.ts +7 -0
  42. package/types/power/decon.d.ts +9 -0
  43. package/types/union.d.ts +20 -0
  44. package/types/url/join.d.ts +2 -1
  45. package/types/compare/value.d.ts +0 -5
package/cjs/clamp.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 获取中间数
5
+ */
6
+ exports.default = (value, min, max) => {
7
+ if (min > max) {
8
+ // js位运算的范围为(-2^32,2^32),超出会产生溢出
9
+ const swap = max;
10
+ max = min;
11
+ min = swap;
12
+ }
13
+ return Math.min(max, Math.max(min, value));
14
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const add = (a, b) => a
4
+ ? a + '\u0020' + b
5
+ : b;
6
+ /**
7
+ * 拼接多个class
8
+ */
9
+ exports.default = (...list) => list.reduce((caches, data) => {
10
+ if (typeof data === 'string') {
11
+ data && (caches = add(caches, data));
12
+ }
13
+ else if (Array.isArray(data)) {
14
+ data.forEach((value) => value && (caches = add(caches, value)));
15
+ }
16
+ else if (data) {
17
+ for (const key in data) {
18
+ key && data[key] && (caches = add(caches, key));
19
+ }
20
+ }
21
+ return caches;
22
+ }, '');
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const CHAR = '.';
4
+ /**
5
+ * 版本号大小比较
6
+ * @description from < to = 1,from === to = 0,from > to = -1
7
+ */
8
+ const compareVersion = (from, to) => {
9
+ const froms = from.split(CHAR);
10
+ const tos = to.split(CHAR);
11
+ for (let i = 0, max = Math.max(froms.length, tos.length); i < max; i++) {
12
+ const fromV = +froms[i] || 0;
13
+ const toV = +tos[i] || 0;
14
+ if (fromV > toV)
15
+ return -1;
16
+ if (fromV < toV)
17
+ return 1;
18
+ }
19
+ return 0;
20
+ };
21
+ exports.default = compareVersion;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /**
4
- * 值比较(深度浅比较)
4
+ * 深度相等性比较(弱比较)
5
5
  */
6
- const compareValue = (from, to) => {
6
+ const deepWeakEqual = (from, to) => {
7
7
  if (typeof from !== 'object'
8
8
  || from === null
9
9
  || typeof to !== 'object'
@@ -13,7 +13,7 @@ const compareValue = (from, to) => {
13
13
  if (from.length !== to.length)
14
14
  return false;
15
15
  return !from.some((t1, index) => {
16
- if (!compareValue(t1, to[index])) {
16
+ if (!deepWeakEqual(t1, to[index])) {
17
17
  return true;
18
18
  }
19
19
  });
@@ -21,7 +21,7 @@ const compareValue = (from, to) => {
21
21
  else {
22
22
  const caches = {};
23
23
  for (const key in from) {
24
- if (!compareValue(from[key], to[key])) {
24
+ if (!deepWeakEqual(from[key], to[key])) {
25
25
  return false;
26
26
  }
27
27
  else {
@@ -31,11 +31,11 @@ const compareValue = (from, to) => {
31
31
  for (const key in to) {
32
32
  if (key in caches)
33
33
  continue;
34
- if (!compareValue(from[key], to[key])) {
34
+ if (!deepWeakEqual(from[key], to[key])) {
35
35
  return false;
36
36
  }
37
37
  }
38
38
  }
39
39
  return true;
40
40
  };
41
- exports.default = compareValue;
41
+ exports.default = deepWeakEqual;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utf8_first_prefix = /^1{2,}/g;
4
+ const utf8_other_prefix = /^10/;
5
+ var Encodes;
6
+ (function (Encodes) {
7
+ Encodes["UTF_8"] = "utf-8";
8
+ Encodes["UTF_16LE"] = "utf-16le";
9
+ Encodes["UTF_16BE"] = "utf-16be";
10
+ Encodes["GBK"] = "gbk";
11
+ })(Encodes || (Encodes = {}));
12
+ const defaults = {
13
+ utf8: [0xef, 0xbb, 0xbf],
14
+ };
15
+ const equal = (uint, list) => {
16
+ if (uint.length !== list.length)
17
+ return false;
18
+ return !uint.some((value, index) => value !== list[index]);
19
+ };
20
+ /**
21
+ * 根据文件内容判断文件的编码
22
+ * @param uint 文件内容Uint8Array格式
23
+ * @param limit 用于约束GBK和utf_8的判定上限
24
+ */
25
+ const getEncoding = (uint, limit = 1024) => {
26
+ let encoding;
27
+ let offset = 0;
28
+ if (equal(uint.slice(0, 3), defaults.utf8)) {
29
+ offset = defaults.utf8.length;
30
+ encoding = Encodes.UTF_8;
31
+ }
32
+ else if (equal(uint.slice(0, 2), [0xff, 0xfe])) {
33
+ encoding = Encodes.UTF_16LE;
34
+ }
35
+ else if (equal(uint.slice(0, 2), [0xfe, 0xff])) {
36
+ encoding = Encodes.UTF_16BE;
37
+ }
38
+ else {
39
+ let isBreak = false;
40
+ top: for (let i = 0; i < Math.min(uint.length, limit); i++) {
41
+ const data = uint[i];
42
+ if (data < 128)
43
+ continue;
44
+ const match = data.toString(2).match(utf8_first_prefix);
45
+ if (match) {
46
+ for (let m = 0; m < match[0].length - 1; m++) {
47
+ const target = uint[++i];
48
+ if (target == void 0 || !utf8_other_prefix.test(target.toString(2))) {
49
+ encoding = Encodes.GBK;
50
+ isBreak = true;
51
+ break top;
52
+ }
53
+ }
54
+ }
55
+ else {
56
+ encoding = Encodes.GBK;
57
+ isBreak = true;
58
+ break;
59
+ }
60
+ }
61
+ isBreak || (encoding = Encodes.UTF_8);
62
+ }
63
+ return { encoding, offset };
64
+ };
65
+ exports.default = getEncoding;
package/cjs/index.js CHANGED
@@ -3,25 +3,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.connectURLParams = exports.joinURLs = exports.isNull = exports.isEmpty = exports.isClass = exports.hash8strings = exports.hash8object = exports.hash8json = exports.compareValue = exports.apiGet = exports.apiPost = void 0;
6
+ exports.connectURLParams = exports.joinURLs = exports.Union = exports.deconPowersSum = exports.once = exports.MemoryPower = exports.MemoryList = exports.MemoryBasic = exports.isNull = exports.isEmpty = exports.isClass = exports.getEncoding = exports.hash8strings = exports.hash8object = exports.hash8json = exports.deepWeakEqual = exports.compareVersion = exports.classnames = exports.clamp = exports.apiGet = exports.apiPost = void 0;
7
7
  var api_1 = require("./api");
8
8
  Object.defineProperty(exports, "apiPost", { enumerable: true, get: function () { return api_1.apiPost; } });
9
9
  Object.defineProperty(exports, "apiGet", { enumerable: true, get: function () { return api_1.apiGet; } });
10
- var value_1 = require("./compare/value");
11
- Object.defineProperty(exports, "compareValue", { enumerable: true, get: function () { return __importDefault(value_1).default; } });
10
+ var clamp_1 = require("./clamp");
11
+ Object.defineProperty(exports, "clamp", { enumerable: true, get: function () { return __importDefault(clamp_1).default; } });
12
+ var classnames_1 = require("./classnames");
13
+ Object.defineProperty(exports, "classnames", { enumerable: true, get: function () { return __importDefault(classnames_1).default; } });
14
+ var version_1 = require("./compare/version");
15
+ Object.defineProperty(exports, "compareVersion", { enumerable: true, get: function () { return __importDefault(version_1).default; } });
16
+ var weak_equal_1 = require("./compare/weak-equal");
17
+ Object.defineProperty(exports, "deepWeakEqual", { enumerable: true, get: function () { return __importDefault(weak_equal_1).default; } });
12
18
  var json_1 = require("./convert/json");
13
19
  Object.defineProperty(exports, "hash8json", { enumerable: true, get: function () { return __importDefault(json_1).default; } });
14
20
  var object_1 = require("./convert/object");
15
21
  Object.defineProperty(exports, "hash8object", { enumerable: true, get: function () { return __importDefault(object_1).default; } });
16
22
  var strings_1 = require("./convert/strings");
17
23
  Object.defineProperty(exports, "hash8strings", { enumerable: true, get: function () { return __importDefault(strings_1).default; } });
24
+ var encoding_1 = require("./encoding");
25
+ Object.defineProperty(exports, "getEncoding", { enumerable: true, get: function () { return __importDefault(encoding_1).default; } });
18
26
  var class_1 = require("./is/class");
19
- Object.defineProperty(exports, "isClass", { enumerable: true, get: function () { return class_1.isClass; } });
27
+ Object.defineProperty(exports, "isClass", { enumerable: true, get: function () { return __importDefault(class_1).default; } });
20
28
  var empty_1 = require("./is/empty");
21
29
  Object.defineProperty(exports, "isEmpty", { enumerable: true, get: function () { return __importDefault(empty_1).default; } });
22
30
  var null_1 = require("./is/null");
23
31
  Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return __importDefault(null_1).default; } });
32
+ var basic_1 = require("./memory/basic");
33
+ Object.defineProperty(exports, "MemoryBasic", { enumerable: true, get: function () { return __importDefault(basic_1).default; } });
34
+ var list_1 = require("./memory/list");
35
+ Object.defineProperty(exports, "MemoryList", { enumerable: true, get: function () { return __importDefault(list_1).default; } });
36
+ var power_1 = require("./memory/power");
37
+ Object.defineProperty(exports, "MemoryPower", { enumerable: true, get: function () { return __importDefault(power_1).default; } });
38
+ var once_1 = require("./once");
39
+ Object.defineProperty(exports, "once", { enumerable: true, get: function () { return __importDefault(once_1).default; } });
40
+ var decon_1 = require("./power/decon");
41
+ Object.defineProperty(exports, "deconPowersSum", { enumerable: true, get: function () { return __importDefault(decon_1).default; } });
42
+ var union_1 = require("./union");
43
+ Object.defineProperty(exports, "Union", { enumerable: true, get: function () { return __importDefault(union_1).default; } });
24
44
  var join_1 = require("./url/join");
25
- Object.defineProperty(exports, "joinURLs", { enumerable: true, get: function () { return join_1.joinURLs; } });
45
+ Object.defineProperty(exports, "joinURLs", { enumerable: true, get: function () { return __importDefault(join_1).default; } });
26
46
  var params_1 = require("./url/params");
27
47
  Object.defineProperty(exports, "connectURLParams", { enumerable: true, get: function () { return __importDefault(params_1).default; } });
package/cjs/is/class.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isClass = void 0;
4
3
  const re_anonymous = /^function\s+\(|^function\s+anonymous\(/;
5
4
  const re_function = /^function\s+[A-Z]/;
6
5
  const re_this = /\b\(this\b|\bthis[\.\[]\b/;
@@ -30,4 +29,4 @@ const isClass = (value, strict = true) => {
30
29
  }
31
30
  return false;
32
31
  };
33
- exports.isClass = isClass;
32
+ exports.default = isClass;
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const strings_1 = __importDefault(require("../convert/strings"));
7
+ /**
8
+ * 分类存储(通过继承,可用于拓展存储方式)
9
+ */
10
+ class MemoryBasic {
11
+ key;
12
+ #mount;
13
+ #reflex;
14
+ list = [];
15
+ memorys = new Map();
16
+ /**
17
+ * 返回存储长度
18
+ */
19
+ get size() {
20
+ return this.list.length;
21
+ }
22
+ /**
23
+ * @param key 用于对数据进行分类的key
24
+ * @param config
25
+ */
26
+ constructor(key, config) {
27
+ this.key = key;
28
+ this.#mount = config.mount;
29
+ this.#reflex = config.reflex;
30
+ }
31
+ getType(data) {
32
+ const { key } = this;
33
+ return typeof key === 'function' ? key(data) : data[key];
34
+ }
35
+ push(...list) {
36
+ const { memorys } = this;
37
+ list.forEach((data) => {
38
+ const type = this.getType(data);
39
+ const memory = memorys.get(type);
40
+ const index = this.list.push(data) - 1;
41
+ const result = this.#mount(index, memory);
42
+ memory === result || memorys.set(type, result);
43
+ });
44
+ return this;
45
+ }
46
+ /**
47
+ * 遍历所有存储数据(按入栈顺序)
48
+ */
49
+ forEach(callback) {
50
+ this.list.forEach(callback);
51
+ return this;
52
+ }
53
+ /**
54
+ * 遍历所有存储类型
55
+ */
56
+ forType(callback) {
57
+ const { memorys, list } = this;
58
+ for (const [type, memory] of memorys) {
59
+ const caches = this.#reflex(memory).map((index) => list[index]);
60
+ callback(caches, type);
61
+ }
62
+ return this;
63
+ }
64
+ /**
65
+ * 检测存储是否包含某种类型
66
+ */
67
+ includes(type) {
68
+ return type in this.memorys;
69
+ }
70
+ /**
71
+ * 获取指定类型存储数据
72
+ */
73
+ get(type) {
74
+ const memory = this.memorys.get(type);
75
+ return memory === void 0
76
+ ? null
77
+ : this.#reflex(memory).map((count) => this.list[count]);
78
+ }
79
+ /**
80
+ * 删除指定存储数据
81
+ */
82
+ delete(data) {
83
+ const { memorys, list } = this;
84
+ let index = -1;
85
+ if (!list.some((value, i) => {
86
+ if (data === value) {
87
+ index = i;
88
+ list.splice(index, 1);
89
+ const type = this.getType(value);
90
+ const memory = this.#reflex(memorys.get(type));
91
+ if (memory.length === 1) {
92
+ memorys.delete(type);
93
+ }
94
+ else {
95
+ memory.some((count, j) => {
96
+ if (count === i) {
97
+ memory.splice(j, 1);
98
+ return true;
99
+ }
100
+ });
101
+ }
102
+ return true;
103
+ }
104
+ }))
105
+ return this;
106
+ for (const [type, target] of memorys) {
107
+ const memory = this.#reflex(target);
108
+ memory.forEach((value, index) => {
109
+ if (value >= index) {
110
+ memory[index] = value - 1;
111
+ }
112
+ });
113
+ if (memory !== target) {
114
+ let reactor;
115
+ memory.forEach((count) => {
116
+ reactor = this.#mount(count, reactor);
117
+ });
118
+ memorys.set(type, reactor);
119
+ }
120
+ }
121
+ return this;
122
+ }
123
+ /**
124
+ * 删除指定类型存储数据
125
+ */
126
+ deleteType(type) {
127
+ const { memorys, list } = this;
128
+ if (!memorys.has(type))
129
+ return this;
130
+ const local = (0, strings_1.default)(this.#reflex(memorys.get(type)));
131
+ const Memory = this.constructor;
132
+ const imitator = new Memory(this.key);
133
+ list.forEach((data, index) => {
134
+ index in local || imitator.push(data);
135
+ });
136
+ this.list = imitator.list;
137
+ this.memorys = imitator.memorys;
138
+ return this;
139
+ }
140
+ /**
141
+ * 清理存储
142
+ */
143
+ clear() {
144
+ this.list = [];
145
+ this.memorys.clear();
146
+ }
147
+ }
148
+ exports.default = MemoryBasic;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const basic_1 = __importDefault(require("./basic"));
7
+ /**
8
+ * 分类存储(基于普通的键值存储)
9
+ */
10
+ class MemoryList extends basic_1.default {
11
+ constructor(key) {
12
+ super(key, {
13
+ mount: (index, reactor) => reactor
14
+ ? (reactor.push(index), reactor)
15
+ : [index],
16
+ reflex: (reactor) => reactor,
17
+ });
18
+ }
19
+ }
20
+ exports.default = MemoryList;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const decon_1 = __importDefault(require("../power/decon"));
7
+ const basic_1 = __importDefault(require("./basic"));
8
+ /**
9
+ * 分类存储(基于2的n次幂之和构建唯一键进行存储)
10
+ */
11
+ class MemoryPower extends basic_1.default {
12
+ constructor(key) {
13
+ super(key, {
14
+ mount: (index, reactor) => (reactor || 0) + 2 ** index,
15
+ reflex: (reactor) => (0, decon_1.default)(reactor, 'asc'),
16
+ });
17
+ }
18
+ }
19
+ exports.default = MemoryPower;
package/cjs/once.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 缓存函数返回值
5
+ * @param callback 运行返回值的函数
6
+ * @param thisArg 绑定到运行函数的this对象
7
+ */
8
+ exports.default = (func, thisArg) => {
9
+ let local;
10
+ let inited = false;
11
+ return (...list) => inited
12
+ ? local
13
+ : (inited = true,
14
+ local = func.apply(thisArg, list));
15
+ };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ERROR_MESSAGE = {
4
+ INT: '参数必须是整数',
5
+ MIN: '多个2的正整数幂(两两不相等)之和必定大于等于1',
6
+ };
7
+ /**
8
+ * 解构多个2的正整数幂(两两不相等)之和
9
+ * @param sum 幂和
10
+ * @param sort 排序方式(默认降序)
11
+ * @description sum > 2**53则会因为精度问题计算报错
12
+ */
13
+ const deconPowersSum = (sum, sort) => {
14
+ if (sum < 1) {
15
+ throw new Error(ERROR_MESSAGE.MIN);
16
+ }
17
+ else if (sum !== Math.floor(sum)) {
18
+ throw new Error(ERROR_MESSAGE.INT);
19
+ }
20
+ const list = [];
21
+ let cache = sum;
22
+ while (cache) {
23
+ const power = Math.log2(cache) ^ 0;
24
+ list.push(power);
25
+ cache -= Math.pow(2, power);
26
+ }
27
+ return sort === 'asc'
28
+ ? list.reverse()
29
+ : list;
30
+ };
31
+ exports.default = deconPowersSum;
package/cjs/union.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * 数据联合(用于需要对加入的数据进行智能提示)
5
+ */
6
+ class Union {
7
+ key;
8
+ formater;
9
+ #map = {};
10
+ get value() {
11
+ return this.#map;
12
+ }
13
+ constructor(key, formater) {
14
+ this.key = key;
15
+ this.formater = formater;
16
+ }
17
+ add(data) {
18
+ const { formater } = this;
19
+ this.#map[data[this.key]] = formater
20
+ ? formater(data)
21
+ : data;
22
+ return this;
23
+ }
24
+ }
25
+ exports.default = Union;
package/cjs/url/join.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.joinURLs = void 0;
4
3
  const re = /(^|[^:/])\/{2,}/g;
5
4
  /**
6
5
  * 实现多个路径拼接
@@ -13,4 +12,4 @@ const joinURLs = (...list) => {
13
12
  ? list[0]
14
13
  : list.join('/').replace(re, ($0, $1) => `${$1}/`);
15
14
  };
16
- exports.joinURLs = joinURLs;
15
+ exports.default = joinURLs;
package/lib/clamp.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 获取中间数
3
+ */
4
+ export default (value, min, max) => {
5
+ if (min > max) {
6
+ // js位运算的范围为(-2^32,2^32),超出会产生溢出
7
+ const swap = max;
8
+ max = min;
9
+ min = swap;
10
+ }
11
+ return Math.min(max, Math.max(min, value));
12
+ };
@@ -0,0 +1,20 @@
1
+ const add = (a, b) => a
2
+ ? a + '\u0020' + b
3
+ : b;
4
+ /**
5
+ * 拼接多个class
6
+ */
7
+ export default (...list) => list.reduce((caches, data) => {
8
+ if (typeof data === 'string') {
9
+ data && (caches = add(caches, data));
10
+ }
11
+ else if (Array.isArray(data)) {
12
+ data.forEach((value) => value && (caches = add(caches, value)));
13
+ }
14
+ else if (data) {
15
+ for (const key in data) {
16
+ key && data[key] && (caches = add(caches, key));
17
+ }
18
+ }
19
+ return caches;
20
+ }, '');
@@ -0,0 +1,19 @@
1
+ const CHAR = '.';
2
+ /**
3
+ * 版本号大小比较
4
+ * @description from < to = 1,from === to = 0,from > to = -1
5
+ */
6
+ const compareVersion = (from, to) => {
7
+ const froms = from.split(CHAR);
8
+ const tos = to.split(CHAR);
9
+ for (let i = 0, max = Math.max(froms.length, tos.length); i < max; i++) {
10
+ const fromV = +froms[i] || 0;
11
+ const toV = +tos[i] || 0;
12
+ if (fromV > toV)
13
+ return -1;
14
+ if (fromV < toV)
15
+ return 1;
16
+ }
17
+ return 0;
18
+ };
19
+ export default compareVersion;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * 值比较(深度浅比较)
2
+ * 深度相等性比较(弱比较)
3
3
  */
4
- const compareValue = (from, to) => {
4
+ const deepWeakEqual = (from, to) => {
5
5
  if (typeof from !== 'object'
6
6
  || from === null
7
7
  || typeof to !== 'object'
@@ -11,7 +11,7 @@ const compareValue = (from, to) => {
11
11
  if (from.length !== to.length)
12
12
  return false;
13
13
  return !from.some((t1, index) => {
14
- if (!compareValue(t1, to[index])) {
14
+ if (!deepWeakEqual(t1, to[index])) {
15
15
  return true;
16
16
  }
17
17
  });
@@ -19,7 +19,7 @@ const compareValue = (from, to) => {
19
19
  else {
20
20
  const caches = {};
21
21
  for (const key in from) {
22
- if (!compareValue(from[key], to[key])) {
22
+ if (!deepWeakEqual(from[key], to[key])) {
23
23
  return false;
24
24
  }
25
25
  else {
@@ -29,11 +29,11 @@ const compareValue = (from, to) => {
29
29
  for (const key in to) {
30
30
  if (key in caches)
31
31
  continue;
32
- if (!compareValue(from[key], to[key])) {
32
+ if (!deepWeakEqual(from[key], to[key])) {
33
33
  return false;
34
34
  }
35
35
  }
36
36
  }
37
37
  return true;
38
38
  };
39
- export default compareValue;
39
+ export default deepWeakEqual;
@@ -0,0 +1,63 @@
1
+ const utf8_first_prefix = /^1{2,}/g;
2
+ const utf8_other_prefix = /^10/;
3
+ var Encodes;
4
+ (function (Encodes) {
5
+ Encodes["UTF_8"] = "utf-8";
6
+ Encodes["UTF_16LE"] = "utf-16le";
7
+ Encodes["UTF_16BE"] = "utf-16be";
8
+ Encodes["GBK"] = "gbk";
9
+ })(Encodes || (Encodes = {}));
10
+ const defaults = {
11
+ utf8: [0xef, 0xbb, 0xbf],
12
+ };
13
+ const equal = (uint, list) => {
14
+ if (uint.length !== list.length)
15
+ return false;
16
+ return !uint.some((value, index) => value !== list[index]);
17
+ };
18
+ /**
19
+ * 根据文件内容判断文件的编码
20
+ * @param uint 文件内容Uint8Array格式
21
+ * @param limit 用于约束GBK和utf_8的判定上限
22
+ */
23
+ const getEncoding = (uint, limit = 1024) => {
24
+ let encoding;
25
+ let offset = 0;
26
+ if (equal(uint.slice(0, 3), defaults.utf8)) {
27
+ offset = defaults.utf8.length;
28
+ encoding = Encodes.UTF_8;
29
+ }
30
+ else if (equal(uint.slice(0, 2), [0xff, 0xfe])) {
31
+ encoding = Encodes.UTF_16LE;
32
+ }
33
+ else if (equal(uint.slice(0, 2), [0xfe, 0xff])) {
34
+ encoding = Encodes.UTF_16BE;
35
+ }
36
+ else {
37
+ let isBreak = false;
38
+ top: for (let i = 0; i < Math.min(uint.length, limit); i++) {
39
+ const data = uint[i];
40
+ if (data < 128)
41
+ continue;
42
+ const match = data.toString(2).match(utf8_first_prefix);
43
+ if (match) {
44
+ for (let m = 0; m < match[0].length - 1; m++) {
45
+ const target = uint[++i];
46
+ if (target == void 0 || !utf8_other_prefix.test(target.toString(2))) {
47
+ encoding = Encodes.GBK;
48
+ isBreak = true;
49
+ break top;
50
+ }
51
+ }
52
+ }
53
+ else {
54
+ encoding = Encodes.GBK;
55
+ isBreak = true;
56
+ break;
57
+ }
58
+ }
59
+ isBreak || (encoding = Encodes.UTF_8);
60
+ }
61
+ return { encoding, offset };
62
+ };
63
+ export default getEncoding;
package/lib/index.js CHANGED
@@ -1,10 +1,20 @@
1
1
  export { apiPost, apiGet } from './api';
2
- export { default as compareValue } from './compare/value';
2
+ export { default as clamp } from './clamp';
3
+ export { default as classnames } from './classnames';
4
+ export { default as compareVersion } from './compare/version';
5
+ export { default as deepWeakEqual } from './compare/weak-equal';
3
6
  export { default as hash8json } from './convert/json';
4
7
  export { default as hash8object } from './convert/object';
5
8
  export { default as hash8strings } from './convert/strings';
6
- export { isClass } from './is/class';
9
+ export { default as getEncoding } from './encoding';
10
+ export { default as isClass } from './is/class';
7
11
  export { default as isEmpty } from './is/empty';
8
12
  export { default as isNull } from './is/null';
9
- export { joinURLs } from './url/join';
13
+ export { default as MemoryBasic } from './memory/basic';
14
+ export { default as MemoryList } from './memory/list';
15
+ export { default as MemoryPower } from './memory/power';
16
+ export { default as once } from './once';
17
+ export { default as deconPowersSum } from './power/decon';
18
+ export { default as Union } from './union';
19
+ export { default as joinURLs } from './url/join';
10
20
  export { default as connectURLParams } from './url/params';
package/lib/is/class.js CHANGED
@@ -6,7 +6,7 @@ const re_default = /^function\sdefault_\d+\s*\(/;
6
6
  /**
7
7
  * 检测是否为class
8
8
  */
9
- export const isClass = (value, strict = true) => {
9
+ const isClass = (value, strict = true) => {
10
10
  if (typeof value !== 'function')
11
11
  return false;
12
12
  const proto = value.prototype;
@@ -27,3 +27,4 @@ export const isClass = (value, strict = true) => {
27
27
  }
28
28
  return false;
29
29
  };
30
+ export default isClass;
@@ -0,0 +1,142 @@
1
+ import hash8strings from '../convert/strings';
2
+ /**
3
+ * 分类存储(通过继承,可用于拓展存储方式)
4
+ */
5
+ export default class MemoryBasic {
6
+ key;
7
+ #mount;
8
+ #reflex;
9
+ list = [];
10
+ memorys = new Map();
11
+ /**
12
+ * 返回存储长度
13
+ */
14
+ get size() {
15
+ return this.list.length;
16
+ }
17
+ /**
18
+ * @param key 用于对数据进行分类的key
19
+ * @param config
20
+ */
21
+ constructor(key, config) {
22
+ this.key = key;
23
+ this.#mount = config.mount;
24
+ this.#reflex = config.reflex;
25
+ }
26
+ getType(data) {
27
+ const { key } = this;
28
+ return typeof key === 'function' ? key(data) : data[key];
29
+ }
30
+ push(...list) {
31
+ const { memorys } = this;
32
+ list.forEach((data) => {
33
+ const type = this.getType(data);
34
+ const memory = memorys.get(type);
35
+ const index = this.list.push(data) - 1;
36
+ const result = this.#mount(index, memory);
37
+ memory === result || memorys.set(type, result);
38
+ });
39
+ return this;
40
+ }
41
+ /**
42
+ * 遍历所有存储数据(按入栈顺序)
43
+ */
44
+ forEach(callback) {
45
+ this.list.forEach(callback);
46
+ return this;
47
+ }
48
+ /**
49
+ * 遍历所有存储类型
50
+ */
51
+ forType(callback) {
52
+ const { memorys, list } = this;
53
+ for (const [type, memory] of memorys) {
54
+ const caches = this.#reflex(memory).map((index) => list[index]);
55
+ callback(caches, type);
56
+ }
57
+ return this;
58
+ }
59
+ /**
60
+ * 检测存储是否包含某种类型
61
+ */
62
+ includes(type) {
63
+ return type in this.memorys;
64
+ }
65
+ /**
66
+ * 获取指定类型存储数据
67
+ */
68
+ get(type) {
69
+ const memory = this.memorys.get(type);
70
+ return memory === void 0
71
+ ? null
72
+ : this.#reflex(memory).map((count) => this.list[count]);
73
+ }
74
+ /**
75
+ * 删除指定存储数据
76
+ */
77
+ delete(data) {
78
+ const { memorys, list } = this;
79
+ let index = -1;
80
+ if (!list.some((value, i) => {
81
+ if (data === value) {
82
+ index = i;
83
+ list.splice(index, 1);
84
+ const type = this.getType(value);
85
+ const memory = this.#reflex(memorys.get(type));
86
+ if (memory.length === 1) {
87
+ memorys.delete(type);
88
+ }
89
+ else {
90
+ memory.some((count, j) => {
91
+ if (count === i) {
92
+ memory.splice(j, 1);
93
+ return true;
94
+ }
95
+ });
96
+ }
97
+ return true;
98
+ }
99
+ }))
100
+ return this;
101
+ for (const [type, target] of memorys) {
102
+ const memory = this.#reflex(target);
103
+ memory.forEach((value, index) => {
104
+ if (value >= index) {
105
+ memory[index] = value - 1;
106
+ }
107
+ });
108
+ if (memory !== target) {
109
+ let reactor;
110
+ memory.forEach((count) => {
111
+ reactor = this.#mount(count, reactor);
112
+ });
113
+ memorys.set(type, reactor);
114
+ }
115
+ }
116
+ return this;
117
+ }
118
+ /**
119
+ * 删除指定类型存储数据
120
+ */
121
+ deleteType(type) {
122
+ const { memorys, list } = this;
123
+ if (!memorys.has(type))
124
+ return this;
125
+ const local = hash8strings(this.#reflex(memorys.get(type)));
126
+ const Memory = this.constructor;
127
+ const imitator = new Memory(this.key);
128
+ list.forEach((data, index) => {
129
+ index in local || imitator.push(data);
130
+ });
131
+ this.list = imitator.list;
132
+ this.memorys = imitator.memorys;
133
+ return this;
134
+ }
135
+ /**
136
+ * 清理存储
137
+ */
138
+ clear() {
139
+ this.list = [];
140
+ this.memorys.clear();
141
+ }
142
+ }
@@ -0,0 +1,14 @@
1
+ import MemoryBasic from './basic';
2
+ /**
3
+ * 分类存储(基于普通的键值存储)
4
+ */
5
+ export default class MemoryList extends MemoryBasic {
6
+ constructor(key) {
7
+ super(key, {
8
+ mount: (index, reactor) => reactor
9
+ ? (reactor.push(index), reactor)
10
+ : [index],
11
+ reflex: (reactor) => reactor,
12
+ });
13
+ }
14
+ }
@@ -0,0 +1,13 @@
1
+ import deconPowersSum from '../power/decon';
2
+ import MemoryBasic from './basic';
3
+ /**
4
+ * 分类存储(基于2的n次幂之和构建唯一键进行存储)
5
+ */
6
+ export default class MemoryPower extends MemoryBasic {
7
+ constructor(key) {
8
+ super(key, {
9
+ mount: (index, reactor) => (reactor || 0) + 2 ** index,
10
+ reflex: (reactor) => deconPowersSum(reactor, 'asc'),
11
+ });
12
+ }
13
+ }
package/lib/once.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 缓存函数返回值
3
+ * @param callback 运行返回值的函数
4
+ * @param thisArg 绑定到运行函数的this对象
5
+ */
6
+ export default (func, thisArg) => {
7
+ let local;
8
+ let inited = false;
9
+ return (...list) => inited
10
+ ? local
11
+ : (inited = true,
12
+ local = func.apply(thisArg, list));
13
+ };
@@ -0,0 +1,29 @@
1
+ const ERROR_MESSAGE = {
2
+ INT: '参数必须是整数',
3
+ MIN: '多个2的正整数幂(两两不相等)之和必定大于等于1',
4
+ };
5
+ /**
6
+ * 解构多个2的正整数幂(两两不相等)之和
7
+ * @param sum 幂和
8
+ * @param sort 排序方式(默认降序)
9
+ * @description sum > 2**53则会因为精度问题计算报错
10
+ */
11
+ const deconPowersSum = (sum, sort) => {
12
+ if (sum < 1) {
13
+ throw new Error(ERROR_MESSAGE.MIN);
14
+ }
15
+ else if (sum !== Math.floor(sum)) {
16
+ throw new Error(ERROR_MESSAGE.INT);
17
+ }
18
+ const list = [];
19
+ let cache = sum;
20
+ while (cache) {
21
+ const power = Math.log2(cache) ^ 0;
22
+ list.push(power);
23
+ cache -= Math.pow(2, power);
24
+ }
25
+ return sort === 'asc'
26
+ ? list.reverse()
27
+ : list;
28
+ };
29
+ export default deconPowersSum;
package/lib/union.js ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 数据联合(用于需要对加入的数据进行智能提示)
3
+ */
4
+ export default class Union {
5
+ key;
6
+ formater;
7
+ #map = {};
8
+ get value() {
9
+ return this.#map;
10
+ }
11
+ constructor(key, formater) {
12
+ this.key = key;
13
+ this.formater = formater;
14
+ }
15
+ add(data) {
16
+ const { formater } = this;
17
+ this.#map[data[this.key]] = formater
18
+ ? formater(data)
19
+ : data;
20
+ return this;
21
+ }
22
+ }
package/lib/url/join.js CHANGED
@@ -2,7 +2,7 @@ const re = /(^|[^:/])\/{2,}/g;
2
2
  /**
3
3
  * 实现多个路径拼接
4
4
  */
5
- export const joinURLs = (...list) => {
5
+ const joinURLs = (...list) => {
6
6
  const { length } = list;
7
7
  if (length === 0)
8
8
  return '';
@@ -10,3 +10,4 @@ export const joinURLs = (...list) => {
10
10
  ? list[0]
11
11
  : list.join('/').replace(re, ($0, $1) => `${$1}/`);
12
12
  };
13
+ export default joinURLs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vope/utils",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -11,16 +11,17 @@
11
11
  "module": "./lib/index.js",
12
12
  "main": "./cjs/index.js",
13
13
  "scripts": {
14
- "build": "rimraf types & npm run cjs | npm run esm",
14
+ "build": "npm run cjs | npm run esm | npm run types",
15
15
  "init:build": "npm run devs & npm run trove & npm run test:build",
16
16
  "cjs": "rimraf cjs & npx tsc -p ./tsconfig.cjs.json",
17
17
  "esm": "rimraf lib & npx tsc -p ./tsconfig.esm.json",
18
+ "types": "rimraf types & npx tsc -p ./tsconfig.types.json & node ./__devs/type.cjs",
18
19
  "trove": "node ./__devs/trove.cjs",
19
20
  "trove:build": "npm run devs & npm run trove",
20
21
  "devs": "rimraf __devs & npx tsc -p ./tsconfig.devs.json",
21
22
  "test": "mocha __tests/**/*.js",
22
23
  "test:dev": "npm run test:build & npm run test",
23
- "test:build": "rimraf __tests & rimraf lib & node ./__devs/test.cjs",
24
+ "test:build": "node ./__devs/test.cjs",
24
25
  "test:all": "npm run devs & npm run test:build & npm run test",
25
26
  "prepublishOnly": "npm run devs & npm run trove & npm run build"
26
27
  },
@@ -44,10 +45,11 @@
44
45
  "@types/babel__traverse": "^7.20.1",
45
46
  "@types/mocha": "^10.0.1",
46
47
  "@types/node": "^20.4.5",
47
- "@vope/types": "^1.0.0",
48
+ "@vope/types": "^1.0.2",
49
+ "iconv-lite": "^0.6.3",
48
50
  "mocha": "^10.2.0",
49
51
  "rimraf": "^5.0.1",
50
- "rollup": "^3.27.1",
52
+ "rollup": "^3.28.1",
51
53
  "tslib": "^2.6.1",
52
54
  "typescript": "^5.1.6"
53
55
  },
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 获取中间数
3
+ */
4
+ declare const _default: (value: number, min: number, max: number) => number;
5
+ export default _default;
@@ -0,0 +1,7 @@
1
+ type Base = string | undefined | null;
2
+ type Item = Base | Base[] | Record<string, boolean>;
3
+ /**
4
+ * 拼接多个class
5
+ */
6
+ declare const _default: (...list: Item[]) => string;
7
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 版本号大小比较
3
+ * @description from < to = 1,from === to = 0,from > to = -1
4
+ */
5
+ declare const compareVersion: (from: string, to: string) => 0 | 1 | -1;
6
+ export default compareVersion;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 深度相等性比较(弱比较)
3
+ */
4
+ declare const deepWeakEqual: (from: any, to: any) => boolean;
5
+ export default deepWeakEqual;
@@ -0,0 +1,16 @@
1
+ declare enum Encodes {
2
+ UTF_8 = "utf-8",
3
+ UTF_16LE = "utf-16le",
4
+ UTF_16BE = "utf-16be",
5
+ GBK = "gbk"
6
+ }
7
+ /**
8
+ * 根据文件内容判断文件的编码
9
+ * @param uint 文件内容Uint8Array格式
10
+ * @param limit 用于约束GBK和utf_8的判定上限
11
+ */
12
+ declare const getEncoding: (uint: Uint8Array, limit?: number) => {
13
+ encoding: Encodes;
14
+ offset: number;
15
+ };
16
+ export default getEncoding;
package/types/index.d.ts CHANGED
@@ -1,10 +1,20 @@
1
1
  export { apiPost, apiGet } from './api';
2
- export { default as compareValue } from './compare/value';
2
+ export { default as clamp } from './clamp';
3
+ export { default as classnames } from './classnames';
4
+ export { default as compareVersion } from './compare/version';
5
+ export { default as deepWeakEqual } from './compare/weak-equal';
3
6
  export { default as hash8json } from './convert/json';
4
7
  export { default as hash8object } from './convert/object';
5
8
  export { default as hash8strings } from './convert/strings';
6
- export { isClass } from './is/class';
9
+ export { default as getEncoding } from './encoding';
10
+ export { default as isClass } from './is/class';
7
11
  export { default as isEmpty } from './is/empty';
8
12
  export { default as isNull } from './is/null';
9
- export { joinURLs } from './url/join';
13
+ export { default as MemoryBasic } from './memory/basic';
14
+ export { default as MemoryList } from './memory/list';
15
+ export { default as MemoryPower } from './memory/power';
16
+ export { default as once } from './once';
17
+ export { default as deconPowersSum } from './power/decon';
18
+ export { default as Union } from './union';
19
+ export { default as joinURLs } from './url/join';
10
20
  export { default as connectURLParams } from './url/params';
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * 检测是否为class
3
3
  */
4
- export declare const isClass: (value: any, strict?: boolean) => value is new (...args: any) => any;
4
+ declare const isClass: (value: any, strict?: boolean) => value is new (...args: any) => any;
5
+ export default isClass;
@@ -0,0 +1,63 @@
1
+ import { Memory } from './type';
2
+ interface Config<Reactor> {
3
+ /**
4
+ * 定义数据如何挂载到存储中
5
+ * @param index 当前存入数据对应的角标
6
+ * @param reactor 当前存入数据对应存储单元
7
+ */
8
+ mount(index: number, reactor?: Reactor): Reactor;
9
+ /**
10
+ * 定义存储单元和存储关系
11
+ * @param reactor 存储单元
12
+ */
13
+ reflex(reactor: Reactor): number[];
14
+ }
15
+ /**
16
+ * 分类存储(通过继承,可用于拓展存储方式)
17
+ */
18
+ export default class MemoryBasic<V, Reactor, Type extends Memory.Type> {
19
+ #private;
20
+ protected key: Memory.Pitch<V, Type>;
21
+ protected list: V[];
22
+ protected memorys: Map<Type, Reactor>;
23
+ /**
24
+ * 返回存储长度
25
+ */
26
+ get size(): number;
27
+ /**
28
+ * @param key 用于对数据进行分类的key
29
+ * @param config
30
+ */
31
+ constructor(key: Memory.Pitch<V, Type>, config: Config<Reactor>);
32
+ protected getType(data: V): Type;
33
+ push(...list: V[]): this;
34
+ /**
35
+ * 遍历所有存储数据(按入栈顺序)
36
+ */
37
+ forEach(callback: (data: V, index: number) => void): this;
38
+ /**
39
+ * 遍历所有存储类型
40
+ */
41
+ forType(callback: (data: V[], type: Type) => void): this;
42
+ /**
43
+ * 检测存储是否包含某种类型
44
+ */
45
+ includes(type: Type): boolean;
46
+ /**
47
+ * 获取指定类型存储数据
48
+ */
49
+ get(type: Type): V[] | null;
50
+ /**
51
+ * 删除指定存储数据
52
+ */
53
+ delete(data: V): this;
54
+ /**
55
+ * 删除指定类型存储数据
56
+ */
57
+ deleteType(type: Type): this;
58
+ /**
59
+ * 清理存储
60
+ */
61
+ clear(): void;
62
+ }
63
+ export {};
@@ -0,0 +1,8 @@
1
+ import MemoryBasic from './basic';
2
+ import { Memory } from './type';
3
+ /**
4
+ * 分类存储(基于普通的键值存储)
5
+ */
6
+ export default class MemoryList<V, Type extends Memory.Type = Memory.Type> extends MemoryBasic<V, number[], Type> {
7
+ constructor(key: Memory.Pitch<V, Type>);
8
+ }
@@ -0,0 +1,8 @@
1
+ import MemoryBasic from './basic';
2
+ import { Memory } from './type';
3
+ /**
4
+ * 分类存储(基于2的n次幂之和构建唯一键进行存储)
5
+ */
6
+ export default class MemoryPower<V, Type extends Memory.Type = Memory.Type> extends MemoryBasic<V, number, Type> {
7
+ constructor(key: Memory.Pitch<V, Type>);
8
+ }
@@ -0,0 +1,11 @@
1
+ import { GetGivenProps } from '@vope/types'
2
+
3
+ export namespace Memory {
4
+ type Type = string | number
5
+
6
+ type Pitch<Data, Type> = (
7
+ Data extends object
8
+ ? GetGivenProps<Data, Type>
9
+ : never
10
+ ) | ((data: Data) => Type)
11
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 缓存函数返回值
3
+ * @param callback 运行返回值的函数
4
+ * @param thisArg 绑定到运行函数的this对象
5
+ */
6
+ declare const _default: <T extends (...args: any) => any>(func: T, thisArg?: any) => (...list: Parameters<T>) => ReturnType<T>;
7
+ export default _default;
@@ -0,0 +1,9 @@
1
+ type Sort = 'asc' | 'desc';
2
+ /**
3
+ * 解构多个2的正整数幂(两两不相等)之和
4
+ * @param sum 幂和
5
+ * @param sort 排序方式(默认降序)
6
+ * @description sum > 2**53则会因为精度问题计算报错
7
+ */
8
+ declare const deconPowersSum: (sum: number, sort?: Sort) => number[];
9
+ export default deconPowersSum;
@@ -0,0 +1,20 @@
1
+ import { Revise } from '@vope/types';
2
+ type IMap<K extends string, VV extends string, T extends {
3
+ [key in K]: string;
4
+ }> = {
5
+ [key in VV]?: T;
6
+ };
7
+ /**
8
+ * 数据联合(用于需要对加入的数据进行智能提示)
9
+ */
10
+ export default class Union<K extends string, VV extends string, T extends {
11
+ [key in K]: string;
12
+ }, L extends VV | never = never> {
13
+ #private;
14
+ private key;
15
+ private formater?;
16
+ get value(): Required<IMap<K, L, T>>;
17
+ constructor(key: K, formater?: ((data: T) => T) | undefined);
18
+ add<V extends Exclude<VV, L>>(data: Revise<T, K, V>): Union<K, VV, T, L | V>;
19
+ }
20
+ export {};
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * 实现多个路径拼接
3
3
  */
4
- export declare const joinURLs: (...list: string[]) => string;
4
+ declare const joinURLs: (...list: string[]) => string;
5
+ export default joinURLs;
@@ -1,5 +0,0 @@
1
- /**
2
- * 值比较(深度浅比较)
3
- */
4
- declare const compareValue: (from: any, to: any) => boolean;
5
- export default compareValue;