@itwin/core-bentley 5.7.0-dev.13 → 5.7.0-dev.14
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/lib/cjs/ObservableSet.d.ts +16 -0
- package/lib/cjs/ObservableSet.d.ts.map +1 -1
- package/lib/cjs/ObservableSet.js +30 -0
- package/lib/cjs/ObservableSet.js.map +1 -1
- package/lib/esm/ObservableSet.d.ts +16 -0
- package/lib/esm/ObservableSet.d.ts.map +1 -1
- package/lib/esm/ObservableSet.js +30 -0
- package/lib/esm/ObservableSet.js.map +1 -1
- package/package.json +2 -2
|
@@ -12,6 +12,10 @@ export declare class ObservableSet<T> extends Set<T> {
|
|
|
12
12
|
readonly onDeleted: BeEvent<(item: T) => void>;
|
|
13
13
|
/** Emitted after this set's contents are cleared. */
|
|
14
14
|
readonly onCleared: BeEvent<() => void>;
|
|
15
|
+
/** Emitted after multiple items are added to this set via [[addAll]]. */
|
|
16
|
+
readonly onBatchAdded: BeEvent<() => void>;
|
|
17
|
+
/** Emitted after multiple items are deleted from this set via [[deleteAll]]. */
|
|
18
|
+
readonly onBatchDeleted: BeEvent<() => void>;
|
|
15
19
|
/** Construct a new ObservableSet.
|
|
16
20
|
* @param elements Optional elements with which to populate the new set.
|
|
17
21
|
*/
|
|
@@ -24,5 +28,17 @@ export declare class ObservableSet<T> extends Set<T> {
|
|
|
24
28
|
* and raises the [[onCleared]] event.
|
|
25
29
|
*/
|
|
26
30
|
clear(): void;
|
|
31
|
+
/** Add multiple items to the set, raising [[onBatchAdded]] only once after all items are added.
|
|
32
|
+
* This is more efficient than calling [[add]] in a loop when listeners need not be notified of each individual addition.
|
|
33
|
+
* @param items The items to add.
|
|
34
|
+
* @returns The number of items that were actually added (i.e., were not already present).
|
|
35
|
+
*/
|
|
36
|
+
addAll(items: Iterable<T>): number;
|
|
37
|
+
/** Delete multiple items from the set, raising [[onBatchDeleted]] only once after all items are deleted.
|
|
38
|
+
* This is more efficient than calling [[delete]] in a loop when listeners need not be notified of each individual deletion.
|
|
39
|
+
* @param items The items to delete.
|
|
40
|
+
* @returns The number of items that were actually deleted (i.e., were present in the set).
|
|
41
|
+
*/
|
|
42
|
+
deleteAll(items: Iterable<T>): number;
|
|
27
43
|
}
|
|
28
44
|
//# sourceMappingURL=ObservableSet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableSet.d.ts","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,CAAC;IAC1C,iDAAiD;IACjD,SAAgB,OAAO,iBAAsB,CAAC,KAAK,IAAI,EAAI;IAC3D,qDAAqD;IACrD,SAAgB,SAAS,iBAAsB,CAAC,KAAK,IAAI,EAAI;IAC7D,qDAAqD;IACrD,SAAgB,SAAS,gBAAqB,IAAI,EAAI;
|
|
1
|
+
{"version":3,"file":"ObservableSet.d.ts","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,CAAC;IAC1C,iDAAiD;IACjD,SAAgB,OAAO,iBAAsB,CAAC,KAAK,IAAI,EAAI;IAC3D,qDAAqD;IACrD,SAAgB,SAAS,iBAAsB,CAAC,KAAK,IAAI,EAAI;IAC7D,qDAAqD;IACrD,SAAgB,SAAS,gBAAqB,IAAI,EAAI;IACtD,yEAAyE;IACzE,SAAgB,YAAY,gBAAqB,IAAI,EAAI;IACzD,gFAAgF;IAChF,SAAgB,cAAc,gBAAqB,IAAI,EAAI;IAE3D;;OAEG;gBACgB,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS;IAcrD;;OAEG;IACa,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO;IAQxC;;OAEG;IACa,KAAK,IAAI,IAAI;IAO7B;;;;OAIG;IACI,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM;IAWzC;;;;OAIG;IACI,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM;CAU7C"}
|
package/lib/cjs/ObservableSet.js
CHANGED
|
@@ -19,6 +19,10 @@ class ObservableSet extends Set {
|
|
|
19
19
|
onDeleted = new BeEvent_1.BeEvent();
|
|
20
20
|
/** Emitted after this set's contents are cleared. */
|
|
21
21
|
onCleared = new BeEvent_1.BeEvent();
|
|
22
|
+
/** Emitted after multiple items are added to this set via [[addAll]]. */
|
|
23
|
+
onBatchAdded = new BeEvent_1.BeEvent();
|
|
24
|
+
/** Emitted after multiple items are deleted from this set via [[deleteAll]]. */
|
|
25
|
+
onBatchDeleted = new BeEvent_1.BeEvent();
|
|
22
26
|
/** Construct a new ObservableSet.
|
|
23
27
|
* @param elements Optional elements with which to populate the new set.
|
|
24
28
|
*/
|
|
@@ -51,6 +55,32 @@ class ObservableSet extends Set {
|
|
|
51
55
|
this.onCleared.raiseEvent();
|
|
52
56
|
}
|
|
53
57
|
}
|
|
58
|
+
/** Add multiple items to the set, raising [[onBatchAdded]] only once after all items are added.
|
|
59
|
+
* This is more efficient than calling [[add]] in a loop when listeners need not be notified of each individual addition.
|
|
60
|
+
* @param items The items to add.
|
|
61
|
+
* @returns The number of items that were actually added (i.e., were not already present).
|
|
62
|
+
*/
|
|
63
|
+
addAll(items) {
|
|
64
|
+
const prevSize = this.size;
|
|
65
|
+
for (const item of items)
|
|
66
|
+
super.add(item);
|
|
67
|
+
if (this.size !== prevSize)
|
|
68
|
+
this.onBatchAdded.raiseEvent();
|
|
69
|
+
return this.size - prevSize;
|
|
70
|
+
}
|
|
71
|
+
/** Delete multiple items from the set, raising [[onBatchDeleted]] only once after all items are deleted.
|
|
72
|
+
* This is more efficient than calling [[delete]] in a loop when listeners need not be notified of each individual deletion.
|
|
73
|
+
* @param items The items to delete.
|
|
74
|
+
* @returns The number of items that were actually deleted (i.e., were present in the set).
|
|
75
|
+
*/
|
|
76
|
+
deleteAll(items) {
|
|
77
|
+
const prevSize = this.size;
|
|
78
|
+
for (const item of items)
|
|
79
|
+
super.delete(item);
|
|
80
|
+
if (this.size !== prevSize)
|
|
81
|
+
this.onBatchDeleted.raiseEvent();
|
|
82
|
+
return prevSize - this.size;
|
|
83
|
+
}
|
|
54
84
|
}
|
|
55
85
|
exports.ObservableSet = ObservableSet;
|
|
56
86
|
//# sourceMappingURL=ObservableSet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AAEpC;;GAEG;AACH,MAAa,aAAiB,SAAQ,GAAM;IAC1C,iDAAiD;IACjC,OAAO,GAAG,IAAI,iBAAO,EAAqB,CAAC;IAC3D,qDAAqD;IACrC,SAAS,GAAG,IAAI,iBAAO,EAAqB,CAAC;IAC7D,qDAAqD;IACrC,SAAS,GAAG,IAAI,iBAAO,EAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AAEpC;;GAEG;AACH,MAAa,aAAiB,SAAQ,GAAM;IAC1C,iDAAiD;IACjC,OAAO,GAAG,IAAI,iBAAO,EAAqB,CAAC;IAC3D,qDAAqD;IACrC,SAAS,GAAG,IAAI,iBAAO,EAAqB,CAAC;IAC7D,qDAAqD;IACrC,SAAS,GAAG,IAAI,iBAAO,EAAc,CAAC;IACtD,yEAAyE;IACzD,YAAY,G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AC;IAED;;;;OAIG;IACI,SAAS,CAAC,KAAkB;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,KAAK;YACtB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAErB,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;YACxB,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;QAEnC,OAAO,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAjFD,sCAiFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Collections\r\n */\r\n\r\nimport { BeEvent } from \"./BeEvent\";\r\n\r\n/** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.\r\n * @public\r\n */\r\nexport class ObservableSet<T> extends Set<T> {\r\n /** Emitted after `item` is added to this set. */\r\n public readonly onAdded = new BeEvent<(item: T) => void>();\r\n /** Emitted after `item` is deleted from this set. */\r\n public readonly onDeleted = new BeEvent<(item: T) => void>();\r\n /** Emitted after this set's contents are cleared. */\r\n public readonly onCleared = new BeEvent<() => void>();\r\n /** Emitted after multiple items are added to this set via [[addAll]]. */\r\n public readonly onBatchAdded = new BeEvent<() => void>();\r\n /** Emitted after multiple items are deleted from this set via [[deleteAll]]. */\r\n public readonly onBatchDeleted = new BeEvent<() => void>();\r\n\r\n /** Construct a new ObservableSet.\r\n * @param elements Optional elements with which to populate the new set.\r\n */\r\n public constructor(elements?: Iterable<T> | undefined) {\r\n // NB: Set constructor will invoke add(). Do not override until initialized.\r\n super(elements);\r\n\r\n this.add = (item: T) => {\r\n const prevSize = this.size;\r\n const ret = super.add(item);\r\n if (this.size !== prevSize)\r\n this.onAdded.raiseEvent(item);\r\n\r\n return ret;\r\n };\r\n }\r\n\r\n /** Invokes [Set.delete](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete), raising\r\n * the [[onDeleted]] event if the item was removed from the set.\r\n */\r\n public override delete(item: T): boolean {\r\n const ret = super.delete(item);\r\n if (ret)\r\n this.onDeleted.raiseEvent(item);\r\n\r\n return ret;\r\n }\r\n\r\n /** If this set is not already empty, invokes [Set.clear](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)\r\n * and raises the [[onCleared]] event.\r\n */\r\n public override clear(): void {\r\n if (0 !== this.size) {\r\n super.clear();\r\n this.onCleared.raiseEvent();\r\n }\r\n }\r\n\r\n /** Add multiple items to the set, raising [[onBatchAdded]] only once after all items are added.\r\n * This is more efficient than calling [[add]] in a loop when listeners need not be notified of each individual addition.\r\n * @param items The items to add.\r\n * @returns The number of items that were actually added (i.e., were not already present).\r\n */\r\n public addAll(items: Iterable<T>): number {\r\n const prevSize = this.size;\r\n for (const item of items)\r\n super.add(item);\r\n\r\n if (this.size !== prevSize)\r\n this.onBatchAdded.raiseEvent();\r\n\r\n return this.size - prevSize;\r\n }\r\n\r\n /** Delete multiple items from the set, raising [[onBatchDeleted]] only once after all items are deleted.\r\n * This is more efficient than calling [[delete]] in a loop when listeners need not be notified of each individual deletion.\r\n * @param items The items to delete.\r\n * @returns The number of items that were actually deleted (i.e., were present in the set).\r\n */\r\n public deleteAll(items: Iterable<T>): number {\r\n const prevSize = this.size;\r\n for (const item of items)\r\n super.delete(item);\r\n\r\n if (this.size !== prevSize)\r\n this.onBatchDeleted.raiseEvent();\r\n\r\n return prevSize - this.size;\r\n }\r\n}\r\n"]}
|
|
@@ -12,6 +12,10 @@ export declare class ObservableSet<T> extends Set<T> {
|
|
|
12
12
|
readonly onDeleted: BeEvent<(item: T) => void>;
|
|
13
13
|
/** Emitted after this set's contents are cleared. */
|
|
14
14
|
readonly onCleared: BeEvent<() => void>;
|
|
15
|
+
/** Emitted after multiple items are added to this set via [[addAll]]. */
|
|
16
|
+
readonly onBatchAdded: BeEvent<() => void>;
|
|
17
|
+
/** Emitted after multiple items are deleted from this set via [[deleteAll]]. */
|
|
18
|
+
readonly onBatchDeleted: BeEvent<() => void>;
|
|
15
19
|
/** Construct a new ObservableSet.
|
|
16
20
|
* @param elements Optional elements with which to populate the new set.
|
|
17
21
|
*/
|
|
@@ -24,5 +28,17 @@ export declare class ObservableSet<T> extends Set<T> {
|
|
|
24
28
|
* and raises the [[onCleared]] event.
|
|
25
29
|
*/
|
|
26
30
|
clear(): void;
|
|
31
|
+
/** Add multiple items to the set, raising [[onBatchAdded]] only once after all items are added.
|
|
32
|
+
* This is more efficient than calling [[add]] in a loop when listeners need not be notified of each individual addition.
|
|
33
|
+
* @param items The items to add.
|
|
34
|
+
* @returns The number of items that were actually added (i.e., were not already present).
|
|
35
|
+
*/
|
|
36
|
+
addAll(items: Iterable<T>): number;
|
|
37
|
+
/** Delete multiple items from the set, raising [[onBatchDeleted]] only once after all items are deleted.
|
|
38
|
+
* This is more efficient than calling [[delete]] in a loop when listeners need not be notified of each individual deletion.
|
|
39
|
+
* @param items The items to delete.
|
|
40
|
+
* @returns The number of items that were actually deleted (i.e., were present in the set).
|
|
41
|
+
*/
|
|
42
|
+
deleteAll(items: Iterable<T>): number;
|
|
27
43
|
}
|
|
28
44
|
//# sourceMappingURL=ObservableSet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableSet.d.ts","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,CAAC;IAC1C,iDAAiD;IACjD,SAAgB,OAAO,iBAAsB,CAAC,KAAK,IAAI,EAAI;IAC3D,qDAAqD;IACrD,SAAgB,SAAS,iBAAsB,CAAC,KAAK,IAAI,EAAI;IAC7D,qDAAqD;IACrD,SAAgB,SAAS,gBAAqB,IAAI,EAAI;
|
|
1
|
+
{"version":3,"file":"ObservableSet.d.ts","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,CAAC;IAC1C,iDAAiD;IACjD,SAAgB,OAAO,iBAAsB,CAAC,KAAK,IAAI,EAAI;IAC3D,qDAAqD;IACrD,SAAgB,SAAS,iBAAsB,CAAC,KAAK,IAAI,EAAI;IAC7D,qDAAqD;IACrD,SAAgB,SAAS,gBAAqB,IAAI,EAAI;IACtD,yEAAyE;IACzE,SAAgB,YAAY,gBAAqB,IAAI,EAAI;IACzD,gFAAgF;IAChF,SAAgB,cAAc,gBAAqB,IAAI,EAAI;IAE3D;;OAEG;gBACgB,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS;IAcrD;;OAEG;IACa,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO;IAQxC;;OAEG;IACa,KAAK,IAAI,IAAI;IAO7B;;;;OAIG;IACI,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM;IAWzC;;;;OAIG;IACI,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM;CAU7C"}
|
package/lib/esm/ObservableSet.js
CHANGED
|
@@ -16,6 +16,10 @@ export class ObservableSet extends Set {
|
|
|
16
16
|
onDeleted = new BeEvent();
|
|
17
17
|
/** Emitted after this set's contents are cleared. */
|
|
18
18
|
onCleared = new BeEvent();
|
|
19
|
+
/** Emitted after multiple items are added to this set via [[addAll]]. */
|
|
20
|
+
onBatchAdded = new BeEvent();
|
|
21
|
+
/** Emitted after multiple items are deleted from this set via [[deleteAll]]. */
|
|
22
|
+
onBatchDeleted = new BeEvent();
|
|
19
23
|
/** Construct a new ObservableSet.
|
|
20
24
|
* @param elements Optional elements with which to populate the new set.
|
|
21
25
|
*/
|
|
@@ -48,5 +52,31 @@ export class ObservableSet extends Set {
|
|
|
48
52
|
this.onCleared.raiseEvent();
|
|
49
53
|
}
|
|
50
54
|
}
|
|
55
|
+
/** Add multiple items to the set, raising [[onBatchAdded]] only once after all items are added.
|
|
56
|
+
* This is more efficient than calling [[add]] in a loop when listeners need not be notified of each individual addition.
|
|
57
|
+
* @param items The items to add.
|
|
58
|
+
* @returns The number of items that were actually added (i.e., were not already present).
|
|
59
|
+
*/
|
|
60
|
+
addAll(items) {
|
|
61
|
+
const prevSize = this.size;
|
|
62
|
+
for (const item of items)
|
|
63
|
+
super.add(item);
|
|
64
|
+
if (this.size !== prevSize)
|
|
65
|
+
this.onBatchAdded.raiseEvent();
|
|
66
|
+
return this.size - prevSize;
|
|
67
|
+
}
|
|
68
|
+
/** Delete multiple items from the set, raising [[onBatchDeleted]] only once after all items are deleted.
|
|
69
|
+
* This is more efficient than calling [[delete]] in a loop when listeners need not be notified of each individual deletion.
|
|
70
|
+
* @param items The items to delete.
|
|
71
|
+
* @returns The number of items that were actually deleted (i.e., were present in the set).
|
|
72
|
+
*/
|
|
73
|
+
deleteAll(items) {
|
|
74
|
+
const prevSize = this.size;
|
|
75
|
+
for (const item of items)
|
|
76
|
+
super.delete(item);
|
|
77
|
+
if (this.size !== prevSize)
|
|
78
|
+
this.onBatchDeleted.raiseEvent();
|
|
79
|
+
return prevSize - this.size;
|
|
80
|
+
}
|
|
51
81
|
}
|
|
52
82
|
//# sourceMappingURL=ObservableSet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO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M,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG;YACL,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAElC,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACa,KAAK;QACnB,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAkB;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,KAAK;YACtB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAElB,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;YACxB,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;QAEjC,OAAO,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,KAAkB;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,KAAK;YACtB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAErB,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;YACxB,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;QAEnC,OAAO,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Collections\r\n */\r\n\r\nimport { BeEvent } from \"./BeEvent\";\r\n\r\n/** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.\r\n * @public\r\n */\r\nexport class ObservableSet<T> extends Set<T> {\r\n /** Emitted after `item` is added to this set. */\r\n public readonly onAdded = new BeEvent<(item: T) => void>();\r\n /** Emitted after `item` is deleted from this set. */\r\n public readonly onDeleted = new BeEvent<(item: T) => void>();\r\n /** Emitted after this set's contents are cleared. */\r\n public readonly onCleared = new BeEvent<() => void>();\r\n /** Emitted after multiple items are added to this set via [[addAll]]. */\r\n public readonly onBatchAdded = new BeEvent<() => void>();\r\n /** Emitted after multiple items are deleted from this set via [[deleteAll]]. */\r\n public readonly onBatchDeleted = new BeEvent<() => void>();\r\n\r\n /** Construct a new ObservableSet.\r\n * @param elements Optional elements with which to populate the new set.\r\n */\r\n public constructor(elements?: Iterable<T> | undefined) {\r\n // NB: Set constructor will invoke add(). Do not override until initialized.\r\n super(elements);\r\n\r\n this.add = (item: T) => {\r\n const prevSize = this.size;\r\n const ret = super.add(item);\r\n if (this.size !== prevSize)\r\n this.onAdded.raiseEvent(item);\r\n\r\n return ret;\r\n };\r\n }\r\n\r\n /** Invokes [Set.delete](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete), raising\r\n * the [[onDeleted]] event if the item was removed from the set.\r\n */\r\n public override delete(item: T): boolean {\r\n const ret = super.delete(item);\r\n if (ret)\r\n this.onDeleted.raiseEvent(item);\r\n\r\n return ret;\r\n }\r\n\r\n /** If this set is not already empty, invokes [Set.clear](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)\r\n * and raises the [[onCleared]] event.\r\n */\r\n public override clear(): void {\r\n if (0 !== this.size) {\r\n super.clear();\r\n this.onCleared.raiseEvent();\r\n }\r\n }\r\n\r\n /** Add multiple items to the set, raising [[onBatchAdded]] only once after all items are added.\r\n * This is more efficient than calling [[add]] in a loop when listeners need not be notified of each individual addition.\r\n * @param items The items to add.\r\n * @returns The number of items that were actually added (i.e., were not already present).\r\n */\r\n public addAll(items: Iterable<T>): number {\r\n const prevSize = this.size;\r\n for (const item of items)\r\n super.add(item);\r\n\r\n if (this.size !== prevSize)\r\n this.onBatchAdded.raiseEvent();\r\n\r\n return this.size - prevSize;\r\n }\r\n\r\n /** Delete multiple items from the set, raising [[onBatchDeleted]] only once after all items are deleted.\r\n * This is more efficient than calling [[delete]] in a loop when listeners need not be notified of each individual deletion.\r\n * @param items The items to delete.\r\n * @returns The number of items that were actually deleted (i.e., were present in the set).\r\n */\r\n public deleteAll(items: Iterable<T>): number {\r\n const prevSize = this.size;\r\n for (const item of items)\r\n super.delete(item);\r\n\r\n if (this.size !== prevSize)\r\n this.onBatchDeleted.raiseEvent();\r\n\r\n return prevSize - this.size;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-bentley",
|
|
3
|
-
"version": "5.7.0-dev.
|
|
3
|
+
"version": "5.7.0-dev.14",
|
|
4
4
|
"description": "Bentley JavaScript core components",
|
|
5
5
|
"main": "lib/cjs/core-bentley.js",
|
|
6
6
|
"module": "lib/esm/core-bentley.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"rimraf": "^6.0.1",
|
|
31
31
|
"typescript": "~5.6.2",
|
|
32
32
|
"vitest": "^3.0.6",
|
|
33
|
-
"@itwin/build-tools": "5.7.0-dev.
|
|
33
|
+
"@itwin/build-tools": "5.7.0-dev.14"
|
|
34
34
|
},
|
|
35
35
|
"nyc": {
|
|
36
36
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|