@vope/utils 1.4.16 → 1.4.18
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 +35 -6
- package/lib/memory/basic.js +22 -1
- package/lib/memory/simple.js +13 -5
- package/package.json +1 -1
- package/types/index.d.ts +1 -1
- package/types/memory/basic.d.ts +12 -0
- package/types/memory/simple.d.ts +8 -0
- package/types/subscriber.d.ts +2 -1
package/cjs/index.js
CHANGED
|
@@ -358,6 +358,24 @@ var MemoryBasic = class {
|
|
|
358
358
|
}
|
|
359
359
|
return this;
|
|
360
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* some(按入栈顺序)
|
|
363
|
+
*/
|
|
364
|
+
some(callback) {
|
|
365
|
+
return this.list.some(callback);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* map(按入栈顺序)
|
|
369
|
+
*/
|
|
370
|
+
map(callback) {
|
|
371
|
+
return this.list.map(callback);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* reduce(按入栈顺序)
|
|
375
|
+
*/
|
|
376
|
+
reduce(callback, initialValue) {
|
|
377
|
+
return this.list.reduce(callback, initialValue);
|
|
378
|
+
}
|
|
361
379
|
/**
|
|
362
380
|
* 检测存储是否包含某种类型
|
|
363
381
|
*/
|
|
@@ -423,7 +441,10 @@ var MemoryBasic = class {
|
|
|
423
441
|
return this;
|
|
424
442
|
const local = hash8strings(this.#reflex(memorys.get(type)));
|
|
425
443
|
const Memory = this.constructor;
|
|
426
|
-
const imitator = new Memory(this.key
|
|
444
|
+
const imitator = new Memory(this.key, {
|
|
445
|
+
mount: this.#mount,
|
|
446
|
+
reflex: this.#reflex
|
|
447
|
+
});
|
|
427
448
|
list.forEach((data, index) => {
|
|
428
449
|
index in local || imitator.push(data);
|
|
429
450
|
});
|
|
@@ -522,15 +543,23 @@ var MemorySimple = class {
|
|
|
522
543
|
this.#memory.forEach(callback);
|
|
523
544
|
return this;
|
|
524
545
|
}
|
|
546
|
+
/**
|
|
547
|
+
* some(按入栈顺序)
|
|
548
|
+
*/
|
|
549
|
+
some(callback) {
|
|
550
|
+
return this.#memory.some(callback);
|
|
551
|
+
}
|
|
525
552
|
/**
|
|
526
553
|
* map(按入栈顺序)
|
|
527
554
|
*/
|
|
528
555
|
map(callback) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
556
|
+
return this.#memory.map(callback);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* reduce(按入栈顺序)
|
|
560
|
+
*/
|
|
561
|
+
reduce(callback, initialValue) {
|
|
562
|
+
return this.#memory.reduce(callback, initialValue);
|
|
534
563
|
}
|
|
535
564
|
/**
|
|
536
565
|
* 获取指定类型存储数据
|
package/lib/memory/basic.js
CHANGED
|
@@ -52,6 +52,24 @@ class MemoryBasic {
|
|
|
52
52
|
}
|
|
53
53
|
return this;
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* some(按入栈顺序)
|
|
57
|
+
*/
|
|
58
|
+
some(callback) {
|
|
59
|
+
return this.list.some(callback);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* map(按入栈顺序)
|
|
63
|
+
*/
|
|
64
|
+
map(callback) {
|
|
65
|
+
return this.list.map(callback);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* reduce(按入栈顺序)
|
|
69
|
+
*/
|
|
70
|
+
reduce(callback, initialValue) {
|
|
71
|
+
return this.list.reduce(callback, initialValue);
|
|
72
|
+
}
|
|
55
73
|
/**
|
|
56
74
|
* 检测存储是否包含某种类型
|
|
57
75
|
*/
|
|
@@ -117,7 +135,10 @@ class MemoryBasic {
|
|
|
117
135
|
return this;
|
|
118
136
|
const local = hash8strings(this.#reflex(memorys.get(type)));
|
|
119
137
|
const Memory2 = this.constructor;
|
|
120
|
-
const imitator = new Memory2(this.key
|
|
138
|
+
const imitator = new Memory2(this.key, {
|
|
139
|
+
mount: this.#mount,
|
|
140
|
+
reflex: this.#reflex
|
|
141
|
+
});
|
|
121
142
|
list.forEach((data, index) => {
|
|
122
143
|
index in local || imitator.push(data);
|
|
123
144
|
});
|
package/lib/memory/simple.js
CHANGED
|
@@ -39,15 +39,23 @@ class MemorySimple {
|
|
|
39
39
|
this.#memory.forEach(callback);
|
|
40
40
|
return this;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* some(按入栈顺序)
|
|
44
|
+
*/
|
|
45
|
+
some(callback) {
|
|
46
|
+
return this.#memory.some(callback);
|
|
47
|
+
}
|
|
42
48
|
/**
|
|
43
49
|
* map(按入栈顺序)
|
|
44
50
|
*/
|
|
45
51
|
map(callback) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
return this.#memory.map(callback);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* reduce(按入栈顺序)
|
|
56
|
+
*/
|
|
57
|
+
reduce(callback, initialValue) {
|
|
58
|
+
return this.#memory.reduce(callback, initialValue);
|
|
51
59
|
}
|
|
52
60
|
/**
|
|
53
61
|
* 获取指定类型存储数据
|
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
|
@@ -39,6 +39,18 @@ export declare class MemoryBasic<T, Reactor, Type extends Memory.Type> {
|
|
|
39
39
|
* 遍历所有存储类型
|
|
40
40
|
*/
|
|
41
41
|
forType(callback: (data: T[], type: Type) => void): this;
|
|
42
|
+
/**
|
|
43
|
+
* some(按入栈顺序)
|
|
44
|
+
*/
|
|
45
|
+
some(callback: (data: T, index: number) => boolean): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* map(按入栈顺序)
|
|
48
|
+
*/
|
|
49
|
+
map<V>(callback: (data: T, index: number) => V): V[];
|
|
50
|
+
/**
|
|
51
|
+
* reduce(按入栈顺序)
|
|
52
|
+
*/
|
|
53
|
+
reduce<V>(callback: (previousValue: V, currentValue: T, currentIndex: number) => V, initialValue: V): V;
|
|
42
54
|
/**
|
|
43
55
|
* 检测存储是否包含某种类型
|
|
44
56
|
*/
|
package/types/memory/simple.d.ts
CHANGED
|
@@ -23,10 +23,18 @@ export declare class MemorySimple<T, Type extends Memory.Type> implements Basic<
|
|
|
23
23
|
* 遍历所有存储数据(按入栈顺序)
|
|
24
24
|
*/
|
|
25
25
|
forEach(callback: (data: T, index: number) => void): this;
|
|
26
|
+
/**
|
|
27
|
+
* some(按入栈顺序)
|
|
28
|
+
*/
|
|
29
|
+
some(callback: (data: T, index: number) => boolean): boolean;
|
|
26
30
|
/**
|
|
27
31
|
* map(按入栈顺序)
|
|
28
32
|
*/
|
|
29
33
|
map<V>(callback: (data: T, index: number) => V): V[];
|
|
34
|
+
/**
|
|
35
|
+
* reduce(按入栈顺序)
|
|
36
|
+
*/
|
|
37
|
+
reduce<V>(callback: (previousValue: V, currentValue: T, currentIndex: number) => V, initialValue: V): V;
|
|
30
38
|
/**
|
|
31
39
|
* 获取指定类型存储数据
|
|
32
40
|
*/
|
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;
|