@vope/utils 1.4.15 → 1.4.17
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 +10 -15
- package/lib/memory/basic.js +9 -10
- package/lib/memory/simple.js +1 -5
- package/package.json +1 -1
- package/types/index.d.ts +1 -1
- package/types/memory/basic.d.ts +1 -2
- package/types/memory/simple.d.ts +2 -2
- package/types/subscriber.d.ts +2 -1
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
|
}
|
|
@@ -427,7 +423,10 @@ var MemoryBasic = class {
|
|
|
427
423
|
return this;
|
|
428
424
|
const local = hash8strings(this.#reflex(memorys.get(type)));
|
|
429
425
|
const Memory = this.constructor;
|
|
430
|
-
const imitator = new Memory(this.key
|
|
426
|
+
const imitator = new Memory(this.key, {
|
|
427
|
+
mount: this.#mount,
|
|
428
|
+
reflex: this.#reflex
|
|
429
|
+
});
|
|
431
430
|
list.forEach((data, index) => {
|
|
432
431
|
index in local || imitator.push(data);
|
|
433
432
|
});
|
|
@@ -506,11 +505,7 @@ var MemorySimple = class {
|
|
|
506
505
|
push(...list) {
|
|
507
506
|
const memory = this.#memory;
|
|
508
507
|
list.forEach((data) => {
|
|
509
|
-
|
|
510
|
-
this.push(...data);
|
|
511
|
-
} else if (!memory.includes(this.#getType(data))) {
|
|
512
|
-
memory.push(data);
|
|
513
|
-
}
|
|
508
|
+
memory.includes(this.#getType(data)) || memory.push(data);
|
|
514
509
|
});
|
|
515
510
|
return this;
|
|
516
511
|
}
|
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
|
}
|
|
@@ -121,7 +117,10 @@ class MemoryBasic {
|
|
|
121
117
|
return this;
|
|
122
118
|
const local = hash8strings(this.#reflex(memorys.get(type)));
|
|
123
119
|
const Memory2 = this.constructor;
|
|
124
|
-
const imitator = new Memory2(this.key
|
|
120
|
+
const imitator = new Memory2(this.key, {
|
|
121
|
+
mount: this.#mount,
|
|
122
|
+
reflex: this.#reflex
|
|
123
|
+
});
|
|
125
124
|
list.forEach((data, index) => {
|
|
126
125
|
index in local || imitator.push(data);
|
|
127
126
|
});
|
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/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export { deconPowersSum } from './power/decon';
|
|
|
22
22
|
export { rotateAngle } from './rotate/angle';
|
|
23
23
|
export { rotateRad } from './rotate/rad';
|
|
24
24
|
export { type CSSProperties, type StyleValue, css } from './style/css';
|
|
25
|
-
export { default as Subscriber } from './subscriber';
|
|
25
|
+
export { type SModel, default as Subscriber } from './subscriber';
|
|
26
26
|
export { FlexTable } from './table/flex';
|
|
27
27
|
export { Union } from './union';
|
|
28
28
|
export { joinPaths } from './url/join';
|
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
|
*/
|
package/types/subscriber.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export type SModel = Record<keyof any, (...args: any[]) => void>;
|
|
1
2
|
/**
|
|
2
3
|
* 订阅
|
|
3
4
|
*/
|
|
4
|
-
export default class Subscriber<T extends
|
|
5
|
+
export default class Subscriber<T extends SModel> {
|
|
5
6
|
#private;
|
|
6
7
|
$on<K extends keyof T>(name: K, listener: T[K]): this;
|
|
7
8
|
$once<K extends keyof T>(name: K, listener: T[K]): this;
|