@itwin/core-bentley 3.4.0 → 3.4.2
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 +13 -1
- package/lib/cjs/TupleKeyedMap.d.ts +37 -0
- package/lib/cjs/TupleKeyedMap.d.ts.map +1 -0
- package/lib/cjs/TupleKeyedMap.js +103 -0
- package/lib/cjs/TupleKeyedMap.js.map +1 -0
- package/lib/cjs/UtilityTypes.d.ts +8 -0
- package/lib/cjs/UtilityTypes.d.ts.map +1 -1
- package/lib/cjs/UtilityTypes.js +15 -1
- package/lib/cjs/UtilityTypes.js.map +1 -1
- package/lib/cjs/core-bentley.d.ts +1 -0
- package/lib/cjs/core-bentley.d.ts.map +1 -1
- package/lib/cjs/core-bentley.js +1 -0
- package/lib/cjs/core-bentley.js.map +1 -1
- package/lib/esm/TupleKeyedMap.d.ts +37 -0
- package/lib/esm/TupleKeyedMap.d.ts.map +1 -0
- package/lib/esm/TupleKeyedMap.js +99 -0
- package/lib/esm/TupleKeyedMap.js.map +1 -0
- package/lib/esm/UtilityTypes.d.ts +8 -0
- package/lib/esm/UtilityTypes.d.ts.map +1 -1
- package/lib/esm/UtilityTypes.js +13 -0
- package/lib/esm/UtilityTypes.js.map +1 -1
- package/lib/esm/core-bentley.d.ts +1 -0
- package/lib/esm/core-bentley.d.ts.map +1 -1
- package/lib/esm/core-bentley.js +1 -0
- package/lib/esm/core-bentley.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Change Log - @itwin/core-bentley
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 24 Oct 2022 13:23:45 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.4.2
|
|
6
|
+
Mon, 24 Oct 2022 13:23:45 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 3.4.1
|
|
11
|
+
Mon, 17 Oct 2022 20:06:51 GMT
|
|
12
|
+
|
|
13
|
+
### Updates
|
|
14
|
+
|
|
15
|
+
- Add EntityReferences
|
|
4
16
|
|
|
5
17
|
## 3.4.0
|
|
6
18
|
Thu, 13 Oct 2022 20:24:47 GMT
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Collections
|
|
3
|
+
*/
|
|
4
|
+
/** A map similar to the standard JavaScript Map collection except that the keys must be a tuple
|
|
5
|
+
* (javascript array), and two keys are considered equal if their elements in order are strict-equal,
|
|
6
|
+
* and the tuples have the same amount of elements
|
|
7
|
+
*
|
|
8
|
+
* This means you can use array literals to key data in Maps that would otherwise be reference-compared
|
|
9
|
+
* if using JavaScript's built in Map
|
|
10
|
+
*
|
|
11
|
+
* Note that JavaScript's Map type, unlike this one that uses strict equality, uses instead
|
|
12
|
+
* SameValueZero equality comparison
|
|
13
|
+
* @see https://262.ecma-international.org/6.0/#sec-samevaluezero
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* const map = new TupleKeyedMap([[1,"y"], "value"]);
|
|
17
|
+
* const value = map.get([1, "y"]); // a normal map would identify these keys as different because they are independent objects
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* It is implemented by each index of the tuple key being used as a singular key into a submap
|
|
21
|
+
* @note this only implements a subset of the Map interface
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare class TupleKeyedMap<K extends readonly any[], V> {
|
|
25
|
+
private _map;
|
|
26
|
+
constructor(entries?: readonly (readonly [K, V])[] | null);
|
|
27
|
+
clear(): void;
|
|
28
|
+
private makeKeyError;
|
|
29
|
+
get(key: K): V | undefined;
|
|
30
|
+
has(key: K): boolean;
|
|
31
|
+
set(key: K, value: V): this;
|
|
32
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
33
|
+
private _size;
|
|
34
|
+
get size(): number;
|
|
35
|
+
get [Symbol.toStringTag](): string;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=TupleKeyedMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TupleKeyedMap.d.ts","sourceRoot":"","sources":["../../src/TupleKeyedMap.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,aAAa,CAAC,CAAC,SAAS,SAAS,GAAG,EAAE,EAAE,CAAC;IACpD,OAAO,CAAC,IAAI,CAAoC;gBAG7B,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAOzD,KAAK,IAAI,IAAI;IAIpB,OAAO,CAAC,YAAY;IAMb,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAc1B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAmB1B,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAcrD,OAAO,CAAC,KAAK,CAAa;IAC1B,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAExC;CACF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Collections
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.TupleKeyedMap = void 0;
|
|
11
|
+
/** A map similar to the standard JavaScript Map collection except that the keys must be a tuple
|
|
12
|
+
* (javascript array), and two keys are considered equal if their elements in order are strict-equal,
|
|
13
|
+
* and the tuples have the same amount of elements
|
|
14
|
+
*
|
|
15
|
+
* This means you can use array literals to key data in Maps that would otherwise be reference-compared
|
|
16
|
+
* if using JavaScript's built in Map
|
|
17
|
+
*
|
|
18
|
+
* Note that JavaScript's Map type, unlike this one that uses strict equality, uses instead
|
|
19
|
+
* SameValueZero equality comparison
|
|
20
|
+
* @see https://262.ecma-international.org/6.0/#sec-samevaluezero
|
|
21
|
+
*
|
|
22
|
+
* ```js
|
|
23
|
+
* const map = new TupleKeyedMap([[1,"y"], "value"]);
|
|
24
|
+
* const value = map.get([1, "y"]); // a normal map would identify these keys as different because they are independent objects
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* It is implemented by each index of the tuple key being used as a singular key into a submap
|
|
28
|
+
* @note this only implements a subset of the Map interface
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
class TupleKeyedMap {
|
|
32
|
+
// argument types match those of Map
|
|
33
|
+
constructor(entries) {
|
|
34
|
+
this._map = new Map();
|
|
35
|
+
this._size = 0;
|
|
36
|
+
if (entries)
|
|
37
|
+
for (const [k, v] of entries) {
|
|
38
|
+
this.set(k, v);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
clear() {
|
|
42
|
+
return this._map.clear();
|
|
43
|
+
}
|
|
44
|
+
makeKeyError() {
|
|
45
|
+
return Error("A Bad key was used, it didn't match the key type of the the map.");
|
|
46
|
+
}
|
|
47
|
+
get(key) {
|
|
48
|
+
let cursor = this._map;
|
|
49
|
+
for (const subkey of key) {
|
|
50
|
+
if (!(cursor instanceof Map))
|
|
51
|
+
throw this.makeKeyError();
|
|
52
|
+
cursor = cursor.get(subkey);
|
|
53
|
+
if (cursor === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
if (cursor instanceof Map)
|
|
57
|
+
throw this.makeKeyError();
|
|
58
|
+
return cursor;
|
|
59
|
+
}
|
|
60
|
+
has(key) {
|
|
61
|
+
return this.get(key) !== undefined;
|
|
62
|
+
}
|
|
63
|
+
set(key, value) {
|
|
64
|
+
let cursor = this._map;
|
|
65
|
+
for (let i = 0; i < key.length - 1; ++i) {
|
|
66
|
+
const subkey = key[i];
|
|
67
|
+
let next = cursor.get(subkey);
|
|
68
|
+
if (next === undefined) {
|
|
69
|
+
next = new Map();
|
|
70
|
+
cursor.set(subkey, next);
|
|
71
|
+
}
|
|
72
|
+
cursor = next;
|
|
73
|
+
}
|
|
74
|
+
const finalSubkey = key[key.length - 1];
|
|
75
|
+
if (!(cursor instanceof Map))
|
|
76
|
+
throw this.makeKeyError();
|
|
77
|
+
cursor.set(finalSubkey, value);
|
|
78
|
+
this._size++;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
*[Symbol.iterator]() {
|
|
82
|
+
function* impl(map, keyPrefix) {
|
|
83
|
+
for (const [k, v] of map) {
|
|
84
|
+
const nextKey = [...keyPrefix, k];
|
|
85
|
+
if (v instanceof Map) {
|
|
86
|
+
yield* impl(v, nextKey);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
yield [nextKey, v];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
yield* impl(this._map, []);
|
|
94
|
+
}
|
|
95
|
+
get size() {
|
|
96
|
+
return this._size;
|
|
97
|
+
}
|
|
98
|
+
get [Symbol.toStringTag]() {
|
|
99
|
+
return this.constructor.name;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.TupleKeyedMap = TupleKeyedMap;
|
|
103
|
+
//# sourceMappingURL=TupleKeyedMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TupleKeyedMap.js","sourceRoot":"","sources":["../../src/TupleKeyedMap.ts"],"names":[],"mappings":";AAAA;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AC7B,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;CACF;AAhFD,sCAgFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Collections\r\n */\r\n\r\n/** A map similar to the standard JavaScript Map collection except that the keys must be a tuple\r\n * (javascript array), and two keys are considered equal if their elements in order are strict-equal,\r\n * and the tuples have the same amount of elements\r\n *\r\n * This means you can use array literals to key data in Maps that would otherwise be reference-compared\r\n * if using JavaScript's built in Map\r\n *\r\n * Note that JavaScript's Map type, unlike this one that uses strict equality, uses instead\r\n * SameValueZero equality comparison\r\n * @see https://262.ecma-international.org/6.0/#sec-samevaluezero\r\n *\r\n * ```js\r\n * const map = new TupleKeyedMap([[1,\"y\"], \"value\"]);\r\n * const value = map.get([1, \"y\"]); // a normal map would identify these keys as different because they are independent objects\r\n * ```\r\n *\r\n * It is implemented by each index of the tuple key being used as a singular key into a submap\r\n * @note this only implements a subset of the Map interface\r\n * @internal\r\n */\r\nexport class TupleKeyedMap<K extends readonly any[], V> {\r\n private _map = new Map<K[0], Map<any, V> | V>();\r\n\r\n // argument types match those of Map\r\n public constructor(entries?: readonly (readonly [K, V])[] | null) {\r\n if (entries)\r\n for (const [k, v] of entries) {\r\n this.set(k, v);\r\n }\r\n }\r\n\r\n public clear(): void {\r\n return this._map.clear();\r\n }\r\n\r\n private makeKeyError() {\r\n return Error(\r\n \"A Bad key was used, it didn't match the key type of the the map.\"\r\n );\r\n }\r\n\r\n public get(key: K): V | undefined {\r\n let cursor: Map<any, any> | V = this._map;\r\n for (const subkey of key) {\r\n if (!(cursor instanceof Map))\r\n throw this.makeKeyError();\r\n cursor = cursor.get(subkey);\r\n if (cursor === undefined)\r\n return undefined;\r\n }\r\n if (cursor instanceof Map)\r\n throw this.makeKeyError();\r\n return cursor;\r\n }\r\n\r\n public has(key: K): boolean {\r\n return this.get(key) !== undefined;\r\n }\r\n\r\n public set(key: K, value: V): this {\r\n let cursor: Map<any, any> = this._map;\r\n for (let i = 0; i < key.length - 1; ++i) {\r\n const subkey = key[i];\r\n let next = cursor.get(subkey);\r\n if (next === undefined) {\r\n next = new Map();\r\n cursor.set(subkey, next);\r\n }\r\n cursor = next;\r\n }\r\n const finalSubkey = key[key.length - 1];\r\n if (!(cursor instanceof Map))\r\n throw this.makeKeyError();\r\n cursor.set(finalSubkey, value);\r\n this._size++;\r\n return this;\r\n }\r\n\r\n public *[Symbol.iterator](): IterableIterator<[K, V]> {\r\n function *impl(map: Map<any, any>, keyPrefix: readonly any[]): IterableIterator<[K, V]> {\r\n for (const [k, v] of map) {\r\n const nextKey = [...keyPrefix, k];\r\n if (v instanceof Map) {\r\n yield* impl(v, nextKey);\r\n } else {\r\n yield [nextKey as any as K, v];\r\n }\r\n }\r\n }\r\n yield* impl(this._map, []);\r\n }\r\n\r\n private _size: number = 0;\r\n public get size(): number {\r\n return this._size;\r\n }\r\n\r\n public get [Symbol.toStringTag](): string {\r\n return this.constructor.name;\r\n }\r\n}\r\n"]}
|
|
@@ -84,4 +84,12 @@ export declare type PromiseReturnType<T extends AsyncFunction> = T extends (...a
|
|
|
84
84
|
* @beta
|
|
85
85
|
*/
|
|
86
86
|
export declare type ExtractLiterals<T, U extends T> = Extract<T, U>;
|
|
87
|
+
/** A runtime property omitter, makes a shallow copy of the given object without the specified properties
|
|
88
|
+
* Compatible with the typescript `Omit` mapped type:
|
|
89
|
+
* ```js
|
|
90
|
+
* const testvar: Omit<{x: string, y: object}, "y"> = omit({x: "hello", y: {}}, ["y"]);
|
|
91
|
+
* ```
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export declare function omit<T extends {}, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]>;
|
|
87
95
|
//# sourceMappingURL=UtilityTypes.d.ts.map
|
|
@@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AACH,oBAAY,eAAe,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5D;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAKpG"}
|
package/lib/cjs/UtilityTypes.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module Utils
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.asInstanceOf = exports.isInstanceOf = void 0;
|
|
10
|
+
exports.omit = exports.asInstanceOf = exports.isInstanceOf = void 0;
|
|
11
11
|
/** Returns true if `obj` is an object of class `T`.
|
|
12
12
|
* @see [[asInstanceOf]] to cast `obj` to class `T`.
|
|
13
13
|
* @public
|
|
@@ -24,4 +24,18 @@ function asInstanceOf(obj, constructor) {
|
|
|
24
24
|
return isInstanceOf(obj, constructor) ? obj : undefined;
|
|
25
25
|
}
|
|
26
26
|
exports.asInstanceOf = asInstanceOf;
|
|
27
|
+
/** A runtime property omitter, makes a shallow copy of the given object without the specified properties
|
|
28
|
+
* Compatible with the typescript `Omit` mapped type:
|
|
29
|
+
* ```js
|
|
30
|
+
* const testvar: Omit<{x: string, y: object}, "y"> = omit({x: "hello", y: {}}, ["y"]);
|
|
31
|
+
* ```
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
function omit(t, keys) {
|
|
35
|
+
const clone = { ...t };
|
|
36
|
+
for (const key of keys)
|
|
37
|
+
delete clone[key];
|
|
38
|
+
return clone;
|
|
39
|
+
}
|
|
40
|
+
exports.omit = omit;
|
|
27
41
|
//# sourceMappingURL=UtilityTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA2BH;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAFD,oCAEC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAFD,oCAEC","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\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\r\n * @public\r\n */\r\nexport type Mutable<T> = {\r\n -readonly [K in keyof T]: T[K];\r\n};\r\n\r\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\r\n * @public\r\n */\r\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\r\n\r\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\r\n * @public\r\n */\r\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\r\n\r\n/** Generically represents a class `T`, for use in type annotations.\r\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\r\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\r\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\r\n * @public\r\n */\r\nexport type Constructor<T> = new (...args: any[]) => T;\r\n\r\n/** Returns true if `obj` is an object of class `T`.\r\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\r\n * @public\r\n */\r\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\r\n return \"object\" === typeof obj && obj instanceof constructor;\r\n}\r\n\r\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\r\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\r\n * @public\r\n */\r\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\r\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\r\n}\r\n\r\n/** Extracts the names of all public properties of `T` that are not of type `function`.\r\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\r\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\r\n * so too does the type that TypeScript infers from that operator.\r\n * `get` syntax. For example:\r\n * ```ts\r\n * class Thing {\r\n * private _a = \"a\"; // a private variable\r\n * public b = \"b\"; // a public variable\r\n * public get c() { return \"c\"; } // a public property\r\n * public d() { return \"d\"; } // a public method\r\n * public e = () => \"e\"; // a public variable of type `function`\r\n * }\r\n *\r\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\r\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\r\n *\r\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\r\n * const thing1 = new Thing();\r\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\r\n * ```\r\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\r\n * @public\r\n */\r\nexport type NonFunctionPropertyNamesOf<T> = {\r\n [K in keyof T]: T[K] extends Function ? never : K;\r\n}[keyof T];\r\n\r\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\r\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\r\n * @public\r\n */\r\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\r\n\r\n/** Any function returning a Promise.\r\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\r\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\r\n * @public\r\n */\r\nexport type AsyncFunction = (...args: any) => Promise<any>;\r\n\r\n/** Extracts the names of all function properties of `T` that return a Promise.\r\n * @public\r\n */\r\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\r\n\r\n/** Extracts the type to which the Promise returned by an async function resolves.\r\n * @public\r\n */\r\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\r\n\r\n/** Extracts a subset of literals `U` from a union of literals `T` in a type-safe way.\r\n * @beta\r\n */\r\nexport type ExtractLiterals<T, U extends T> = Extract<T, U>;\r\n"]}
|
|
1
|
+
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA2BH;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAFD,oCAEC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAFD,oCAEC;AA0DD;;;;;;GAMG;AACH,SAAgB,IAAI,CAA+C,CAAI,EAAE,IAAO;IAC9E,MAAM,KAAK,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,IAAI;QACpB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,CAAC;AACf,CAAC;AALD,oBAKC","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\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\r\n * @public\r\n */\r\nexport type Mutable<T> = {\r\n -readonly [K in keyof T]: T[K];\r\n};\r\n\r\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\r\n * @public\r\n */\r\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\r\n\r\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\r\n * @public\r\n */\r\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\r\n\r\n/** Generically represents a class `T`, for use in type annotations.\r\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\r\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\r\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\r\n * @public\r\n */\r\nexport type Constructor<T> = new (...args: any[]) => T;\r\n\r\n/** Returns true if `obj` is an object of class `T`.\r\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\r\n * @public\r\n */\r\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\r\n return \"object\" === typeof obj && obj instanceof constructor;\r\n}\r\n\r\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\r\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\r\n * @public\r\n */\r\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\r\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\r\n}\r\n\r\n/** Extracts the names of all public properties of `T` that are not of type `function`.\r\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\r\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\r\n * so too does the type that TypeScript infers from that operator.\r\n * `get` syntax. For example:\r\n * ```ts\r\n * class Thing {\r\n * private _a = \"a\"; // a private variable\r\n * public b = \"b\"; // a public variable\r\n * public get c() { return \"c\"; } // a public property\r\n * public d() { return \"d\"; } // a public method\r\n * public e = () => \"e\"; // a public variable of type `function`\r\n * }\r\n *\r\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\r\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\r\n *\r\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\r\n * const thing1 = new Thing();\r\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\r\n * ```\r\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\r\n * @public\r\n */\r\nexport type NonFunctionPropertyNamesOf<T> = {\r\n [K in keyof T]: T[K] extends Function ? never : K;\r\n}[keyof T];\r\n\r\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\r\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\r\n * @public\r\n */\r\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\r\n\r\n/** Any function returning a Promise.\r\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\r\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\r\n * @public\r\n */\r\nexport type AsyncFunction = (...args: any) => Promise<any>;\r\n\r\n/** Extracts the names of all function properties of `T` that return a Promise.\r\n * @public\r\n */\r\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\r\n\r\n/** Extracts the type to which the Promise returned by an async function resolves.\r\n * @public\r\n */\r\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\r\n\r\n/** Extracts a subset of literals `U` from a union of literals `T` in a type-safe way.\r\n * @beta\r\n */\r\nexport type ExtractLiterals<T, U extends T> = Extract<T, U>;\r\n\r\n/** A runtime property omitter, makes a shallow copy of the given object without the specified properties\r\n * Compatible with the typescript `Omit` mapped type:\r\n * ```js\r\n * const testvar: Omit<{x: string, y: object}, \"y\"> = omit({x: \"hello\", y: {}}, [\"y\"]);\r\n * ```\r\n * @internal\r\n */\r\nexport function omit<T extends {}, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]> {\r\n const clone = { ...t };\r\n for (const key of keys)\r\n delete clone[key];\r\n return clone;\r\n}\r\n"]}
|
|
@@ -29,6 +29,7 @@ export * from "./SortedArray";
|
|
|
29
29
|
export * from "./StringUtils";
|
|
30
30
|
export * from "./Time";
|
|
31
31
|
export * from "./Tracing";
|
|
32
|
+
export * from "./TupleKeyedMap";
|
|
32
33
|
export * from "./TypedArrayBuilder";
|
|
33
34
|
export * from "./UnexpectedErrors";
|
|
34
35
|
export * from "./UtilityTypes";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-bentley.d.ts","sourceRoot":"","sources":["../../src/core-bentley.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc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C;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
|
package/lib/cjs/core-bentley.js
CHANGED
|
@@ -45,6 +45,7 @@ __exportStar(require("./SortedArray"), exports);
|
|
|
45
45
|
__exportStar(require("./StringUtils"), exports);
|
|
46
46
|
__exportStar(require("./Time"), exports);
|
|
47
47
|
__exportStar(require("./Tracing"), exports);
|
|
48
|
+
__exportStar(require("./TupleKeyedMap"), exports);
|
|
48
49
|
__exportStar(require("./TypedArrayBuilder"), exports);
|
|
49
50
|
__exportStar(require("./UnexpectedErrors"), exports);
|
|
50
51
|
__exportStar(require("./UtilityTypes"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-bentley.js","sourceRoot":"","sources":["../../src/core-bentley.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,gDAA8B;AAC9B,2CAAyB;AACzB,+CAA6B;AAC7B,4CAA0B;AAC1B,iDAA+B;AAC/B,0DAAwC;AACxC,mDAAiC;AACjC,6CAA2B;AAC3B,+CAA6B;AAC7B,+CAA6B;AAC7B,4CAA0B;AAC1B,sDAAoC;AACpC,+CAA6B;AAC7B,+CAA6B;AAC7B,uCAAqB;AACrB,6CAA2B;AAC3B,+CAA6B;AAC7B,8CAA4B;AAC5B,2CAAyB;AACzB,2CAAyB;AACzB,kDAAgC;AAChC,qDAAmC;AACnC,wDAAsC;AACtC,+CAA6B;AAC7B,mDAAiC;AACjC,kDAAgC;AAChC,oDAAkC;AAClC,gDAA8B;AAC9B,gDAA8B;AAC9B,yCAAuB;AACvB,4CAA0B;AAC1B,sDAAoC;AACpC,qDAAmC;AACnC,iDAA+B;AAC/B,iDAA+B;AAE/B;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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\nexport * from \"./AccessToken\";\r\nexport * from \"./Assert\";\r\nexport * from \"./AsyncMutex\";\r\nexport * from \"./BeEvent\";\r\nexport * from \"./BentleyError\";\r\nexport * from \"./BentleyLoggerCategory\";\r\nexport * from \"./StatusCategory\";\r\nexport * from \"./BeSQLite\";\r\nexport * from \"./ByteStream\";\r\nexport * from \"./ClassUtils\";\r\nexport * from \"./Compare\";\r\nexport * from \"./CompressedId64Set\";\r\nexport * from \"./Dictionary\";\r\nexport * from \"./Disposable\";\r\nexport * from \"./Id\";\r\nexport * from \"./IndexMap\";\r\nexport * from \"./JsonSchema\";\r\nexport * from \"./JsonUtils\";\r\nexport * from \"./Logger\";\r\nexport * from \"./LRUMap\";\r\nexport * from \"./ObservableSet\";\r\nexport * from \"./OneAtATimeAction\";\r\nexport * from \"./OrderedId64Iterable\";\r\nexport * from \"./OrderedSet\";\r\nexport * from \"./partitionArray\";\r\nexport * from \"./PriorityQueue\";\r\nexport * from \"./ProcessDetector\";\r\nexport * from \"./SortedArray\";\r\nexport * from \"./StringUtils\";\r\nexport * from \"./Time\";\r\nexport * from \"./Tracing\";\r\nexport * from \"./TypedArrayBuilder\";\r\nexport * from \"./UnexpectedErrors\";\r\nexport * from \"./UtilityTypes\";\r\nexport * from \"./YieldManager\";\r\n\r\n/** @docs-package-description\r\n * The core-bentley package contains classes to solve problems that are common for both client and server use cases.\r\n */\r\n/**\r\n * @docs-group-description BeSQLite\r\n * Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)\r\n */\r\n/**\r\n * @docs-group-description Errors\r\n * Classes for working with errors.\r\n */\r\n/**\r\n * @docs-group-description Events\r\n * Classes for raising and handling events.\r\n */\r\n/**\r\n * @docs-group-description Ids\r\n * Classes for working with unique identifiers.\r\n */\r\n/**\r\n * @docs-group-description Logging\r\n * Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)\r\n */\r\n/**\r\n * @docs-group-description Collections\r\n * Specialized, customizable collection classes like priority queues.\r\n */\r\n/**\r\n * @docs-group-description Json\r\n * utilities for dealing with Json strings and files.\r\n */\r\n/**\r\n * @docs-group-description Utils\r\n * Miscellaneous utility classes.\r\n */\r\n/**\r\n * @docs-group-description ProcessDetector\r\n * Functions for determining the type of the current JavaScript process.\r\n */\r\n"]}
|
|
1
|
+
{"version":3,"file":"core-bentley.js","sourceRoot":"","sources":["../../src/core-bentley.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,gDAA8B;AAC9B,2CAAyB;AACzB,+CAA6B;AAC7B,4CAA0B;AAC1B,iDAA+B;AAC/B,0DAAwC;AACxC,mDAAiC;AACjC,6CAA2B;AAC3B,+CAA6B;AAC7B,+CAA6B;AAC7B,4CAA0B;AAC1B,sDAAoC;AACpC,+CAA6B;AAC7B,+CAA6B;AAC7B,uCAAqB;AACrB,6CAA2B;AAC3B,+CAA6B;AAC7B,8CAA4B;AAC5B,2CAAyB;AACzB,2CAAyB;AACzB,kDAAgC;AAChC,qDAAmC;AACnC,wDAAsC;AACtC,+CAA6B;AAC7B,mDAAiC;AACjC,kDAAgC;AAChC,oDAAkC;AAClC,gDAA8B;AAC9B,gDAA8B;AAC9B,yCAAuB;AACvB,4CAA0B;AAC1B,kDAAgC;AAChC,sDAAoC;AACpC,qDAAmC;AACnC,iDAA+B;AAC/B,iDAA+B;AAE/B;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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\nexport * from \"./AccessToken\";\r\nexport * from \"./Assert\";\r\nexport * from \"./AsyncMutex\";\r\nexport * from \"./BeEvent\";\r\nexport * from \"./BentleyError\";\r\nexport * from \"./BentleyLoggerCategory\";\r\nexport * from \"./StatusCategory\";\r\nexport * from \"./BeSQLite\";\r\nexport * from \"./ByteStream\";\r\nexport * from \"./ClassUtils\";\r\nexport * from \"./Compare\";\r\nexport * from \"./CompressedId64Set\";\r\nexport * from \"./Dictionary\";\r\nexport * from \"./Disposable\";\r\nexport * from \"./Id\";\r\nexport * from \"./IndexMap\";\r\nexport * from \"./JsonSchema\";\r\nexport * from \"./JsonUtils\";\r\nexport * from \"./Logger\";\r\nexport * from \"./LRUMap\";\r\nexport * from \"./ObservableSet\";\r\nexport * from \"./OneAtATimeAction\";\r\nexport * from \"./OrderedId64Iterable\";\r\nexport * from \"./OrderedSet\";\r\nexport * from \"./partitionArray\";\r\nexport * from \"./PriorityQueue\";\r\nexport * from \"./ProcessDetector\";\r\nexport * from \"./SortedArray\";\r\nexport * from \"./StringUtils\";\r\nexport * from \"./Time\";\r\nexport * from \"./Tracing\";\r\nexport * from \"./TupleKeyedMap\";\r\nexport * from \"./TypedArrayBuilder\";\r\nexport * from \"./UnexpectedErrors\";\r\nexport * from \"./UtilityTypes\";\r\nexport * from \"./YieldManager\";\r\n\r\n/** @docs-package-description\r\n * The core-bentley package contains classes to solve problems that are common for both client and server use cases.\r\n */\r\n/**\r\n * @docs-group-description BeSQLite\r\n * Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)\r\n */\r\n/**\r\n * @docs-group-description Errors\r\n * Classes for working with errors.\r\n */\r\n/**\r\n * @docs-group-description Events\r\n * Classes for raising and handling events.\r\n */\r\n/**\r\n * @docs-group-description Ids\r\n * Classes for working with unique identifiers.\r\n */\r\n/**\r\n * @docs-group-description Logging\r\n * Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)\r\n */\r\n/**\r\n * @docs-group-description Collections\r\n * Specialized, customizable collection classes like priority queues.\r\n */\r\n/**\r\n * @docs-group-description Json\r\n * utilities for dealing with Json strings and files.\r\n */\r\n/**\r\n * @docs-group-description Utils\r\n * Miscellaneous utility classes.\r\n */\r\n/**\r\n * @docs-group-description ProcessDetector\r\n * Functions for determining the type of the current JavaScript process.\r\n */\r\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Collections
|
|
3
|
+
*/
|
|
4
|
+
/** A map similar to the standard JavaScript Map collection except that the keys must be a tuple
|
|
5
|
+
* (javascript array), and two keys are considered equal if their elements in order are strict-equal,
|
|
6
|
+
* and the tuples have the same amount of elements
|
|
7
|
+
*
|
|
8
|
+
* This means you can use array literals to key data in Maps that would otherwise be reference-compared
|
|
9
|
+
* if using JavaScript's built in Map
|
|
10
|
+
*
|
|
11
|
+
* Note that JavaScript's Map type, unlike this one that uses strict equality, uses instead
|
|
12
|
+
* SameValueZero equality comparison
|
|
13
|
+
* @see https://262.ecma-international.org/6.0/#sec-samevaluezero
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* const map = new TupleKeyedMap([[1,"y"], "value"]);
|
|
17
|
+
* const value = map.get([1, "y"]); // a normal map would identify these keys as different because they are independent objects
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* It is implemented by each index of the tuple key being used as a singular key into a submap
|
|
21
|
+
* @note this only implements a subset of the Map interface
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare class TupleKeyedMap<K extends readonly any[], V> {
|
|
25
|
+
private _map;
|
|
26
|
+
constructor(entries?: readonly (readonly [K, V])[] | null);
|
|
27
|
+
clear(): void;
|
|
28
|
+
private makeKeyError;
|
|
29
|
+
get(key: K): V | undefined;
|
|
30
|
+
has(key: K): boolean;
|
|
31
|
+
set(key: K, value: V): this;
|
|
32
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
33
|
+
private _size;
|
|
34
|
+
get size(): number;
|
|
35
|
+
get [Symbol.toStringTag](): string;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=TupleKeyedMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TupleKeyedMap.d.ts","sourceRoot":"","sources":["../../src/TupleKeyedMap.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,aAAa,CAAC,CAAC,SAAS,SAAS,GAAG,EAAE,EAAE,CAAC;IACpD,OAAO,CAAC,IAAI,CAAoC;gBAG7B,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAOzD,KAAK,IAAI,IAAI;IAIpB,OAAO,CAAC,YAAY;IAMb,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAc1B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAmB1B,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAcrD,OAAO,CAAC,KAAK,CAAa;IAC1B,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAExC;CACF"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Collections
|
|
7
|
+
*/
|
|
8
|
+
/** A map similar to the standard JavaScript Map collection except that the keys must be a tuple
|
|
9
|
+
* (javascript array), and two keys are considered equal if their elements in order are strict-equal,
|
|
10
|
+
* and the tuples have the same amount of elements
|
|
11
|
+
*
|
|
12
|
+
* This means you can use array literals to key data in Maps that would otherwise be reference-compared
|
|
13
|
+
* if using JavaScript's built in Map
|
|
14
|
+
*
|
|
15
|
+
* Note that JavaScript's Map type, unlike this one that uses strict equality, uses instead
|
|
16
|
+
* SameValueZero equality comparison
|
|
17
|
+
* @see https://262.ecma-international.org/6.0/#sec-samevaluezero
|
|
18
|
+
*
|
|
19
|
+
* ```js
|
|
20
|
+
* const map = new TupleKeyedMap([[1,"y"], "value"]);
|
|
21
|
+
* const value = map.get([1, "y"]); // a normal map would identify these keys as different because they are independent objects
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* It is implemented by each index of the tuple key being used as a singular key into a submap
|
|
25
|
+
* @note this only implements a subset of the Map interface
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export class TupleKeyedMap {
|
|
29
|
+
// argument types match those of Map
|
|
30
|
+
constructor(entries) {
|
|
31
|
+
this._map = new Map();
|
|
32
|
+
this._size = 0;
|
|
33
|
+
if (entries)
|
|
34
|
+
for (const [k, v] of entries) {
|
|
35
|
+
this.set(k, v);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
clear() {
|
|
39
|
+
return this._map.clear();
|
|
40
|
+
}
|
|
41
|
+
makeKeyError() {
|
|
42
|
+
return Error("A Bad key was used, it didn't match the key type of the the map.");
|
|
43
|
+
}
|
|
44
|
+
get(key) {
|
|
45
|
+
let cursor = this._map;
|
|
46
|
+
for (const subkey of key) {
|
|
47
|
+
if (!(cursor instanceof Map))
|
|
48
|
+
throw this.makeKeyError();
|
|
49
|
+
cursor = cursor.get(subkey);
|
|
50
|
+
if (cursor === undefined)
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
if (cursor instanceof Map)
|
|
54
|
+
throw this.makeKeyError();
|
|
55
|
+
return cursor;
|
|
56
|
+
}
|
|
57
|
+
has(key) {
|
|
58
|
+
return this.get(key) !== undefined;
|
|
59
|
+
}
|
|
60
|
+
set(key, value) {
|
|
61
|
+
let cursor = this._map;
|
|
62
|
+
for (let i = 0; i < key.length - 1; ++i) {
|
|
63
|
+
const subkey = key[i];
|
|
64
|
+
let next = cursor.get(subkey);
|
|
65
|
+
if (next === undefined) {
|
|
66
|
+
next = new Map();
|
|
67
|
+
cursor.set(subkey, next);
|
|
68
|
+
}
|
|
69
|
+
cursor = next;
|
|
70
|
+
}
|
|
71
|
+
const finalSubkey = key[key.length - 1];
|
|
72
|
+
if (!(cursor instanceof Map))
|
|
73
|
+
throw this.makeKeyError();
|
|
74
|
+
cursor.set(finalSubkey, value);
|
|
75
|
+
this._size++;
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
*[Symbol.iterator]() {
|
|
79
|
+
function* impl(map, keyPrefix) {
|
|
80
|
+
for (const [k, v] of map) {
|
|
81
|
+
const nextKey = [...keyPrefix, k];
|
|
82
|
+
if (v instanceof Map) {
|
|
83
|
+
yield* impl(v, nextKey);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
yield [nextKey, v];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
yield* impl(this._map, []);
|
|
91
|
+
}
|
|
92
|
+
get size() {
|
|
93
|
+
return this._size;
|
|
94
|
+
}
|
|
95
|
+
get [Symbol.toStringTag]() {
|
|
96
|
+
return this.constructor.name;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=TupleKeyedMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TupleKeyedMap.js","sourceRoot":"","sources":["../../src/TupleKeyedMap.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,aAAa;IAGxB,oCAAoC;IACpC,YAAmB,OAA6C;QAHxD,SAAI,GAAG,IAAI,GAAG,EAAyB,CAAC;QAuExC,UAAK,GAAW,CAAC,CAAC;QAnExB,IAAI,OAAO;YACT,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAAO,EAAE;gBAC5B,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAChB;IACL,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAEO,YAAY;QAClB,OAAO,KAAK,CACV,kEAAkE,CACnE,CAAC;IACJ,CAAC;IAEM,GAAG,CAAC,GAAM;QACf,IAAI,MAAM,GAAsB,IAAI,CAAC,IAAI,CAAC;QAC1C,KAAK,MAAM,MAAM,IAAI,GAAG,EAAE;YACxB,IAAI,CAAC,CAAC,MAAM,YAAY,GAAG,CAAC;gBAC1B,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5B,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC5B,IAAI,MAAM,KAAK,SAAS;gBACtB,OAAO,SAAS,CAAC;SACpB;QACD,IAAI,MAAM,YAAY,GAAG;YACvB,MAAM,IAAI,CAAC,YAAY,EAAE,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C,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;iBACzB;qBAAM;oBACL,MAAM,CAAC,OAAmB,EAAE,CAAC,CAAC,CAAC;iBAChC;aACF;QACH,CAAC;QACD,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IAGD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAW,CAAC,MAAM,CAAC,WAAW,CAAC;QAC7B,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Collections\r\n */\r\n\r\n/** A map similar to the standard JavaScript Map collection except that the keys must be a tuple\r\n * (javascript array), and two keys are considered equal if their elements in order are strict-equal,\r\n * and the tuples have the same amount of elements\r\n *\r\n * This means you can use array literals to key data in Maps that would otherwise be reference-compared\r\n * if using JavaScript's built in Map\r\n *\r\n * Note that JavaScript's Map type, unlike this one that uses strict equality, uses instead\r\n * SameValueZero equality comparison\r\n * @see https://262.ecma-international.org/6.0/#sec-samevaluezero\r\n *\r\n * ```js\r\n * const map = new TupleKeyedMap([[1,\"y\"], \"value\"]);\r\n * const value = map.get([1, \"y\"]); // a normal map would identify these keys as different because they are independent objects\r\n * ```\r\n *\r\n * It is implemented by each index of the tuple key being used as a singular key into a submap\r\n * @note this only implements a subset of the Map interface\r\n * @internal\r\n */\r\nexport class TupleKeyedMap<K extends readonly any[], V> {\r\n private _map = new Map<K[0], Map<any, V> | V>();\r\n\r\n // argument types match those of Map\r\n public constructor(entries?: readonly (readonly [K, V])[] | null) {\r\n if (entries)\r\n for (const [k, v] of entries) {\r\n this.set(k, v);\r\n }\r\n }\r\n\r\n public clear(): void {\r\n return this._map.clear();\r\n }\r\n\r\n private makeKeyError() {\r\n return Error(\r\n \"A Bad key was used, it didn't match the key type of the the map.\"\r\n );\r\n }\r\n\r\n public get(key: K): V | undefined {\r\n let cursor: Map<any, any> | V = this._map;\r\n for (const subkey of key) {\r\n if (!(cursor instanceof Map))\r\n throw this.makeKeyError();\r\n cursor = cursor.get(subkey);\r\n if (cursor === undefined)\r\n return undefined;\r\n }\r\n if (cursor instanceof Map)\r\n throw this.makeKeyError();\r\n return cursor;\r\n }\r\n\r\n public has(key: K): boolean {\r\n return this.get(key) !== undefined;\r\n }\r\n\r\n public set(key: K, value: V): this {\r\n let cursor: Map<any, any> = this._map;\r\n for (let i = 0; i < key.length - 1; ++i) {\r\n const subkey = key[i];\r\n let next = cursor.get(subkey);\r\n if (next === undefined) {\r\n next = new Map();\r\n cursor.set(subkey, next);\r\n }\r\n cursor = next;\r\n }\r\n const finalSubkey = key[key.length - 1];\r\n if (!(cursor instanceof Map))\r\n throw this.makeKeyError();\r\n cursor.set(finalSubkey, value);\r\n this._size++;\r\n return this;\r\n }\r\n\r\n public *[Symbol.iterator](): IterableIterator<[K, V]> {\r\n function *impl(map: Map<any, any>, keyPrefix: readonly any[]): IterableIterator<[K, V]> {\r\n for (const [k, v] of map) {\r\n const nextKey = [...keyPrefix, k];\r\n if (v instanceof Map) {\r\n yield* impl(v, nextKey);\r\n } else {\r\n yield [nextKey as any as K, v];\r\n }\r\n }\r\n }\r\n yield* impl(this._map, []);\r\n }\r\n\r\n private _size: number = 0;\r\n public get size(): number {\r\n return this._size;\r\n }\r\n\r\n public get [Symbol.toStringTag](): string {\r\n return this.constructor.name;\r\n }\r\n}\r\n"]}
|
|
@@ -84,4 +84,12 @@ export declare type PromiseReturnType<T extends AsyncFunction> = T extends (...a
|
|
|
84
84
|
* @beta
|
|
85
85
|
*/
|
|
86
86
|
export declare type ExtractLiterals<T, U extends T> = Extract<T, U>;
|
|
87
|
+
/** A runtime property omitter, makes a shallow copy of the given object without the specified properties
|
|
88
|
+
* Compatible with the typescript `Omit` mapped type:
|
|
89
|
+
* ```js
|
|
90
|
+
* const testvar: Omit<{x: string, y: object}, "y"> = omit({x: "hello", y: {}}, ["y"]);
|
|
91
|
+
* ```
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export declare function omit<T extends {}, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]>;
|
|
87
95
|
//# sourceMappingURL=UtilityTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UtilityTypes.d.ts","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,oBAAY,OAAO,CAAC,CAAC,IAAI;IACvB,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,oBAAY,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9E;;GAEG;AACH,oBAAY,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEnF;;;;;GAKG;AACH,oBAAY,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAE9E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,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AAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,GAAG,CAAC,GAAG,KAAK;CAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AAEpG;;GAEG;AACH,oBAAY,iBAAiB,CAAC,CAAC,SAAS,aAAa,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AAEhH;;GAEG;AACH,oBAAY,eAAe,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5D;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAKpG"}
|
package/lib/esm/UtilityTypes.js
CHANGED
|
@@ -19,4 +19,17 @@ export function isInstanceOf(obj, constructor) {
|
|
|
19
19
|
export function asInstanceOf(obj, constructor) {
|
|
20
20
|
return isInstanceOf(obj, constructor) ? obj : undefined;
|
|
21
21
|
}
|
|
22
|
+
/** A runtime property omitter, makes a shallow copy of the given object without the specified properties
|
|
23
|
+
* Compatible with the typescript `Omit` mapped type:
|
|
24
|
+
* ```js
|
|
25
|
+
* const testvar: Omit<{x: string, y: object}, "y"> = omit({x: "hello", y: {}}, ["y"]);
|
|
26
|
+
* ```
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export function omit(t, keys) {
|
|
30
|
+
const clone = { ...t };
|
|
31
|
+
for (const key of keys)
|
|
32
|
+
delete clone[key];
|
|
33
|
+
return clone;
|
|
34
|
+
}
|
|
22
35
|
//# sourceMappingURL=UtilityTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA2BH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC","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\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\r\n * @public\r\n */\r\nexport type Mutable<T> = {\r\n -readonly [K in keyof T]: T[K];\r\n};\r\n\r\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\r\n * @public\r\n */\r\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\r\n\r\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\r\n * @public\r\n */\r\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\r\n\r\n/** Generically represents a class `T`, for use in type annotations.\r\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\r\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\r\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\r\n * @public\r\n */\r\nexport type Constructor<T> = new (...args: any[]) => T;\r\n\r\n/** Returns true if `obj` is an object of class `T`.\r\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\r\n * @public\r\n */\r\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\r\n return \"object\" === typeof obj && obj instanceof constructor;\r\n}\r\n\r\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\r\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\r\n * @public\r\n */\r\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\r\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\r\n}\r\n\r\n/** Extracts the names of all public properties of `T` that are not of type `function`.\r\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\r\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\r\n * so too does the type that TypeScript infers from that operator.\r\n * `get` syntax. For example:\r\n * ```ts\r\n * class Thing {\r\n * private _a = \"a\"; // a private variable\r\n * public b = \"b\"; // a public variable\r\n * public get c() { return \"c\"; } // a public property\r\n * public d() { return \"d\"; } // a public method\r\n * public e = () => \"e\"; // a public variable of type `function`\r\n * }\r\n *\r\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\r\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\r\n *\r\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\r\n * const thing1 = new Thing();\r\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\r\n * ```\r\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\r\n * @public\r\n */\r\nexport type NonFunctionPropertyNamesOf<T> = {\r\n [K in keyof T]: T[K] extends Function ? never : K;\r\n}[keyof T];\r\n\r\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\r\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\r\n * @public\r\n */\r\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\r\n\r\n/** Any function returning a Promise.\r\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\r\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\r\n * @public\r\n */\r\nexport type AsyncFunction = (...args: any) => Promise<any>;\r\n\r\n/** Extracts the names of all function properties of `T` that return a Promise.\r\n * @public\r\n */\r\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\r\n\r\n/** Extracts the type to which the Promise returned by an async function resolves.\r\n * @public\r\n */\r\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\r\n\r\n/** Extracts a subset of literals `U` from a union of literals `T` in a type-safe way.\r\n * @beta\r\n */\r\nexport type ExtractLiterals<T, U extends T> = Extract<T, U>;\r\n"]}
|
|
1
|
+
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA2BH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AA0DD;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAA+C,CAAI,EAAE,IAAO;IAC9E,MAAM,KAAK,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,IAAI;QACpB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,CAAC;AACf,CAAC","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\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\r\n * @public\r\n */\r\nexport type Mutable<T> = {\r\n -readonly [K in keyof T]: T[K];\r\n};\r\n\r\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\r\n * @public\r\n */\r\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\r\n\r\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\r\n * @public\r\n */\r\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\r\n\r\n/** Generically represents a class `T`, for use in type annotations.\r\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\r\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\r\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\r\n * @public\r\n */\r\nexport type Constructor<T> = new (...args: any[]) => T;\r\n\r\n/** Returns true if `obj` is an object of class `T`.\r\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\r\n * @public\r\n */\r\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\r\n return \"object\" === typeof obj && obj instanceof constructor;\r\n}\r\n\r\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\r\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\r\n * @public\r\n */\r\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\r\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\r\n}\r\n\r\n/** Extracts the names of all public properties of `T` that are not of type `function`.\r\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\r\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\r\n * so too does the type that TypeScript infers from that operator.\r\n * `get` syntax. For example:\r\n * ```ts\r\n * class Thing {\r\n * private _a = \"a\"; // a private variable\r\n * public b = \"b\"; // a public variable\r\n * public get c() { return \"c\"; } // a public property\r\n * public d() { return \"d\"; } // a public method\r\n * public e = () => \"e\"; // a public variable of type `function`\r\n * }\r\n *\r\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\r\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\r\n *\r\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\r\n * const thing1 = new Thing();\r\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\r\n * ```\r\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\r\n * @public\r\n */\r\nexport type NonFunctionPropertyNamesOf<T> = {\r\n [K in keyof T]: T[K] extends Function ? never : K;\r\n}[keyof T];\r\n\r\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\r\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\r\n * @public\r\n */\r\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\r\n\r\n/** Any function returning a Promise.\r\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\r\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\r\n * @public\r\n */\r\nexport type AsyncFunction = (...args: any) => Promise<any>;\r\n\r\n/** Extracts the names of all function properties of `T` that return a Promise.\r\n * @public\r\n */\r\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\r\n\r\n/** Extracts the type to which the Promise returned by an async function resolves.\r\n * @public\r\n */\r\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\r\n\r\n/** Extracts a subset of literals `U` from a union of literals `T` in a type-safe way.\r\n * @beta\r\n */\r\nexport type ExtractLiterals<T, U extends T> = Extract<T, U>;\r\n\r\n/** A runtime property omitter, makes a shallow copy of the given object without the specified properties\r\n * Compatible with the typescript `Omit` mapped type:\r\n * ```js\r\n * const testvar: Omit<{x: string, y: object}, \"y\"> = omit({x: \"hello\", y: {}}, [\"y\"]);\r\n * ```\r\n * @internal\r\n */\r\nexport function omit<T extends {}, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]> {\r\n const clone = { ...t };\r\n for (const key of keys)\r\n delete clone[key];\r\n return clone;\r\n}\r\n"]}
|
|
@@ -29,6 +29,7 @@ export * from "./SortedArray";
|
|
|
29
29
|
export * from "./StringUtils";
|
|
30
30
|
export * from "./Time";
|
|
31
31
|
export * from "./Tracing";
|
|
32
|
+
export * from "./TupleKeyedMap";
|
|
32
33
|
export * from "./TypedArrayBuilder";
|
|
33
34
|
export * from "./UnexpectedErrors";
|
|
34
35
|
export * from "./UtilityTypes";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-bentley.d.ts","sourceRoot":"","sources":["../../src/core-bentley.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,i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AC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
|
package/lib/esm/core-bentley.js
CHANGED
|
@@ -33,6 +33,7 @@ export * from "./SortedArray";
|
|
|
33
33
|
export * from "./StringUtils";
|
|
34
34
|
export * from "./Time";
|
|
35
35
|
export * from "./Tracing";
|
|
36
|
+
export * from "./TupleKeyedMap";
|
|
36
37
|
export * from "./TypedArrayBuilder";
|
|
37
38
|
export * from "./UnexpectedErrors";
|
|
38
39
|
export * from "./UtilityTypes";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-bentley.js","sourceRoot":"","sources":["../../src/core-bentley.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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\nexport * from \"./AccessToken\";\r\nexport * from \"./Assert\";\r\nexport * from \"./AsyncMutex\";\r\nexport * from \"./BeEvent\";\r\nexport * from \"./BentleyError\";\r\nexport * from \"./BentleyLoggerCategory\";\r\nexport * from \"./StatusCategory\";\r\nexport * from \"./BeSQLite\";\r\nexport * from \"./ByteStream\";\r\nexport * from \"./ClassUtils\";\r\nexport * from \"./Compare\";\r\nexport * from \"./CompressedId64Set\";\r\nexport * from \"./Dictionary\";\r\nexport * from \"./Disposable\";\r\nexport * from \"./Id\";\r\nexport * from \"./IndexMap\";\r\nexport * from \"./JsonSchema\";\r\nexport * from \"./JsonUtils\";\r\nexport * from \"./Logger\";\r\nexport * from \"./LRUMap\";\r\nexport * from \"./ObservableSet\";\r\nexport * from \"./OneAtATimeAction\";\r\nexport * from \"./OrderedId64Iterable\";\r\nexport * from \"./OrderedSet\";\r\nexport * from \"./partitionArray\";\r\nexport * from \"./PriorityQueue\";\r\nexport * from \"./ProcessDetector\";\r\nexport * from \"./SortedArray\";\r\nexport * from \"./StringUtils\";\r\nexport * from \"./Time\";\r\nexport * from \"./Tracing\";\r\nexport * from \"./TypedArrayBuilder\";\r\nexport * from \"./UnexpectedErrors\";\r\nexport * from \"./UtilityTypes\";\r\nexport * from \"./YieldManager\";\r\n\r\n/** @docs-package-description\r\n * The core-bentley package contains classes to solve problems that are common for both client and server use cases.\r\n */\r\n/**\r\n * @docs-group-description BeSQLite\r\n * Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)\r\n */\r\n/**\r\n * @docs-group-description Errors\r\n * Classes for working with errors.\r\n */\r\n/**\r\n * @docs-group-description Events\r\n * Classes for raising and handling events.\r\n */\r\n/**\r\n * @docs-group-description Ids\r\n * Classes for working with unique identifiers.\r\n */\r\n/**\r\n * @docs-group-description Logging\r\n * Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)\r\n */\r\n/**\r\n * @docs-group-description Collections\r\n * Specialized, customizable collection classes like priority queues.\r\n */\r\n/**\r\n * @docs-group-description Json\r\n * utilities for dealing with Json strings and files.\r\n */\r\n/**\r\n * @docs-group-description Utils\r\n * Miscellaneous utility classes.\r\n */\r\n/**\r\n * @docs-group-description ProcessDetector\r\n * Functions for determining the type of the current JavaScript process.\r\n */\r\n"]}
|
|
1
|
+
{"version":3,"file":"core-bentley.js","sourceRoot":"","sources":["../../src/core-bentley.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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\nexport * from \"./AccessToken\";\r\nexport * from \"./Assert\";\r\nexport * from \"./AsyncMutex\";\r\nexport * from \"./BeEvent\";\r\nexport * from \"./BentleyError\";\r\nexport * from \"./BentleyLoggerCategory\";\r\nexport * from \"./StatusCategory\";\r\nexport * from \"./BeSQLite\";\r\nexport * from \"./ByteStream\";\r\nexport * from \"./ClassUtils\";\r\nexport * from \"./Compare\";\r\nexport * from \"./CompressedId64Set\";\r\nexport * from \"./Dictionary\";\r\nexport * from \"./Disposable\";\r\nexport * from \"./Id\";\r\nexport * from \"./IndexMap\";\r\nexport * from \"./JsonSchema\";\r\nexport * from \"./JsonUtils\";\r\nexport * from \"./Logger\";\r\nexport * from \"./LRUMap\";\r\nexport * from \"./ObservableSet\";\r\nexport * from \"./OneAtATimeAction\";\r\nexport * from \"./OrderedId64Iterable\";\r\nexport * from \"./OrderedSet\";\r\nexport * from \"./partitionArray\";\r\nexport * from \"./PriorityQueue\";\r\nexport * from \"./ProcessDetector\";\r\nexport * from \"./SortedArray\";\r\nexport * from \"./StringUtils\";\r\nexport * from \"./Time\";\r\nexport * from \"./Tracing\";\r\nexport * from \"./TupleKeyedMap\";\r\nexport * from \"./TypedArrayBuilder\";\r\nexport * from \"./UnexpectedErrors\";\r\nexport * from \"./UtilityTypes\";\r\nexport * from \"./YieldManager\";\r\n\r\n/** @docs-package-description\r\n * The core-bentley package contains classes to solve problems that are common for both client and server use cases.\r\n */\r\n/**\r\n * @docs-group-description BeSQLite\r\n * Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)\r\n */\r\n/**\r\n * @docs-group-description Errors\r\n * Classes for working with errors.\r\n */\r\n/**\r\n * @docs-group-description Events\r\n * Classes for raising and handling events.\r\n */\r\n/**\r\n * @docs-group-description Ids\r\n * Classes for working with unique identifiers.\r\n */\r\n/**\r\n * @docs-group-description Logging\r\n * Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)\r\n */\r\n/**\r\n * @docs-group-description Collections\r\n * Specialized, customizable collection classes like priority queues.\r\n */\r\n/**\r\n * @docs-group-description Json\r\n * utilities for dealing with Json strings and files.\r\n */\r\n/**\r\n * @docs-group-description Utils\r\n * Miscellaneous utility classes.\r\n */\r\n/**\r\n * @docs-group-description ProcessDetector\r\n * Functions for determining the type of the current JavaScript process.\r\n */\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-bentley",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.2",
|
|
4
4
|
"description": "Bentley JavaScript core components",
|
|
5
5
|
"main": "lib/cjs/core-bentley.js",
|
|
6
6
|
"module": "lib/esm/core-bentley.js",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"url": "http://www.bentley.com"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@itwin/build-tools": "3.4.
|
|
25
|
-
"@itwin/eslint-plugin": "3.4.
|
|
24
|
+
"@itwin/build-tools": "3.4.2",
|
|
25
|
+
"@itwin/eslint-plugin": "3.4.2",
|
|
26
26
|
"@opentelemetry/api": "1.0.4",
|
|
27
27
|
"@types/chai": "4.3.1",
|
|
28
28
|
"@types/chai-as-promised": "^7",
|