@vope/utils 1.4.15 → 1.4.16
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/cjs/index.js +6 -14
- package/lib/memory/basic.js +5 -9
- package/lib/memory/simple.js +1 -5
- package/package.json +1 -1
- package/types/memory/basic.d.ts +1 -2
- package/types/memory/simple.d.ts +2 -2
package/cjs/index.js
CHANGED
|
@@ -332,15 +332,11 @@ var MemoryBasic = class {
|
|
|
332
332
|
push(...list) {
|
|
333
333
|
const { memorys } = this;
|
|
334
334
|
list.forEach((data) => {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const index = this.list.push(data) - 1;
|
|
341
|
-
const result = this.#mount(index, memory);
|
|
342
|
-
memory === result || memorys.set(type, result);
|
|
343
|
-
}
|
|
335
|
+
const type = this.getType(data);
|
|
336
|
+
const memory = memorys.get(type);
|
|
337
|
+
const index = this.list.push(data) - 1;
|
|
338
|
+
const result = this.#mount(index, memory);
|
|
339
|
+
memory === result || memorys.set(type, result);
|
|
344
340
|
});
|
|
345
341
|
return this;
|
|
346
342
|
}
|
|
@@ -506,11 +502,7 @@ var MemorySimple = class {
|
|
|
506
502
|
push(...list) {
|
|
507
503
|
const memory = this.#memory;
|
|
508
504
|
list.forEach((data) => {
|
|
509
|
-
|
|
510
|
-
this.push(...data);
|
|
511
|
-
} else if (!memory.includes(this.#getType(data))) {
|
|
512
|
-
memory.push(data);
|
|
513
|
-
}
|
|
505
|
+
memory.includes(this.#getType(data)) || memory.push(data);
|
|
514
506
|
});
|
|
515
507
|
return this;
|
|
516
508
|
}
|
package/lib/memory/basic.js
CHANGED
|
@@ -26,15 +26,11 @@ class MemoryBasic {
|
|
|
26
26
|
push(...list) {
|
|
27
27
|
const { memorys } = this;
|
|
28
28
|
list.forEach((data) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const index = this.list.push(data) - 1;
|
|
35
|
-
const result = this.#mount(index, memory);
|
|
36
|
-
memory === result || memorys.set(type, result);
|
|
37
|
-
}
|
|
29
|
+
const type = this.getType(data);
|
|
30
|
+
const memory = memorys.get(type);
|
|
31
|
+
const index = this.list.push(data) - 1;
|
|
32
|
+
const result = this.#mount(index, memory);
|
|
33
|
+
memory === result || memorys.set(type, result);
|
|
38
34
|
});
|
|
39
35
|
return this;
|
|
40
36
|
}
|
package/lib/memory/simple.js
CHANGED
|
@@ -19,11 +19,7 @@ class MemorySimple {
|
|
|
19
19
|
push(...list) {
|
|
20
20
|
const memory = this.#memory;
|
|
21
21
|
list.forEach((data) => {
|
|
22
|
-
|
|
23
|
-
this.push(...data);
|
|
24
|
-
} else if (!memory.includes(this.#getType(data))) {
|
|
25
|
-
memory.push(data);
|
|
26
|
-
}
|
|
22
|
+
memory.includes(this.#getType(data)) || memory.push(data);
|
|
27
23
|
});
|
|
28
24
|
return this;
|
|
29
25
|
}
|
package/package.json
CHANGED
package/types/memory/basic.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ interface Config<Reactor> {
|
|
|
12
12
|
*/
|
|
13
13
|
reflex(reactor: Reactor): number[];
|
|
14
14
|
}
|
|
15
|
-
export type _LV<T> = (T | _LV<T>)[];
|
|
16
15
|
/**
|
|
17
16
|
* 分类存储(通过继承,可用于拓展存储方式)
|
|
18
17
|
*/
|
|
@@ -31,7 +30,7 @@ export declare class MemoryBasic<T, Reactor, Type extends Memory.Type> {
|
|
|
31
30
|
*/
|
|
32
31
|
constructor(key: Memory.Pitch<T, Type>, config: Config<Reactor>);
|
|
33
32
|
protected getType(data: T): Type;
|
|
34
|
-
push(...list:
|
|
33
|
+
push(...list: T[]): this;
|
|
35
34
|
/**
|
|
36
35
|
* 遍历所有存储数据(按入栈顺序)
|
|
37
36
|
*/
|
package/types/memory/simple.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Assign } from '@vope/types';
|
|
2
|
-
import { MemoryBasic
|
|
2
|
+
import { MemoryBasic } from './basic';
|
|
3
3
|
import { Memory } from './type';
|
|
4
4
|
type Transform<T, V> = {
|
|
5
5
|
[P in keyof T]: T[P] extends (...args: any) => any ? (...args: Parameters<T[P]>) => ReturnType<T[P]> extends T ? V : ReturnType<T[P]> : T[P];
|
|
@@ -14,7 +14,7 @@ export declare class MemorySimple<T, Type extends Memory.Type> implements Basic<
|
|
|
14
14
|
#private;
|
|
15
15
|
get size(): number;
|
|
16
16
|
constructor(key: Memory.Pitch<T, Type>);
|
|
17
|
-
push(...list:
|
|
17
|
+
push(...list: T[]): this;
|
|
18
18
|
/**
|
|
19
19
|
* 获取指定类型存储数据
|
|
20
20
|
*/
|