@vope/utils 1.3.1 → 1.4.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.
Files changed (55) hide show
  1. package/cjs/clamp.js +29 -12
  2. package/cjs/classnames.js +34 -20
  3. package/cjs/compare/version.js +35 -18
  4. package/cjs/compare/weak-equal.js +49 -36
  5. package/cjs/convert/json.js +25 -15
  6. package/cjs/convert/object.js +26 -16
  7. package/cjs/convert/strings.js +25 -9
  8. package/cjs/encoding.js +64 -51
  9. package/cjs/index.js +76 -53
  10. package/cjs/input-regex.js +24 -5
  11. package/cjs/is/class.js +40 -23
  12. package/cjs/is/empty.js +34 -10
  13. package/cjs/is/null.js +24 -7
  14. package/cjs/memory/basic.js +159 -139
  15. package/cjs/memory/list.js +39 -17
  16. package/cjs/memory/power.js +40 -16
  17. package/cjs/memory/type.d.js +16 -0
  18. package/cjs/once.js +26 -13
  19. package/cjs/power/decon.js +38 -26
  20. package/cjs/rotate/angle.js +34 -12
  21. package/cjs/rotate/rad.js +29 -14
  22. package/cjs/union.js +41 -26
  23. package/cjs/url/join.js +27 -11
  24. package/cjs/url/params.js +41 -33
  25. package/cjs/wait.js +23 -5
  26. package/lib/clamp.js +7 -10
  27. package/lib/classnames.js +12 -18
  28. package/lib/compare/version.js +13 -16
  29. package/lib/compare/weak-equal.js +27 -34
  30. package/lib/convert/json.js +3 -13
  31. package/lib/convert/object.js +4 -14
  32. package/lib/convert/strings.js +3 -7
  33. package/lib/encoding.js +42 -49
  34. package/lib/index.js +24 -24
  35. package/lib/input-regex.js +2 -3
  36. package/lib/is/class.js +18 -21
  37. package/lib/is/empty.js +3 -6
  38. package/lib/is/null.js +2 -5
  39. package/lib/memory/basic.js +129 -135
  40. package/lib/memory/list.js +8 -12
  41. package/lib/memory/power.js +9 -11
  42. package/lib/memory/type.d.js +1 -0
  43. package/lib/once.js +4 -11
  44. package/lib/power/decon.js +16 -24
  45. package/lib/rotate/angle.js +2 -7
  46. package/lib/rotate/rad.js +7 -12
  47. package/lib/union.js +20 -24
  48. package/lib/url/join.js +5 -9
  49. package/lib/url/params.js +19 -31
  50. package/lib/wait.js +1 -3
  51. package/package.json +6 -8
  52. package/types/index.d.ts +0 -1
  53. package/cjs/api.js +0 -56
  54. package/lib/api.js +0 -48
  55. package/types/api.d.ts +0 -19
@@ -1,19 +1,16 @@
1
- const CHAR = '.';
2
- /**
3
- * 版本号大小比较
4
- * @description from < to = 1,from === to = 0,from > to = -1
5
- */
1
+ "use strict";
2
+ const CHAR = ".";
6
3
  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;
4
+ const froms = from.split(CHAR);
5
+ const tos = to.split(CHAR);
6
+ for (let i = 0, max = Math.max(froms.length, tos.length); i < max; i++) {
7
+ const fromV = +froms[i] || 0;
8
+ const toV = +tos[i] || 0;
9
+ if (fromV > toV)
10
+ return -1;
11
+ if (fromV < toV)
12
+ return 1;
13
+ }
14
+ return 0;
18
15
  };
19
16
  export default compareVersion;
@@ -1,39 +1,32 @@
1
- /**
2
- * 深度相等性比较(弱比较)
3
- */
1
+ "use strict";
4
2
  const deepWeakEqual = (from, to) => {
5
- if (typeof from !== 'object'
6
- || from === null
7
- || typeof to !== 'object'
8
- || to === null)
9
- return from === to;
10
- if (Array.isArray(from) && Array.isArray(to)) {
11
- if (from.length !== to.length)
12
- return false;
13
- return !from.some((t1, index) => {
14
- if (!deepWeakEqual(t1, to[index])) {
15
- return true;
16
- }
17
- });
3
+ if (typeof from !== "object" || from === null || typeof to !== "object" || to === null)
4
+ return from === to;
5
+ if (Array.isArray(from) && Array.isArray(to)) {
6
+ if (from.length !== to.length)
7
+ return false;
8
+ return !from.some((t1, index) => {
9
+ if (!deepWeakEqual(t1, to[index])) {
10
+ return true;
11
+ }
12
+ });
13
+ } else {
14
+ const caches = {};
15
+ for (const key in from) {
16
+ if (!deepWeakEqual(from[key], to[key])) {
17
+ return false;
18
+ } else {
19
+ caches[key] = key;
20
+ }
18
21
  }
19
- else {
20
- const caches = {};
21
- for (const key in from) {
22
- if (!deepWeakEqual(from[key], to[key])) {
23
- return false;
24
- }
25
- else {
26
- caches[key] = key;
27
- }
28
- }
29
- for (const key in to) {
30
- if (key in caches)
31
- continue;
32
- if (!deepWeakEqual(from[key], to[key])) {
33
- return false;
34
- }
35
- }
22
+ for (const key in to) {
23
+ if (key in caches)
24
+ continue;
25
+ if (!deepWeakEqual(from[key], to[key])) {
26
+ return false;
27
+ }
36
28
  }
37
- return true;
29
+ }
30
+ return true;
38
31
  };
39
32
  export default deepWeakEqual;
@@ -1,16 +1,6 @@
1
- /**
2
- * 对象数组转hash(要求主键值为string|number类型)
3
- * @example
4
- * hash8json(
5
- * [
6
- * { key: 'a', value: 1 },
7
- * { key: 'b', value: 2 }
8
- * ],
9
- * 'key'
10
- * ).a.value // 1
11
- */
1
+ "use strict";
12
2
  const hash8json = (list, key) => list.reduce((caches, data) => {
13
- caches[data[key]] = data;
14
- return caches;
3
+ caches[data[key]] = data;
4
+ return caches;
15
5
  }, {});
16
6
  export default hash8json;
@@ -1,16 +1,6 @@
1
- /**
2
- * 对象数组转hash
3
- * @example
4
- * hash8object(
5
- * [
6
- * { key: String, value: 1 },
7
- * { key: Object, value: 2 }
8
- * ],
9
- * 'key'
10
- * ).get(Object).value // 2
11
- */
1
+ "use strict";
12
2
  const hash8object = (list, key) => list.reduce((caches, data) => {
13
- caches.set(data[key], data);
14
- return caches;
15
- }, new Map());
3
+ caches.set(data[key], data);
4
+ return caches;
5
+ }, /* @__PURE__ */ new Map());
16
6
  export default hash8object;
@@ -1,10 +1,6 @@
1
- /**
2
- * 字符数组转hash
3
- * @example
4
- * hash8strings(['a', 'b']).a // 0
5
- */
1
+ "use strict";
6
2
  const hash8strings = (list) => list.reduce((caches, data, index) => {
7
- caches[data] = index;
8
- return caches;
3
+ caches[data] = index;
4
+ return caches;
9
5
  }, {});
10
6
  export default hash8strings;
package/lib/encoding.js CHANGED
@@ -1,62 +1,55 @@
1
+ "use strict";
1
2
  const utf8_first_prefix = /^1{2,}/g;
2
3
  const utf8_other_prefix = /^10/;
3
4
  const Encodes = {
4
- UTF_8: 'utf-8',
5
- UTF_16LE: 'utf-16le',
6
- UTF_16BE: 'utf-16be',
7
- GBK: 'gbk'
5
+ UTF_8: "utf-8",
6
+ UTF_16LE: "utf-16le",
7
+ UTF_16BE: "utf-16be",
8
+ GBK: "gbk"
8
9
  };
9
10
  const defaults = {
10
- utf8: [0xef, 0xbb, 0xbf],
11
+ utf8: [239, 187, 191]
11
12
  };
12
13
  const equal = (uint, list) => {
13
- if (uint.length !== list.length)
14
- return false;
15
- return !uint.some((value, index) => value !== list[index]);
14
+ if (uint.length !== list.length)
15
+ return false;
16
+ return !uint.some((value, index) => value !== list[index]);
16
17
  };
17
- /**
18
- * 根据文件内容判断文件的编码
19
- * @param uint 文件内容Uint8Array格式
20
- * @param limit 用于约束GBK和utf_8的判定上限
21
- */
22
18
  const getEncoding = (uint, limit = 1024) => {
23
- let encoding;
24
- let offset = 0;
25
- if (equal(uint.slice(0, 3), defaults.utf8)) {
26
- offset = defaults.utf8.length;
27
- encoding = Encodes.UTF_8;
28
- }
29
- else if (equal(uint.slice(0, 2), [0xff, 0xfe])) {
30
- encoding = Encodes.UTF_16LE;
31
- }
32
- else if (equal(uint.slice(0, 2), [0xfe, 0xff])) {
33
- encoding = Encodes.UTF_16BE;
34
- }
35
- else {
36
- let isBreak = false;
37
- top: for (let i = 0; i < Math.min(uint.length, limit); i++) {
38
- const data = uint[i];
39
- if (data < 128)
40
- continue;
41
- const match = data.toString(2).match(utf8_first_prefix);
42
- if (match) {
43
- for (let m = 0; m < match[0].length - 1; m++) {
44
- const target = uint[++i];
45
- if (target == void 0 || !utf8_other_prefix.test(target.toString(2))) {
46
- encoding = Encodes.GBK;
47
- isBreak = true;
48
- break top;
49
- }
50
- }
51
- }
52
- else {
53
- encoding = Encodes.GBK;
54
- isBreak = true;
55
- break;
19
+ let encoding;
20
+ let offset = 0;
21
+ if (equal(uint.slice(0, 3), defaults.utf8)) {
22
+ offset = defaults.utf8.length;
23
+ encoding = Encodes.UTF_8;
24
+ } else if (equal(uint.slice(0, 2), [255, 254])) {
25
+ encoding = Encodes.UTF_16LE;
26
+ } else if (equal(uint.slice(0, 2), [254, 255])) {
27
+ encoding = Encodes.UTF_16BE;
28
+ } else {
29
+ let isBreak = false;
30
+ top:
31
+ for (let i = 0; i < Math.min(uint.length, limit); i++) {
32
+ const data = uint[i];
33
+ if (data < 128)
34
+ continue;
35
+ const match = data.toString(2).match(utf8_first_prefix);
36
+ if (match) {
37
+ for (let m = 0; m < match[0].length - 1; m++) {
38
+ const target = uint[++i];
39
+ if (target == void 0 || !utf8_other_prefix.test(target.toString(2))) {
40
+ encoding = Encodes.GBK;
41
+ isBreak = true;
42
+ break top;
56
43
  }
44
+ }
45
+ } else {
46
+ encoding = Encodes.GBK;
47
+ isBreak = true;
48
+ break;
57
49
  }
58
- isBreak || (encoding = Encodes.UTF_8);
59
- }
60
- return { encoding, offset };
50
+ }
51
+ isBreak || (encoding = Encodes.UTF_8);
52
+ }
53
+ return { encoding, offset };
61
54
  };
62
55
  export default getEncoding;
package/lib/index.js CHANGED
@@ -1,24 +1,24 @@
1
- export { apiPost, apiGet } from './api';
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';
6
- export { default as hash8json } from './convert/json';
7
- export { default as hash8object } from './convert/object';
8
- export { default as hash8strings } from './convert/strings';
9
- export { default as getEncoding } from './encoding';
10
- export { default as inputRegex } from './input-regex';
11
- export { default as isClass } from './is/class';
12
- export { default as isEmpty } from './is/empty';
13
- export { default as isNull } from './is/null';
14
- export { default as MemoryBasic } from './memory/basic';
15
- export { default as MemoryList } from './memory/list';
16
- export { default as MemoryPower } from './memory/power';
17
- export { default as once } from './once';
18
- export { default as deconPowersSum } from './power/decon';
19
- export { default as rotateAngle } from './rotate/angle';
20
- export { default as rotateRad } from './rotate/rad';
21
- export { default as Union } from './union';
22
- export { default as joinPaths } from './url/join';
23
- export { default as connectURLParams } from './url/params';
24
- export { default as wait } from './wait';
1
+ "use strict";
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";
6
+ export { default as hash8json } from "./convert/json";
7
+ export { default as hash8object } from "./convert/object";
8
+ export { default as hash8strings } from "./convert/strings";
9
+ export { default as getEncoding } from "./encoding";
10
+ export { default as inputRegex } from "./input-regex";
11
+ export { default as isClass } from "./is/class";
12
+ export { default as isEmpty } from "./is/empty";
13
+ export { default as isNull } from "./is/null";
14
+ export { default as MemoryBasic } from "./memory/basic";
15
+ export { default as MemoryList } from "./memory/list";
16
+ export { default as MemoryPower } from "./memory/power";
17
+ export { default as once } from "./once";
18
+ export { default as deconPowersSum } from "./power/decon";
19
+ export { default as rotateAngle } from "./rotate/angle";
20
+ export { default as rotateRad } from "./rotate/rad";
21
+ export { default as Union } from "./union";
22
+ export { default as joinPaths } from "./url/join";
23
+ export { default as connectURLParams } from "./url/params";
24
+ export { default as wait } from "./wait";
@@ -1,8 +1,7 @@
1
+ "use strict";
1
2
  const RE_REGEX = /[$()*+.[?\\^{|]/g;
2
3
  const RE_STRING = /[$()*+.[?\\^{|-]/g;
3
4
  function inputRegex(text, flags) {
4
- return flags === false
5
- ? text.replace(RE_STRING, ($0) => '\\' + $0)
6
- : new RegExp(text.replace(RE_REGEX, ($0) => '\\' + $0), flags);
5
+ return flags === false ? text.replace(RE_STRING, ($0) => "\\" + $0) : new RegExp(text.replace(RE_REGEX, ($0) => "\\" + $0), flags);
7
6
  }
8
7
  export default inputRegex;
package/lib/is/class.js CHANGED
@@ -1,30 +1,27 @@
1
+ "use strict";
1
2
  const re_anonymous = /^function\s+\(|^function\s+anonymous\(/;
2
3
  const re_function = /^function\s+[A-Z]/;
3
4
  const re_this = /\b\(this\b|\bthis[\.\[]\b/;
4
5
  const re_check = /classCallCheck\(this/;
5
6
  const re_default = /^function\sdefault_\d+\s*\(/;
6
- /**
7
- * 检测是否为class
8
- */
9
7
  const isClass = (value, strict = true) => {
10
- if (typeof value !== 'function')
11
- return false;
12
- const proto = value.prototype;
13
- if (!proto || proto.constructor !== value)
14
- return false;
15
- const str = value.toString();
16
- if (str.slice(0, 5) === 'class'
17
- || Object.getOwnPropertyNames(proto).length >= 2)
18
- return true;
19
- if (re_anonymous.test(str))
20
- return false;
21
- if (strict && re_function.test(str))
22
- return true;
23
- if (re_this.test(str)) {
24
- if (!strict || re_check.test(str))
25
- return true;
26
- return re_default.test(str);
27
- }
8
+ if (typeof value !== "function")
28
9
  return false;
10
+ const proto = value.prototype;
11
+ if (!proto || proto.constructor !== value)
12
+ return false;
13
+ const str = value.toString();
14
+ if (str.slice(0, 5) === "class" || Object.getOwnPropertyNames(proto).length >= 2)
15
+ return true;
16
+ if (re_anonymous.test(str))
17
+ return false;
18
+ if (strict && re_function.test(str))
19
+ return true;
20
+ if (re_this.test(str)) {
21
+ if (!strict || re_check.test(str))
22
+ return true;
23
+ return re_default.test(str);
24
+ }
25
+ return false;
29
26
  };
30
27
  export default isClass;
package/lib/is/empty.js CHANGED
@@ -1,7 +1,4 @@
1
- import isNull from './null';
2
- /**
3
- * 检测是否为空(undefined/null/'')
4
- */
5
- const isEmpty = (value) => isNull(value)
6
- || value === '';
1
+ "use strict";
2
+ import isNull from "./null";
3
+ const isEmpty = (value) => isNull(value) || value === "";
7
4
  export default isEmpty;
package/lib/is/null.js CHANGED
@@ -1,6 +1,3 @@
1
- /**
2
- * 检测是否无值(undefined/null)
3
- */
4
- const isNull = (value) => value === void 0
5
- || value === null;
1
+ "use strict";
2
+ const isNull = (value) => value === void 0 || value === null;
6
3
  export default isNull;
@@ -1,142 +1,136 @@
1
- import hash8strings from '../convert/strings';
2
- /**
3
- * 分类存储(通过继承,可用于拓展存储方式)
4
- */
1
+ "use strict";
2
+ import hash8strings from "../convert/strings";
5
3
  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;
4
+ /**
5
+ * @param key 用于对数据进行分类的key
6
+ * @param config
7
+ */
8
+ constructor(key, config) {
9
+ this.key = key;
10
+ this.#mount = config.mount;
11
+ this.#reflex = config.reflex;
12
+ }
13
+ #mount;
14
+ #reflex;
15
+ list = [];
16
+ memorys = /* @__PURE__ */ new Map();
17
+ /**
18
+ * 返回存储长度
19
+ */
20
+ get size() {
21
+ return this.list.length;
22
+ }
23
+ getType(data) {
24
+ const { key } = this;
25
+ return typeof key === "function" ? key(data) : data[key];
26
+ }
27
+ push(...list) {
28
+ const { memorys } = this;
29
+ list.forEach((data) => {
30
+ const type = this.getType(data);
31
+ const memory = memorys.get(type);
32
+ const index = this.list.push(data) - 1;
33
+ const result = this.#mount(index, memory);
34
+ memory === result || memorys.set(type, result);
35
+ });
36
+ return this;
37
+ }
38
+ /**
39
+ * 遍历所有存储数据(按入栈顺序)
40
+ */
41
+ forEach(callback) {
42
+ this.list.forEach(callback);
43
+ return this;
44
+ }
45
+ /**
46
+ * 遍历所有存储类型
47
+ */
48
+ forType(callback) {
49
+ const { memorys, list } = this;
50
+ for (const [type, memory] of memorys) {
51
+ const caches = this.#reflex(memory).map((index) => list[index]);
52
+ callback(caches, type);
16
53
  }
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 this.memorys.has(type);
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);
54
+ return this;
55
+ }
56
+ /**
57
+ * 检测存储是否包含某种类型
58
+ */
59
+ includes(type) {
60
+ return this.memorys.has(type);
61
+ }
62
+ /**
63
+ * 获取指定类型存储数据
64
+ */
65
+ get(type) {
66
+ const memory = this.memorys.get(type);
67
+ return memory === void 0 ? null : this.#reflex(memory).map((count) => this.list[count]);
68
+ }
69
+ /**
70
+ * 删除指定存储数据
71
+ */
72
+ delete(data) {
73
+ const { memorys, list } = this;
74
+ let index = -1;
75
+ if (!list.some((value, i) => {
76
+ if (data === value) {
77
+ index = i;
78
+ list.splice(index, 1);
79
+ const type = this.getType(value);
80
+ const memory = this.#reflex(memorys.get(type));
81
+ if (memory.length === 1) {
82
+ memorys.delete(type);
83
+ } else {
84
+ memory.some((count, j) => {
85
+ if (count === i) {
86
+ memory.splice(j, 1);
87
+ return true;
114
88
  }
89
+ });
115
90
  }
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);
91
+ return true;
92
+ }
93
+ }))
94
+ return this;
95
+ for (const [type, target] of memorys) {
96
+ const memory = this.#reflex(target);
97
+ memory.forEach((value, index2) => {
98
+ if (value >= index2) {
99
+ memory[index2] = value - 1;
100
+ }
101
+ });
102
+ if (memory !== target) {
103
+ let reactor;
104
+ memory.forEach((count) => {
105
+ reactor = this.#mount(count, reactor);
130
106
  });
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();
107
+ memorys.set(type, reactor);
108
+ }
141
109
  }
110
+ return this;
111
+ }
112
+ /**
113
+ * 删除指定类型存储数据
114
+ */
115
+ deleteType(type) {
116
+ const { memorys, list } = this;
117
+ if (!memorys.has(type))
118
+ return this;
119
+ const local = hash8strings(this.#reflex(memorys.get(type)));
120
+ const Memory2 = this.constructor;
121
+ const imitator = new Memory2(this.key);
122
+ list.forEach((data, index) => {
123
+ index in local || imitator.push(data);
124
+ });
125
+ this.list = imitator.list;
126
+ this.memorys = imitator.memorys;
127
+ return this;
128
+ }
129
+ /**
130
+ * 清理存储
131
+ */
132
+ clear() {
133
+ this.list = [];
134
+ this.memorys.clear();
135
+ }
142
136
  }