@itwin/core-bentley 4.8.0-dev.17 → 4.8.0-dev.19
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/BeEvent.d.ts +17 -0
- package/lib/cjs/BeEvent.d.ts.map +1 -1
- package/lib/cjs/BeEvent.js.map +1 -1
- package/lib/cjs/CompressedId64Set.d.ts +1 -1
- package/lib/cjs/CompressedId64Set.js +1 -1
- package/lib/cjs/CompressedId64Set.js.map +1 -1
- package/lib/esm/BeEvent.d.ts +17 -0
- package/lib/esm/BeEvent.d.ts.map +1 -1
- package/lib/esm/BeEvent.js.map +1 -1
- package/lib/esm/CompressedId64Set.d.ts +1 -1
- package/lib/esm/CompressedId64Set.js +1 -1
- package/lib/esm/CompressedId64Set.js.map +1 -1
- package/package.json +2 -2
package/lib/cjs/BeEvent.d.ts
CHANGED
|
@@ -79,4 +79,21 @@ export declare class BeEventList<T extends Listener> {
|
|
|
79
79
|
*/
|
|
80
80
|
remove(name: string): void;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the type of the callback function for an event type like [[BeEvent]].
|
|
84
|
+
* For example:
|
|
85
|
+
* ```ts
|
|
86
|
+
* const event = new BeEvent<(x: number, y: string) => void>();
|
|
87
|
+
* const callback: ListenerType<typeof event> = (x, y) => {
|
|
88
|
+
* console.log(`${x}, ${y}`);
|
|
89
|
+
* };
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export type ListenerType<TEvent extends {
|
|
95
|
+
addListener(listener: Listener): () => void;
|
|
96
|
+
}> = TEvent extends {
|
|
97
|
+
addListener(listener: infer TListener): () => void;
|
|
98
|
+
} ? TListener : never;
|
|
82
99
|
//# sourceMappingURL=BeEvent.d.ts.map
|
package/lib/cjs/BeEvent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeEvent.d.ts","source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CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,KAAK;YACP,OAAO,KAAK,CAAC;QAEf,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAY;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IACjC,CAAC;CACF;AAxBD,kCAwBC","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 Events\r\n */\r\n\r\nimport { UnexpectedErrors } from \"./UnexpectedErrors\";\r\n\r\n/** A function invoked when a BeEvent is raised.\r\n * @public\r\n */\r\nexport type Listener = (...arg: any[]) => void;\r\n\r\ninterface EventContext {\r\n listener: Listener | undefined;\r\n scope: any;\r\n once: boolean;\r\n}\r\n\r\n/**\r\n * Manages a set of *listeners* for a particular event and notifies them when the event is raised.\r\n * This class is usually instantiated inside of a container class and\r\n * exposed as a property for others to *subscribe* via [[BeEvent.addListener]].\r\n * @public\r\n */\r\nexport class BeEvent<T extends Listener> {\r\n private _listeners: EventContext[] = [];\r\n private _insideRaiseEvent: boolean = false;\r\n\r\n /** The number of listeners currently subscribed to the event. */\r\n public get numberOfListeners() { return this._listeners.length; }\r\n\r\n /**\r\n * Registers a Listener to be executed whenever this event is raised.\r\n * @param listener The function to be executed when the event is raised.\r\n * @param scope An optional object scope to serve as the 'this' pointer when listener is invoked.\r\n * @returns A function that will remove this event listener.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\r\n */\r\n public addListener(listener: T, scope?: any): () => void {\r\n this._listeners.push({ listener, scope, once: false });\r\n return () => this.removeListener(listener, scope);\r\n }\r\n\r\n /**\r\n * Registers a callback function to be executed *only once* when the event is raised.\r\n * @param listener The function to be executed once when the event is raised.\r\n * @param scope An optional object scope to serve as the `this` pointer in which the listener function will execute.\r\n * @returns A function that will remove this event listener.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\r\n */\r\n public addOnce(listener: T, scope?: any): () => void {\r\n this._listeners.push({ listener, scope, once: true });\r\n return () => this.removeListener(listener, scope);\r\n }\r\n\r\n /**\r\n * Un-register a previously registered listener.\r\n * @param listener The listener to be unregistered.\r\n * @param scope The scope that was originally passed to addListener.\r\n * @returns 'true' if the listener was removed; 'false' if the listener and scope are not registered with the event.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.addListener]]\r\n */\r\n public removeListener(listener: T, scope?: any): boolean {\r\n const listeners = this._listeners;\r\n\r\n for (let i = 0; i < listeners.length; ++i) {\r\n const context = listeners[i];\r\n if (context.listener === listener && context.scope === scope) {\r\n if (this._insideRaiseEvent) {\r\n context.listener = undefined;\r\n } else {\r\n listeners.splice(i, 1);\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Raises the event by calling each registered listener with the supplied arguments.\r\n * @param args This method takes any number of parameters and passes them through to the listeners.\r\n * @see [[BeEvent.removeListener]], [[BeEvent.addListener]]\r\n */\r\n public raiseEvent(...args: Parameters<T>) {\r\n this._insideRaiseEvent = true;\r\n\r\n const listeners = this._listeners;\r\n const length = listeners.length;\r\n let dropped = false;\r\n\r\n for (let i = 0; i < length; ++i) {\r\n const context = listeners[i];\r\n if (!context.listener) {\r\n dropped = true;\r\n } else {\r\n try {\r\n context.listener.apply(context.scope, args);\r\n } catch (e) {\r\n UnexpectedErrors.handle(e);\r\n }\r\n if (context.once) {\r\n context.listener = undefined;\r\n dropped = true;\r\n }\r\n }\r\n }\r\n\r\n // if we had dropped listeners, remove them now\r\n if (dropped)\r\n this._listeners = this._listeners.filter((ctx) => ctx.listener !== undefined);\r\n\r\n this._insideRaiseEvent = false;\r\n }\r\n\r\n /** Determine whether this BeEvent has a specified listener registered.\r\n * @param listener The listener to check.\r\n * @param scope optional scope argument to match call to addListener\r\n */\r\n public has(listener: T, scope?: any): boolean {\r\n for (const ctx of this._listeners) {\r\n if (ctx.listener === listener && ctx.scope === scope) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /** Clear all Listeners from this BeEvent. */\r\n public clear(): void { this._listeners.length = 0; }\r\n}\r\n\r\n/** Specialization of BeEvent for events that take a single strongly typed argument, primarily used for UI events.\r\n * @public\r\n */\r\nexport class BeUiEvent<TEventArgs> extends BeEvent<(args: TEventArgs) => void> {\r\n /** Raises event with single strongly typed argument. */\r\n public emit(args: TEventArgs): void { this.raiseEvent(args); }\r\n}\r\n\r\n/**\r\n * A list of BeEvent objects, accessible by an event name.\r\n * This class may be used instead of explicitly declaring each BeEvent as a member of a containing class.\r\n * @public\r\n */\r\nexport class BeEventList<T extends Listener> {\r\n private _events: { [name: string]: BeEvent<T> | undefined } = {};\r\n\r\n /**\r\n * Gets the event associated with the specified name, creating the event if it does not already exist.\r\n * @param name The name of the event.\r\n */\r\n public get(name: string): BeEvent<T> {\r\n let event = this._events[name];\r\n if (event)\r\n return event;\r\n\r\n event = new BeEvent();\r\n this._events[name] = event;\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes the event associated with a name.\r\n * @param name The name of the event.\r\n */\r\n public remove(name: string): void {\r\n this._events[name] = undefined;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BeEvent.js","sourceRoot":"","sources":["../../src/BeEvent.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yDAAsD;AAatD;;;;;GAKG;AACH,MAAa,OAAO;IAApB;QACU,eAAU,GAAmB,EAAE,CAAC;QAChC,sBAAiB,GAAY,KAAK,CAAC;IAwG7C,CAAC;IAtGC,iEAAiE;IACjE,IAAW,iBAAiB,KAAK,OAAO,IAAI,CAAC,UAAU,CAAC,MAA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YACd,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6CAA6C;IACtC,KAAK,KAAW,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;CACrD;AA1GD,0BA0GC;AAED;;GAEG;AACH,MAAa,SAAsB,SAAQ,OAAmC;IAC5E,wDAAwD;IACjD,IAAI,CAAC,IAAgB,IAAU,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CAC/D;AAHD,8BAGC;AAED;;;;GAIG;AACH,MAAa,WAAW;IAAxB;QACU,YAAO,GAA+C,EAAE,CAAC;IAuBnE,CAAC;IArBC;;;OAGG;IACI,GAAG,CAAC,IAAY;QACrB,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,KAAK;YACP,OAAO,KAAK,CAAC;QAEf,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAY;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IACjC,CAAC;CACF;AAxBD,kCAwBC","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 Events\r\n */\r\n\r\nimport { UnexpectedErrors } from \"./UnexpectedErrors\";\r\n\r\n/** A function invoked when a BeEvent is raised.\r\n * @public\r\n */\r\nexport type Listener = (...arg: any[]) => void;\r\n\r\ninterface EventContext {\r\n listener: Listener | undefined;\r\n scope: any;\r\n once: boolean;\r\n}\r\n\r\n/**\r\n * Manages a set of *listeners* for a particular event and notifies them when the event is raised.\r\n * This class is usually instantiated inside of a container class and\r\n * exposed as a property for others to *subscribe* via [[BeEvent.addListener]].\r\n * @public\r\n */\r\nexport class BeEvent<T extends Listener> {\r\n private _listeners: EventContext[] = [];\r\n private _insideRaiseEvent: boolean = false;\r\n\r\n /** The number of listeners currently subscribed to the event. */\r\n public get numberOfListeners() { return this._listeners.length; }\r\n\r\n /**\r\n * Registers a Listener to be executed whenever this event is raised.\r\n * @param listener The function to be executed when the event is raised.\r\n * @param scope An optional object scope to serve as the 'this' pointer when listener is invoked.\r\n * @returns A function that will remove this event listener.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\r\n */\r\n public addListener(listener: T, scope?: any): () => void {\r\n this._listeners.push({ listener, scope, once: false });\r\n return () => this.removeListener(listener, scope);\r\n }\r\n\r\n /**\r\n * Registers a callback function to be executed *only once* when the event is raised.\r\n * @param listener The function to be executed once when the event is raised.\r\n * @param scope An optional object scope to serve as the `this` pointer in which the listener function will execute.\r\n * @returns A function that will remove this event listener.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\r\n */\r\n public addOnce(listener: T, scope?: any): () => void {\r\n this._listeners.push({ listener, scope, once: true });\r\n return () => this.removeListener(listener, scope);\r\n }\r\n\r\n /**\r\n * Un-register a previously registered listener.\r\n * @param listener The listener to be unregistered.\r\n * @param scope The scope that was originally passed to addListener.\r\n * @returns 'true' if the listener was removed; 'false' if the listener and scope are not registered with the event.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.addListener]]\r\n */\r\n public removeListener(listener: T, scope?: any): boolean {\r\n const listeners = this._listeners;\r\n\r\n for (let i = 0; i < listeners.length; ++i) {\r\n const context = listeners[i];\r\n if (context.listener === listener && context.scope === scope) {\r\n if (this._insideRaiseEvent) {\r\n context.listener = undefined;\r\n } else {\r\n listeners.splice(i, 1);\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Raises the event by calling each registered listener with the supplied arguments.\r\n * @param args This method takes any number of parameters and passes them through to the listeners.\r\n * @see [[BeEvent.removeListener]], [[BeEvent.addListener]]\r\n */\r\n public raiseEvent(...args: Parameters<T>) {\r\n this._insideRaiseEvent = true;\r\n\r\n const listeners = this._listeners;\r\n const length = listeners.length;\r\n let dropped = false;\r\n\r\n for (let i = 0; i < length; ++i) {\r\n const context = listeners[i];\r\n if (!context.listener) {\r\n dropped = true;\r\n } else {\r\n try {\r\n context.listener.apply(context.scope, args);\r\n } catch (e) {\r\n UnexpectedErrors.handle(e);\r\n }\r\n if (context.once) {\r\n context.listener = undefined;\r\n dropped = true;\r\n }\r\n }\r\n }\r\n\r\n // if we had dropped listeners, remove them now\r\n if (dropped)\r\n this._listeners = this._listeners.filter((ctx) => ctx.listener !== undefined);\r\n\r\n this._insideRaiseEvent = false;\r\n }\r\n\r\n /** Determine whether this BeEvent has a specified listener registered.\r\n * @param listener The listener to check.\r\n * @param scope optional scope argument to match call to addListener\r\n */\r\n public has(listener: T, scope?: any): boolean {\r\n for (const ctx of this._listeners) {\r\n if (ctx.listener === listener && ctx.scope === scope) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /** Clear all Listeners from this BeEvent. */\r\n public clear(): void { this._listeners.length = 0; }\r\n}\r\n\r\n/** Specialization of BeEvent for events that take a single strongly typed argument, primarily used for UI events.\r\n * @public\r\n */\r\nexport class BeUiEvent<TEventArgs> extends BeEvent<(args: TEventArgs) => void> {\r\n /** Raises event with single strongly typed argument. */\r\n public emit(args: TEventArgs): void { this.raiseEvent(args); }\r\n}\r\n\r\n/**\r\n * A list of BeEvent objects, accessible by an event name.\r\n * This class may be used instead of explicitly declaring each BeEvent as a member of a containing class.\r\n * @public\r\n */\r\nexport class BeEventList<T extends Listener> {\r\n private _events: { [name: string]: BeEvent<T> | undefined } = {};\r\n\r\n /**\r\n * Gets the event associated with the specified name, creating the event if it does not already exist.\r\n * @param name The name of the event.\r\n */\r\n public get(name: string): BeEvent<T> {\r\n let event = this._events[name];\r\n if (event)\r\n return event;\r\n\r\n event = new BeEvent();\r\n this._events[name] = event;\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes the event associated with a name.\r\n * @param name The name of the event.\r\n */\r\n public remove(name: string): void {\r\n this._events[name] = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * Retrieves the type of the callback function for an event type like [[BeEvent]].\r\n * For example:\r\n * ```ts\r\n * const event = new BeEvent<(x: number, y: string) => void>();\r\n * const callback: ListenerType<typeof event> = (x, y) => {\r\n * console.log(`${x}, ${y}`);\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport type ListenerType<TEvent extends {\r\n addListener(listener: Listener): () => void;\r\n}> =\r\n TEvent extends {\r\n addListener(listener: infer TListener): () => void;\r\n } ? TListener : never;\r\n"]}
|
|
@@ -24,7 +24,7 @@ export declare namespace CompressedId64Set {
|
|
|
24
24
|
*/
|
|
25
25
|
function compressSet(ids: Id64Set): CompressedId64Set;
|
|
26
26
|
/** Create a sorted array from `ids`, then return a compact string representation of those Ids.
|
|
27
|
-
* @see [[compressIds]] if `ids` is known to already be sorted.
|
|
27
|
+
* @see [[CompressedId64Set.compressIds]] if `ids` is known to already be sorted.
|
|
28
28
|
*/
|
|
29
29
|
function sortAndCompress(ids: Iterable<Id64String>): CompressedId64Set;
|
|
30
30
|
/** Give a **numerically-ordered** array of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.
|
|
@@ -50,7 +50,7 @@ var CompressedId64Set;
|
|
|
50
50
|
}
|
|
51
51
|
CompressedId64Set.compressSet = compressSet;
|
|
52
52
|
/** Create a sorted array from `ids`, then return a compact string representation of those Ids.
|
|
53
|
-
* @see [[compressIds]] if `ids` is known to already be sorted.
|
|
53
|
+
* @see [[CompressedId64Set.compressIds]] if `ids` is known to already be sorted.
|
|
54
54
|
*/
|
|
55
55
|
function sortAndCompress(ids) {
|
|
56
56
|
// `string` is an Iterable<string>. In that case assume caller passed a single Id64String.
|
|
@@ -1 +1 @@
|
|
|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AAM,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,yCAAmB,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7G,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEjD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF;AA3HD,4DA2HC","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 Ids\r\n */\r\n\r\nimport { assert } from \"./Assert\";\r\nimport { Id64, Id64Array, Id64Set, Id64String } from \"./Id\";\r\nimport { OrderedId64Iterable } from \"./OrderedId64Iterable\";\r\nimport { SortedArray } from \"./SortedArray\";\r\n\r\n/** @public */\r\nexport type CompressedId64Set = string;\r\n\r\n/** A compact string representation of an [[Id64Set]]. Such a representation is useful when serializing potentially very large\r\n * sets of Ids.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids represented by a compact string.\r\n * @see [[CompressedId64Set.compressSet]] and [[CompressedId64Set.compressArray]] to produce a compact string from a collection of Ids.\r\n * @see [[CompressedId64Set.decompressSet]] and [[CompressedId64Set.decompressArray]] to produce a collection of Ids from a compact string.\r\n * @see [[OrderedId64Iterable]] for a generic representation of an ordered set of Ids (compressed or otherwise).\r\n * @see [[MutableCompressedId64Set]] for a mutable version.\r\n * @public\r\n */\r\nexport namespace CompressedId64Set { // eslint-disable-line @typescript-eslint/no-redeclare\r\n function isHexDigit(ch: number): boolean {\r\n // ascii values:\r\n // '0' = 48\r\n // '9' = 57\r\n // 'a' = 65\r\n // 'f' = 70\r\n\r\n return (ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 70);\r\n }\r\n\r\n function compactRange(increment: Uint64, length: number): string {\r\n assert(length > 0);\r\n const inc = `+${increment.toString()}`;\r\n if (length <= 1)\r\n return inc;\r\n\r\n const len = length.toString(16).toUpperCase();\r\n return `${inc}*${len}`;\r\n }\r\n\r\n /** Given a set of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n * @see [[CompressedId64Set.compressArray]] to perform the same operation on an [[Id64Array]].\r\n * @see [[CompressedId64Set.decompressSet]] to perform the inverse operation.\r\n */\r\n export function compressSet(ids: Id64Set): CompressedId64Set {\r\n return sortAndCompress(ids);\r\n }\r\n\r\n /** Create a sorted array from `ids`, then return a compact string representation of those Ids.\r\n * @see [[compressIds]] if `ids` is known to already be sorted.\r\n */\r\n export function sortAndCompress(ids: Iterable<Id64String>): CompressedId64Set {\r\n // `string` is an Iterable<string>. In that case assume caller passed a single Id64String.\r\n const arr = typeof ids === \"string\" ? [ids] : Array.from(ids);\r\n OrderedId64Iterable.sortArray(arr);\r\n return compressArray(arr);\r\n }\r\n\r\n /** Give a **numerically-ordered** array of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * Duplicate Ids are included only once in the string representation.\r\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the array is not properly sorted.\r\n * @note The array must be sorted according to the 64-bit numerical value of each Id.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.decompressArray]] to perform the inverse operation.\r\n * @see [[OrderedId64Iterable.sortArray]] to ensure the Ids are properly sorted.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n */\r\n export function compressArray(ids: Id64Array): CompressedId64Set {\r\n return compressIds(ids);\r\n }\r\n\r\n /** Give a **numerically-ordered** collection of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * Duplicate Ids are included only once in the string representation.\r\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the collection is not properly sorted.\r\n * @note The collection must be sorted according to the 64-bit numerical value of each Id.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.iterable]] to perform the inverse operation.\r\n * @see [[OrderedId64Iterable.sortArray]] or [[OrderedId64Iterable.compare]] to ensure the Ids are properly sorted.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n */\r\n export function compressIds(ids: OrderedId64Iterable): CompressedId64Set {\r\n if (\"string\" === typeof ids)\r\n return ids;\r\n\r\n let str = \"\";\r\n\r\n const prevId = new Uint64();\r\n const rangeIncrement = new Uint64();\r\n let rangeLen = 0;\r\n\r\n const curId = new Uint64();\r\n const curIncrement = new Uint64();\r\n for (const id of ids) {\r\n if (!Id64.isValidId64(id))\r\n continue; // ignore garbage and invalid Ids (\"0\")\r\n\r\n curId.setFromId(id);\r\n curIncrement.setFromDifference(curId, prevId);\r\n\r\n const cmp = prevId.compare(curId);\r\n if (0 === cmp)\r\n continue; // ignore duplicates\r\n else if (cmp > 0)\r\n throw new Error(\"CompressedId64Set.compressArray requires a sorted array as input\");\r\n\r\n prevId.copyFrom(curId);\r\n\r\n if (0 === rangeLen) {\r\n rangeIncrement.copyFrom(curIncrement);\r\n rangeLen = 1;\r\n } else if (curIncrement.equals(rangeIncrement)) {\r\n ++rangeLen;\r\n } else {\r\n str += compactRange(rangeIncrement, rangeLen);\r\n rangeIncrement.copyFrom(curIncrement);\r\n rangeLen = 1;\r\n }\r\n }\r\n\r\n if (0 < rangeLen)\r\n str += compactRange(rangeIncrement, rangeLen);\r\n\r\n return str;\r\n }\r\n\r\n /** This exists strictly for the purposes of compressed sets of 64-bit Ids, to avoid the overhead of BigInt for handling 64-bit integers. */\r\n class Uint64 implements Id64.Uint32Pair {\r\n private static readonly _base = 0x100000000;\r\n\r\n private static assertUint32(num: number): void {\r\n assert(num >= 0);\r\n assert(num < Uint64._base);\r\n assert(Math.floor(num) === num);\r\n }\r\n\r\n private assertConstraints(): void {\r\n Uint64.assertUint32(this.lower);\r\n Uint64.assertUint32(this.upper);\r\n }\r\n\r\n constructor(public lower = 0, public upper = 0) {\r\n this.assertConstraints();\r\n }\r\n\r\n public compare(rhs: Uint64): number {\r\n const diff = this.upper - rhs.upper;\r\n return 0 === diff ? this.lower - rhs.lower : diff;\r\n }\r\n\r\n public equals(rhs: Uint64): boolean { return 0 === this.compare(rhs); }\r\n public isLessThan(rhs: Uint64): boolean { return this.compare(rhs) < 0; }\r\n public isGreaterThan(rhs: Uint64): boolean { return this.compare(rhs) > 0; }\r\n\r\n public get isZero(): boolean { return 0 === this.lower && 0 === this.upper; }\r\n\r\n public setFromDifference(lhs: Uint64, rhs: Uint64): void {\r\n assert(!rhs.isGreaterThan(lhs));\r\n\r\n this.lower = lhs.lower - rhs.lower;\r\n this.upper = lhs.upper - rhs.upper;\r\n if (this.lower < 0) {\r\n this.lower += Uint64._base;\r\n this.upper -= 1;\r\n }\r\n }\r\n\r\n public add(rhs: Uint64): void {\r\n let lower = rhs.lower;\r\n let upper = rhs.upper;\r\n if (lower + this.lower >= Uint64._base) {\r\n lower -= Uint64._base;\r\n upper += 1;\r\n }\r\n\r\n this.lower += lower;\r\n this.upper += upper;\r\n this.assertConstraints();\r\n }\r\n\r\n public setFromId(id: Id64String): void {\r\n Id64.getUint32Pair(id, this);\r\n }\r\n\r\n public copyFrom(other: Uint64): void {\r\n this.lower = other.lower;\r\n this.upper = other.upper;\r\n }\r\n\r\n public toString(): string {\r\n if (0 === this.upper)\r\n return this.lower.toString(16).toUpperCase();\r\n\r\n const upper = this.upper.toString(16);\r\n const lower = this.lower.toString(16).padStart(8, \"0\");\r\n assert(lower.length === 8);\r\n return `${upper}${lower}`.toUpperCase();\r\n }\r\n\r\n public toId64String(): string {\r\n return Id64.fromUint32Pair(this.lower, this.upper);\r\n }\r\n }\r\n\r\n /** Supplies an iterator over the [[Id64String]]s in a [[CompressedId64Set]].\r\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\r\n */\r\n export function* iterator(ids: CompressedId64Set): Iterator<Id64String> {\r\n if (0 === ids.length)\r\n return; // empty set.\r\n\r\n if (\"+\" !== ids[0])\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n let curIndex = 1; // skip the leading '+'\r\n const curId = new Uint64();\r\n\r\n function parseUint32(): number {\r\n let value = 0;\r\n let nChars = 0;\r\n while (curIndex < ids.length && nChars < 8) {\r\n ++nChars;\r\n const ch = ids.charCodeAt(curIndex);\r\n if (!isHexDigit(ch))\r\n break; // not a hex digit in [0..9] or [A..F]\r\n\r\n value <<= 4;\r\n value |= (ch >= 65 ? ch - 65 + 10 : ch - 48); // ch - 'A' + 10 or ch - '0'\r\n value = value >>> 0; // restore unsignedness because silly javascript.\r\n ++curIndex;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n function parseUint64(uint64: Uint64): void {\r\n let lower = 0;\r\n let upper = 0;\r\n\r\n // Read up to the first 8 digits.\r\n const startIndex = curIndex;\r\n const first = parseUint32();\r\n\r\n const nFirstDigits = curIndex - startIndex;\r\n assert(nFirstDigits <= 8);\r\n\r\n if (8 === nFirstDigits && curIndex + 1 < ids.length && isHexDigit(ids.charCodeAt(curIndex + 1))) {\r\n // We've got up to 8 more digits remaining\r\n const secondIndex = curIndex;\r\n const second = parseUint32();\r\n\r\n // Transfer excess digits from upper to lower.\r\n const nSecondDigits = curIndex - secondIndex;\r\n assert(nSecondDigits > 0 && nSecondDigits <= 8);\r\n\r\n const nDigitsToTransfer = 8 - nSecondDigits;\r\n upper = first >>> (4 * nDigitsToTransfer);\r\n const transfer = first - ((upper << (4 * nDigitsToTransfer)) >>> 0);\r\n lower = (second | ((transfer << (4 * nSecondDigits)) >>> 0)) >>> 0;\r\n } else {\r\n lower = first;\r\n }\r\n\r\n uint64.lower = lower;\r\n uint64.upper = upper;\r\n }\r\n\r\n const increment = new Uint64();\r\n while (curIndex < ids.length) {\r\n let multiplier = 1;\r\n parseUint64(increment);\r\n if (increment.isZero)\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n if (curIndex < ids.length) {\r\n switch (ids[curIndex++]) {\r\n case \"*\":\r\n multiplier = parseUint32();\r\n if (0 === multiplier)\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n if (curIndex !== ids.length && ids[curIndex++] !== \"+\")\r\n return;\r\n\r\n break;\r\n case \"+\":\r\n break;\r\n default:\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n }\r\n }\r\n\r\n for (let i = 0; i < multiplier; i++) {\r\n curId.add(increment);\r\n yield curId.toId64String();\r\n }\r\n }\r\n }\r\n\r\n /** Supplies an iterable over the [[Id64String]]s in a [[CompressedId64Set]].\r\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\r\n */\r\n export function iterable(ids: CompressedId64Set): OrderedId64Iterable {\r\n return {\r\n [Symbol.iterator]: () => iterator(ids),\r\n };\r\n }\r\n\r\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Set]].\r\n * @param compressedIds The compact string representation.\r\n * @param out If supplied, the Ids will be inserted into this set rather than allocating and returning a new set.\r\n * @returns The set containing the decompressed Ids.\r\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\r\n * @see [[CompressedId64Set.compressSet]] to perform the inverse operation.\r\n * @see [[CompressedId64Set.decompressArray]] to decompress as an [[Id64Array]] instead.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\r\n */\r\n export function decompressSet(compressedIds: CompressedId64Set, out?: Id64Set): Id64Set {\r\n const set = out ?? new Set<string>();\r\n for (const id of iterable(compressedIds))\r\n set.add(id);\r\n\r\n return set;\r\n }\r\n\r\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Array]].\r\n * @param compressedIds The compact string representation.\r\n * @param out If supplied, the Ids will be appended to this array rather than allocating and returning a new array.\r\n * @returns The array containing the decompressed Ids.\r\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\r\n * @note The Ids are decompressed and appended to the array in ascending order based on their 64-bit numerical values.\r\n * @see [[CompressedId64Set.compressArray]] to perform the inverse operation.\r\n * @see [[CompressedId64Set.decompressSet]] to decompress as an [[Id64Set]] instead.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\r\n */\r\n export function decompressArray(compressedIds: CompressedId64Set, out?: Id64Array): Id64Array {\r\n const arr = out ?? [];\r\n for (const id of iterable(compressedIds))\r\n arr.push(id);\r\n\r\n return arr;\r\n }\r\n}\r\n\r\n/** A [[SortedArray]] of unique [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer values of the Ids.\r\n * @see [[CompressedId64Set]] for an immutable compact string representation.\r\n * @public\r\n */\r\nexport class OrderedId64Array extends SortedArray<Id64String> {\r\n /** Construct a new, empty array. */\r\n public constructor() {\r\n super((lhs, rhs) => OrderedId64Iterable.compare(lhs, rhs));\r\n }\r\n\r\n /** An iterable that iterates over the Ids in sorted order. */\r\n public get ids(): OrderedId64Iterable { return this._array; }\r\n\r\n /** The underlying array of Ids. */\r\n public get array(): ReadonlyArray<Id64String> { return this._array; }\r\n}\r\n\r\n/** A mutable set of valid [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer value of the Ids.\r\n * Internally the set of Ids is maintained as a [[CompressedId64Set]] string representation.\r\n * Insertions and removals are buffered until the string representation needs to be recomputed. The string representation is recomputed by every public method except [[add]] and [[delete]] -\r\n * therefore, if multiple removals and/or insertions are required, it is most efficient to perform them all before invoking other methods.\r\n * @public\r\n */\r\nexport class MutableCompressedId64Set implements OrderedId64Iterable {\r\n private _ids: CompressedId64Set;\r\n private readonly _inserted = new OrderedId64Array();\r\n private readonly _deleted = new OrderedId64Array();\r\n\r\n /** Construct a new set, optionally initialized to contain the Ids represented by `ids`. */\r\n public constructor(ids?: CompressedId64Set) {\r\n this._ids = ids ?? \"\";\r\n }\r\n\r\n /** Obtain the compact string representation of the contents of this set. If any insertions or removals are pending, they will be applied and the string recomputed. */\r\n public get ids(): CompressedId64Set {\r\n this.updateIds();\r\n return this._ids;\r\n }\r\n\r\n /** Add the specified Id to the set.\r\n * @throws Error if `id` is not a valid [[Id64String]].\r\n */\r\n public add(id: Id64String): void {\r\n if (!Id64.isValidId64(id))\r\n throw new Error(\"MutableCompressedId64Set.add: invalid Id\");\r\n\r\n this._deleted.remove(id);\r\n this._inserted.insert(id);\r\n }\r\n\r\n /** Remove the specified Id from the set.\r\n * @throws Error if `id` is not a valid [[Id64String]].\r\n */\r\n public delete(id: Id64String): void {\r\n if (!Id64.isValidId64(id))\r\n throw new Error(\"MutableCompressedId64Set.delete: invalid Id\");\r\n\r\n this._inserted.remove(id);\r\n this._deleted.insert(id);\r\n }\r\n\r\n /** Remove all Ids from the set. */\r\n public clear(): void {\r\n this._ids = \"\";\r\n this._inserted.clear();\r\n this._deleted.clear();\r\n }\r\n\r\n /** Remove all Ids from the set, then add the specified Ids. */\r\n public reset(ids?: CompressedId64Set): void {\r\n this.clear();\r\n this._ids = ids ?? \"\";\r\n }\r\n\r\n /** Obtain an iterator over the Ids in this set. The Ids are returned in ascending order based on their unsigned 64-bit integer values. */\r\n public [Symbol.iterator]() {\r\n return CompressedId64Set.iterator(this.ids);\r\n }\r\n\r\n /** Compute a compact string representation of the union of this and another set of Ids - i.e., those Ids present in either this and/or the other set. */\r\n public computeUnion(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.isEmpty)\r\n return CompressedId64Set.compressIds(ids);\r\n else if (OrderedId64Iterable.isEmptySet(ids) || this.equals(ids))\r\n return this.ids;\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.union(this, ids));\r\n }\r\n\r\n /** Compute a compact string representation of the intersection of this and another set of Ids - i.e., those Ids present in both this and the other set. */\r\n public computeIntersection(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.equals(ids))\r\n return this.ids;\r\n else if (this.isEmpty || OrderedId64Iterable.isEmptySet(ids))\r\n return \"\";\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.intersection(this, ids));\r\n }\r\n\r\n /** Compute a compact string representation of the difference between this and another set - i.e., those Ids present in this but not in the other set. */\r\n public computeDifference(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.isEmpty || this.equals(ids))\r\n return \"\";\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.difference(this, ids));\r\n }\r\n\r\n /** Return true if this set contains no Ids. */\r\n public get isEmpty(): boolean {\r\n return OrderedId64Iterable.isEmptySet(this.ids);\r\n }\r\n\r\n /** Return true if the set of Ids represented by `other` is identical to those in this set.\r\n * @note This considers only the **distinct** Ids in `other` - duplicates are ignored.\r\n */\r\n public equals(other: CompressedId64Set | MutableCompressedId64Set | OrderedId64Iterable): boolean {\r\n if (other instanceof MutableCompressedId64Set) {\r\n if (other === this)\r\n return true;\r\n\r\n if (typeof other !== \"string\")\r\n other = other.ids;\r\n }\r\n\r\n if (typeof other === \"string\")\r\n return other === this.ids;\r\n\r\n this.updateIds();\r\n return OrderedId64Iterable.areEqualSets(this, other);\r\n }\r\n\r\n private get _isDirty(): boolean {\r\n return !this._inserted.isEmpty || !this._deleted.isEmpty;\r\n }\r\n\r\n private updateIds(): void {\r\n if (!this._isDirty)\r\n return;\r\n\r\n const difference = OrderedId64Iterable.difference(CompressedId64Set.iterable(this._ids), this._deleted.ids);\r\n const union = { [Symbol.iterator]: () => OrderedId64Iterable.unionIterator(difference, this._inserted.ids) };\r\n this._ids = CompressedId64Set.compressIds(union);\r\n\r\n this._inserted.clear();\r\n this._deleted.clear();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CompressedId64Set.js","sourceRoot":"","sources":["../../src/CompressedId64Set.ts"],"names":[],"mappings":";AAAA;;;+FAG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a,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7G,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEjD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF;AA3HD,4DA2HC","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 Ids\r\n */\r\n\r\nimport { assert } from \"./Assert\";\r\nimport { Id64, Id64Array, Id64Set, Id64String } from \"./Id\";\r\nimport { OrderedId64Iterable } from \"./OrderedId64Iterable\";\r\nimport { SortedArray } from \"./SortedArray\";\r\n\r\n/** @public */\r\nexport type CompressedId64Set = string;\r\n\r\n/** A compact string representation of an [[Id64Set]]. Such a representation is useful when serializing potentially very large\r\n * sets of Ids.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids represented by a compact string.\r\n * @see [[CompressedId64Set.compressSet]] and [[CompressedId64Set.compressArray]] to produce a compact string from a collection of Ids.\r\n * @see [[CompressedId64Set.decompressSet]] and [[CompressedId64Set.decompressArray]] to produce a collection of Ids from a compact string.\r\n * @see [[OrderedId64Iterable]] for a generic representation of an ordered set of Ids (compressed or otherwise).\r\n * @see [[MutableCompressedId64Set]] for a mutable version.\r\n * @public\r\n */\r\nexport namespace CompressedId64Set { // eslint-disable-line @typescript-eslint/no-redeclare\r\n function isHexDigit(ch: number): boolean {\r\n // ascii values:\r\n // '0' = 48\r\n // '9' = 57\r\n // 'a' = 65\r\n // 'f' = 70\r\n\r\n return (ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 70);\r\n }\r\n\r\n function compactRange(increment: Uint64, length: number): string {\r\n assert(length > 0);\r\n const inc = `+${increment.toString()}`;\r\n if (length <= 1)\r\n return inc;\r\n\r\n const len = length.toString(16).toUpperCase();\r\n return `${inc}*${len}`;\r\n }\r\n\r\n /** Given a set of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n * @see [[CompressedId64Set.compressArray]] to perform the same operation on an [[Id64Array]].\r\n * @see [[CompressedId64Set.decompressSet]] to perform the inverse operation.\r\n */\r\n export function compressSet(ids: Id64Set): CompressedId64Set {\r\n return sortAndCompress(ids);\r\n }\r\n\r\n /** Create a sorted array from `ids`, then return a compact string representation of those Ids.\r\n * @see [[CompressedId64Set.compressIds]] if `ids` is known to already be sorted.\r\n */\r\n export function sortAndCompress(ids: Iterable<Id64String>): CompressedId64Set {\r\n // `string` is an Iterable<string>. In that case assume caller passed a single Id64String.\r\n const arr = typeof ids === \"string\" ? [ids] : Array.from(ids);\r\n OrderedId64Iterable.sortArray(arr);\r\n return compressArray(arr);\r\n }\r\n\r\n /** Give a **numerically-ordered** array of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * Duplicate Ids are included only once in the string representation.\r\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the array is not properly sorted.\r\n * @note The array must be sorted according to the 64-bit numerical value of each Id.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.decompressArray]] to perform the inverse operation.\r\n * @see [[OrderedId64Iterable.sortArray]] to ensure the Ids are properly sorted.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n */\r\n export function compressArray(ids: Id64Array): CompressedId64Set {\r\n return compressIds(ids);\r\n }\r\n\r\n /** Give a **numerically-ordered** collection of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * Duplicate Ids are included only once in the string representation.\r\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the collection is not properly sorted.\r\n * @note The collection must be sorted according to the 64-bit numerical value of each Id.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.iterable]] to perform the inverse operation.\r\n * @see [[OrderedId64Iterable.sortArray]] or [[OrderedId64Iterable.compare]] to ensure the Ids are properly sorted.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n */\r\n export function compressIds(ids: OrderedId64Iterable): CompressedId64Set {\r\n if (\"string\" === typeof ids)\r\n return ids;\r\n\r\n let str = \"\";\r\n\r\n const prevId = new Uint64();\r\n const rangeIncrement = new Uint64();\r\n let rangeLen = 0;\r\n\r\n const curId = new Uint64();\r\n const curIncrement = new Uint64();\r\n for (const id of ids) {\r\n if (!Id64.isValidId64(id))\r\n continue; // ignore garbage and invalid Ids (\"0\")\r\n\r\n curId.setFromId(id);\r\n curIncrement.setFromDifference(curId, prevId);\r\n\r\n const cmp = prevId.compare(curId);\r\n if (0 === cmp)\r\n continue; // ignore duplicates\r\n else if (cmp > 0)\r\n throw new Error(\"CompressedId64Set.compressArray requires a sorted array as input\");\r\n\r\n prevId.copyFrom(curId);\r\n\r\n if (0 === rangeLen) {\r\n rangeIncrement.copyFrom(curIncrement);\r\n rangeLen = 1;\r\n } else if (curIncrement.equals(rangeIncrement)) {\r\n ++rangeLen;\r\n } else {\r\n str += compactRange(rangeIncrement, rangeLen);\r\n rangeIncrement.copyFrom(curIncrement);\r\n rangeLen = 1;\r\n }\r\n }\r\n\r\n if (0 < rangeLen)\r\n str += compactRange(rangeIncrement, rangeLen);\r\n\r\n return str;\r\n }\r\n\r\n /** This exists strictly for the purposes of compressed sets of 64-bit Ids, to avoid the overhead of BigInt for handling 64-bit integers. */\r\n class Uint64 implements Id64.Uint32Pair {\r\n private static readonly _base = 0x100000000;\r\n\r\n private static assertUint32(num: number): void {\r\n assert(num >= 0);\r\n assert(num < Uint64._base);\r\n assert(Math.floor(num) === num);\r\n }\r\n\r\n private assertConstraints(): void {\r\n Uint64.assertUint32(this.lower);\r\n Uint64.assertUint32(this.upper);\r\n }\r\n\r\n constructor(public lower = 0, public upper = 0) {\r\n this.assertConstraints();\r\n }\r\n\r\n public compare(rhs: Uint64): number {\r\n const diff = this.upper - rhs.upper;\r\n return 0 === diff ? this.lower - rhs.lower : diff;\r\n }\r\n\r\n public equals(rhs: Uint64): boolean { return 0 === this.compare(rhs); }\r\n public isLessThan(rhs: Uint64): boolean { return this.compare(rhs) < 0; }\r\n public isGreaterThan(rhs: Uint64): boolean { return this.compare(rhs) > 0; }\r\n\r\n public get isZero(): boolean { return 0 === this.lower && 0 === this.upper; }\r\n\r\n public setFromDifference(lhs: Uint64, rhs: Uint64): void {\r\n assert(!rhs.isGreaterThan(lhs));\r\n\r\n this.lower = lhs.lower - rhs.lower;\r\n this.upper = lhs.upper - rhs.upper;\r\n if (this.lower < 0) {\r\n this.lower += Uint64._base;\r\n this.upper -= 1;\r\n }\r\n }\r\n\r\n public add(rhs: Uint64): void {\r\n let lower = rhs.lower;\r\n let upper = rhs.upper;\r\n if (lower + this.lower >= Uint64._base) {\r\n lower -= Uint64._base;\r\n upper += 1;\r\n }\r\n\r\n this.lower += lower;\r\n this.upper += upper;\r\n this.assertConstraints();\r\n }\r\n\r\n public setFromId(id: Id64String): void {\r\n Id64.getUint32Pair(id, this);\r\n }\r\n\r\n public copyFrom(other: Uint64): void {\r\n this.lower = other.lower;\r\n this.upper = other.upper;\r\n }\r\n\r\n public toString(): string {\r\n if (0 === this.upper)\r\n return this.lower.toString(16).toUpperCase();\r\n\r\n const upper = this.upper.toString(16);\r\n const lower = this.lower.toString(16).padStart(8, \"0\");\r\n assert(lower.length === 8);\r\n return `${upper}${lower}`.toUpperCase();\r\n }\r\n\r\n public toId64String(): string {\r\n return Id64.fromUint32Pair(this.lower, this.upper);\r\n }\r\n }\r\n\r\n /** Supplies an iterator over the [[Id64String]]s in a [[CompressedId64Set]].\r\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\r\n */\r\n export function* iterator(ids: CompressedId64Set): Iterator<Id64String> {\r\n if (0 === ids.length)\r\n return; // empty set.\r\n\r\n if (\"+\" !== ids[0])\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n let curIndex = 1; // skip the leading '+'\r\n const curId = new Uint64();\r\n\r\n function parseUint32(): number {\r\n let value = 0;\r\n let nChars = 0;\r\n while (curIndex < ids.length && nChars < 8) {\r\n ++nChars;\r\n const ch = ids.charCodeAt(curIndex);\r\n if (!isHexDigit(ch))\r\n break; // not a hex digit in [0..9] or [A..F]\r\n\r\n value <<= 4;\r\n value |= (ch >= 65 ? ch - 65 + 10 : ch - 48); // ch - 'A' + 10 or ch - '0'\r\n value = value >>> 0; // restore unsignedness because silly javascript.\r\n ++curIndex;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n function parseUint64(uint64: Uint64): void {\r\n let lower = 0;\r\n let upper = 0;\r\n\r\n // Read up to the first 8 digits.\r\n const startIndex = curIndex;\r\n const first = parseUint32();\r\n\r\n const nFirstDigits = curIndex - startIndex;\r\n assert(nFirstDigits <= 8);\r\n\r\n if (8 === nFirstDigits && curIndex + 1 < ids.length && isHexDigit(ids.charCodeAt(curIndex + 1))) {\r\n // We've got up to 8 more digits remaining\r\n const secondIndex = curIndex;\r\n const second = parseUint32();\r\n\r\n // Transfer excess digits from upper to lower.\r\n const nSecondDigits = curIndex - secondIndex;\r\n assert(nSecondDigits > 0 && nSecondDigits <= 8);\r\n\r\n const nDigitsToTransfer = 8 - nSecondDigits;\r\n upper = first >>> (4 * nDigitsToTransfer);\r\n const transfer = first - ((upper << (4 * nDigitsToTransfer)) >>> 0);\r\n lower = (second | ((transfer << (4 * nSecondDigits)) >>> 0)) >>> 0;\r\n } else {\r\n lower = first;\r\n }\r\n\r\n uint64.lower = lower;\r\n uint64.upper = upper;\r\n }\r\n\r\n const increment = new Uint64();\r\n while (curIndex < ids.length) {\r\n let multiplier = 1;\r\n parseUint64(increment);\r\n if (increment.isZero)\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n if (curIndex < ids.length) {\r\n switch (ids[curIndex++]) {\r\n case \"*\":\r\n multiplier = parseUint32();\r\n if (0 === multiplier)\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n if (curIndex !== ids.length && ids[curIndex++] !== \"+\")\r\n return;\r\n\r\n break;\r\n case \"+\":\r\n break;\r\n default:\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n }\r\n }\r\n\r\n for (let i = 0; i < multiplier; i++) {\r\n curId.add(increment);\r\n yield curId.toId64String();\r\n }\r\n }\r\n }\r\n\r\n /** Supplies an iterable over the [[Id64String]]s in a [[CompressedId64Set]].\r\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\r\n */\r\n export function iterable(ids: CompressedId64Set): OrderedId64Iterable {\r\n return {\r\n [Symbol.iterator]: () => iterator(ids),\r\n };\r\n }\r\n\r\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Set]].\r\n * @param compressedIds The compact string representation.\r\n * @param out If supplied, the Ids will be inserted into this set rather than allocating and returning a new set.\r\n * @returns The set containing the decompressed Ids.\r\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\r\n * @see [[CompressedId64Set.compressSet]] to perform the inverse operation.\r\n * @see [[CompressedId64Set.decompressArray]] to decompress as an [[Id64Array]] instead.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\r\n */\r\n export function decompressSet(compressedIds: CompressedId64Set, out?: Id64Set): Id64Set {\r\n const set = out ?? new Set<string>();\r\n for (const id of iterable(compressedIds))\r\n set.add(id);\r\n\r\n return set;\r\n }\r\n\r\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Array]].\r\n * @param compressedIds The compact string representation.\r\n * @param out If supplied, the Ids will be appended to this array rather than allocating and returning a new array.\r\n * @returns The array containing the decompressed Ids.\r\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\r\n * @note The Ids are decompressed and appended to the array in ascending order based on their 64-bit numerical values.\r\n * @see [[CompressedId64Set.compressArray]] to perform the inverse operation.\r\n * @see [[CompressedId64Set.decompressSet]] to decompress as an [[Id64Set]] instead.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\r\n */\r\n export function decompressArray(compressedIds: CompressedId64Set, out?: Id64Array): Id64Array {\r\n const arr = out ?? [];\r\n for (const id of iterable(compressedIds))\r\n arr.push(id);\r\n\r\n return arr;\r\n }\r\n}\r\n\r\n/** A [[SortedArray]] of unique [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer values of the Ids.\r\n * @see [[CompressedId64Set]] for an immutable compact string representation.\r\n * @public\r\n */\r\nexport class OrderedId64Array extends SortedArray<Id64String> {\r\n /** Construct a new, empty array. */\r\n public constructor() {\r\n super((lhs, rhs) => OrderedId64Iterable.compare(lhs, rhs));\r\n }\r\n\r\n /** An iterable that iterates over the Ids in sorted order. */\r\n public get ids(): OrderedId64Iterable { return this._array; }\r\n\r\n /** The underlying array of Ids. */\r\n public get array(): ReadonlyArray<Id64String> { return this._array; }\r\n}\r\n\r\n/** A mutable set of valid [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer value of the Ids.\r\n * Internally the set of Ids is maintained as a [[CompressedId64Set]] string representation.\r\n * Insertions and removals are buffered until the string representation needs to be recomputed. The string representation is recomputed by every public method except [[add]] and [[delete]] -\r\n * therefore, if multiple removals and/or insertions are required, it is most efficient to perform them all before invoking other methods.\r\n * @public\r\n */\r\nexport class MutableCompressedId64Set implements OrderedId64Iterable {\r\n private _ids: CompressedId64Set;\r\n private readonly _inserted = new OrderedId64Array();\r\n private readonly _deleted = new OrderedId64Array();\r\n\r\n /** Construct a new set, optionally initialized to contain the Ids represented by `ids`. */\r\n public constructor(ids?: CompressedId64Set) {\r\n this._ids = ids ?? \"\";\r\n }\r\n\r\n /** Obtain the compact string representation of the contents of this set. If any insertions or removals are pending, they will be applied and the string recomputed. */\r\n public get ids(): CompressedId64Set {\r\n this.updateIds();\r\n return this._ids;\r\n }\r\n\r\n /** Add the specified Id to the set.\r\n * @throws Error if `id` is not a valid [[Id64String]].\r\n */\r\n public add(id: Id64String): void {\r\n if (!Id64.isValidId64(id))\r\n throw new Error(\"MutableCompressedId64Set.add: invalid Id\");\r\n\r\n this._deleted.remove(id);\r\n this._inserted.insert(id);\r\n }\r\n\r\n /** Remove the specified Id from the set.\r\n * @throws Error if `id` is not a valid [[Id64String]].\r\n */\r\n public delete(id: Id64String): void {\r\n if (!Id64.isValidId64(id))\r\n throw new Error(\"MutableCompressedId64Set.delete: invalid Id\");\r\n\r\n this._inserted.remove(id);\r\n this._deleted.insert(id);\r\n }\r\n\r\n /** Remove all Ids from the set. */\r\n public clear(): void {\r\n this._ids = \"\";\r\n this._inserted.clear();\r\n this._deleted.clear();\r\n }\r\n\r\n /** Remove all Ids from the set, then add the specified Ids. */\r\n public reset(ids?: CompressedId64Set): void {\r\n this.clear();\r\n this._ids = ids ?? \"\";\r\n }\r\n\r\n /** Obtain an iterator over the Ids in this set. The Ids are returned in ascending order based on their unsigned 64-bit integer values. */\r\n public [Symbol.iterator]() {\r\n return CompressedId64Set.iterator(this.ids);\r\n }\r\n\r\n /** Compute a compact string representation of the union of this and another set of Ids - i.e., those Ids present in either this and/or the other set. */\r\n public computeUnion(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.isEmpty)\r\n return CompressedId64Set.compressIds(ids);\r\n else if (OrderedId64Iterable.isEmptySet(ids) || this.equals(ids))\r\n return this.ids;\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.union(this, ids));\r\n }\r\n\r\n /** Compute a compact string representation of the intersection of this and another set of Ids - i.e., those Ids present in both this and the other set. */\r\n public computeIntersection(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.equals(ids))\r\n return this.ids;\r\n else if (this.isEmpty || OrderedId64Iterable.isEmptySet(ids))\r\n return \"\";\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.intersection(this, ids));\r\n }\r\n\r\n /** Compute a compact string representation of the difference between this and another set - i.e., those Ids present in this but not in the other set. */\r\n public computeDifference(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.isEmpty || this.equals(ids))\r\n return \"\";\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.difference(this, ids));\r\n }\r\n\r\n /** Return true if this set contains no Ids. */\r\n public get isEmpty(): boolean {\r\n return OrderedId64Iterable.isEmptySet(this.ids);\r\n }\r\n\r\n /** Return true if the set of Ids represented by `other` is identical to those in this set.\r\n * @note This considers only the **distinct** Ids in `other` - duplicates are ignored.\r\n */\r\n public equals(other: CompressedId64Set | MutableCompressedId64Set | OrderedId64Iterable): boolean {\r\n if (other instanceof MutableCompressedId64Set) {\r\n if (other === this)\r\n return true;\r\n\r\n if (typeof other !== \"string\")\r\n other = other.ids;\r\n }\r\n\r\n if (typeof other === \"string\")\r\n return other === this.ids;\r\n\r\n this.updateIds();\r\n return OrderedId64Iterable.areEqualSets(this, other);\r\n }\r\n\r\n private get _isDirty(): boolean {\r\n return !this._inserted.isEmpty || !this._deleted.isEmpty;\r\n }\r\n\r\n private updateIds(): void {\r\n if (!this._isDirty)\r\n return;\r\n\r\n const difference = OrderedId64Iterable.difference(CompressedId64Set.iterable(this._ids), this._deleted.ids);\r\n const union = { [Symbol.iterator]: () => OrderedId64Iterable.unionIterator(difference, this._inserted.ids) };\r\n this._ids = CompressedId64Set.compressIds(union);\r\n\r\n this._inserted.clear();\r\n this._deleted.clear();\r\n }\r\n}\r\n"]}
|
package/lib/esm/BeEvent.d.ts
CHANGED
|
@@ -79,4 +79,21 @@ export declare class BeEventList<T extends Listener> {
|
|
|
79
79
|
*/
|
|
80
80
|
remove(name: string): void;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the type of the callback function for an event type like [[BeEvent]].
|
|
84
|
+
* For example:
|
|
85
|
+
* ```ts
|
|
86
|
+
* const event = new BeEvent<(x: number, y: string) => void>();
|
|
87
|
+
* const callback: ListenerType<typeof event> = (x, y) => {
|
|
88
|
+
* console.log(`${x}, ${y}`);
|
|
89
|
+
* };
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export type ListenerType<TEvent extends {
|
|
95
|
+
addListener(listener: Listener): () => void;
|
|
96
|
+
}> = TEvent extends {
|
|
97
|
+
addListener(listener: infer TListener): () => void;
|
|
98
|
+
} ? TListener : never;
|
|
82
99
|
//# sourceMappingURL=BeEvent.d.ts.map
|
package/lib/esm/BeEvent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeEvent.d.ts","sourceRoot":"","sources":["../../src/BeEvent.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAQ/C;;;;;GAKG;AACH,qBAAa,OAAO,CAAC,CAAC,SAAS,QAAQ;IACrC,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,iBAAiB,CAAkB;IAE3C,iEAAiE;IACjE,IAAW,iBAAiB,WAAqC;IAEjE;;;;;;OAMG;IACI,WAAW,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,MAAM,IAAI;IAKxD;;;;;;OAMG;IACI,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,MAAM,IAAI;IAKpD;;;;;;OAMG;IACI,cAAc,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,OAAO;IAiBxD;;;;OAIG;IACI,UAAU,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IA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,GAAG,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;gBACrD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6CAA6C;IACtC,KAAK,KAAW,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,OAAO,SAAsB,SAAQ,OAAmC;IAC5E,wDAAwD;IACjD,IAAI,CAAC,IAAgB,IAAU,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CAC/D;AAED;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAAxB;QACU,YAAO,GAA+C,EAAE,CAAC;IAuBnE,CAAC;IArBC;;;OAGG;IACI,GAAG,CAAC,IAAY;QACrB,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,KAAK;YACP,OAAO,KAAK,CAAC;QAEf,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAY;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IACjC,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 Events\r\n */\r\n\r\nimport { UnexpectedErrors } from \"./UnexpectedErrors\";\r\n\r\n/** A function invoked when a BeEvent is raised.\r\n * @public\r\n */\r\nexport type Listener = (...arg: any[]) => void;\r\n\r\ninterface EventContext {\r\n listener: Listener | undefined;\r\n scope: any;\r\n once: boolean;\r\n}\r\n\r\n/**\r\n * Manages a set of *listeners* for a particular event and notifies them when the event is raised.\r\n * This class is usually instantiated inside of a container class and\r\n * exposed as a property for others to *subscribe* via [[BeEvent.addListener]].\r\n * @public\r\n */\r\nexport class BeEvent<T extends Listener> {\r\n private _listeners: EventContext[] = [];\r\n private _insideRaiseEvent: boolean = false;\r\n\r\n /** The number of listeners currently subscribed to the event. */\r\n public get numberOfListeners() { return this._listeners.length; }\r\n\r\n /**\r\n * Registers a Listener to be executed whenever this event is raised.\r\n * @param listener The function to be executed when the event is raised.\r\n * @param scope An optional object scope to serve as the 'this' pointer when listener is invoked.\r\n * @returns A function that will remove this event listener.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\r\n */\r\n public addListener(listener: T, scope?: any): () => void {\r\n this._listeners.push({ listener, scope, once: false });\r\n return () => this.removeListener(listener, scope);\r\n }\r\n\r\n /**\r\n * Registers a callback function to be executed *only once* when the event is raised.\r\n * @param listener The function to be executed once when the event is raised.\r\n * @param scope An optional object scope to serve as the `this` pointer in which the listener function will execute.\r\n * @returns A function that will remove this event listener.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\r\n */\r\n public addOnce(listener: T, scope?: any): () => void {\r\n this._listeners.push({ listener, scope, once: true });\r\n return () => this.removeListener(listener, scope);\r\n }\r\n\r\n /**\r\n * Un-register a previously registered listener.\r\n * @param listener The listener to be unregistered.\r\n * @param scope The scope that was originally passed to addListener.\r\n * @returns 'true' if the listener was removed; 'false' if the listener and scope are not registered with the event.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.addListener]]\r\n */\r\n public removeListener(listener: T, scope?: any): boolean {\r\n const listeners = this._listeners;\r\n\r\n for (let i = 0; i < listeners.length; ++i) {\r\n const context = listeners[i];\r\n if (context.listener === listener && context.scope === scope) {\r\n if (this._insideRaiseEvent) {\r\n context.listener = undefined;\r\n } else {\r\n listeners.splice(i, 1);\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Raises the event by calling each registered listener with the supplied arguments.\r\n * @param args This method takes any number of parameters and passes them through to the listeners.\r\n * @see [[BeEvent.removeListener]], [[BeEvent.addListener]]\r\n */\r\n public raiseEvent(...args: Parameters<T>) {\r\n this._insideRaiseEvent = true;\r\n\r\n const listeners = this._listeners;\r\n const length = listeners.length;\r\n let dropped = false;\r\n\r\n for (let i = 0; i < length; ++i) {\r\n const context = listeners[i];\r\n if (!context.listener) {\r\n dropped = true;\r\n } else {\r\n try {\r\n context.listener.apply(context.scope, args);\r\n } catch (e) {\r\n UnexpectedErrors.handle(e);\r\n }\r\n if (context.once) {\r\n context.listener = undefined;\r\n dropped = true;\r\n }\r\n }\r\n }\r\n\r\n // if we had dropped listeners, remove them now\r\n if (dropped)\r\n this._listeners = this._listeners.filter((ctx) => ctx.listener !== undefined);\r\n\r\n this._insideRaiseEvent = false;\r\n }\r\n\r\n /** Determine whether this BeEvent has a specified listener registered.\r\n * @param listener The listener to check.\r\n * @param scope optional scope argument to match call to addListener\r\n */\r\n public has(listener: T, scope?: any): boolean {\r\n for (const ctx of this._listeners) {\r\n if (ctx.listener === listener && ctx.scope === scope) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /** Clear all Listeners from this BeEvent. */\r\n public clear(): void { this._listeners.length = 0; }\r\n}\r\n\r\n/** Specialization of BeEvent for events that take a single strongly typed argument, primarily used for UI events.\r\n * @public\r\n */\r\nexport class BeUiEvent<TEventArgs> extends BeEvent<(args: TEventArgs) => void> {\r\n /** Raises event with single strongly typed argument. */\r\n public emit(args: TEventArgs): void { this.raiseEvent(args); }\r\n}\r\n\r\n/**\r\n * A list of BeEvent objects, accessible by an event name.\r\n * This class may be used instead of explicitly declaring each BeEvent as a member of a containing class.\r\n * @public\r\n */\r\nexport class BeEventList<T extends Listener> {\r\n private _events: { [name: string]: BeEvent<T> | undefined } = {};\r\n\r\n /**\r\n * Gets the event associated with the specified name, creating the event if it does not already exist.\r\n * @param name The name of the event.\r\n */\r\n public get(name: string): BeEvent<T> {\r\n let event = this._events[name];\r\n if (event)\r\n return event;\r\n\r\n event = new BeEvent();\r\n this._events[name] = event;\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes the event associated with a name.\r\n * @param name The name of the event.\r\n */\r\n public remove(name: string): void {\r\n this._events[name] = undefined;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BeEvent.js","sourceRoot":"","sources":["../../src/BeEvent.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAatD;;;;;GAKG;AACH,MAAM,OAAO,OAAO;IAApB;QACU,eAAU,GAAmB,EAAE,CAAC;QAChC,sBAAiB,GAAY,KAAK,CAAC;IAwG7C,CAAC;IAtGC,iEAAiE;IACjE,IAAW,iBAAiB,KAAK,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjE;;;;;;OAMG;IACI,WAAW,CAAC,QAAW,EAAE,KAAW;QACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACI,OAAO,CAAC,QAAW,EAAE,KAAW;QACrC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAC,QAAW,EAAE,KAAW;QAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;QAElC,KAAK,IAA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AAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAY;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IACjC,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 Events\r\n */\r\n\r\nimport { UnexpectedErrors } from \"./UnexpectedErrors\";\r\n\r\n/** A function invoked when a BeEvent is raised.\r\n * @public\r\n */\r\nexport type Listener = (...arg: any[]) => void;\r\n\r\ninterface EventContext {\r\n listener: Listener | undefined;\r\n scope: any;\r\n once: boolean;\r\n}\r\n\r\n/**\r\n * Manages a set of *listeners* for a particular event and notifies them when the event is raised.\r\n * This class is usually instantiated inside of a container class and\r\n * exposed as a property for others to *subscribe* via [[BeEvent.addListener]].\r\n * @public\r\n */\r\nexport class BeEvent<T extends Listener> {\r\n private _listeners: EventContext[] = [];\r\n private _insideRaiseEvent: boolean = false;\r\n\r\n /** The number of listeners currently subscribed to the event. */\r\n public get numberOfListeners() { return this._listeners.length; }\r\n\r\n /**\r\n * Registers a Listener to be executed whenever this event is raised.\r\n * @param listener The function to be executed when the event is raised.\r\n * @param scope An optional object scope to serve as the 'this' pointer when listener is invoked.\r\n * @returns A function that will remove this event listener.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\r\n */\r\n public addListener(listener: T, scope?: any): () => void {\r\n this._listeners.push({ listener, scope, once: false });\r\n return () => this.removeListener(listener, scope);\r\n }\r\n\r\n /**\r\n * Registers a callback function to be executed *only once* when the event is raised.\r\n * @param listener The function to be executed once when the event is raised.\r\n * @param scope An optional object scope to serve as the `this` pointer in which the listener function will execute.\r\n * @returns A function that will remove this event listener.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\r\n */\r\n public addOnce(listener: T, scope?: any): () => void {\r\n this._listeners.push({ listener, scope, once: true });\r\n return () => this.removeListener(listener, scope);\r\n }\r\n\r\n /**\r\n * Un-register a previously registered listener.\r\n * @param listener The listener to be unregistered.\r\n * @param scope The scope that was originally passed to addListener.\r\n * @returns 'true' if the listener was removed; 'false' if the listener and scope are not registered with the event.\r\n * @see [[BeEvent.raiseEvent]], [[BeEvent.addListener]]\r\n */\r\n public removeListener(listener: T, scope?: any): boolean {\r\n const listeners = this._listeners;\r\n\r\n for (let i = 0; i < listeners.length; ++i) {\r\n const context = listeners[i];\r\n if (context.listener === listener && context.scope === scope) {\r\n if (this._insideRaiseEvent) {\r\n context.listener = undefined;\r\n } else {\r\n listeners.splice(i, 1);\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Raises the event by calling each registered listener with the supplied arguments.\r\n * @param args This method takes any number of parameters and passes them through to the listeners.\r\n * @see [[BeEvent.removeListener]], [[BeEvent.addListener]]\r\n */\r\n public raiseEvent(...args: Parameters<T>) {\r\n this._insideRaiseEvent = true;\r\n\r\n const listeners = this._listeners;\r\n const length = listeners.length;\r\n let dropped = false;\r\n\r\n for (let i = 0; i < length; ++i) {\r\n const context = listeners[i];\r\n if (!context.listener) {\r\n dropped = true;\r\n } else {\r\n try {\r\n context.listener.apply(context.scope, args);\r\n } catch (e) {\r\n UnexpectedErrors.handle(e);\r\n }\r\n if (context.once) {\r\n context.listener = undefined;\r\n dropped = true;\r\n }\r\n }\r\n }\r\n\r\n // if we had dropped listeners, remove them now\r\n if (dropped)\r\n this._listeners = this._listeners.filter((ctx) => ctx.listener !== undefined);\r\n\r\n this._insideRaiseEvent = false;\r\n }\r\n\r\n /** Determine whether this BeEvent has a specified listener registered.\r\n * @param listener The listener to check.\r\n * @param scope optional scope argument to match call to addListener\r\n */\r\n public has(listener: T, scope?: any): boolean {\r\n for (const ctx of this._listeners) {\r\n if (ctx.listener === listener && ctx.scope === scope) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /** Clear all Listeners from this BeEvent. */\r\n public clear(): void { this._listeners.length = 0; }\r\n}\r\n\r\n/** Specialization of BeEvent for events that take a single strongly typed argument, primarily used for UI events.\r\n * @public\r\n */\r\nexport class BeUiEvent<TEventArgs> extends BeEvent<(args: TEventArgs) => void> {\r\n /** Raises event with single strongly typed argument. */\r\n public emit(args: TEventArgs): void { this.raiseEvent(args); }\r\n}\r\n\r\n/**\r\n * A list of BeEvent objects, accessible by an event name.\r\n * This class may be used instead of explicitly declaring each BeEvent as a member of a containing class.\r\n * @public\r\n */\r\nexport class BeEventList<T extends Listener> {\r\n private _events: { [name: string]: BeEvent<T> | undefined } = {};\r\n\r\n /**\r\n * Gets the event associated with the specified name, creating the event if it does not already exist.\r\n * @param name The name of the event.\r\n */\r\n public get(name: string): BeEvent<T> {\r\n let event = this._events[name];\r\n if (event)\r\n return event;\r\n\r\n event = new BeEvent();\r\n this._events[name] = event;\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes the event associated with a name.\r\n * @param name The name of the event.\r\n */\r\n public remove(name: string): void {\r\n this._events[name] = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * Retrieves the type of the callback function for an event type like [[BeEvent]].\r\n * For example:\r\n * ```ts\r\n * const event = new BeEvent<(x: number, y: string) => void>();\r\n * const callback: ListenerType<typeof event> = (x, y) => {\r\n * console.log(`${x}, ${y}`);\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport type ListenerType<TEvent extends {\r\n addListener(listener: Listener): () => void;\r\n}> =\r\n TEvent extends {\r\n addListener(listener: infer TListener): () => void;\r\n } ? TListener : never;\r\n"]}
|
|
@@ -24,7 +24,7 @@ export declare namespace CompressedId64Set {
|
|
|
24
24
|
*/
|
|
25
25
|
function compressSet(ids: Id64Set): CompressedId64Set;
|
|
26
26
|
/** Create a sorted array from `ids`, then return a compact string representation of those Ids.
|
|
27
|
-
* @see [[compressIds]] if `ids` is known to already be sorted.
|
|
27
|
+
* @see [[CompressedId64Set.compressIds]] if `ids` is known to already be sorted.
|
|
28
28
|
*/
|
|
29
29
|
function sortAndCompress(ids: Iterable<Id64String>): CompressedId64Set;
|
|
30
30
|
/** Give a **numerically-ordered** array of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.
|
|
@@ -47,7 +47,7 @@ export var CompressedId64Set;
|
|
|
47
47
|
}
|
|
48
48
|
CompressedId64Set.compressSet = compressSet;
|
|
49
49
|
/** Create a sorted array from `ids`, then return a compact string representation of those Ids.
|
|
50
|
-
* @see [[compressIds]] if `ids` is known to already be sorted.
|
|
50
|
+
* @see [[CompressedId64Set.compressIds]] if `ids` is known to already be sorted.
|
|
51
51
|
*/
|
|
52
52
|
function sortAndCompress(ids) {
|
|
53
53
|
// `string` is an Iterable<string>. In that case assume caller passed a single Id64String.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompressedId64Set.js","sourceRoot":"","sources":["../../src/CompressedId64Set.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAkC,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C;;;;;;;;GAQG;AACH,MAAM,KAAW,iBAAiB,CAoUjC;AApUD,WAAiB,iBAAiB;IAChC,SAAS,UAAU,CAAC,EAAU;QAC5B,gBAAgB;QAChB,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QAEX,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,SAAS,YAAY,CAAC,SAAiB,EAAE,MAAc;QACrD,MAAM,CAAC,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I,OAAO,KAAK,KAAK,QAAQ;gBAC3B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;QACtB,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ;YAC3B,OAAO,KAAK,KAAK,IAAI,CAAC,GAAG,CAAC;QAE5B,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,OAAO,mBAAmB,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,IAAY,QAAQ;QAClB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC3D,CAAC;IAEO,SAAS;QACf,IAAI,CAAC,IAAI,CAAC,QAAQ;YAChB,OAAO;QAET,MAAM,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5G,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7G,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEjD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,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 Ids\r\n */\r\n\r\nimport { assert } from \"./Assert\";\r\nimport { Id64, Id64Array, Id64Set, Id64String } from \"./Id\";\r\nimport { OrderedId64Iterable } from \"./OrderedId64Iterable\";\r\nimport { SortedArray } from \"./SortedArray\";\r\n\r\n/** @public */\r\nexport type CompressedId64Set = string;\r\n\r\n/** A compact string representation of an [[Id64Set]]. Such a representation is useful when serializing potentially very large\r\n * sets of Ids.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids represented by a compact string.\r\n * @see [[CompressedId64Set.compressSet]] and [[CompressedId64Set.compressArray]] to produce a compact string from a collection of Ids.\r\n * @see [[CompressedId64Set.decompressSet]] and [[CompressedId64Set.decompressArray]] to produce a collection of Ids from a compact string.\r\n * @see [[OrderedId64Iterable]] for a generic representation of an ordered set of Ids (compressed or otherwise).\r\n * @see [[MutableCompressedId64Set]] for a mutable version.\r\n * @public\r\n */\r\nexport namespace CompressedId64Set { // eslint-disable-line @typescript-eslint/no-redeclare\r\n function isHexDigit(ch: number): boolean {\r\n // ascii values:\r\n // '0' = 48\r\n // '9' = 57\r\n // 'a' = 65\r\n // 'f' = 70\r\n\r\n return (ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 70);\r\n }\r\n\r\n function compactRange(increment: Uint64, length: number): string {\r\n assert(length > 0);\r\n const inc = `+${increment.toString()}`;\r\n if (length <= 1)\r\n return inc;\r\n\r\n const len = length.toString(16).toUpperCase();\r\n return `${inc}*${len}`;\r\n }\r\n\r\n /** Given a set of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n * @see [[CompressedId64Set.compressArray]] to perform the same operation on an [[Id64Array]].\r\n * @see [[CompressedId64Set.decompressSet]] to perform the inverse operation.\r\n */\r\n export function compressSet(ids: Id64Set): CompressedId64Set {\r\n return sortAndCompress(ids);\r\n }\r\n\r\n /** Create a sorted array from `ids`, then return a compact string representation of those Ids.\r\n * @see [[compressIds]] if `ids` is known to already be sorted.\r\n */\r\n export function sortAndCompress(ids: Iterable<Id64String>): CompressedId64Set {\r\n // `string` is an Iterable<string>. In that case assume caller passed a single Id64String.\r\n const arr = typeof ids === \"string\" ? [ids] : Array.from(ids);\r\n OrderedId64Iterable.sortArray(arr);\r\n return compressArray(arr);\r\n }\r\n\r\n /** Give a **numerically-ordered** array of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * Duplicate Ids are included only once in the string representation.\r\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the array is not properly sorted.\r\n * @note The array must be sorted according to the 64-bit numerical value of each Id.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.decompressArray]] to perform the inverse operation.\r\n * @see [[OrderedId64Iterable.sortArray]] to ensure the Ids are properly sorted.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n */\r\n export function compressArray(ids: Id64Array): CompressedId64Set {\r\n return compressIds(ids);\r\n }\r\n\r\n /** Give a **numerically-ordered** collection of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * Duplicate Ids are included only once in the string representation.\r\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the collection is not properly sorted.\r\n * @note The collection must be sorted according to the 64-bit numerical value of each Id.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.iterable]] to perform the inverse operation.\r\n * @see [[OrderedId64Iterable.sortArray]] or [[OrderedId64Iterable.compare]] to ensure the Ids are properly sorted.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n */\r\n export function compressIds(ids: OrderedId64Iterable): CompressedId64Set {\r\n if (\"string\" === typeof ids)\r\n return ids;\r\n\r\n let str = \"\";\r\n\r\n const prevId = new Uint64();\r\n const rangeIncrement = new Uint64();\r\n let rangeLen = 0;\r\n\r\n const curId = new Uint64();\r\n const curIncrement = new Uint64();\r\n for (const id of ids) {\r\n if (!Id64.isValidId64(id))\r\n continue; // ignore garbage and invalid Ids (\"0\")\r\n\r\n curId.setFromId(id);\r\n curIncrement.setFromDifference(curId, prevId);\r\n\r\n const cmp = prevId.compare(curId);\r\n if (0 === cmp)\r\n continue; // ignore duplicates\r\n else if (cmp > 0)\r\n throw new Error(\"CompressedId64Set.compressArray requires a sorted array as input\");\r\n\r\n prevId.copyFrom(curId);\r\n\r\n if (0 === rangeLen) {\r\n rangeIncrement.copyFrom(curIncrement);\r\n rangeLen = 1;\r\n } else if (curIncrement.equals(rangeIncrement)) {\r\n ++rangeLen;\r\n } else {\r\n str += compactRange(rangeIncrement, rangeLen);\r\n rangeIncrement.copyFrom(curIncrement);\r\n rangeLen = 1;\r\n }\r\n }\r\n\r\n if (0 < rangeLen)\r\n str += compactRange(rangeIncrement, rangeLen);\r\n\r\n return str;\r\n }\r\n\r\n /** This exists strictly for the purposes of compressed sets of 64-bit Ids, to avoid the overhead of BigInt for handling 64-bit integers. */\r\n class Uint64 implements Id64.Uint32Pair {\r\n private static readonly _base = 0x100000000;\r\n\r\n private static assertUint32(num: number): void {\r\n assert(num >= 0);\r\n assert(num < Uint64._base);\r\n assert(Math.floor(num) === num);\r\n }\r\n\r\n private assertConstraints(): void {\r\n Uint64.assertUint32(this.lower);\r\n Uint64.assertUint32(this.upper);\r\n }\r\n\r\n constructor(public lower = 0, public upper = 0) {\r\n this.assertConstraints();\r\n }\r\n\r\n public compare(rhs: Uint64): number {\r\n const diff = this.upper - rhs.upper;\r\n return 0 === diff ? this.lower - rhs.lower : diff;\r\n }\r\n\r\n public equals(rhs: Uint64): boolean { return 0 === this.compare(rhs); }\r\n public isLessThan(rhs: Uint64): boolean { return this.compare(rhs) < 0; }\r\n public isGreaterThan(rhs: Uint64): boolean { return this.compare(rhs) > 0; }\r\n\r\n public get isZero(): boolean { return 0 === this.lower && 0 === this.upper; }\r\n\r\n public setFromDifference(lhs: Uint64, rhs: Uint64): void {\r\n assert(!rhs.isGreaterThan(lhs));\r\n\r\n this.lower = lhs.lower - rhs.lower;\r\n this.upper = lhs.upper - rhs.upper;\r\n if (this.lower < 0) {\r\n this.lower += Uint64._base;\r\n this.upper -= 1;\r\n }\r\n }\r\n\r\n public add(rhs: Uint64): void {\r\n let lower = rhs.lower;\r\n let upper = rhs.upper;\r\n if (lower + this.lower >= Uint64._base) {\r\n lower -= Uint64._base;\r\n upper += 1;\r\n }\r\n\r\n this.lower += lower;\r\n this.upper += upper;\r\n this.assertConstraints();\r\n }\r\n\r\n public setFromId(id: Id64String): void {\r\n Id64.getUint32Pair(id, this);\r\n }\r\n\r\n public copyFrom(other: Uint64): void {\r\n this.lower = other.lower;\r\n this.upper = other.upper;\r\n }\r\n\r\n public toString(): string {\r\n if (0 === this.upper)\r\n return this.lower.toString(16).toUpperCase();\r\n\r\n const upper = this.upper.toString(16);\r\n const lower = this.lower.toString(16).padStart(8, \"0\");\r\n assert(lower.length === 8);\r\n return `${upper}${lower}`.toUpperCase();\r\n }\r\n\r\n public toId64String(): string {\r\n return Id64.fromUint32Pair(this.lower, this.upper);\r\n }\r\n }\r\n\r\n /** Supplies an iterator over the [[Id64String]]s in a [[CompressedId64Set]].\r\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\r\n */\r\n export function* iterator(ids: CompressedId64Set): Iterator<Id64String> {\r\n if (0 === ids.length)\r\n return; // empty set.\r\n\r\n if (\"+\" !== ids[0])\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n let curIndex = 1; // skip the leading '+'\r\n const curId = new Uint64();\r\n\r\n function parseUint32(): number {\r\n let value = 0;\r\n let nChars = 0;\r\n while (curIndex < ids.length && nChars < 8) {\r\n ++nChars;\r\n const ch = ids.charCodeAt(curIndex);\r\n if (!isHexDigit(ch))\r\n break; // not a hex digit in [0..9] or [A..F]\r\n\r\n value <<= 4;\r\n value |= (ch >= 65 ? ch - 65 + 10 : ch - 48); // ch - 'A' + 10 or ch - '0'\r\n value = value >>> 0; // restore unsignedness because silly javascript.\r\n ++curIndex;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n function parseUint64(uint64: Uint64): void {\r\n let lower = 0;\r\n let upper = 0;\r\n\r\n // Read up to the first 8 digits.\r\n const startIndex = curIndex;\r\n const first = parseUint32();\r\n\r\n const nFirstDigits = curIndex - startIndex;\r\n assert(nFirstDigits <= 8);\r\n\r\n if (8 === nFirstDigits && curIndex + 1 < ids.length && isHexDigit(ids.charCodeAt(curIndex + 1))) {\r\n // We've got up to 8 more digits remaining\r\n const secondIndex = curIndex;\r\n const second = parseUint32();\r\n\r\n // Transfer excess digits from upper to lower.\r\n const nSecondDigits = curIndex - secondIndex;\r\n assert(nSecondDigits > 0 && nSecondDigits <= 8);\r\n\r\n const nDigitsToTransfer = 8 - nSecondDigits;\r\n upper = first >>> (4 * nDigitsToTransfer);\r\n const transfer = first - ((upper << (4 * nDigitsToTransfer)) >>> 0);\r\n lower = (second | ((transfer << (4 * nSecondDigits)) >>> 0)) >>> 0;\r\n } else {\r\n lower = first;\r\n }\r\n\r\n uint64.lower = lower;\r\n uint64.upper = upper;\r\n }\r\n\r\n const increment = new Uint64();\r\n while (curIndex < ids.length) {\r\n let multiplier = 1;\r\n parseUint64(increment);\r\n if (increment.isZero)\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n if (curIndex < ids.length) {\r\n switch (ids[curIndex++]) {\r\n case \"*\":\r\n multiplier = parseUint32();\r\n if (0 === multiplier)\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n if (curIndex !== ids.length && ids[curIndex++] !== \"+\")\r\n return;\r\n\r\n break;\r\n case \"+\":\r\n break;\r\n default:\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n }\r\n }\r\n\r\n for (let i = 0; i < multiplier; i++) {\r\n curId.add(increment);\r\n yield curId.toId64String();\r\n }\r\n }\r\n }\r\n\r\n /** Supplies an iterable over the [[Id64String]]s in a [[CompressedId64Set]].\r\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\r\n */\r\n export function iterable(ids: CompressedId64Set): OrderedId64Iterable {\r\n return {\r\n [Symbol.iterator]: () => iterator(ids),\r\n };\r\n }\r\n\r\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Set]].\r\n * @param compressedIds The compact string representation.\r\n * @param out If supplied, the Ids will be inserted into this set rather than allocating and returning a new set.\r\n * @returns The set containing the decompressed Ids.\r\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\r\n * @see [[CompressedId64Set.compressSet]] to perform the inverse operation.\r\n * @see [[CompressedId64Set.decompressArray]] to decompress as an [[Id64Array]] instead.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\r\n */\r\n export function decompressSet(compressedIds: CompressedId64Set, out?: Id64Set): Id64Set {\r\n const set = out ?? new Set<string>();\r\n for (const id of iterable(compressedIds))\r\n set.add(id);\r\n\r\n return set;\r\n }\r\n\r\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Array]].\r\n * @param compressedIds The compact string representation.\r\n * @param out If supplied, the Ids will be appended to this array rather than allocating and returning a new array.\r\n * @returns The array containing the decompressed Ids.\r\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\r\n * @note The Ids are decompressed and appended to the array in ascending order based on their 64-bit numerical values.\r\n * @see [[CompressedId64Set.compressArray]] to perform the inverse operation.\r\n * @see [[CompressedId64Set.decompressSet]] to decompress as an [[Id64Set]] instead.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\r\n */\r\n export function decompressArray(compressedIds: CompressedId64Set, out?: Id64Array): Id64Array {\r\n const arr = out ?? [];\r\n for (const id of iterable(compressedIds))\r\n arr.push(id);\r\n\r\n return arr;\r\n }\r\n}\r\n\r\n/** A [[SortedArray]] of unique [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer values of the Ids.\r\n * @see [[CompressedId64Set]] for an immutable compact string representation.\r\n * @public\r\n */\r\nexport class OrderedId64Array extends SortedArray<Id64String> {\r\n /** Construct a new, empty array. */\r\n public constructor() {\r\n super((lhs, rhs) => OrderedId64Iterable.compare(lhs, rhs));\r\n }\r\n\r\n /** An iterable that iterates over the Ids in sorted order. */\r\n public get ids(): OrderedId64Iterable { return this._array; }\r\n\r\n /** The underlying array of Ids. */\r\n public get array(): ReadonlyArray<Id64String> { return this._array; }\r\n}\r\n\r\n/** A mutable set of valid [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer value of the Ids.\r\n * Internally the set of Ids is maintained as a [[CompressedId64Set]] string representation.\r\n * Insertions and removals are buffered until the string representation needs to be recomputed. The string representation is recomputed by every public method except [[add]] and [[delete]] -\r\n * therefore, if multiple removals and/or insertions are required, it is most efficient to perform them all before invoking other methods.\r\n * @public\r\n */\r\nexport class MutableCompressedId64Set implements OrderedId64Iterable {\r\n private _ids: CompressedId64Set;\r\n private readonly _inserted = new OrderedId64Array();\r\n private readonly _deleted = new OrderedId64Array();\r\n\r\n /** Construct a new set, optionally initialized to contain the Ids represented by `ids`. */\r\n public constructor(ids?: CompressedId64Set) {\r\n this._ids = ids ?? \"\";\r\n }\r\n\r\n /** Obtain the compact string representation of the contents of this set. If any insertions or removals are pending, they will be applied and the string recomputed. */\r\n public get ids(): CompressedId64Set {\r\n this.updateIds();\r\n return this._ids;\r\n }\r\n\r\n /** Add the specified Id to the set.\r\n * @throws Error if `id` is not a valid [[Id64String]].\r\n */\r\n public add(id: Id64String): void {\r\n if (!Id64.isValidId64(id))\r\n throw new Error(\"MutableCompressedId64Set.add: invalid Id\");\r\n\r\n this._deleted.remove(id);\r\n this._inserted.insert(id);\r\n }\r\n\r\n /** Remove the specified Id from the set.\r\n * @throws Error if `id` is not a valid [[Id64String]].\r\n */\r\n public delete(id: Id64String): void {\r\n if (!Id64.isValidId64(id))\r\n throw new Error(\"MutableCompressedId64Set.delete: invalid Id\");\r\n\r\n this._inserted.remove(id);\r\n this._deleted.insert(id);\r\n }\r\n\r\n /** Remove all Ids from the set. */\r\n public clear(): void {\r\n this._ids = \"\";\r\n this._inserted.clear();\r\n this._deleted.clear();\r\n }\r\n\r\n /** Remove all Ids from the set, then add the specified Ids. */\r\n public reset(ids?: CompressedId64Set): void {\r\n this.clear();\r\n this._ids = ids ?? \"\";\r\n }\r\n\r\n /** Obtain an iterator over the Ids in this set. The Ids are returned in ascending order based on their unsigned 64-bit integer values. */\r\n public [Symbol.iterator]() {\r\n return CompressedId64Set.iterator(this.ids);\r\n }\r\n\r\n /** Compute a compact string representation of the union of this and another set of Ids - i.e., those Ids present in either this and/or the other set. */\r\n public computeUnion(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.isEmpty)\r\n return CompressedId64Set.compressIds(ids);\r\n else if (OrderedId64Iterable.isEmptySet(ids) || this.equals(ids))\r\n return this.ids;\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.union(this, ids));\r\n }\r\n\r\n /** Compute a compact string representation of the intersection of this and another set of Ids - i.e., those Ids present in both this and the other set. */\r\n public computeIntersection(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.equals(ids))\r\n return this.ids;\r\n else if (this.isEmpty || OrderedId64Iterable.isEmptySet(ids))\r\n return \"\";\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.intersection(this, ids));\r\n }\r\n\r\n /** Compute a compact string representation of the difference between this and another set - i.e., those Ids present in this but not in the other set. */\r\n public computeDifference(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.isEmpty || this.equals(ids))\r\n return \"\";\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.difference(this, ids));\r\n }\r\n\r\n /** Return true if this set contains no Ids. */\r\n public get isEmpty(): boolean {\r\n return OrderedId64Iterable.isEmptySet(this.ids);\r\n }\r\n\r\n /** Return true if the set of Ids represented by `other` is identical to those in this set.\r\n * @note This considers only the **distinct** Ids in `other` - duplicates are ignored.\r\n */\r\n public equals(other: CompressedId64Set | MutableCompressedId64Set | OrderedId64Iterable): boolean {\r\n if (other instanceof MutableCompressedId64Set) {\r\n if (other === this)\r\n return true;\r\n\r\n if (typeof other !== \"string\")\r\n other = other.ids;\r\n }\r\n\r\n if (typeof other === \"string\")\r\n return other === this.ids;\r\n\r\n this.updateIds();\r\n return OrderedId64Iterable.areEqualSets(this, other);\r\n }\r\n\r\n private get _isDirty(): boolean {\r\n return !this._inserted.isEmpty || !this._deleted.isEmpty;\r\n }\r\n\r\n private updateIds(): void {\r\n if (!this._isDirty)\r\n return;\r\n\r\n const difference = OrderedId64Iterable.difference(CompressedId64Set.iterable(this._ids), this._deleted.ids);\r\n const union = { [Symbol.iterator]: () => OrderedId64Iterable.unionIterator(difference, this._inserted.ids) };\r\n this._ids = CompressedId64Set.compressIds(union);\r\n\r\n this._inserted.clear();\r\n this._deleted.clear();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CompressedId64Set.js","sourceRoot":"","sources":["../../src/CompressedId64Set.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAkC,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C;;;;;;;;GAQG;AACH,MAAM,KAAW,iBAAiB,CAoUjC;AApUD,WAAiB,iBAAiB;IAChC,SAAS,UAAU,CAAC,EAAU;QAC5B,gBAAgB;QAChB,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QAEX,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,SAAS,YAAY,CAAC,SAAiB,EAAE,MAAc;QACrD,MAAM,CAAC,MAAM,GAAG,CAAC,CA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QAAQ;gBAC3B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;QACtB,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ;YAC3B,OAAO,KAAK,KAAK,IAAI,CAAC,GAAG,CAAC;QAE5B,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,OAAO,mBAAmB,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,IAAY,QAAQ;QAClB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC3D,CAAC;IAEO,SAAS;QACf,IAAI,CAAC,IAAI,CAAC,QAAQ;YAChB,OAAO;QAET,MAAM,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5G,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7G,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEjD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,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 Ids\r\n */\r\n\r\nimport { assert } from \"./Assert\";\r\nimport { Id64, Id64Array, Id64Set, Id64String } from \"./Id\";\r\nimport { OrderedId64Iterable } from \"./OrderedId64Iterable\";\r\nimport { SortedArray } from \"./SortedArray\";\r\n\r\n/** @public */\r\nexport type CompressedId64Set = string;\r\n\r\n/** A compact string representation of an [[Id64Set]]. Such a representation is useful when serializing potentially very large\r\n * sets of Ids.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids represented by a compact string.\r\n * @see [[CompressedId64Set.compressSet]] and [[CompressedId64Set.compressArray]] to produce a compact string from a collection of Ids.\r\n * @see [[CompressedId64Set.decompressSet]] and [[CompressedId64Set.decompressArray]] to produce a collection of Ids from a compact string.\r\n * @see [[OrderedId64Iterable]] for a generic representation of an ordered set of Ids (compressed or otherwise).\r\n * @see [[MutableCompressedId64Set]] for a mutable version.\r\n * @public\r\n */\r\nexport namespace CompressedId64Set { // eslint-disable-line @typescript-eslint/no-redeclare\r\n function isHexDigit(ch: number): boolean {\r\n // ascii values:\r\n // '0' = 48\r\n // '9' = 57\r\n // 'a' = 65\r\n // 'f' = 70\r\n\r\n return (ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 70);\r\n }\r\n\r\n function compactRange(increment: Uint64, length: number): string {\r\n assert(length > 0);\r\n const inc = `+${increment.toString()}`;\r\n if (length <= 1)\r\n return inc;\r\n\r\n const len = length.toString(16).toUpperCase();\r\n return `${inc}*${len}`;\r\n }\r\n\r\n /** Given a set of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n * @see [[CompressedId64Set.compressArray]] to perform the same operation on an [[Id64Array]].\r\n * @see [[CompressedId64Set.decompressSet]] to perform the inverse operation.\r\n */\r\n export function compressSet(ids: Id64Set): CompressedId64Set {\r\n return sortAndCompress(ids);\r\n }\r\n\r\n /** Create a sorted array from `ids`, then return a compact string representation of those Ids.\r\n * @see [[CompressedId64Set.compressIds]] if `ids` is known to already be sorted.\r\n */\r\n export function sortAndCompress(ids: Iterable<Id64String>): CompressedId64Set {\r\n // `string` is an Iterable<string>. In that case assume caller passed a single Id64String.\r\n const arr = typeof ids === \"string\" ? [ids] : Array.from(ids);\r\n OrderedId64Iterable.sortArray(arr);\r\n return compressArray(arr);\r\n }\r\n\r\n /** Give a **numerically-ordered** array of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * Duplicate Ids are included only once in the string representation.\r\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the array is not properly sorted.\r\n * @note The array must be sorted according to the 64-bit numerical value of each Id.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.decompressArray]] to perform the inverse operation.\r\n * @see [[OrderedId64Iterable.sortArray]] to ensure the Ids are properly sorted.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n */\r\n export function compressArray(ids: Id64Array): CompressedId64Set {\r\n return compressIds(ids);\r\n }\r\n\r\n /** Give a **numerically-ordered** collection of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\r\n * Duplicate Ids are included only once in the string representation.\r\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the collection is not properly sorted.\r\n * @note The collection must be sorted according to the 64-bit numerical value of each Id.\r\n * @note Invalid Ids are ignored.\r\n * @see [[CompressedId64Set.iterable]] to perform the inverse operation.\r\n * @see [[OrderedId64Iterable.sortArray]] or [[OrderedId64Iterable.compare]] to ensure the Ids are properly sorted.\r\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\r\n */\r\n export function compressIds(ids: OrderedId64Iterable): CompressedId64Set {\r\n if (\"string\" === typeof ids)\r\n return ids;\r\n\r\n let str = \"\";\r\n\r\n const prevId = new Uint64();\r\n const rangeIncrement = new Uint64();\r\n let rangeLen = 0;\r\n\r\n const curId = new Uint64();\r\n const curIncrement = new Uint64();\r\n for (const id of ids) {\r\n if (!Id64.isValidId64(id))\r\n continue; // ignore garbage and invalid Ids (\"0\")\r\n\r\n curId.setFromId(id);\r\n curIncrement.setFromDifference(curId, prevId);\r\n\r\n const cmp = prevId.compare(curId);\r\n if (0 === cmp)\r\n continue; // ignore duplicates\r\n else if (cmp > 0)\r\n throw new Error(\"CompressedId64Set.compressArray requires a sorted array as input\");\r\n\r\n prevId.copyFrom(curId);\r\n\r\n if (0 === rangeLen) {\r\n rangeIncrement.copyFrom(curIncrement);\r\n rangeLen = 1;\r\n } else if (curIncrement.equals(rangeIncrement)) {\r\n ++rangeLen;\r\n } else {\r\n str += compactRange(rangeIncrement, rangeLen);\r\n rangeIncrement.copyFrom(curIncrement);\r\n rangeLen = 1;\r\n }\r\n }\r\n\r\n if (0 < rangeLen)\r\n str += compactRange(rangeIncrement, rangeLen);\r\n\r\n return str;\r\n }\r\n\r\n /** This exists strictly for the purposes of compressed sets of 64-bit Ids, to avoid the overhead of BigInt for handling 64-bit integers. */\r\n class Uint64 implements Id64.Uint32Pair {\r\n private static readonly _base = 0x100000000;\r\n\r\n private static assertUint32(num: number): void {\r\n assert(num >= 0);\r\n assert(num < Uint64._base);\r\n assert(Math.floor(num) === num);\r\n }\r\n\r\n private assertConstraints(): void {\r\n Uint64.assertUint32(this.lower);\r\n Uint64.assertUint32(this.upper);\r\n }\r\n\r\n constructor(public lower = 0, public upper = 0) {\r\n this.assertConstraints();\r\n }\r\n\r\n public compare(rhs: Uint64): number {\r\n const diff = this.upper - rhs.upper;\r\n return 0 === diff ? this.lower - rhs.lower : diff;\r\n }\r\n\r\n public equals(rhs: Uint64): boolean { return 0 === this.compare(rhs); }\r\n public isLessThan(rhs: Uint64): boolean { return this.compare(rhs) < 0; }\r\n public isGreaterThan(rhs: Uint64): boolean { return this.compare(rhs) > 0; }\r\n\r\n public get isZero(): boolean { return 0 === this.lower && 0 === this.upper; }\r\n\r\n public setFromDifference(lhs: Uint64, rhs: Uint64): void {\r\n assert(!rhs.isGreaterThan(lhs));\r\n\r\n this.lower = lhs.lower - rhs.lower;\r\n this.upper = lhs.upper - rhs.upper;\r\n if (this.lower < 0) {\r\n this.lower += Uint64._base;\r\n this.upper -= 1;\r\n }\r\n }\r\n\r\n public add(rhs: Uint64): void {\r\n let lower = rhs.lower;\r\n let upper = rhs.upper;\r\n if (lower + this.lower >= Uint64._base) {\r\n lower -= Uint64._base;\r\n upper += 1;\r\n }\r\n\r\n this.lower += lower;\r\n this.upper += upper;\r\n this.assertConstraints();\r\n }\r\n\r\n public setFromId(id: Id64String): void {\r\n Id64.getUint32Pair(id, this);\r\n }\r\n\r\n public copyFrom(other: Uint64): void {\r\n this.lower = other.lower;\r\n this.upper = other.upper;\r\n }\r\n\r\n public toString(): string {\r\n if (0 === this.upper)\r\n return this.lower.toString(16).toUpperCase();\r\n\r\n const upper = this.upper.toString(16);\r\n const lower = this.lower.toString(16).padStart(8, \"0\");\r\n assert(lower.length === 8);\r\n return `${upper}${lower}`.toUpperCase();\r\n }\r\n\r\n public toId64String(): string {\r\n return Id64.fromUint32Pair(this.lower, this.upper);\r\n }\r\n }\r\n\r\n /** Supplies an iterator over the [[Id64String]]s in a [[CompressedId64Set]].\r\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\r\n */\r\n export function* iterator(ids: CompressedId64Set): Iterator<Id64String> {\r\n if (0 === ids.length)\r\n return; // empty set.\r\n\r\n if (\"+\" !== ids[0])\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n let curIndex = 1; // skip the leading '+'\r\n const curId = new Uint64();\r\n\r\n function parseUint32(): number {\r\n let value = 0;\r\n let nChars = 0;\r\n while (curIndex < ids.length && nChars < 8) {\r\n ++nChars;\r\n const ch = ids.charCodeAt(curIndex);\r\n if (!isHexDigit(ch))\r\n break; // not a hex digit in [0..9] or [A..F]\r\n\r\n value <<= 4;\r\n value |= (ch >= 65 ? ch - 65 + 10 : ch - 48); // ch - 'A' + 10 or ch - '0'\r\n value = value >>> 0; // restore unsignedness because silly javascript.\r\n ++curIndex;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n function parseUint64(uint64: Uint64): void {\r\n let lower = 0;\r\n let upper = 0;\r\n\r\n // Read up to the first 8 digits.\r\n const startIndex = curIndex;\r\n const first = parseUint32();\r\n\r\n const nFirstDigits = curIndex - startIndex;\r\n assert(nFirstDigits <= 8);\r\n\r\n if (8 === nFirstDigits && curIndex + 1 < ids.length && isHexDigit(ids.charCodeAt(curIndex + 1))) {\r\n // We've got up to 8 more digits remaining\r\n const secondIndex = curIndex;\r\n const second = parseUint32();\r\n\r\n // Transfer excess digits from upper to lower.\r\n const nSecondDigits = curIndex - secondIndex;\r\n assert(nSecondDigits > 0 && nSecondDigits <= 8);\r\n\r\n const nDigitsToTransfer = 8 - nSecondDigits;\r\n upper = first >>> (4 * nDigitsToTransfer);\r\n const transfer = first - ((upper << (4 * nDigitsToTransfer)) >>> 0);\r\n lower = (second | ((transfer << (4 * nSecondDigits)) >>> 0)) >>> 0;\r\n } else {\r\n lower = first;\r\n }\r\n\r\n uint64.lower = lower;\r\n uint64.upper = upper;\r\n }\r\n\r\n const increment = new Uint64();\r\n while (curIndex < ids.length) {\r\n let multiplier = 1;\r\n parseUint64(increment);\r\n if (increment.isZero)\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n if (curIndex < ids.length) {\r\n switch (ids[curIndex++]) {\r\n case \"*\":\r\n multiplier = parseUint32();\r\n if (0 === multiplier)\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n\r\n if (curIndex !== ids.length && ids[curIndex++] !== \"+\")\r\n return;\r\n\r\n break;\r\n case \"+\":\r\n break;\r\n default:\r\n throw new Error(\"Invalid CompressedId64Set\");\r\n }\r\n }\r\n\r\n for (let i = 0; i < multiplier; i++) {\r\n curId.add(increment);\r\n yield curId.toId64String();\r\n }\r\n }\r\n }\r\n\r\n /** Supplies an iterable over the [[Id64String]]s in a [[CompressedId64Set]].\r\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\r\n */\r\n export function iterable(ids: CompressedId64Set): OrderedId64Iterable {\r\n return {\r\n [Symbol.iterator]: () => iterator(ids),\r\n };\r\n }\r\n\r\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Set]].\r\n * @param compressedIds The compact string representation.\r\n * @param out If supplied, the Ids will be inserted into this set rather than allocating and returning a new set.\r\n * @returns The set containing the decompressed Ids.\r\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\r\n * @see [[CompressedId64Set.compressSet]] to perform the inverse operation.\r\n * @see [[CompressedId64Set.decompressArray]] to decompress as an [[Id64Array]] instead.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\r\n */\r\n export function decompressSet(compressedIds: CompressedId64Set, out?: Id64Set): Id64Set {\r\n const set = out ?? new Set<string>();\r\n for (const id of iterable(compressedIds))\r\n set.add(id);\r\n\r\n return set;\r\n }\r\n\r\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Array]].\r\n * @param compressedIds The compact string representation.\r\n * @param out If supplied, the Ids will be appended to this array rather than allocating and returning a new array.\r\n * @returns The array containing the decompressed Ids.\r\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\r\n * @note The Ids are decompressed and appended to the array in ascending order based on their 64-bit numerical values.\r\n * @see [[CompressedId64Set.compressArray]] to perform the inverse operation.\r\n * @see [[CompressedId64Set.decompressSet]] to decompress as an [[Id64Set]] instead.\r\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\r\n */\r\n export function decompressArray(compressedIds: CompressedId64Set, out?: Id64Array): Id64Array {\r\n const arr = out ?? [];\r\n for (const id of iterable(compressedIds))\r\n arr.push(id);\r\n\r\n return arr;\r\n }\r\n}\r\n\r\n/** A [[SortedArray]] of unique [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer values of the Ids.\r\n * @see [[CompressedId64Set]] for an immutable compact string representation.\r\n * @public\r\n */\r\nexport class OrderedId64Array extends SortedArray<Id64String> {\r\n /** Construct a new, empty array. */\r\n public constructor() {\r\n super((lhs, rhs) => OrderedId64Iterable.compare(lhs, rhs));\r\n }\r\n\r\n /** An iterable that iterates over the Ids in sorted order. */\r\n public get ids(): OrderedId64Iterable { return this._array; }\r\n\r\n /** The underlying array of Ids. */\r\n public get array(): ReadonlyArray<Id64String> { return this._array; }\r\n}\r\n\r\n/** A mutable set of valid [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer value of the Ids.\r\n * Internally the set of Ids is maintained as a [[CompressedId64Set]] string representation.\r\n * Insertions and removals are buffered until the string representation needs to be recomputed. The string representation is recomputed by every public method except [[add]] and [[delete]] -\r\n * therefore, if multiple removals and/or insertions are required, it is most efficient to perform them all before invoking other methods.\r\n * @public\r\n */\r\nexport class MutableCompressedId64Set implements OrderedId64Iterable {\r\n private _ids: CompressedId64Set;\r\n private readonly _inserted = new OrderedId64Array();\r\n private readonly _deleted = new OrderedId64Array();\r\n\r\n /** Construct a new set, optionally initialized to contain the Ids represented by `ids`. */\r\n public constructor(ids?: CompressedId64Set) {\r\n this._ids = ids ?? \"\";\r\n }\r\n\r\n /** Obtain the compact string representation of the contents of this set. If any insertions or removals are pending, they will be applied and the string recomputed. */\r\n public get ids(): CompressedId64Set {\r\n this.updateIds();\r\n return this._ids;\r\n }\r\n\r\n /** Add the specified Id to the set.\r\n * @throws Error if `id` is not a valid [[Id64String]].\r\n */\r\n public add(id: Id64String): void {\r\n if (!Id64.isValidId64(id))\r\n throw new Error(\"MutableCompressedId64Set.add: invalid Id\");\r\n\r\n this._deleted.remove(id);\r\n this._inserted.insert(id);\r\n }\r\n\r\n /** Remove the specified Id from the set.\r\n * @throws Error if `id` is not a valid [[Id64String]].\r\n */\r\n public delete(id: Id64String): void {\r\n if (!Id64.isValidId64(id))\r\n throw new Error(\"MutableCompressedId64Set.delete: invalid Id\");\r\n\r\n this._inserted.remove(id);\r\n this._deleted.insert(id);\r\n }\r\n\r\n /** Remove all Ids from the set. */\r\n public clear(): void {\r\n this._ids = \"\";\r\n this._inserted.clear();\r\n this._deleted.clear();\r\n }\r\n\r\n /** Remove all Ids from the set, then add the specified Ids. */\r\n public reset(ids?: CompressedId64Set): void {\r\n this.clear();\r\n this._ids = ids ?? \"\";\r\n }\r\n\r\n /** Obtain an iterator over the Ids in this set. The Ids are returned in ascending order based on their unsigned 64-bit integer values. */\r\n public [Symbol.iterator]() {\r\n return CompressedId64Set.iterator(this.ids);\r\n }\r\n\r\n /** Compute a compact string representation of the union of this and another set of Ids - i.e., those Ids present in either this and/or the other set. */\r\n public computeUnion(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.isEmpty)\r\n return CompressedId64Set.compressIds(ids);\r\n else if (OrderedId64Iterable.isEmptySet(ids) || this.equals(ids))\r\n return this.ids;\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.union(this, ids));\r\n }\r\n\r\n /** Compute a compact string representation of the intersection of this and another set of Ids - i.e., those Ids present in both this and the other set. */\r\n public computeIntersection(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.equals(ids))\r\n return this.ids;\r\n else if (this.isEmpty || OrderedId64Iterable.isEmptySet(ids))\r\n return \"\";\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.intersection(this, ids));\r\n }\r\n\r\n /** Compute a compact string representation of the difference between this and another set - i.e., those Ids present in this but not in the other set. */\r\n public computeDifference(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\r\n if (this.isEmpty || this.equals(ids))\r\n return \"\";\r\n\r\n return CompressedId64Set.compressIds(OrderedId64Iterable.difference(this, ids));\r\n }\r\n\r\n /** Return true if this set contains no Ids. */\r\n public get isEmpty(): boolean {\r\n return OrderedId64Iterable.isEmptySet(this.ids);\r\n }\r\n\r\n /** Return true if the set of Ids represented by `other` is identical to those in this set.\r\n * @note This considers only the **distinct** Ids in `other` - duplicates are ignored.\r\n */\r\n public equals(other: CompressedId64Set | MutableCompressedId64Set | OrderedId64Iterable): boolean {\r\n if (other instanceof MutableCompressedId64Set) {\r\n if (other === this)\r\n return true;\r\n\r\n if (typeof other !== \"string\")\r\n other = other.ids;\r\n }\r\n\r\n if (typeof other === \"string\")\r\n return other === this.ids;\r\n\r\n this.updateIds();\r\n return OrderedId64Iterable.areEqualSets(this, other);\r\n }\r\n\r\n private get _isDirty(): boolean {\r\n return !this._inserted.isEmpty || !this._deleted.isEmpty;\r\n }\r\n\r\n private updateIds(): void {\r\n if (!this._isDirty)\r\n return;\r\n\r\n const difference = OrderedId64Iterable.difference(CompressedId64Set.iterable(this._ids), this._deleted.ids);\r\n const union = { [Symbol.iterator]: () => OrderedId64Iterable.unionIterator(difference, this._inserted.ids) };\r\n this._ids = CompressedId64Set.compressIds(union);\r\n\r\n this._inserted.clear();\r\n this._deleted.clear();\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-bentley",
|
|
3
|
-
"version": "4.8.0-dev.
|
|
3
|
+
"version": "4.8.0-dev.19",
|
|
4
4
|
"description": "Bentley JavaScript core components",
|
|
5
5
|
"main": "lib/cjs/core-bentley.js",
|
|
6
6
|
"module": "lib/esm/core-bentley.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"nyc": "^15.1.0",
|
|
36
36
|
"rimraf": "^3.0.2",
|
|
37
37
|
"typescript": "~5.3.3",
|
|
38
|
-
"@itwin/build-tools": "4.8.0-dev.
|
|
38
|
+
"@itwin/build-tools": "4.8.0-dev.19"
|
|
39
39
|
},
|
|
40
40
|
"nyc": {
|
|
41
41
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|