@itwin/core-bentley 5.0.0-dev.9 → 5.0.0-dev.92
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/CHANGELOG.md +51 -1
- package/lib/cjs/AccessToken.js.map +1 -1
- package/lib/cjs/Assert.js.map +1 -1
- package/lib/cjs/BeEvent.js +3 -7
- package/lib/cjs/BeEvent.js.map +1 -1
- package/lib/cjs/BeSQLite.js.map +1 -1
- package/lib/cjs/BentleyError.d.ts +3 -0
- package/lib/cjs/BentleyError.d.ts.map +1 -1
- package/lib/cjs/BentleyError.js +6 -1
- package/lib/cjs/BentleyError.js.map +1 -1
- package/lib/cjs/BentleyLoggerCategory.js.map +1 -1
- package/lib/cjs/ByteStream.d.ts +3 -22
- package/lib/cjs/ByteStream.d.ts.map +1 -1
- package/lib/cjs/ByteStream.js +7 -21
- package/lib/cjs/ByteStream.js.map +1 -1
- package/lib/cjs/ClassUtils.js.map +1 -1
- package/lib/cjs/Compare.d.ts +15 -0
- package/lib/cjs/Compare.d.ts.map +1 -1
- package/lib/cjs/Compare.js +48 -0
- package/lib/cjs/Compare.js.map +1 -1
- package/lib/cjs/CompressedId64Set.js +6 -3
- package/lib/cjs/CompressedId64Set.js.map +1 -1
- package/lib/cjs/Dictionary.js +8 -3
- package/lib/cjs/Dictionary.js.map +1 -1
- package/lib/cjs/Disposable.d.ts +18 -0
- package/lib/cjs/Disposable.d.ts.map +1 -1
- package/lib/cjs/Disposable.js +25 -25
- package/lib/cjs/Disposable.js.map +1 -1
- package/lib/cjs/Id.d.ts +0 -4
- package/lib/cjs/Id.d.ts.map +1 -1
- package/lib/cjs/Id.js +9 -11
- package/lib/cjs/Id.js.map +1 -1
- package/lib/cjs/IndexMap.js +6 -1
- package/lib/cjs/IndexMap.js.map +1 -1
- package/lib/cjs/JsonSchema.js.map +1 -1
- package/lib/cjs/JsonUtils.js.map +1 -1
- package/lib/cjs/LRUMap.js +16 -0
- package/lib/cjs/LRUMap.js.map +1 -1
- package/lib/cjs/Logger.d.ts +24 -2
- package/lib/cjs/Logger.d.ts.map +1 -1
- package/lib/cjs/Logger.js +26 -7
- package/lib/cjs/Logger.js.map +1 -1
- package/lib/cjs/ObservableSet.js +6 -6
- package/lib/cjs/ObservableSet.js.map +1 -1
- package/lib/cjs/OneAtATimeAction.js +9 -0
- package/lib/cjs/OneAtATimeAction.js.map +1 -1
- package/lib/cjs/OrderedId64Iterable.js.map +1 -1
- package/lib/cjs/OrderedSet.js +1 -0
- package/lib/cjs/OrderedSet.js.map +1 -1
- package/lib/cjs/PriorityQueue.js +3 -1
- package/lib/cjs/PriorityQueue.js.map +1 -1
- package/lib/cjs/ProcessDetector.js.map +1 -1
- package/lib/cjs/SortedArray.js +4 -1
- package/lib/cjs/SortedArray.js.map +1 -1
- package/lib/cjs/StatusCategory.js +42 -105
- package/lib/cjs/StatusCategory.js.map +1 -1
- package/lib/cjs/StringUtils.js.map +1 -1
- package/lib/cjs/Time.js +5 -0
- package/lib/cjs/Time.js.map +1 -1
- package/lib/cjs/Tracing.js +2 -0
- package/lib/cjs/Tracing.js.map +1 -1
- package/lib/cjs/TupleKeyedMap.js +2 -2
- package/lib/cjs/TupleKeyedMap.js.map +1 -1
- package/lib/cjs/TypedArrayBuilder.js +8 -0
- package/lib/cjs/TypedArrayBuilder.js.map +1 -1
- package/lib/cjs/UnexpectedErrors.js +10 -12
- package/lib/cjs/UnexpectedErrors.js.map +1 -1
- package/lib/cjs/UtilityTypes.js.map +1 -1
- package/lib/cjs/YieldManager.js +3 -1
- package/lib/cjs/YieldManager.js.map +1 -1
- package/lib/cjs/core-bentley.js.map +1 -1
- package/lib/cjs/internal/BeSQLiteInternal.js.map +1 -1
- package/lib/cjs/internal/RepositoryStatus.js.map +1 -1
- package/lib/cjs/internal/cross-package.d.ts +0 -1
- package/lib/cjs/internal/cross-package.d.ts.map +1 -1
- package/lib/cjs/internal/cross-package.js +1 -3
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/partitionArray.js.map +1 -1
- package/lib/esm/AccessToken.js.map +1 -1
- package/lib/esm/Assert.js.map +1 -1
- package/lib/esm/BeEvent.js +3 -7
- package/lib/esm/BeEvent.js.map +1 -1
- package/lib/esm/BeSQLite.js.map +1 -1
- package/lib/esm/BentleyError.d.ts +3 -0
- package/lib/esm/BentleyError.d.ts.map +1 -1
- package/lib/esm/BentleyError.js +6 -1
- package/lib/esm/BentleyError.js.map +1 -1
- package/lib/esm/BentleyLoggerCategory.js.map +1 -1
- package/lib/esm/ByteStream.d.ts +3 -22
- package/lib/esm/ByteStream.d.ts.map +1 -1
- package/lib/esm/ByteStream.js +7 -21
- package/lib/esm/ByteStream.js.map +1 -1
- package/lib/esm/ClassUtils.js.map +1 -1
- package/lib/esm/Compare.d.ts +15 -0
- package/lib/esm/Compare.d.ts.map +1 -1
- package/lib/esm/Compare.js +46 -0
- package/lib/esm/Compare.js.map +1 -1
- package/lib/esm/CompressedId64Set.js +6 -3
- package/lib/esm/CompressedId64Set.js.map +1 -1
- package/lib/esm/Dictionary.js +8 -3
- package/lib/esm/Dictionary.js.map +1 -1
- package/lib/esm/Disposable.d.ts +18 -0
- package/lib/esm/Disposable.d.ts.map +1 -1
- package/lib/esm/Disposable.js +24 -25
- package/lib/esm/Disposable.js.map +1 -1
- package/lib/esm/Id.d.ts +0 -4
- package/lib/esm/Id.d.ts.map +1 -1
- package/lib/esm/Id.js +9 -11
- package/lib/esm/Id.js.map +1 -1
- package/lib/esm/IndexMap.js +6 -1
- package/lib/esm/IndexMap.js.map +1 -1
- package/lib/esm/JsonSchema.js.map +1 -1
- package/lib/esm/JsonUtils.js.map +1 -1
- package/lib/esm/LRUMap.js +16 -0
- package/lib/esm/LRUMap.js.map +1 -1
- package/lib/esm/Logger.d.ts +24 -2
- package/lib/esm/Logger.d.ts.map +1 -1
- package/lib/esm/Logger.js +26 -7
- package/lib/esm/Logger.js.map +1 -1
- package/lib/esm/ObservableSet.js +6 -6
- package/lib/esm/ObservableSet.js.map +1 -1
- package/lib/esm/OneAtATimeAction.js +9 -0
- package/lib/esm/OneAtATimeAction.js.map +1 -1
- package/lib/esm/OrderedId64Iterable.js.map +1 -1
- package/lib/esm/OrderedSet.js +1 -0
- package/lib/esm/OrderedSet.js.map +1 -1
- package/lib/esm/PriorityQueue.js +3 -1
- package/lib/esm/PriorityQueue.js.map +1 -1
- package/lib/esm/ProcessDetector.js.map +1 -1
- package/lib/esm/SortedArray.js +4 -1
- package/lib/esm/SortedArray.js.map +1 -1
- package/lib/esm/StatusCategory.js +42 -105
- package/lib/esm/StatusCategory.js.map +1 -1
- package/lib/esm/StringUtils.js.map +1 -1
- package/lib/esm/Time.js +5 -0
- package/lib/esm/Time.js.map +1 -1
- package/lib/esm/Tracing.js +2 -0
- package/lib/esm/Tracing.js.map +1 -1
- package/lib/esm/TupleKeyedMap.js +2 -2
- package/lib/esm/TupleKeyedMap.js.map +1 -1
- package/lib/esm/TypedArrayBuilder.js +8 -0
- package/lib/esm/TypedArrayBuilder.js.map +1 -1
- package/lib/esm/UnexpectedErrors.js +10 -12
- package/lib/esm/UnexpectedErrors.js.map +1 -1
- package/lib/esm/UtilityTypes.js.map +1 -1
- package/lib/esm/YieldManager.js +3 -1
- package/lib/esm/YieldManager.js.map +1 -1
- package/lib/esm/core-bentley.js.map +1 -1
- package/lib/esm/internal/BeSQLiteInternal.js.map +1 -1
- package/lib/esm/internal/RepositoryStatus.js.map +1 -1
- package/lib/esm/internal/cross-package.d.ts +0 -1
- package/lib/esm/internal/cross-package.d.ts.map +1 -1
- package/lib/esm/internal/cross-package.js +0 -1
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/lib/esm/partitionArray.js.map +1 -1
- package/package.json +8 -8
- package/lib/cjs/internal/staticLoggerMetadata.d.ts +0 -11
- package/lib/cjs/internal/staticLoggerMetadata.d.ts.map +0 -1
- package/lib/cjs/internal/staticLoggerMetadata.js +0 -17
- package/lib/cjs/internal/staticLoggerMetadata.js.map +0 -1
- package/lib/esm/internal/staticLoggerMetadata.d.ts +0 -11
- package/lib/esm/internal/staticLoggerMetadata.d.ts.map +0 -1
- package/lib/esm/internal/staticLoggerMetadata.js +0 -14
- package/lib/esm/internal/staticLoggerMetadata.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BentleyLoggerCategory.js","sourceRoot":"","sources":["../../src/BentleyLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;;GAGG;AACH,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,2EAA2E;IAC3E,oDAA2B,CAAA;AAC7B,CAAC,EAHW,qBAAqB,qCAArB,qBAAqB,QAGhC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"BentleyLoggerCategory.js","sourceRoot":"","sources":["../../src/BentleyLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;;GAGG;AACH,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,2EAA2E;IAC3E,oDAA2B,CAAA;AAC7B,CAAC,EAHW,qBAAqB,qCAArB,qBAAqB,QAGhC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\n/** Logger categories used by this package\n * @see [Logger]($bentley)\n * @public\n */\nexport enum BentleyLoggerCategory {\n /** The logger category used by common classes relating to ElementProps. */\n Performance = \"Performance\",\n}\n"]}
|
package/lib/cjs/ByteStream.d.ts
CHANGED
|
@@ -24,15 +24,12 @@ export declare class ByteStream {
|
|
|
24
24
|
* ArrayBuffer. If `bytes` represents only a **sub-range** of the underlying buffer's data, the results will be unexpected unless the optional `subView`
|
|
25
25
|
* argument is supplied, with correct offset and length.
|
|
26
26
|
*
|
|
27
|
-
* For both of the above reasons,
|
|
28
|
-
* @deprecated in 3.x. Use [[fromUint8Array]] or [[fromArrayBuffer]].
|
|
27
|
+
* For both of the above reasons, this constructor is private, and [[fromUint8Array]] or [[fromArrayBuffer]] should be used to create a ByteStream.
|
|
29
28
|
*/
|
|
30
|
-
constructor(
|
|
31
|
-
byteOffset: number;
|
|
32
|
-
byteLength: number;
|
|
33
|
-
});
|
|
29
|
+
private constructor();
|
|
34
30
|
/** Construct a new ByteStream for the range of bytes represented by `bytes`, which may be a subset of the range of bytes
|
|
35
31
|
* represented by the underlying ArrayBuffer. The read position will be set to the beginning of the range of bytes.
|
|
32
|
+
* @param bytes The Uint8Array from which data is to be extracted.
|
|
36
33
|
*/
|
|
37
34
|
static fromUint8Array(bytes: Uint8Array): ByteStream;
|
|
38
35
|
/** Construct a new ByteStream with the read position set to the beginning.
|
|
@@ -80,22 +77,6 @@ export declare class ByteStream {
|
|
|
80
77
|
readId64(): Id64String;
|
|
81
78
|
/** Read an unsigned 24-bit integer from the current read position and advance by 3 bytes. */
|
|
82
79
|
readUint24(): number;
|
|
83
|
-
/** @deprecated in 3.x. use [[readUint8]]. */
|
|
84
|
-
get nextUint8(): number;
|
|
85
|
-
/** @deprecated in 3.x. use [[readUint16]]. */
|
|
86
|
-
get nextUint16(): number;
|
|
87
|
-
/** @deprecated in 3.x. use [[readUint32]]. */
|
|
88
|
-
get nextUint32(): number;
|
|
89
|
-
/** @deprecated in 3.x. use [[readInt32]]. */
|
|
90
|
-
get nextInt32(): number;
|
|
91
|
-
/** @deprecated in 3.x. use [[readFloat32]]. */
|
|
92
|
-
get nextFloat32(): number;
|
|
93
|
-
/** @deprecated in 3.x. use [[readFloat64]]. */
|
|
94
|
-
get nextFloat64(): number;
|
|
95
|
-
/** @deprecated in 3.x. use [[readId64]]. */
|
|
96
|
-
get nextId64(): Id64String;
|
|
97
|
-
/** @deprecated in 3.x. use [[readUint32]]. */
|
|
98
|
-
get nextUint24(): number;
|
|
99
80
|
/** Read the specified number of bytes beginning at the current read position into a Uint8Array and advance by the specified number of byte.
|
|
100
81
|
* @param numBytes The number of bytes to read.
|
|
101
82
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ByteStream.d.ts","sourceRoot":"","sources":["../../src/ByteStream.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAQ,UAAU,EAAE,MAAM,MAAM,CAAC;AAExC;;;;;;GAMG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,OAAO,CAAa;IAE5B
|
|
1
|
+
{"version":3,"file":"ByteStream.d.ts","sourceRoot":"","sources":["../../src/ByteStream.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAQ,UAAU,EAAE,MAAM,MAAM,CAAC;AAExC;;;;;;GAMG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,OAAO,CAAa;IAE5B;;;;;;;;;;;;OAYG;IACH,OAAO;IAUP;;;OAGG;WACW,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;IAK3D;;;OAGG;WACW,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,iBAAiB,EAAE,OAAO,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,UAAU;IAIxI,yCAAyC;IACzC,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,0FAA0F;IAC1F,IAAW,eAAe,IAAI,MAAM,CAEnC;IAED;;OAEG;IACH,IAAW,YAAY,IAAI,OAAO,CAEjC;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED,sEAAsE;IACtE,IAAW,MAAM,IAAI,MAAM,CAAyB;IACpD,IAAW,MAAM,CAAC,GAAG,EAAE,MAAM,EAG5B;IAED,sEAAsE;IAC/D,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKzC,6EAA6E;IACtE,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAQxC,sEAAsE;IAC/D,KAAK,IAAI,IAAI;IAEpB,0FAA0F;IACnF,SAAS,IAAI,MAAM;IAC1B,6FAA6F;IACtF,UAAU,IAAI,MAAM;IAC3B,6FAA6F;IACtF,UAAU,IAAI,MAAM;IAC3B,0FAA0F;IACnF,SAAS,IAAI,MAAM;IAC1B,iGAAiG;IAC1F,WAAW,IAAI,MAAM;IAC5B,iGAAiG;IAC1F,WAAW,IAAI,MAAM;IAC5B,wIAAwI;IACjI,QAAQ,IAAI,UAAU;IAC7B,6FAA6F;IACtF,UAAU,IAAI,MAAM;IAE3B;;OAEG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU;IAM9C,qGAAqG;IAC9F,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU;IAI/D,0HAA0H;IACnH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW;IAOnD,0CAA0C;IAC1C,IAAW,WAAW,IAAI,WAAW,GAAG,iBAAiB,CAA8B;IAEvF,OAAO,CAAC,IAAI;CAKb"}
|
package/lib/cjs/ByteStream.js
CHANGED
|
@@ -18,6 +18,9 @@ const Id_1 = require("./Id");
|
|
|
18
18
|
* @public
|
|
19
19
|
*/
|
|
20
20
|
class ByteStream {
|
|
21
|
+
_view;
|
|
22
|
+
_byteOffset;
|
|
23
|
+
_curPos = 0;
|
|
21
24
|
/** Construct a new ByteStream with the read position set to the beginning.
|
|
22
25
|
* @param buffer The underlying buffer from which data is to be extracted.
|
|
23
26
|
* @param subView If defined, specifies the subset of the underlying buffer's data to use.
|
|
@@ -29,11 +32,9 @@ class ByteStream {
|
|
|
29
32
|
* ArrayBuffer. If `bytes` represents only a **sub-range** of the underlying buffer's data, the results will be unexpected unless the optional `subView`
|
|
30
33
|
* argument is supplied, with correct offset and length.
|
|
31
34
|
*
|
|
32
|
-
* For both of the above reasons,
|
|
33
|
-
* @deprecated in 3.x. Use [[fromUint8Array]] or [[fromArrayBuffer]].
|
|
35
|
+
* For both of the above reasons, this constructor is private, and [[fromUint8Array]] or [[fromArrayBuffer]] should be used to create a ByteStream.
|
|
34
36
|
*/
|
|
35
37
|
constructor(buffer, subView) {
|
|
36
|
-
this._curPos = 0;
|
|
37
38
|
if (undefined !== subView) {
|
|
38
39
|
this._view = new DataView(buffer, subView.byteOffset, subView.byteLength);
|
|
39
40
|
this._byteOffset = subView.byteOffset;
|
|
@@ -45,17 +46,18 @@ class ByteStream {
|
|
|
45
46
|
}
|
|
46
47
|
/** Construct a new ByteStream for the range of bytes represented by `bytes`, which may be a subset of the range of bytes
|
|
47
48
|
* represented by the underlying ArrayBuffer. The read position will be set to the beginning of the range of bytes.
|
|
49
|
+
* @param bytes The Uint8Array from which data is to be extracted.
|
|
48
50
|
*/
|
|
49
51
|
static fromUint8Array(bytes) {
|
|
50
52
|
const { byteOffset, byteLength } = bytes;
|
|
51
|
-
return new ByteStream(bytes.buffer, { byteOffset, byteLength });
|
|
53
|
+
return new ByteStream(bytes.buffer, { byteOffset, byteLength });
|
|
52
54
|
}
|
|
53
55
|
/** Construct a new ByteStream with the read position set to the beginning.
|
|
54
56
|
* @param buffer The underlying buffer from which data is to be extracted.
|
|
55
57
|
* @param subView If defined, specifies the subset of the underlying buffer's data to use.
|
|
56
58
|
*/
|
|
57
59
|
static fromArrayBuffer(buffer, subView) {
|
|
58
|
-
return new ByteStream(buffer, subView);
|
|
60
|
+
return new ByteStream(buffer, subView);
|
|
59
61
|
}
|
|
60
62
|
/** The number of bytes in this stream */
|
|
61
63
|
get length() {
|
|
@@ -113,22 +115,6 @@ class ByteStream {
|
|
|
113
115
|
readId64() { return Id_1.Id64.fromUint32Pair(this.readUint32(), this.readUint32()); }
|
|
114
116
|
/** Read an unsigned 24-bit integer from the current read position and advance by 3 bytes. */
|
|
115
117
|
readUint24() { return this.readUint8() | (this.readUint8() << 8) | (this.readUint8() << 16); }
|
|
116
|
-
/** @deprecated in 3.x. use [[readUint8]]. */
|
|
117
|
-
get nextUint8() { return this.readUint8(); }
|
|
118
|
-
/** @deprecated in 3.x. use [[readUint16]]. */
|
|
119
|
-
get nextUint16() { return this.readUint16(); }
|
|
120
|
-
/** @deprecated in 3.x. use [[readUint32]]. */
|
|
121
|
-
get nextUint32() { return this.readUint32(); }
|
|
122
|
-
/** @deprecated in 3.x. use [[readInt32]]. */
|
|
123
|
-
get nextInt32() { return this.readInt32(); }
|
|
124
|
-
/** @deprecated in 3.x. use [[readFloat32]]. */
|
|
125
|
-
get nextFloat32() { return this.readFloat32(); }
|
|
126
|
-
/** @deprecated in 3.x. use [[readFloat64]]. */
|
|
127
|
-
get nextFloat64() { return this.readFloat64(); }
|
|
128
|
-
/** @deprecated in 3.x. use [[readId64]]. */
|
|
129
|
-
get nextId64() { return this.readId64(); }
|
|
130
|
-
/** @deprecated in 3.x. use [[readUint32]]. */
|
|
131
|
-
get nextUint24() { return this.readUint24(); }
|
|
132
118
|
/** Read the specified number of bytes beginning at the current read position into a Uint8Array and advance by the specified number of byte.
|
|
133
119
|
* @param numBytes The number of bytes to read.
|
|
134
120
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ByteStream.js","sourceRoot":"","sources":["../../src/ByteStream.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qCAAkC;AAClC,6BAAwC;AAExC;;;;;;GAMG;AACH,MAAa,UAAU;IAKrB;;;;;;;;;;;;;OAaG;IACH,YAAmB,MAAuC,EAAE,OAAoD;QAhBxG,YAAO,GAAW,CAAC,CAAC;QAiB1B,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,IAA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,CAAC,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA9JD,gCA8JC","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 Utils\r\n */\r\n\r\nimport { assert } from \"./Assert\";\r\nimport { Id64, Id64String } from \"./Id\";\r\n\r\n/** Allows the contents of an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)\r\n * to be consumed sequentially using methods to extract\r\n * data of a particular type from the bytes beginning at the current read position.\r\n * Methods and properties beginning with 'read' and taking no arguments consume data at the current read position and advance it\r\n * by the size of the data read. The read position can also be directly adjusted by the caller.\r\n * @public\r\n */\r\nexport class ByteStream {\r\n private readonly _view: DataView;\r\n private readonly _byteOffset: number;\r\n private _curPos: number = 0;\r\n\r\n /** Construct a new ByteStream with the read position set to the beginning.\r\n * @param buffer The underlying buffer from which data is to be extracted.\r\n * @param subView If defined, specifies the subset of the underlying buffer's data to use.\r\n * This constructor is subject to two common mistakes:\r\n *\r\n * 1. Given `bytes: Uint8Array`, `new ByteStream(bytes)` will compile but at run-time will produce an error asserting that\r\n * the DataView constructor requires an ArrayBuffer. The correct usage is `new ByteStream(bytes.buffer)`.\r\n * 2. Given `bytes: Uint8Array`, `new ByteStream(bytes.buffer)` creates a stream for the entire range of bytes represented by the underlying\r\n * ArrayBuffer. If `bytes` represents only a **sub-range** of the underlying buffer's data, the results will be unexpected unless the optional `subView`\r\n * argument is supplied, with correct offset and length.\r\n *\r\n * For both of the above reasons, prefer to use [[fromUint8Array]].\r\n * @deprecated in 3.x. Use [[fromUint8Array]] or [[fromArrayBuffer]].\r\n */\r\n public constructor(buffer: ArrayBuffer | SharedArrayBuffer, subView?: { byteOffset: number, byteLength: number }) {\r\n if (undefined !== subView) {\r\n this._view = new DataView(buffer, subView.byteOffset, subView.byteLength);\r\n this._byteOffset = subView.byteOffset;\r\n } else {\r\n this._view = new DataView(buffer);\r\n this._byteOffset = 0;\r\n }\r\n }\r\n\r\n /** Construct a new ByteStream for the range of bytes represented by `bytes`, which may be a subset of the range of bytes\r\n * represented by the underlying ArrayBuffer. The read position will be set to the beginning of the range of bytes.\r\n */\r\n public static fromUint8Array(bytes: Uint8Array): ByteStream {\r\n const { byteOffset, byteLength } = bytes;\r\n return new ByteStream(bytes.buffer, { byteOffset, byteLength }); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n\r\n /** Construct a new ByteStream with the read position set to the beginning.\r\n * @param buffer The underlying buffer from which data is to be extracted.\r\n * @param subView If defined, specifies the subset of the underlying buffer's data to use.\r\n */\r\n public static fromArrayBuffer(buffer: ArrayBuffer | SharedArrayBuffer, subView?: { byteOffset: number, byteLength: number }): ByteStream {\r\n return new ByteStream(buffer, subView); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n\r\n /** The number of bytes in this stream */\r\n public get length(): number {\r\n return this._view.byteLength;\r\n }\r\n\r\n /** The number of bytes remaining to be read, from [[curPos]] to the end of the stream. */\r\n public get remainingLength(): number {\r\n return this.length - this.curPos;\r\n }\r\n\r\n /** Returns true if the current read position has been advanced past the end of the stream. This generally indicates that an attempt was made to read more data than is available.\r\n * @see [[isAtTheEnd]]\r\n */\r\n public get isPastTheEnd(): boolean {\r\n return this.curPos > this.length;\r\n }\r\n\r\n /** Returns true if the current read position has advanced precisely to the end of the stream, indicating all of the data has been consumed.\r\n * @see [[isPastTheEnd]].\r\n */\r\n public get isAtTheEnd(): boolean {\r\n return this.curPos === this.length;\r\n }\r\n\r\n /** The current read position as an index into the stream of bytes. */\r\n public get curPos(): number { return this._curPos; }\r\n public set curPos(pos: number) {\r\n this._curPos = pos;\r\n assert(!this.isPastTheEnd);\r\n }\r\n\r\n /** Adds the specified number of bytes to the current read position */\r\n public advance(numBytes: number): boolean {\r\n this.curPos = (this.curPos + numBytes);\r\n return !this.isPastTheEnd;\r\n }\r\n\r\n /** Subtracts the specified number of bytes from the current read position */\r\n public rewind(numBytes: number): boolean {\r\n if (this.curPos - numBytes < 0)\r\n return false;\r\n\r\n this.curPos = this.curPos - numBytes;\r\n return true;\r\n }\r\n\r\n /** Resets the current read position to the beginning of the stream */\r\n public reset(): void { this.curPos = 0; }\r\n\r\n /** Read a unsigned 8-bit integer from the current read position and advance by 1 byte. */\r\n public readUint8(): number { return this.read(1, (view) => view.getUint8(this.curPos)); }\r\n /** Read an unsigned 16-bit integer from the current read position and advance by 2 bytes. */\r\n public readUint16(): number { return this.read(2, (view) => view.getUint16(this.curPos, true)); }\r\n /** Read an unsigned 32-bit integer from the current read position and advance by 4 bytes. */\r\n public readUint32(): number { return this.read(4, (view) => view.getUint32(this.curPos, true)); }\r\n /** Read a signed 32-bit integer from the current read position and advance by 4 bytes. */\r\n public readInt32(): number { return this.read(4, (view) => view.getInt32(this.curPos, true)); }\r\n /** Read a 32-bit floating point number from the current read position and advance by 4 bytes. */\r\n public readFloat32(): number { return this.read(4, (view) => view.getFloat32(this.curPos, true)); }\r\n /** Read a 64-bit floating point number from the current read position and advance by 8 bytes. */\r\n public readFloat64(): number { return this.read(8, (view) => view.getFloat64(this.curPos, true)); }\r\n /** Read an unsigned 64-bit integer from the current read position, advance by 8 bytes, and return the 64-bit value as an Id64String. */\r\n public readId64(): Id64String { return Id64.fromUint32Pair(this.readUint32(), this.readUint32()); }\r\n /** Read an unsigned 24-bit integer from the current read position and advance by 3 bytes. */\r\n public readUint24(): number { return this.readUint8() | (this.readUint8() << 8) | (this.readUint8() << 16); }\r\n\r\n /** @deprecated in 3.x. use [[readUint8]]. */\r\n public get nextUint8(): number { return this.readUint8(); }\r\n /** @deprecated in 3.x. use [[readUint16]]. */\r\n public get nextUint16(): number { return this.readUint16(); }\r\n /** @deprecated in 3.x. use [[readUint32]]. */\r\n public get nextUint32(): number { return this.readUint32(); }\r\n /** @deprecated in 3.x. use [[readInt32]]. */\r\n public get nextInt32(): number { return this.readInt32(); }\r\n /** @deprecated in 3.x. use [[readFloat32]]. */\r\n public get nextFloat32(): number { return this.readFloat32(); }\r\n /** @deprecated in 3.x. use [[readFloat64]]. */\r\n public get nextFloat64(): number { return this.readFloat64(); }\r\n /** @deprecated in 3.x. use [[readId64]]. */\r\n public get nextId64(): Id64String { return this.readId64(); }\r\n /** @deprecated in 3.x. use [[readUint32]]. */\r\n public get nextUint24(): number { return this.readUint24(); }\r\n\r\n /** Read the specified number of bytes beginning at the current read position into a Uint8Array and advance by the specified number of byte.\r\n * @param numBytes The number of bytes to read.\r\n */\r\n public nextBytes(numBytes: number): Uint8Array {\r\n const bytes = new Uint8Array(this.arrayBuffer, this.curPos + this._byteOffset, numBytes);\r\n this.advance(numBytes);\r\n return bytes;\r\n }\r\n\r\n /** Read the specified number of bytes at the specified offset without changing the read position. */\r\n public readBytes(readPos: number, numBytes: number): Uint8Array {\r\n return new Uint8Array(this.arrayBuffer, readPos + this._byteOffset, numBytes);\r\n }\r\n\r\n /** Read the specified number of unsigned 32-bit integers from the current read position and advance the read position. */\r\n public nextUint32s(numUint32s: number): Uint32Array {\r\n const numBytes = numUint32s * 4;\r\n const uint32s = new Uint32Array(this.arrayBuffer, this.curPos + this._byteOffset, numUint32s);\r\n this.advance(numBytes);\r\n return uint32s;\r\n }\r\n\r\n /** Returns the underlying array buffer */\r\n public get arrayBuffer(): ArrayBuffer | SharedArrayBuffer { return this._view.buffer; }\r\n\r\n private read(numBytes: number, read: (view: DataView) => number) {\r\n const result = read(this._view);\r\n this.advance(numBytes);\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ByteStream.js","sourceRoot":"","sources":["../../src/ByteStream.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qCAAkC;AAClC,6BAAwC;AAExC;;;;;;GAMG;AACH,MAAa,UAAU;IACJ,KAAK,CAAW;IAChB,WAAW,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ChD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAChF,CAAC;IAED,0HAA0H;IACnH,WAAW,CAAC,UAAkB;QACnC,MAAM,QAAQ,GAAG,UAAU,GAAG,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC9F,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,0CAA0C;IAC1C,IAAW,WAAW,KAAsC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAE/E,IAAI,CAAC,QAAgB,EAAE,IAAgC;QAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA7ID,gCA6IC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\nimport { assert } from \"./Assert\";\nimport { Id64, Id64String } from \"./Id\";\n\n/** Allows the contents of an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)\n * to be consumed sequentially using methods to extract\n * data of a particular type from the bytes beginning at the current read position.\n * Methods and properties beginning with 'read' and taking no arguments consume data at the current read position and advance it\n * by the size of the data read. The read position can also be directly adjusted by the caller.\n * @public\n */\nexport class ByteStream {\n private readonly _view: DataView;\n private readonly _byteOffset: number;\n private _curPos: number = 0;\n\n /** Construct a new ByteStream with the read position set to the beginning.\n * @param buffer The underlying buffer from which data is to be extracted.\n * @param subView If defined, specifies the subset of the underlying buffer's data to use.\n * This constructor is subject to two common mistakes:\n *\n * 1. Given `bytes: Uint8Array`, `new ByteStream(bytes)` will compile but at run-time will produce an error asserting that\n * the DataView constructor requires an ArrayBuffer. The correct usage is `new ByteStream(bytes.buffer)`.\n * 2. Given `bytes: Uint8Array`, `new ByteStream(bytes.buffer)` creates a stream for the entire range of bytes represented by the underlying\n * ArrayBuffer. If `bytes` represents only a **sub-range** of the underlying buffer's data, the results will be unexpected unless the optional `subView`\n * argument is supplied, with correct offset and length.\n *\n * For both of the above reasons, this constructor is private, and [[fromUint8Array]] or [[fromArrayBuffer]] should be used to create a ByteStream.\n */\n private constructor(buffer: ArrayBuffer | SharedArrayBuffer, subView?: { byteOffset: number, byteLength: number }) {\n if (undefined !== subView) {\n this._view = new DataView(buffer, subView.byteOffset, subView.byteLength);\n this._byteOffset = subView.byteOffset;\n } else {\n this._view = new DataView(buffer);\n this._byteOffset = 0;\n }\n }\n\n /** Construct a new ByteStream for the range of bytes represented by `bytes`, which may be a subset of the range of bytes\n * represented by the underlying ArrayBuffer. The read position will be set to the beginning of the range of bytes.\n * @param bytes The Uint8Array from which data is to be extracted.\n */\n public static fromUint8Array(bytes: Uint8Array): ByteStream {\n const { byteOffset, byteLength } = bytes;\n return new ByteStream(bytes.buffer, { byteOffset, byteLength }); \n }\n\n /** Construct a new ByteStream with the read position set to the beginning.\n * @param buffer The underlying buffer from which data is to be extracted.\n * @param subView If defined, specifies the subset of the underlying buffer's data to use.\n */\n public static fromArrayBuffer(buffer: ArrayBuffer | SharedArrayBuffer, subView?: { byteOffset: number, byteLength: number }): ByteStream {\n return new ByteStream(buffer, subView); \n }\n\n /** The number of bytes in this stream */\n public get length(): number {\n return this._view.byteLength;\n }\n\n /** The number of bytes remaining to be read, from [[curPos]] to the end of the stream. */\n public get remainingLength(): number {\n return this.length - this.curPos;\n }\n\n /** Returns true if the current read position has been advanced past the end of the stream. This generally indicates that an attempt was made to read more data than is available.\n * @see [[isAtTheEnd]]\n */\n public get isPastTheEnd(): boolean {\n return this.curPos > this.length;\n }\n\n /** Returns true if the current read position has advanced precisely to the end of the stream, indicating all of the data has been consumed.\n * @see [[isPastTheEnd]].\n */\n public get isAtTheEnd(): boolean {\n return this.curPos === this.length;\n }\n\n /** The current read position as an index into the stream of bytes. */\n public get curPos(): number { return this._curPos; }\n public set curPos(pos: number) {\n this._curPos = pos;\n assert(!this.isPastTheEnd);\n }\n\n /** Adds the specified number of bytes to the current read position */\n public advance(numBytes: number): boolean {\n this.curPos = (this.curPos + numBytes);\n return !this.isPastTheEnd;\n }\n\n /** Subtracts the specified number of bytes from the current read position */\n public rewind(numBytes: number): boolean {\n if (this.curPos - numBytes < 0)\n return false;\n\n this.curPos = this.curPos - numBytes;\n return true;\n }\n\n /** Resets the current read position to the beginning of the stream */\n public reset(): void { this.curPos = 0; }\n\n /** Read a unsigned 8-bit integer from the current read position and advance by 1 byte. */\n public readUint8(): number { return this.read(1, (view) => view.getUint8(this.curPos)); }\n /** Read an unsigned 16-bit integer from the current read position and advance by 2 bytes. */\n public readUint16(): number { return this.read(2, (view) => view.getUint16(this.curPos, true)); }\n /** Read an unsigned 32-bit integer from the current read position and advance by 4 bytes. */\n public readUint32(): number { return this.read(4, (view) => view.getUint32(this.curPos, true)); }\n /** Read a signed 32-bit integer from the current read position and advance by 4 bytes. */\n public readInt32(): number { return this.read(4, (view) => view.getInt32(this.curPos, true)); }\n /** Read a 32-bit floating point number from the current read position and advance by 4 bytes. */\n public readFloat32(): number { return this.read(4, (view) => view.getFloat32(this.curPos, true)); }\n /** Read a 64-bit floating point number from the current read position and advance by 8 bytes. */\n public readFloat64(): number { return this.read(8, (view) => view.getFloat64(this.curPos, true)); }\n /** Read an unsigned 64-bit integer from the current read position, advance by 8 bytes, and return the 64-bit value as an Id64String. */\n public readId64(): Id64String { return Id64.fromUint32Pair(this.readUint32(), this.readUint32()); }\n /** Read an unsigned 24-bit integer from the current read position and advance by 3 bytes. */\n public readUint24(): number { return this.readUint8() | (this.readUint8() << 8) | (this.readUint8() << 16); }\n\n /** Read the specified number of bytes beginning at the current read position into a Uint8Array and advance by the specified number of byte.\n * @param numBytes The number of bytes to read.\n */\n public nextBytes(numBytes: number): Uint8Array {\n const bytes = new Uint8Array(this.arrayBuffer, this.curPos + this._byteOffset, numBytes);\n this.advance(numBytes);\n return bytes;\n }\n\n /** Read the specified number of bytes at the specified offset without changing the read position. */\n public readBytes(readPos: number, numBytes: number): Uint8Array {\n return new Uint8Array(this.arrayBuffer, readPos + this._byteOffset, numBytes);\n }\n\n /** Read the specified number of unsigned 32-bit integers from the current read position and advance the read position. */\n public nextUint32s(numUint32s: number): Uint32Array {\n const numBytes = numUint32s * 4;\n const uint32s = new Uint32Array(this.arrayBuffer, this.curPos + this._byteOffset, numUint32s);\n this.advance(numBytes);\n return uint32s;\n }\n\n /** Returns the underlying array buffer */\n public get arrayBuffer(): ArrayBuffer | SharedArrayBuffer { return this._view.buffer; }\n\n private read(numBytes: number, read: (view: DataView) => number) {\n const result = read(this._view);\n this.advance(numBytes);\n return result;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassUtils.js","sourceRoot":"","sources":["../../src/ClassUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AASH,gDAMC;AASD,oCAMC;AA5BD;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAIhC,QAAgC,EAAE,UAAsB;IACxD,OAAO,QAAQ,CAAC,SAAS,YAAY,UAAU,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAI1B,QAA6C,EAAE,UAAsB;IACrE,OAAO,QAAQ,KAAK,UAAU,IAAI,kBAAkB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"ClassUtils.js","sourceRoot":"","sources":["../../src/ClassUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AASH,gDAMC;AASD,oCAMC;AA5BD;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAIhC,QAAgC,EAAE,UAAsB;IACxD,OAAO,QAAQ,CAAC,SAAS,YAAY,UAAU,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAI1B,QAA6C,EAAE,UAAsB;IACrE,OAAO,QAAQ,KAAK,UAAU,IAAI,kBAAkB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\n/** Check if class `subclass` is a different class from `superclass` but extends from `superclass`\n * @param subclass the class that may be a subclass of `superclass`\n * @param superclass the class that may be a base class of `subclass`\n * @note The constructors of all types must be `public`.\n * @returns whether `subclass` is a proper subclass of `superclass`\n * @public\n */\nexport function isProperSubclassOf<\n SuperClass extends new (..._: any[]) => any,\n NonSubClass extends new (..._: any[]) => any,\n SubClass extends new (..._: any[]) => InstanceType<SuperClass>,\n>(subclass: SubClass | NonSubClass, superclass: SuperClass): subclass is SubClass {\n return subclass.prototype instanceof superclass;\n}\n\n/** Check if class `subclass` is `superclass` or extends from `superclass`\n * @param subclass the class that may be a subclass of `superclass`.\n * @param superclass the class that may be a base class of `subclass`.\n * @note The constructors of all types must be `public`.\n * @returns whether `subclass` is a subclass of `superclass`\n * @public\n */\nexport function isSubclassOf<\n SuperClass extends new (..._: any[]) => any,\n NonSubClass extends new (..._: any[]) => any,\n SubClass extends new (..._: any[]) => InstanceType<SuperClass>,\n>(subclass: SuperClass | SubClass | NonSubClass, superclass: SuperClass): subclass is SubClass | SuperClass {\n return subclass === superclass || isProperSubclassOf(subclass, superclass);\n}\n"]}
|
package/lib/cjs/Compare.d.ts
CHANGED
|
@@ -45,4 +45,19 @@ export declare function compareBooleansOrUndefined(lhs?: boolean, rhs?: boolean)
|
|
|
45
45
|
* @public
|
|
46
46
|
*/
|
|
47
47
|
export declare function areEqualPossiblyUndefined<T, U>(t: T | undefined, u: U | undefined, areEqual: (t: T, u: U) => boolean): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Compare two simples types (number, string, boolean)
|
|
50
|
+
* This essentially wraps the existing type-specific comparison functions
|
|
51
|
+
* @beta */
|
|
52
|
+
export declare function compareSimpleTypes(lhs: number | string | boolean, rhs: number | string | boolean): number;
|
|
53
|
+
/**
|
|
54
|
+
* An array of simple types (number, string, boolean)
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
export type SimpleTypesArray = number[] | string[] | boolean[];
|
|
58
|
+
/**
|
|
59
|
+
* Compare two arrays of simple types (number, string, boolean)
|
|
60
|
+
* @beta
|
|
61
|
+
*/
|
|
62
|
+
export declare function compareSimpleArrays(lhs?: SimpleTypesArray, rhs?: SimpleTypesArray): number;
|
|
48
63
|
//# sourceMappingURL=Compare.d.ts.map
|
package/lib/cjs/Compare.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Compare.d.ts","sourceRoot":"","sources":["../../src/Compare.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,MAAM,CAAC;AAErE;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,SAAM,GAAG,MAAM,CAOlF;AAED,cAAc;AACd,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,E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wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAmBzG;AACD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;AAE/D;;;GAGG;AAEH,wBAAgB,mBAAmB,CAAE,GAAG,CAAC,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,gBAAgB,UAmBlF"}
|
package/lib/cjs/Compare.js
CHANGED
|
@@ -16,6 +16,8 @@ exports.compareStringsOrUndefined = compareStringsOrUndefined;
|
|
|
16
16
|
exports.compareNumbersOrUndefined = compareNumbersOrUndefined;
|
|
17
17
|
exports.compareBooleansOrUndefined = compareBooleansOrUndefined;
|
|
18
18
|
exports.areEqualPossiblyUndefined = areEqualPossiblyUndefined;
|
|
19
|
+
exports.compareSimpleTypes = compareSimpleTypes;
|
|
20
|
+
exports.compareSimpleArrays = compareSimpleArrays;
|
|
19
21
|
/**
|
|
20
22
|
* An [[OrderedComparator]] for numbers that treats two numbers as equal if the absolute value of their difference is less than a specified tolerance.
|
|
21
23
|
* @public
|
|
@@ -72,4 +74,50 @@ function areEqualPossiblyUndefined(t, u, areEqual) {
|
|
|
72
74
|
else
|
|
73
75
|
return areEqual(t, u);
|
|
74
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Compare two simples types (number, string, boolean)
|
|
79
|
+
* This essentially wraps the existing type-specific comparison functions
|
|
80
|
+
* @beta */
|
|
81
|
+
function compareSimpleTypes(lhs, rhs) {
|
|
82
|
+
let cmp = 0;
|
|
83
|
+
// Make sure the types are the same
|
|
84
|
+
cmp = compareStrings(typeof lhs, typeof rhs);
|
|
85
|
+
if (cmp !== 0) {
|
|
86
|
+
return cmp;
|
|
87
|
+
}
|
|
88
|
+
// Compare actual values
|
|
89
|
+
switch (typeof lhs) {
|
|
90
|
+
case "number":
|
|
91
|
+
return compareNumbers(lhs, rhs);
|
|
92
|
+
case "string":
|
|
93
|
+
return compareStrings(lhs, rhs);
|
|
94
|
+
case "boolean":
|
|
95
|
+
return compareBooleans(lhs, rhs);
|
|
96
|
+
}
|
|
97
|
+
return cmp;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Compare two arrays of simple types (number, string, boolean)
|
|
101
|
+
* @beta
|
|
102
|
+
*/
|
|
103
|
+
function compareSimpleArrays(lhs, rhs) {
|
|
104
|
+
if (undefined === lhs)
|
|
105
|
+
return undefined === rhs ? 0 : -1;
|
|
106
|
+
else if (undefined === rhs)
|
|
107
|
+
return 1;
|
|
108
|
+
else if (lhs.length === 0 && rhs.length === 0) {
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
else if (lhs.length !== rhs.length) {
|
|
112
|
+
return lhs.length - rhs.length;
|
|
113
|
+
}
|
|
114
|
+
let cmp = 0;
|
|
115
|
+
for (let i = 0; i < lhs.length; i++) {
|
|
116
|
+
cmp = compareSimpleTypes(lhs[i], rhs[i]);
|
|
117
|
+
if (cmp !== 0) {
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return cmp;
|
|
122
|
+
}
|
|
75
123
|
//# sourceMappingURL=Compare.js.map
|
package/lib/cjs/Compare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Compare.js","sourceRoot":"","sources":["../../src/Compare.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AA4BH,oDAOC;AAGD,wCAEC;AAGD,0CAEC;AAGD,wCAEC;AAGD,4DAOC;AAGD,8DAEC;AAGD,8DAEC;AAGD,gEAEC;AAKD,8DAOC;
|
|
1
|
+
{"version":3,"file":"Compare.js","sourceRoot":"","sources":["../../src/Compare.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AA4BH,oDAOC;AAGD,wCAEC;AAGD,0C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AAG,CAAC;AACb,CAAC;AAOD;;;GAGG;AAEH,SAAgB,mBAAmB,CAAE,GAAsB,EAAE,GAAsB;IACjF,IAAI,SAAS,KAAK,GAAG;QACnB,OAAO,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/B,IAAI,SAAS,KAAK,GAAG;QACxB,OAAO,CAAC,CAAC;SACN,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9C,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;QACrC,OAAO,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;YACd,MAAM;QACR,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\n/**\n * A function that returns a numerical value indicating how two objects are ordered in relation to one another.\n * Such functions are used by various collection classes throughout the library.\n * Given values `lhs` and `rhs`, the function returns:\n * - Zero if lhs == rhs\n * - A negative number if lhs < rhs\n * - A positive number if lhs > rhs\n *\n * An OrderedComparator `must` implement [strict weak ordering](https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings), which can be summarized by the following rules:\n * - `compare(x, x)` returns zero.\n * - If `compare(x, y)` returns zero, then so does `compare(y, x)` (i.e., `x == y` implies `y == x`).\n * - If `compare(x, y)` returns non-zero, then `compare(y, x)` returns a value with an opposite sign (i.e., `x < y` implies `y > x`).\n * - If `compare(x, y)` and `compare(y, z)` return non-zero values with the same sign, then `compare(x, z)` returns a value with the same sign (i.e., `x < y < z` implies `x < z`).\n *\n * @see SortedArray\n * @see Dictionary\n * @see IndexMap\n * @see PriorityQueue\n * @public\n */\nexport type OrderedComparator<T, U = T> = (lhs: T, rhs: U) => number;\n\n/**\n * An [[OrderedComparator]] for numbers that treats two numbers as equal if the absolute value of their difference is less than a specified tolerance.\n * @public\n */\nexport function compareWithTolerance(a: number, b: number, tolerance = 0.1): number {\n if (a < b - tolerance)\n return -1;\n else if (a > b + tolerance)\n return 1;\n else\n return 0;\n}\n\n/** @public */\nexport function compareNumbers(a: number, b: number): number {\n return a - b;\n}\n\n/** @public */\nexport function compareBooleans(a: boolean, b: boolean): number {\n return a !== b ? (a < b ? -1 : 1) : 0;\n}\n\n/** @public */\nexport function compareStrings(a: string, b: string): number {\n return a === b ? 0 : (a < b ? -1 : 1);\n}\n\n/** @public */\nexport function comparePossiblyUndefined<T>(compareDefined: (lhs: T, rhs: T) => number, lhs?: T, rhs?: T): number {\n if (undefined === lhs)\n return undefined === rhs ? 0 : -1;\n else if (undefined === rhs)\n return 1;\n else\n return compareDefined(lhs, rhs);\n}\n\n/** @public */\nexport function compareStringsOrUndefined(lhs?: string, rhs?: string): number {\n return comparePossiblyUndefined(compareStrings, lhs, rhs);\n}\n\n/** @public */\nexport function compareNumbersOrUndefined(lhs?: number, rhs?: number): number {\n return comparePossiblyUndefined(compareNumbers, lhs, rhs);\n}\n\n/** @public */\nexport function compareBooleansOrUndefined(lhs?: boolean, rhs?: boolean): number {\n return comparePossiblyUndefined(compareBooleans, lhs, rhs);\n}\n\n/** Compare two possibly-undefined values for equality. If both are undefined, the comparison is performed by the supplied `areEqual` function.\n * @public\n */\nexport function areEqualPossiblyUndefined<T, U>(t: T | undefined, u: U | undefined, areEqual: (t: T, u: U) => boolean): boolean {\n if (undefined === t)\n return undefined === u;\n else if (undefined === u)\n return false;\n else\n return areEqual(t, u);\n}\n\n/**\n * Compare two simples types (number, string, boolean)\n * This essentially wraps the existing type-specific comparison functions\n * @beta */\nexport function compareSimpleTypes(lhs: number | string | boolean, rhs: number | string | boolean): number {\n let cmp = 0;\n\n // Make sure the types are the same\n cmp = compareStrings(typeof lhs, typeof rhs);\n if (cmp !== 0) {\n return cmp;\n }\n\n // Compare actual values\n switch (typeof lhs) {\n case \"number\":\n return compareNumbers(lhs, rhs as number);\n case \"string\":\n return compareStrings(lhs, rhs as string);\n case \"boolean\":\n return compareBooleans(lhs, rhs as boolean);\n }\n return cmp;\n}\n/**\n * An array of simple types (number, string, boolean)\n * @beta\n */\nexport type SimpleTypesArray = number[] | string[] | boolean[];\n\n/**\n * Compare two arrays of simple types (number, string, boolean)\n * @beta\n */\n\nexport function compareSimpleArrays (lhs?: SimpleTypesArray, rhs?: SimpleTypesArray ) {\n if (undefined === lhs)\n return undefined === rhs ? 0 : -1;\n else if (undefined === rhs)\n return 1;\n else if (lhs.length === 0 && rhs.length === 0) {\n return 0;\n } else if (lhs.length !== rhs.length) {\n return lhs.length - rhs.length;\n }\n\n let cmp = 0;\n for (let i = 0; i < lhs.length; i++) {\n cmp = compareSimpleTypes(lhs[i], rhs[i]);\n if (cmp !== 0) {\n break;\n }\n }\n return cmp;\n}"]}
|
|
@@ -121,6 +121,9 @@ var CompressedId64Set;
|
|
|
121
121
|
CompressedId64Set.compressIds = compressIds;
|
|
122
122
|
/** This exists strictly for the purposes of compressed sets of 64-bit Ids, to avoid the overhead of BigInt for handling 64-bit integers. */
|
|
123
123
|
class Uint64 {
|
|
124
|
+
lower;
|
|
125
|
+
upper;
|
|
126
|
+
static _base = 0x100000000;
|
|
124
127
|
static assertUint32(num) {
|
|
125
128
|
(0, Assert_1.assert)(num >= 0);
|
|
126
129
|
(0, Assert_1.assert)(num < Uint64._base);
|
|
@@ -182,7 +185,6 @@ var CompressedId64Set;
|
|
|
182
185
|
return Id_1.Id64.fromUint32Pair(this.lower, this.upper);
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
|
-
Uint64._base = 0x100000000;
|
|
186
188
|
/** Supplies an iterator over the [[Id64String]]s in a [[CompressedId64Set]].
|
|
187
189
|
* The Ids are iterated in ascending order based on their unsigned 64-bit integer values.
|
|
188
190
|
*/
|
|
@@ -327,10 +329,11 @@ exports.OrderedId64Array = OrderedId64Array;
|
|
|
327
329
|
* @public
|
|
328
330
|
*/
|
|
329
331
|
class MutableCompressedId64Set {
|
|
332
|
+
_ids;
|
|
333
|
+
_inserted = new OrderedId64Array();
|
|
334
|
+
_deleted = new OrderedId64Array();
|
|
330
335
|
/** Construct a new set, optionally initialized to contain the Ids represented by `ids`. */
|
|
331
336
|
constructor(ids) {
|
|
332
|
-
this._inserted = new OrderedId64Array();
|
|
333
|
-
this._deleted = new OrderedId64Array();
|
|
334
337
|
this._ids = ids ?? "";
|
|
335
338
|
}
|
|
336
339
|
/** 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. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompressedId64Set.js","sourceRoot":"","sources":["../../src/CompressedId64Set.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qCAAkC;AAClC,6BAA4D;AAC5D,+DAA4D;AAC5D,+CAA4C;AAK5C;;;;;;;;GAQG;AACH,IAAiB,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,EA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GAAG,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,KAAyE;QACrF,IAAI,KAAK,YAAY,wBAAwB,EAAE,CAAC;YAC9C,IAAI,KAAK,KAAK,IAAI;gBAChB,OAAO,IAAI,CAAC;YAEd,IAAI,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,yCAAmB,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,yCAAmB,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,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 [[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"]}
|
|
1
|
+
{"version":3,"file":"CompressedId64Set.js","sourceRoot":"","sources":["../../src/CompressedId64Set.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qCAAkC;AAClC,6BAA4D;AAC5D,+DAA4D;AAC5D,+CAA4C;AAK5C;;;;;;;;GAQG;AACH,IAAiB,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,CAA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,MAAM,CAAC,KAAyE;QACrF,IAAI,KAAK,YAAY,wBAAwB,EAAE,CAAC;YAC9C,IAAI,KAAK,KAAK,IAAI;gBAChB,OAAO,IAAI,CAAC;YAEd,IAAI,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,yCAAmB,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,yCAAmB,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,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Ids\n */\n\nimport { assert } from \"./Assert\";\nimport { Id64, Id64Array, Id64Set, Id64String } from \"./Id\";\nimport { OrderedId64Iterable } from \"./OrderedId64Iterable\";\nimport { SortedArray } from \"./SortedArray\";\n\n/** @public */\nexport type CompressedId64Set = string;\n\n/** A compact string representation of an [[Id64Set]]. Such a representation is useful when serializing potentially very large\n * sets of Ids.\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids represented by a compact string.\n * @see [[CompressedId64Set.compressSet]] and [[CompressedId64Set.compressArray]] to produce a compact string from a collection of Ids.\n * @see [[CompressedId64Set.decompressSet]] and [[CompressedId64Set.decompressArray]] to produce a collection of Ids from a compact string.\n * @see [[OrderedId64Iterable]] for a generic representation of an ordered set of Ids (compressed or otherwise).\n * @see [[MutableCompressedId64Set]] for a mutable version.\n * @public\n */\nexport namespace CompressedId64Set { // eslint-disable-line @typescript-eslint/no-redeclare\n function isHexDigit(ch: number): boolean {\n // ascii values:\n // '0' = 48\n // '9' = 57\n // 'a' = 65\n // 'f' = 70\n\n return (ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 70);\n }\n\n function compactRange(increment: Uint64, length: number): string {\n assert(length > 0);\n const inc = `+${increment.toString()}`;\n if (length <= 1)\n return inc;\n\n const len = length.toString(16).toUpperCase();\n return `${inc}*${len}`;\n }\n\n /** Given a set of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\n * @note Invalid Ids are ignored.\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\n * @see [[CompressedId64Set.compressArray]] to perform the same operation on an [[Id64Array]].\n * @see [[CompressedId64Set.decompressSet]] to perform the inverse operation.\n */\n export function compressSet(ids: Id64Set): CompressedId64Set {\n return sortAndCompress(ids);\n }\n\n /** Create a sorted array from `ids`, then return a compact string representation of those Ids.\n * @see [[CompressedId64Set.compressIds]] if `ids` is known to already be sorted.\n */\n export function sortAndCompress(ids: Iterable<Id64String>): CompressedId64Set {\n // `string` is an Iterable<string>. In that case assume caller passed a single Id64String.\n const arr = typeof ids === \"string\" ? [ids] : Array.from(ids);\n OrderedId64Iterable.sortArray(arr);\n return compressArray(arr);\n }\n\n /** Give a **numerically-ordered** array of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\n * Duplicate Ids are included only once in the string representation.\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.\n * @note The array must be sorted according to the 64-bit numerical value of each Id.\n * @note Invalid Ids are ignored.\n * @see [[CompressedId64Set.decompressArray]] to perform the inverse operation.\n * @see [[OrderedId64Iterable.sortArray]] to ensure the Ids are properly sorted.\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\n */\n export function compressArray(ids: Id64Array): CompressedId64Set {\n return compressIds(ids);\n }\n\n /** Give a **numerically-ordered** collection of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\n * Duplicate Ids are included only once in the string representation.\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.\n * @note The collection must be sorted according to the 64-bit numerical value of each Id.\n * @note Invalid Ids are ignored.\n * @see [[CompressedId64Set.iterable]] to perform the inverse operation.\n * @see [[OrderedId64Iterable.sortArray]] or [[OrderedId64Iterable.compare]] to ensure the Ids are properly sorted.\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\n */\n export function compressIds(ids: OrderedId64Iterable): CompressedId64Set {\n if (\"string\" === typeof ids)\n return ids;\n\n let str = \"\";\n\n const prevId = new Uint64();\n const rangeIncrement = new Uint64();\n let rangeLen = 0;\n\n const curId = new Uint64();\n const curIncrement = new Uint64();\n for (const id of ids) {\n if (!Id64.isValidId64(id))\n continue; // ignore garbage and invalid Ids (\"0\")\n\n curId.setFromId(id);\n curIncrement.setFromDifference(curId, prevId);\n\n const cmp = prevId.compare(curId);\n if (0 === cmp)\n continue; // ignore duplicates\n else if (cmp > 0)\n throw new Error(\"CompressedId64Set.compressArray requires a sorted array as input\");\n\n prevId.copyFrom(curId);\n\n if (0 === rangeLen) {\n rangeIncrement.copyFrom(curIncrement);\n rangeLen = 1;\n } else if (curIncrement.equals(rangeIncrement)) {\n ++rangeLen;\n } else {\n str += compactRange(rangeIncrement, rangeLen);\n rangeIncrement.copyFrom(curIncrement);\n rangeLen = 1;\n }\n }\n\n if (0 < rangeLen)\n str += compactRange(rangeIncrement, rangeLen);\n\n return str;\n }\n\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. */\n class Uint64 implements Id64.Uint32Pair {\n private static readonly _base = 0x100000000;\n\n private static assertUint32(num: number): void {\n assert(num >= 0);\n assert(num < Uint64._base);\n assert(Math.floor(num) === num);\n }\n\n private assertConstraints(): void {\n Uint64.assertUint32(this.lower);\n Uint64.assertUint32(this.upper);\n }\n\n constructor(public lower = 0, public upper = 0) {\n this.assertConstraints();\n }\n\n public compare(rhs: Uint64): number {\n const diff = this.upper - rhs.upper;\n return 0 === diff ? this.lower - rhs.lower : diff;\n }\n\n public equals(rhs: Uint64): boolean { return 0 === this.compare(rhs); }\n public isLessThan(rhs: Uint64): boolean { return this.compare(rhs) < 0; }\n public isGreaterThan(rhs: Uint64): boolean { return this.compare(rhs) > 0; }\n\n public get isZero(): boolean { return 0 === this.lower && 0 === this.upper; }\n\n public setFromDifference(lhs: Uint64, rhs: Uint64): void {\n assert(!rhs.isGreaterThan(lhs));\n\n this.lower = lhs.lower - rhs.lower;\n this.upper = lhs.upper - rhs.upper;\n if (this.lower < 0) {\n this.lower += Uint64._base;\n this.upper -= 1;\n }\n }\n\n public add(rhs: Uint64): void {\n let lower = rhs.lower;\n let upper = rhs.upper;\n if (lower + this.lower >= Uint64._base) {\n lower -= Uint64._base;\n upper += 1;\n }\n\n this.lower += lower;\n this.upper += upper;\n this.assertConstraints();\n }\n\n public setFromId(id: Id64String): void {\n Id64.getUint32Pair(id, this);\n }\n\n public copyFrom(other: Uint64): void {\n this.lower = other.lower;\n this.upper = other.upper;\n }\n\n public toString(): string {\n if (0 === this.upper)\n return this.lower.toString(16).toUpperCase();\n\n const upper = this.upper.toString(16);\n const lower = this.lower.toString(16).padStart(8, \"0\");\n assert(lower.length === 8);\n return `${upper}${lower}`.toUpperCase();\n }\n\n public toId64String(): string {\n return Id64.fromUint32Pair(this.lower, this.upper);\n }\n }\n\n /** Supplies an iterator over the [[Id64String]]s in a [[CompressedId64Set]].\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\n */\n export function* iterator(ids: CompressedId64Set): Iterator<Id64String> {\n if (0 === ids.length)\n return; // empty set.\n\n if (\"+\" !== ids[0])\n throw new Error(\"Invalid CompressedId64Set\");\n\n let curIndex = 1; // skip the leading '+'\n const curId = new Uint64();\n\n function parseUint32(): number {\n let value = 0;\n let nChars = 0;\n while (curIndex < ids.length && nChars < 8) {\n ++nChars;\n const ch = ids.charCodeAt(curIndex);\n if (!isHexDigit(ch))\n break; // not a hex digit in [0..9] or [A..F]\n\n value <<= 4;\n value |= (ch >= 65 ? ch - 65 + 10 : ch - 48); // ch - 'A' + 10 or ch - '0'\n value = value >>> 0; // restore unsignedness because silly javascript.\n ++curIndex;\n }\n\n return value;\n }\n\n function parseUint64(uint64: Uint64): void {\n let lower = 0;\n let upper = 0;\n\n // Read up to the first 8 digits.\n const startIndex = curIndex;\n const first = parseUint32();\n\n const nFirstDigits = curIndex - startIndex;\n assert(nFirstDigits <= 8);\n\n if (8 === nFirstDigits && curIndex + 1 < ids.length && isHexDigit(ids.charCodeAt(curIndex + 1))) {\n // We've got up to 8 more digits remaining\n const secondIndex = curIndex;\n const second = parseUint32();\n\n // Transfer excess digits from upper to lower.\n const nSecondDigits = curIndex - secondIndex;\n assert(nSecondDigits > 0 && nSecondDigits <= 8);\n\n const nDigitsToTransfer = 8 - nSecondDigits;\n upper = first >>> (4 * nDigitsToTransfer);\n const transfer = first - ((upper << (4 * nDigitsToTransfer)) >>> 0);\n lower = (second | ((transfer << (4 * nSecondDigits)) >>> 0)) >>> 0;\n } else {\n lower = first;\n }\n\n uint64.lower = lower;\n uint64.upper = upper;\n }\n\n const increment = new Uint64();\n while (curIndex < ids.length) {\n let multiplier = 1;\n parseUint64(increment);\n if (increment.isZero)\n throw new Error(\"Invalid CompressedId64Set\");\n\n if (curIndex < ids.length) {\n switch (ids[curIndex++]) {\n case \"*\":\n multiplier = parseUint32();\n if (0 === multiplier)\n throw new Error(\"Invalid CompressedId64Set\");\n\n if (curIndex !== ids.length && ids[curIndex++] !== \"+\")\n return;\n\n break;\n case \"+\":\n break;\n default:\n throw new Error(\"Invalid CompressedId64Set\");\n }\n }\n\n for (let i = 0; i < multiplier; i++) {\n curId.add(increment);\n yield curId.toId64String();\n }\n }\n }\n\n /** Supplies an iterable over the [[Id64String]]s in a [[CompressedId64Set]].\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\n */\n export function iterable(ids: CompressedId64Set): OrderedId64Iterable {\n return {\n [Symbol.iterator]: () => iterator(ids),\n };\n }\n\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Set]].\n * @param compressedIds The compact string representation.\n * @param out If supplied, the Ids will be inserted into this set rather than allocating and returning a new set.\n * @returns The set containing the decompressed Ids.\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\n * @see [[CompressedId64Set.compressSet]] to perform the inverse operation.\n * @see [[CompressedId64Set.decompressArray]] to decompress as an [[Id64Array]] instead.\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\n */\n export function decompressSet(compressedIds: CompressedId64Set, out?: Id64Set): Id64Set {\n const set = out ?? new Set<string>();\n for (const id of iterable(compressedIds))\n set.add(id);\n\n return set;\n }\n\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Array]].\n * @param compressedIds The compact string representation.\n * @param out If supplied, the Ids will be appended to this array rather than allocating and returning a new array.\n * @returns The array containing the decompressed Ids.\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\n * @note The Ids are decompressed and appended to the array in ascending order based on their 64-bit numerical values.\n * @see [[CompressedId64Set.compressArray]] to perform the inverse operation.\n * @see [[CompressedId64Set.decompressSet]] to decompress as an [[Id64Set]] instead.\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\n */\n export function decompressArray(compressedIds: CompressedId64Set, out?: Id64Array): Id64Array {\n const arr = out ?? [];\n for (const id of iterable(compressedIds))\n arr.push(id);\n\n return arr;\n }\n}\n\n/** A [[SortedArray]] of unique [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer values of the Ids.\n * @see [[CompressedId64Set]] for an immutable compact string representation.\n * @public\n */\nexport class OrderedId64Array extends SortedArray<Id64String> {\n /** Construct a new, empty array. */\n public constructor() {\n super((lhs, rhs) => OrderedId64Iterable.compare(lhs, rhs));\n }\n\n /** An iterable that iterates over the Ids in sorted order. */\n public get ids(): OrderedId64Iterable { return this._array; }\n\n /** The underlying array of Ids. */\n public get array(): ReadonlyArray<Id64String> { return this._array; }\n}\n\n/** A mutable set of valid [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer value of the Ids.\n * Internally the set of Ids is maintained as a [[CompressedId64Set]] string representation.\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]] -\n * therefore, if multiple removals and/or insertions are required, it is most efficient to perform them all before invoking other methods.\n * @public\n */\nexport class MutableCompressedId64Set implements OrderedId64Iterable {\n private _ids: CompressedId64Set;\n private readonly _inserted = new OrderedId64Array();\n private readonly _deleted = new OrderedId64Array();\n\n /** Construct a new set, optionally initialized to contain the Ids represented by `ids`. */\n public constructor(ids?: CompressedId64Set) {\n this._ids = ids ?? \"\";\n }\n\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. */\n public get ids(): CompressedId64Set {\n this.updateIds();\n return this._ids;\n }\n\n /** Add the specified Id to the set.\n * @throws Error if `id` is not a valid [[Id64String]].\n */\n public add(id: Id64String): void {\n if (!Id64.isValidId64(id))\n throw new Error(\"MutableCompressedId64Set.add: invalid Id\");\n\n this._deleted.remove(id);\n this._inserted.insert(id);\n }\n\n /** Remove the specified Id from the set.\n * @throws Error if `id` is not a valid [[Id64String]].\n */\n public delete(id: Id64String): void {\n if (!Id64.isValidId64(id))\n throw new Error(\"MutableCompressedId64Set.delete: invalid Id\");\n\n this._inserted.remove(id);\n this._deleted.insert(id);\n }\n\n /** Remove all Ids from the set. */\n public clear(): void {\n this._ids = \"\";\n this._inserted.clear();\n this._deleted.clear();\n }\n\n /** Remove all Ids from the set, then add the specified Ids. */\n public reset(ids?: CompressedId64Set): void {\n this.clear();\n this._ids = ids ?? \"\";\n }\n\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. */\n public [Symbol.iterator]() {\n return CompressedId64Set.iterator(this.ids);\n }\n\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. */\n public computeUnion(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\n if (this.isEmpty)\n return CompressedId64Set.compressIds(ids);\n else if (OrderedId64Iterable.isEmptySet(ids) || this.equals(ids))\n return this.ids;\n\n return CompressedId64Set.compressIds(OrderedId64Iterable.union(this, ids));\n }\n\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. */\n public computeIntersection(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\n if (this.equals(ids))\n return this.ids;\n else if (this.isEmpty || OrderedId64Iterable.isEmptySet(ids))\n return \"\";\n\n return CompressedId64Set.compressIds(OrderedId64Iterable.intersection(this, ids));\n }\n\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. */\n public computeDifference(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\n if (this.isEmpty || this.equals(ids))\n return \"\";\n\n return CompressedId64Set.compressIds(OrderedId64Iterable.difference(this, ids));\n }\n\n /** Return true if this set contains no Ids. */\n public get isEmpty(): boolean {\n return OrderedId64Iterable.isEmptySet(this.ids);\n }\n\n /** Return true if the set of Ids represented by `other` is identical to those in this set.\n * @note This considers only the **distinct** Ids in `other` - duplicates are ignored.\n */\n public equals(other: CompressedId64Set | MutableCompressedId64Set | OrderedId64Iterable): boolean {\n if (other instanceof MutableCompressedId64Set) {\n if (other === this)\n return true;\n\n if (typeof other !== \"string\")\n other = other.ids;\n }\n\n if (typeof other === \"string\")\n return other === this.ids;\n\n this.updateIds();\n return OrderedId64Iterable.areEqualSets(this, other);\n }\n\n private get _isDirty(): boolean {\n return !this._inserted.isEmpty || !this._deleted.isEmpty;\n }\n\n private updateIds(): void {\n if (!this._isDirty)\n return;\n\n const difference = OrderedId64Iterable.difference(CompressedId64Set.iterable(this._ids), this._deleted.ids);\n const union = { [Symbol.iterator]: () => OrderedId64Iterable.unionIterator(difference, this._inserted.ids) };\n this._ids = CompressedId64Set.compressIds(union);\n\n this._inserted.clear();\n this._deleted.clear();\n }\n}\n"]}
|
package/lib/cjs/Dictionary.js
CHANGED
|
@@ -10,8 +10,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.Dictionary = void 0;
|
|
11
11
|
const SortedArray_1 = require("./SortedArray");
|
|
12
12
|
class DictionaryIterator {
|
|
13
|
+
_keys;
|
|
14
|
+
_values;
|
|
15
|
+
_curIndex = -1;
|
|
13
16
|
constructor(keys, values) {
|
|
14
|
-
this._curIndex = -1;
|
|
15
17
|
this._keys = keys;
|
|
16
18
|
this._values = values;
|
|
17
19
|
}
|
|
@@ -46,6 +48,11 @@ class DictionaryIterator {
|
|
|
46
48
|
* @public
|
|
47
49
|
*/
|
|
48
50
|
class Dictionary {
|
|
51
|
+
_keys = [];
|
|
52
|
+
_compareKeys;
|
|
53
|
+
_cloneKey;
|
|
54
|
+
_values = [];
|
|
55
|
+
_cloneValue;
|
|
49
56
|
/**
|
|
50
57
|
* Construct a new Dictionary<K, V>.
|
|
51
58
|
* @param compareKeys The function used to compare keys within the dictionary.
|
|
@@ -53,8 +60,6 @@ class Dictionary {
|
|
|
53
60
|
* @param cloneValue The function invoked to clone a value for insertion into the dictionary. The default implementation simply returns its input.
|
|
54
61
|
*/
|
|
55
62
|
constructor(compareKeys, cloneKey = SortedArray_1.shallowClone, cloneValue = SortedArray_1.shallowClone) {
|
|
56
|
-
this._keys = [];
|
|
57
|
-
this._values = [];
|
|
58
63
|
this._compareKeys = compareKeys;
|
|
59
64
|
this._cloneKey = cloneKey;
|
|
60
65
|
this._cloneValue = cloneValue;
|