@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":"Dictionary.js","sourceRoot":"","sources":["../../src/Dictionary.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAAwE;AAExE,MAAM,kBAAkB;IAKtB,YAAmB,IAAS,EAAE,MAAW;QAFjC,cAAS,GAAG,CAAC,CAAC,CAAC;QAGrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEM,IAAI;QACT,IAAI,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAC1C,0JAA0J;YAC1J,OAAO,EAAE,IAAI,EAAE,IAAI,EAAkD,CAAC;QACxE,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,KAAK,EAAE;oBACL,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;oBAC/B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;iBACpC;gBACD,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAaD;;;;;;;;;;;;;GAaG;AACH,MAAa,UAAU;IAOrB;;;;;OAKG;IACH,YAAmB,WAAiC,EAAE,WAA6B,0BAAY,EAAE,aAA+B,0BAAY;QAZlI,UAAK,GAAQ,EAAE,CAAC;QAGhB,YAAO,GAAQ,EAAE,CAAC;QAU1B,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;I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,IAAgC;QAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACO,UAAU,CAAC,GAAM,IAAuC,OAAO,IAAA,wBAAU,EAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAC3H;AA/KD,gCA+KC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Collections\r\n */\r\n\r\nimport { OrderedComparator } from \"./Compare\";\r\nimport { CloneFunction, lowerBound, shallowClone } from \"./SortedArray\";\r\n\r\nclass DictionaryIterator<K, V> implements Iterator<DictionaryEntry<K, V>> {\r\n private _keys: K[];\r\n private _values: V[];\r\n private _curIndex = -1;\r\n\r\n public constructor(keys: K[], values: V[]) {\r\n this._keys = keys;\r\n this._values = values;\r\n }\r\n\r\n public next(): IteratorResult<DictionaryEntry<K, V>> {\r\n if (++this._curIndex >= this._keys.length) {\r\n // The ECMAScript spec states that value=undefined is valid if done=true. The TypeScript interface violates the spec hence the cast to any and back below.\r\n return { done: true } as any as IteratorResult<DictionaryEntry<K, V>>;\r\n } else {\r\n return {\r\n value: {\r\n key: this._keys[this._curIndex],\r\n value: this._values[this._curIndex],\r\n },\r\n done: false,\r\n };\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Represents an entry in a [[Dictionary]].\r\n * @public\r\n */\r\nexport interface DictionaryEntry<K, V> {\r\n /** The key used for lookup in the Dictionary. */\r\n key: K;\r\n /** The value associated with the key in the Dictionary. */\r\n value: V;\r\n}\r\n\r\n/**\r\n * Maintains a mapping of keys to values.\r\n * Unlike the standard Map<K, V>, a Dictionary<K, V> supports custom comparison logic for keys of object type (and for any other type).\r\n * The user supplies a key comparison function to the constructor, that must meet the following criteria given 'lhs' and 'rhs' of type K:\r\n * - If lhs is equal to rhs, returns 0\r\n * - If lhs is less than rhs, returns a negative value\r\n * - If lhs is greater than rhs, returns a positive value\r\n * - If compare(lhs, rhs) returns 0, then compare(rhs, lhs) must also return 0\r\n * - If compare(lhs, rhs) returns a negative value, then compare(rhs, lhs) must return a positive value, and vice versa.\r\n *\r\n * Modifying a key in a way that affects the comparison function will produce unpredictable results, the\r\n * most likely of which is that keys will cease to map to the values with which they were initially inserted.\r\n * @public\r\n */\r\nexport class Dictionary<K, V> implements Iterable<DictionaryEntry<K, V>> {\r\n protected _keys: K[] = [];\r\n protected readonly _compareKeys: OrderedComparator<K>;\r\n protected readonly _cloneKey: CloneFunction<K>;\r\n protected _values: V[] = [];\r\n protected readonly _cloneValue: CloneFunction<V>;\r\n\r\n /**\r\n * Construct a new Dictionary<K, V>.\r\n * @param compareKeys The function used to compare keys within the dictionary.\r\n * @param cloneKey The function invoked to clone a key for insertion into the dictionary. The default implementation simply returns its input.\r\n * @param cloneValue The function invoked to clone a value for insertion into the dictionary. The default implementation simply returns its input.\r\n */\r\n public constructor(compareKeys: OrderedComparator<K>, cloneKey: CloneFunction<K> = shallowClone, cloneValue: CloneFunction<V> = shallowClone) {\r\n this._compareKeys = compareKeys;\r\n this._cloneKey = cloneKey;\r\n this._cloneValue = cloneValue;\r\n }\r\n\r\n /** The number of entries in the dictionary. */\r\n public get size(): number { return this._keys.length; }\r\n\r\n /** Returns an iterator over the key-value pairs in the Dictionary suitable for use in `for-of` loops. Entries are returned in sorted order by key. */\r\n public [Symbol.iterator](): Iterator<DictionaryEntry<K, V>> {\r\n return new DictionaryIterator<K, V>(this._keys, this._values);\r\n }\r\n\r\n /** Provides iteration over the keys in this Dictionary, in sorted order. */\r\n public keys(): Iterable<K> {\r\n function * iterator(dict: Dictionary<K, V>) {\r\n for (const entry of dict)\r\n yield entry.key;\r\n }\r\n\r\n return {\r\n [Symbol.iterator]: () => iterator(this),\r\n };\r\n }\r\n\r\n /** Provides iteration over the values in this Dictionary, in sorted order by the corresponding keys. */\r\n public values(): Iterable<V> {\r\n function * iterator(dict: Dictionary<K, V>) {\r\n for (const entry of dict)\r\n yield entry.value;\r\n }\r\n\r\n return {\r\n [Symbol.iterator]: () => iterator(this),\r\n };\r\n }\r\n\r\n /** Removes all entries from this dictionary */\r\n public clear(): void {\r\n this._keys = [];\r\n this._values = [];\r\n }\r\n\r\n /**\r\n * Looks up a value by its key.\r\n * @param key The key to search for\r\n * @returns the value associated with the key, or undefined if the key is not present in the dictionary.\r\n */\r\n public get(key: K): V | undefined {\r\n const bound = this.lowerBound(key);\r\n return bound.equal ? this._values[bound.index] : undefined;\r\n }\r\n\r\n /**\r\n * Determines if an entry exists for the specified key\r\n * @param key The key to search for\r\n * @returns true if an entry exists in this dictionary corresponding to the specified key.\r\n */\r\n public has(key: K): boolean {\r\n return this.lowerBound(key).equal;\r\n }\r\n\r\n /**\r\n * Deletes a value using its key.\r\n * @param key The key to delete\r\n * @returns true if the key was found and deleted.\r\n */\r\n public delete(key: K): boolean {\r\n const bound = this.lowerBound(key);\r\n if (bound.equal) {\r\n this._values.splice(bound.index, 1);\r\n this._keys.splice(bound.index, 1);\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Attempts to insert a new entry into the dictionary. If an entry with an equivalent key exists, the dictionary is unmodified.\r\n * If the new entry is in fact inserted, both the key and value will be cloned using the functions supplied to the dictionary's constructor.\r\n * @param key The key to associate with the value\r\n * @param value The value to associate with the key\r\n * @returns true if the new entry was inserted, false if an entry with an equivalent key already exists.\r\n */\r\n public insert(key: K, value: V): boolean {\r\n const result = this.findOrInsert(key, value);\r\n return result.inserted;\r\n }\r\n\r\n /** Obtains the value associated with the specified key, or inserts it if the specified key does not yet exist.\r\n * @param key The key to search for.\r\n * @param value The value to associate with `key` if `key` does not yet exist in the dictionary.\r\n * @returns The found or inserted value and a flag indicating whether the new value was inserted.\r\n */\r\n public findOrInsert(key: K, value: V): { value: V, inserted: boolean } {\r\n const bound = this.lowerBound(key);\r\n if (bound.equal)\r\n return { value: this._values[bound.index], inserted: false };\r\n\r\n value = this._cloneValue(value);\r\n this._keys.splice(bound.index, 0, this._cloneKey(key));\r\n this._values.splice(bound.index, 0, this._cloneValue(value));\r\n return { value, inserted: true };\r\n }\r\n\r\n /**\r\n * Sets the value associated with the specified key in the dictionary.\r\n * If no such key already exists, this is equivalent to insert(key, value); otherwise, the existing value associated with the key is replaced.\r\n * In either case, the value will be cloned using the function supplied to the dictionary's constructor.\r\n */\r\n public set(key: K, value: V): void {\r\n value = this._cloneValue(value);\r\n const bound = this.lowerBound(key);\r\n if (bound.equal) {\r\n this._values[bound.index] = value;\r\n } else {\r\n this._keys.splice(bound.index, 0, this._cloneKey(key));\r\n this._values.splice(bound.index, 0, value);\r\n }\r\n }\r\n\r\n /**\r\n * Extracts the contents of this dictionary as an array of { key, value } pairs, and empties this dictionary.\r\n * @returns An array of { key, value } pairs sorted by key.\r\n */\r\n public extractPairs(): Array<{ key: K, value: V }> {\r\n const pairs: Array<{ key: K, value: V }> = [];\r\n for (let i = 0; i < this.size; i++)\r\n pairs.push({ key: this._keys[i], value: this._values[i] });\r\n\r\n this.clear();\r\n return pairs;\r\n }\r\n\r\n /**\r\n * Extracts the contents of this dictionary as a pair of { keys, values } arrays, and empties this dictionary.\r\n * The array of keys is sorted according to the comparison criterion.\r\n * The position of each value in the array of values corresponds the the position of the corresponding key in the array of keys.\r\n * @returns a pair of { keys, values } arrays in which key[i] corresponds to value[i] in this dictionary and the keys are in sorted order.\r\n */\r\n public extractArrays(): { keys: K[], values: V[] } {\r\n const result = { keys: this._keys, values: this._values };\r\n this.clear();\r\n return result;\r\n }\r\n\r\n /** Apply a function to each (key, value) pair in the dictionary, in sorted order.\r\n * @param func The function to be applied.\r\n */\r\n public forEach(func: (key: K, value: V) => void): void {\r\n for (let i = 0; i < this.size; i++)\r\n func(this._keys[i], this._values[i]);\r\n }\r\n\r\n /**\r\n * Computes the position at which the specified key should be inserted to maintain sorted order.\r\n * @param key The key whose position is to be computed.\r\n * @returns an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent key already exists at that index.\r\n */\r\n protected lowerBound(key: K): { index: number, equal: boolean } { return lowerBound(key, this._keys, this._compareKeys); }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Dictionary.js","sourceRoot":"","sources":["../../src/Dictionary.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAAwE;AAExE,MAAM,kBAAkB;IACd,KAAK,CAAM;IACX,OAAO,CAAM;IACb,SAAS,GAAG,CAAC,CAAC,CAAC;IAEvB,YAAmB,IAAS,EAAE,MAAW;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEM,IAAI;QACT,IAAI,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAC1C,0JAA0J;YAC1J,OAAO,EAAE,IAAI,EAAE,IAAI,EAAkD,CAAC;QACxE,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,KAAK,EAAE;oBACL,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;oBAC/B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;iBACpC;gBACD,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAaD;;;;;;;;;;;;;GAaG;AACH,MAAa,UAAU;IACX,KAAK,GAAQ,EAAE,CAAC;IACP,YAAY,CAAuB;IACnC,SAAS,CAAmB;IACrC,OAAO,GAAQ,EAAE,C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ED;;;;;OAKG;IACI,aAAa;QAClB,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,IAAgC;QAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACO,UAAU,CAAC,GAAM,IAAuC,OAAO,IAAA,wBAAU,EAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAC3H;AA/KD,gCA+KC","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 Collections\n */\n\nimport { OrderedComparator } from \"./Compare\";\nimport { CloneFunction, lowerBound, shallowClone } from \"./SortedArray\";\n\nclass DictionaryIterator<K, V> implements Iterator<DictionaryEntry<K, V>> {\n private _keys: K[];\n private _values: V[];\n private _curIndex = -1;\n\n public constructor(keys: K[], values: V[]) {\n this._keys = keys;\n this._values = values;\n }\n\n public next(): IteratorResult<DictionaryEntry<K, V>> {\n if (++this._curIndex >= this._keys.length) {\n // The ECMAScript spec states that value=undefined is valid if done=true. The TypeScript interface violates the spec hence the cast to any and back below.\n return { done: true } as any as IteratorResult<DictionaryEntry<K, V>>;\n } else {\n return {\n value: {\n key: this._keys[this._curIndex],\n value: this._values[this._curIndex],\n },\n done: false,\n };\n }\n }\n}\n\n/**\n * Represents an entry in a [[Dictionary]].\n * @public\n */\nexport interface DictionaryEntry<K, V> {\n /** The key used for lookup in the Dictionary. */\n key: K;\n /** The value associated with the key in the Dictionary. */\n value: V;\n}\n\n/**\n * Maintains a mapping of keys to values.\n * Unlike the standard Map<K, V>, a Dictionary<K, V> supports custom comparison logic for keys of object type (and for any other type).\n * The user supplies a key comparison function to the constructor, that must meet the following criteria given 'lhs' and 'rhs' of type K:\n * - If lhs is equal to rhs, returns 0\n * - If lhs is less than rhs, returns a negative value\n * - If lhs is greater than rhs, returns a positive value\n * - If compare(lhs, rhs) returns 0, then compare(rhs, lhs) must also return 0\n * - If compare(lhs, rhs) returns a negative value, then compare(rhs, lhs) must return a positive value, and vice versa.\n *\n * Modifying a key in a way that affects the comparison function will produce unpredictable results, the\n * most likely of which is that keys will cease to map to the values with which they were initially inserted.\n * @public\n */\nexport class Dictionary<K, V> implements Iterable<DictionaryEntry<K, V>> {\n protected _keys: K[] = [];\n protected readonly _compareKeys: OrderedComparator<K>;\n protected readonly _cloneKey: CloneFunction<K>;\n protected _values: V[] = [];\n protected readonly _cloneValue: CloneFunction<V>;\n\n /**\n * Construct a new Dictionary<K, V>.\n * @param compareKeys The function used to compare keys within the dictionary.\n * @param cloneKey The function invoked to clone a key for insertion into the dictionary. The default implementation simply returns its input.\n * @param cloneValue The function invoked to clone a value for insertion into the dictionary. The default implementation simply returns its input.\n */\n public constructor(compareKeys: OrderedComparator<K>, cloneKey: CloneFunction<K> = shallowClone, cloneValue: CloneFunction<V> = shallowClone) {\n this._compareKeys = compareKeys;\n this._cloneKey = cloneKey;\n this._cloneValue = cloneValue;\n }\n\n /** The number of entries in the dictionary. */\n public get size(): number { return this._keys.length; }\n\n /** Returns an iterator over the key-value pairs in the Dictionary suitable for use in `for-of` loops. Entries are returned in sorted order by key. */\n public [Symbol.iterator](): Iterator<DictionaryEntry<K, V>> {\n return new DictionaryIterator<K, V>(this._keys, this._values);\n }\n\n /** Provides iteration over the keys in this Dictionary, in sorted order. */\n public keys(): Iterable<K> {\n function * iterator(dict: Dictionary<K, V>) {\n for (const entry of dict)\n yield entry.key;\n }\n\n return {\n [Symbol.iterator]: () => iterator(this),\n };\n }\n\n /** Provides iteration over the values in this Dictionary, in sorted order by the corresponding keys. */\n public values(): Iterable<V> {\n function * iterator(dict: Dictionary<K, V>) {\n for (const entry of dict)\n yield entry.value;\n }\n\n return {\n [Symbol.iterator]: () => iterator(this),\n };\n }\n\n /** Removes all entries from this dictionary */\n public clear(): void {\n this._keys = [];\n this._values = [];\n }\n\n /**\n * Looks up a value by its key.\n * @param key The key to search for\n * @returns the value associated with the key, or undefined if the key is not present in the dictionary.\n */\n public get(key: K): V | undefined {\n const bound = this.lowerBound(key);\n return bound.equal ? this._values[bound.index] : undefined;\n }\n\n /**\n * Determines if an entry exists for the specified key\n * @param key The key to search for\n * @returns true if an entry exists in this dictionary corresponding to the specified key.\n */\n public has(key: K): boolean {\n return this.lowerBound(key).equal;\n }\n\n /**\n * Deletes a value using its key.\n * @param key The key to delete\n * @returns true if the key was found and deleted.\n */\n public delete(key: K): boolean {\n const bound = this.lowerBound(key);\n if (bound.equal) {\n this._values.splice(bound.index, 1);\n this._keys.splice(bound.index, 1);\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Attempts to insert a new entry into the dictionary. If an entry with an equivalent key exists, the dictionary is unmodified.\n * If the new entry is in fact inserted, both the key and value will be cloned using the functions supplied to the dictionary's constructor.\n * @param key The key to associate with the value\n * @param value The value to associate with the key\n * @returns true if the new entry was inserted, false if an entry with an equivalent key already exists.\n */\n public insert(key: K, value: V): boolean {\n const result = this.findOrInsert(key, value);\n return result.inserted;\n }\n\n /** Obtains the value associated with the specified key, or inserts it if the specified key does not yet exist.\n * @param key The key to search for.\n * @param value The value to associate with `key` if `key` does not yet exist in the dictionary.\n * @returns The found or inserted value and a flag indicating whether the new value was inserted.\n */\n public findOrInsert(key: K, value: V): { value: V, inserted: boolean } {\n const bound = this.lowerBound(key);\n if (bound.equal)\n return { value: this._values[bound.index], inserted: false };\n\n value = this._cloneValue(value);\n this._keys.splice(bound.index, 0, this._cloneKey(key));\n this._values.splice(bound.index, 0, this._cloneValue(value));\n return { value, inserted: true };\n }\n\n /**\n * Sets the value associated with the specified key in the dictionary.\n * If no such key already exists, this is equivalent to insert(key, value); otherwise, the existing value associated with the key is replaced.\n * In either case, the value will be cloned using the function supplied to the dictionary's constructor.\n */\n public set(key: K, value: V): void {\n value = this._cloneValue(value);\n const bound = this.lowerBound(key);\n if (bound.equal) {\n this._values[bound.index] = value;\n } else {\n this._keys.splice(bound.index, 0, this._cloneKey(key));\n this._values.splice(bound.index, 0, value);\n }\n }\n\n /**\n * Extracts the contents of this dictionary as an array of { key, value } pairs, and empties this dictionary.\n * @returns An array of { key, value } pairs sorted by key.\n */\n public extractPairs(): Array<{ key: K, value: V }> {\n const pairs: Array<{ key: K, value: V }> = [];\n for (let i = 0; i < this.size; i++)\n pairs.push({ key: this._keys[i], value: this._values[i] });\n\n this.clear();\n return pairs;\n }\n\n /**\n * Extracts the contents of this dictionary as a pair of { keys, values } arrays, and empties this dictionary.\n * The array of keys is sorted according to the comparison criterion.\n * The position of each value in the array of values corresponds the the position of the corresponding key in the array of keys.\n * @returns a pair of { keys, values } arrays in which key[i] corresponds to value[i] in this dictionary and the keys are in sorted order.\n */\n public extractArrays(): { keys: K[], values: V[] } {\n const result = { keys: this._keys, values: this._values };\n this.clear();\n return result;\n }\n\n /** Apply a function to each (key, value) pair in the dictionary, in sorted order.\n * @param func The function to be applied.\n */\n public forEach(func: (key: K, value: V) => void): void {\n for (let i = 0; i < this.size; i++)\n func(this._keys[i], this._values[i]);\n }\n\n /**\n * Computes the position at which the specified key should be inserted to maintain sorted order.\n * @param key The key whose position is to be computed.\n * @returns an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent key already exists at that index.\n */\n protected lowerBound(key: K): { index: number, equal: boolean } { return lowerBound(key, this._keys, this._compareKeys); }\n}\n"]}
|
package/lib/cjs/Disposable.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Implementations of IDisposable tend to be more "low-level" types. The disposal of such types is often handled on your behalf.
|
|
16
16
|
* However, always consult the documentation for an IDisposable type to determine under what circumstances you are expected to explicitly dispose of it.
|
|
17
|
+
* @deprecated in 5.0 Use builtin Disposable type instead.
|
|
17
18
|
* @public
|
|
18
19
|
*/
|
|
19
20
|
export interface IDisposable {
|
|
@@ -24,9 +25,15 @@ export interface IDisposable {
|
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* A type guard that checks whether the given argument implements `IDisposable` interface
|
|
28
|
+
* @deprecated in 5.0 Use isDisposable instead.
|
|
27
29
|
* @public
|
|
28
30
|
*/
|
|
29
31
|
export declare function isIDisposable(obj: unknown): obj is IDisposable;
|
|
32
|
+
/**
|
|
33
|
+
* A type guard that checks whether the given argument implements `Disposable` interface
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare function isDisposable(obj: unknown): obj is Disposable;
|
|
30
37
|
/** Convenience function for disposing of a disposable object that may be undefined.
|
|
31
38
|
* This is primarily used to simplify implementations of [[IDisposable.dispose]].
|
|
32
39
|
* As a simple example:
|
|
@@ -45,18 +52,29 @@ export declare function isIDisposable(obj: unknown): obj is IDisposable;
|
|
|
45
52
|
* @returns undefined
|
|
46
53
|
* @public
|
|
47
54
|
*/
|
|
55
|
+
export declare function dispose(disposable?: Disposable): undefined;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated in 5.0 Use builtin Disposable type instead.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
48
60
|
export declare function dispose(disposable?: IDisposable): undefined;
|
|
49
61
|
/** Disposes of and empties a list of disposable objects.
|
|
50
62
|
* @param list The list of disposable objects.
|
|
51
63
|
* @returns undefined
|
|
52
64
|
* @public
|
|
53
65
|
*/
|
|
66
|
+
export declare function disposeArray(list?: Disposable[]): undefined;
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated in 5.0 Use builtin Disposable type instead.
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
54
71
|
export declare function disposeArray(list?: IDisposable[]): undefined;
|
|
55
72
|
/** A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose'
|
|
56
73
|
* is called on the resource no matter if the func returns or throws. If func returns, the return value
|
|
57
74
|
* of this function is equal to return value of func. If func throws, this function also throws (after
|
|
58
75
|
* disposing the resource).
|
|
59
76
|
* @public
|
|
77
|
+
* @deprecated in 5.0 Use `using` declarations instead.
|
|
60
78
|
*/
|
|
61
79
|
export declare function using<T extends IDisposable, TResult>(resources: T | T[], func: (...r: T[]) => TResult): TResult;
|
|
62
80
|
/** A definition of function which may be called to dispose an object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Disposable.d.ts","sourceRoot":"","sources":["../../src/Disposable.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"Disposable.d.ts","sourceRoot":"","sources":["../../src/Disposable.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW,CAE9D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,UAAU,CAE5D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,OAAO,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;AAC5D;;;GAGG;AACH,wBAAgB,OAAO,CAAC,UAAU,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;AAW7D;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;AAC7D;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;AAgB9D;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,OAAO,GAAG,OAAO,CAkB/G;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAQrC;;GAEG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,OAAO,CAAC,YAAY,CAAgB;IAEpC,iCAAiC;gBACrB,WAAW,GAAE,KAAK,CAAC,WAAW,GAAG,WAAW,CAAM;IAO9D,OAAO,CAAC,YAAY;IAIpB,uCAAuC;IAChC,GAAG,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW;IAOhD,oCAAoC;IAC7B,MAAM,CAAC,UAAU,EAAE,WAAW,GAAG,IAAI;IAM5C,uCAAuC;IAChC,OAAO,IAAI,IAAI;CAIvB"}
|
package/lib/cjs/Disposable.js
CHANGED
|
@@ -9,49 +9,46 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.DisposableList = void 0;
|
|
11
11
|
exports.isIDisposable = isIDisposable;
|
|
12
|
+
exports.isDisposable = isDisposable;
|
|
12
13
|
exports.dispose = dispose;
|
|
13
14
|
exports.disposeArray = disposeArray;
|
|
14
15
|
exports.using = using;
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
17
|
+
Symbol.dispose ??= Symbol("Symbol.dispose");
|
|
18
|
+
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
15
19
|
/**
|
|
16
20
|
* A type guard that checks whether the given argument implements `IDisposable` interface
|
|
21
|
+
* @deprecated in 5.0 Use isDisposable instead.
|
|
17
22
|
* @public
|
|
18
23
|
*/
|
|
19
24
|
function isIDisposable(obj) {
|
|
20
25
|
return !!obj && (obj instanceof Object) && !!obj.dispose && (typeof obj.dispose === "function");
|
|
21
26
|
}
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* As a simple example:
|
|
25
|
-
* ```ts
|
|
26
|
-
* class Disposable implements IDisposable {
|
|
27
|
-
* public member1?: DisposableType1;
|
|
28
|
-
* public member2?: DisposableType2;
|
|
29
|
-
*
|
|
30
|
-
* public dispose() {
|
|
31
|
-
* this.member1 = dispose(this.member1); // If member1 is defined, dispose of it and set it to undefined.
|
|
32
|
-
* this.member2 = dispose(this.member2); // Likewise for member2.
|
|
33
|
-
* }
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
* @param disposable The object to be disposed of.
|
|
37
|
-
* @returns undefined
|
|
27
|
+
/**
|
|
28
|
+
* A type guard that checks whether the given argument implements `Disposable` interface
|
|
38
29
|
* @public
|
|
39
30
|
*/
|
|
31
|
+
function isDisposable(obj) {
|
|
32
|
+
return !!obj && (obj instanceof Object) && !!obj[Symbol.dispose] && (typeof obj[Symbol.dispose] === "function");
|
|
33
|
+
}
|
|
40
34
|
function dispose(disposable) {
|
|
41
|
-
if (undefined !== disposable)
|
|
42
|
-
|
|
35
|
+
if (undefined !== disposable) {
|
|
36
|
+
if (Symbol.dispose in disposable)
|
|
37
|
+
disposable[Symbol.dispose]();
|
|
38
|
+
else
|
|
39
|
+
disposable.dispose();
|
|
40
|
+
}
|
|
43
41
|
return undefined;
|
|
44
42
|
}
|
|
45
|
-
/** Disposes of and empties a list of disposable objects.
|
|
46
|
-
* @param list The list of disposable objects.
|
|
47
|
-
* @returns undefined
|
|
48
|
-
* @public
|
|
49
|
-
*/
|
|
50
43
|
function disposeArray(list) {
|
|
51
44
|
if (undefined === list)
|
|
52
45
|
return undefined;
|
|
53
|
-
for (const entry of list)
|
|
54
|
-
dispose
|
|
46
|
+
for (const entry of list) {
|
|
47
|
+
if (Symbol.dispose in entry)
|
|
48
|
+
entry[Symbol.dispose]();
|
|
49
|
+
else
|
|
50
|
+
entry.dispose();
|
|
51
|
+
}
|
|
55
52
|
list.length = 0;
|
|
56
53
|
return undefined;
|
|
57
54
|
}
|
|
@@ -60,6 +57,7 @@ function disposeArray(list) {
|
|
|
60
57
|
* of this function is equal to return value of func. If func throws, this function also throws (after
|
|
61
58
|
* disposing the resource).
|
|
62
59
|
* @public
|
|
60
|
+
* @deprecated in 5.0 Use `using` declarations instead.
|
|
63
61
|
*/
|
|
64
62
|
function using(resources, func) {
|
|
65
63
|
if (!Array.isArray(resources))
|
|
@@ -80,6 +78,7 @@ function using(resources, func) {
|
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
80
|
class FuncDisposable {
|
|
81
|
+
_disposeFunc;
|
|
83
82
|
constructor(disposeFunc) { this._disposeFunc = disposeFunc; }
|
|
84
83
|
dispose() { this._disposeFunc(); }
|
|
85
84
|
}
|
|
@@ -87,6 +86,7 @@ class FuncDisposable {
|
|
|
87
86
|
* @public
|
|
88
87
|
*/
|
|
89
88
|
class DisposableList {
|
|
89
|
+
_disposables;
|
|
90
90
|
/** Creates a disposable list. */
|
|
91
91
|
constructor(disposables = []) {
|
|
92
92
|
this._disposables = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Disposable.js","sourceRoot":"","sources":["../../src/Disposable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA4BH,sCAEC;AAoBD,0BAIC;AAOD,oCASC;AAQD,sBAkBC;AAxED;;;GAGG;AACH,SAAgB,aAAa,CAAC,GAAY;IACxC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,YAAY,MAAM,CAAC,IAAI,CAAC,CAAE,GAAmB,CAAC,OAAO,IAAI,CAAC,OAAQ,GAAmB,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;AACpI,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,OAAO,CAAC,UAAwB;IAC9C,IAAI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zB,iCAAiC;IACjC,YAAY,cAAgD,EAAE;QAC5D,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,YAAY,CAAC,CAA4B;QAC/C,OAAQ,CAAiB,CAAC,OAAO,KAAK,SAAS,CAAC;IAClD,CAAC;IAED,uCAAuC;IAChC,GAAG,CAAC,UAAqC;QAC9C,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;YAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;;YAEnC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,oCAAoC;IAC7B,MAAM,CAAC,UAAuB;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,CAAC,KAAK,GAAG;YACZ,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,uCAAuC;IAChC,OAAO;QACZ,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,YAAY;YACxC,UAAU,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF;AAnCD,wCAmCC","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/** Interface adopted by a type which has deterministic cleanup logic.\r\n * For example:\r\n * - Most rendering-related types, such as [[RenderGraphic]] and [[Viewport]], own WebGL resources which must be explicitly released when no longer needed.\r\n * - Some low-level objects like [[ECDb]] own native types defined in C++ code which must be explicitly released when no longer needed.\r\n *\r\n * A similar concept exists in languages like C++ (implemented as \"destructors\") and C# (\"IDisposable\").\r\n * However, because TypeScript and Javascript lack any built-in support for deterministic destruction, it is up to the programmer to ensure dispose() is called appropriately.\r\n * Failure to do so may result in memory leaks or leaking of other resources.\r\n *\r\n * IDisposable tends to be contagious; that is, if a type has members which implement IDisposable, that type should also implement IDisposable to dispose of those members.\r\n *\r\n * Implementations of IDisposable tend to be more \"low-level\" types. The disposal of such types is often handled on your behalf.\r\n * However, always consult the documentation for an IDisposable type to determine under what circumstances you are expected to explicitly dispose of it.\r\n * @public\r\n */\r\nexport interface IDisposable {\r\n /** Disposes of any resources owned by this object.\r\n * @note The object is generally considered unusable after it has been disposed of.\r\n */\r\n dispose(): void;\r\n}\r\n\r\n/**\r\n * A type guard that checks whether the given argument implements `IDisposable` interface\r\n * @public\r\n */\r\nexport function isIDisposable(obj: unknown): obj is IDisposable {\r\n return !!obj && (obj instanceof Object) && !!(obj as IDisposable).dispose && (typeof (obj as IDisposable).dispose === \"function\");\r\n}\r\n\r\n/** Convenience function for disposing of a disposable object that may be undefined.\r\n * This is primarily used to simplify implementations of [[IDisposable.dispose]].\r\n * As a simple example:\r\n * ```ts\r\n * class Disposable implements IDisposable {\r\n * public member1?: DisposableType1;\r\n * public member2?: DisposableType2;\r\n *\r\n * public dispose() {\r\n * this.member1 = dispose(this.member1); // If member1 is defined, dispose of it and set it to undefined.\r\n * this.member2 = dispose(this.member2); // Likewise for member2.\r\n * }\r\n * }\r\n * ```\r\n * @param disposable The object to be disposed of.\r\n * @returns undefined\r\n * @public\r\n */\r\nexport function dispose(disposable?: IDisposable): undefined {\r\n if (undefined !== disposable)\r\n disposable.dispose();\r\n return undefined;\r\n}\r\n\r\n/** Disposes of and empties a list of disposable objects.\r\n * @param list The list of disposable objects.\r\n * @returns undefined\r\n * @public\r\n */\r\nexport function disposeArray(list?: IDisposable[]): undefined {\r\n if (undefined === list)\r\n return undefined;\r\n\r\n for (const entry of list)\r\n dispose(entry);\r\n\r\n list.length = 0;\r\n return undefined;\r\n}\r\n\r\n/** A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose'\r\n * is called on the resource no matter if the func returns or throws. If func returns, the return value\r\n * of this function is equal to return value of func. If func throws, this function also throws (after\r\n * disposing the resource).\r\n * @public\r\n */\r\nexport function using<T extends IDisposable, TResult>(resources: T | T[], func: (...r: T[]) => TResult): TResult {\r\n if (!Array.isArray(resources))\r\n return using([resources], func);\r\n\r\n const doDispose = () => resources.forEach((disposable) => disposable.dispose());\r\n let shouldDisposeImmediately = true;\r\n\r\n try {\r\n const result = func(...resources);\r\n if (result instanceof Promise) {\r\n shouldDisposeImmediately = false;\r\n result.then(doDispose, doDispose);\r\n }\r\n return result;\r\n } finally {\r\n if (shouldDisposeImmediately)\r\n doDispose();\r\n }\r\n}\r\n\r\n/** A definition of function which may be called to dispose an object\r\n * @public\r\n */\r\nexport type DisposeFunc = () => void;\r\n\r\nclass FuncDisposable implements IDisposable {\r\n private _disposeFunc: () => void;\r\n constructor(disposeFunc: () => void) { this._disposeFunc = disposeFunc; }\r\n public dispose() { this._disposeFunc(); }\r\n}\r\n\r\n/** A disposable container of disposable objects.\r\n * @public\r\n */\r\nexport class DisposableList implements IDisposable {\r\n private _disposables: IDisposable[];\r\n\r\n /** Creates a disposable list. */\r\n constructor(disposables: Array<IDisposable | DisposeFunc> = []) {\r\n this._disposables = [];\r\n disposables.forEach((disposable) => {\r\n this.add(disposable);\r\n });\r\n }\r\n\r\n private isDisposable(x: IDisposable | DisposeFunc): x is IDisposable {\r\n return (x as IDisposable).dispose !== undefined;\r\n }\r\n\r\n /** Register an object for disposal. */\r\n public add(disposable: IDisposable | DisposeFunc) {\r\n if (this.isDisposable(disposable))\r\n this._disposables.push(disposable);\r\n else\r\n this._disposables.push(new FuncDisposable(disposable));\r\n }\r\n\r\n /** Unregister disposable object. */\r\n public remove(disposable: IDisposable): void {\r\n const idx = this._disposables.indexOf(disposable);\r\n if (-1 !== idx)\r\n this._disposables.splice(idx, 1);\r\n }\r\n\r\n /** Disposes all registered objects. */\r\n public dispose(): void {\r\n for (const disposable of this._disposables)\r\n disposable.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Disposable.js","sourceRoot":"","sources":["../../src/Disposable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAkCH,sCAEC;AAMD,oCAEC;AA0BD,0BAQC;AAaD,oCAaC;AASD,sBAkBC;AAjID,qDAAqD;AACpD,MAAc,CAAC,OAAO,KAAK,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACpD,MAAc,CAAC,YAAY,KAAK,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAyB/D;;;;GAIG;AACH,SAAgB,aAAa,CAAC,GAAY;IACxC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,YAAY,MAAM,CAAC,IAAI,CAAC,CAAE,GAAmB,CAAC,OAAO,IAAI,CAAC,OAAQ,GAAmB,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;AACpI,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,GAAY;IACvC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,YAAY,MAAM,CAAC,IAAI,CAAC,CAAE,GAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAQ,GAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC;AAClJ,CAAC;AA0BD,SAAgB,OAAO,CAAC,UAAqC;IAC3D,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,OAAO,IAAI,UAAU;YAC9B,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;;YAE7B,UAAU,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AA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;;GAEG;AACH,MAAa,cAAc;IACjB,YAAY,CAAgB;IAEpC,iCAAiC;IACjC,YAAY,cAAgD,EAAE;QAC5D,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,YAAY,CAAC,CAA4B;QAC/C,OAAQ,CAAiB,CAAC,OAAO,KAAK,SAAS,CAAC;IAClD,CAAC;IAED,uCAAuC;IAChC,GAAG,CAAC,UAAqC;QAC9C,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;YAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;;YAEnC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,oCAAoC;IAC7B,MAAM,CAAC,UAAuB;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,CAAC,KAAK,GAAG;YACZ,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,uCAAuC;IAChC,OAAO;QACZ,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,YAAY;YACxC,UAAU,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF;AAnCD,wCAmCC","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/* eslint-disable @typescript-eslint/no-deprecated */\n(Symbol as any).dispose ??= Symbol(\"Symbol.dispose\");\n(Symbol as any).asyncDispose ??= Symbol(\"Symbol.asyncDispose\");\n\n/** Interface adopted by a type which has deterministic cleanup logic.\n * For example:\n * - Most rendering-related types, such as [[RenderGraphic]] and [[Viewport]], own WebGL resources which must be explicitly released when no longer needed.\n * - Some low-level objects like [[ECDb]] own native types defined in C++ code which must be explicitly released when no longer needed.\n *\n * A similar concept exists in languages like C++ (implemented as \"destructors\") and C# (\"IDisposable\").\n * However, because TypeScript and Javascript lack any built-in support for deterministic destruction, it is up to the programmer to ensure dispose() is called appropriately.\n * Failure to do so may result in memory leaks or leaking of other resources.\n *\n * IDisposable tends to be contagious; that is, if a type has members which implement IDisposable, that type should also implement IDisposable to dispose of those members.\n *\n * Implementations of IDisposable tend to be more \"low-level\" types. The disposal of such types is often handled on your behalf.\n * However, always consult the documentation for an IDisposable type to determine under what circumstances you are expected to explicitly dispose of it.\n * @deprecated in 5.0 Use builtin Disposable type instead.\n * @public\n */\nexport interface IDisposable {\n /** Disposes of any resources owned by this object.\n * @note The object is generally considered unusable after it has been disposed of.\n */\n dispose(): void;\n}\n\n/**\n * A type guard that checks whether the given argument implements `IDisposable` interface\n * @deprecated in 5.0 Use isDisposable instead.\n * @public\n */\nexport function isIDisposable(obj: unknown): obj is IDisposable {\n return !!obj && (obj instanceof Object) && !!(obj as IDisposable).dispose && (typeof (obj as IDisposable).dispose === \"function\");\n}\n\n/**\n * A type guard that checks whether the given argument implements `Disposable` interface\n * @public\n */\nexport function isDisposable(obj: unknown): obj is Disposable {\n return !!obj && (obj instanceof Object) && !!(obj as Disposable)[Symbol.dispose] && (typeof (obj as Disposable)[Symbol.dispose] === \"function\");\n}\n\n/** Convenience function for disposing of a disposable object that may be undefined.\n * This is primarily used to simplify implementations of [[IDisposable.dispose]].\n * As a simple example:\n * ```ts\n * class Disposable implements IDisposable {\n * public member1?: DisposableType1;\n * public member2?: DisposableType2;\n *\n * public dispose() {\n * this.member1 = dispose(this.member1); // If member1 is defined, dispose of it and set it to undefined.\n * this.member2 = dispose(this.member2); // Likewise for member2.\n * }\n * }\n * ```\n * @param disposable The object to be disposed of.\n * @returns undefined\n * @public\n */\nexport function dispose(disposable?: Disposable): undefined;\n/**\n * @deprecated in 5.0 Use builtin Disposable type instead.\n * @public\n */\nexport function dispose(disposable?: IDisposable): undefined; // eslint-disable-line @typescript-eslint/unified-signatures\nexport function dispose(disposable?: Disposable | IDisposable): undefined {\n if (undefined !== disposable) {\n if (Symbol.dispose in disposable)\n disposable[Symbol.dispose]();\n else\n disposable.dispose();\n }\n return undefined;\n}\n\n/** Disposes of and empties a list of disposable objects.\n * @param list The list of disposable objects.\n * @returns undefined\n * @public\n */\nexport function disposeArray(list?: Disposable[]): undefined;\n/**\n * @deprecated in 5.0 Use builtin Disposable type instead.\n * @public\n */\nexport function disposeArray(list?: IDisposable[]): undefined; // eslint-disable-line @typescript-eslint/unified-signatures\nexport function disposeArray(list?: Disposable[] | IDisposable[]): undefined {\n if (undefined === list)\n return undefined;\n\n for (const entry of list) {\n if (Symbol.dispose in entry)\n entry[Symbol.dispose]();\n else\n entry.dispose();\n }\n\n list.length = 0;\n return undefined;\n}\n\n/** A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose'\n * is called on the resource no matter if the func returns or throws. If func returns, the return value\n * of this function is equal to return value of func. If func throws, this function also throws (after\n * disposing the resource).\n * @public\n * @deprecated in 5.0 Use `using` declarations instead.\n */\nexport function using<T extends IDisposable, TResult>(resources: T | T[], func: (...r: T[]) => TResult): TResult {\n if (!Array.isArray(resources))\n return using([resources], func);\n\n const doDispose = () => resources.forEach((disposable) => disposable.dispose());\n let shouldDisposeImmediately = true;\n\n try {\n const result = func(...resources);\n if (result instanceof Promise) {\n shouldDisposeImmediately = false;\n result.then(doDispose, doDispose);\n }\n return result;\n } finally {\n if (shouldDisposeImmediately)\n doDispose();\n }\n}\n\n/** A definition of function which may be called to dispose an object\n * @public\n */\nexport type DisposeFunc = () => void;\n\nclass FuncDisposable implements IDisposable {\n private _disposeFunc: () => void;\n constructor(disposeFunc: () => void) { this._disposeFunc = disposeFunc; }\n public dispose() { this._disposeFunc(); }\n}\n\n/** A disposable container of disposable objects.\n * @public\n */\nexport class DisposableList implements IDisposable {\n private _disposables: IDisposable[];\n\n /** Creates a disposable list. */\n constructor(disposables: Array<IDisposable | DisposeFunc> = []) {\n this._disposables = [];\n disposables.forEach((disposable) => {\n this.add(disposable);\n });\n }\n\n private isDisposable(x: IDisposable | DisposeFunc): x is IDisposable {\n return (x as IDisposable).dispose !== undefined;\n }\n\n /** Register an object for disposal. */\n public add(disposable: IDisposable | DisposeFunc) {\n if (this.isDisposable(disposable))\n this._disposables.push(disposable);\n else\n this._disposables.push(new FuncDisposable(disposable));\n }\n\n /** Unregister disposable object. */\n public remove(disposable: IDisposable): void {\n const idx = this._disposables.indexOf(disposable);\n if (-1 !== idx)\n this._disposables.splice(idx, 1);\n }\n\n /** Disposes all registered objects. */\n public dispose(): void {\n for (const disposable of this._disposables)\n disposable.dispose();\n }\n}\n"]}
|
package/lib/cjs/Id.d.ts
CHANGED
|
@@ -276,10 +276,6 @@ export declare class TransientIdSequence {
|
|
|
276
276
|
* Each call to [[getNext]] increments this by 1 and uses it as the local Id of the generated [[Id64String]].
|
|
277
277
|
*/
|
|
278
278
|
get currentLocalId(): number;
|
|
279
|
-
/** Generate and return the next transient Id64String in the sequence.
|
|
280
|
-
* @deprecated in 3.x. Use [[getNext]].
|
|
281
|
-
*/
|
|
282
|
-
get next(): Id64String;
|
|
283
279
|
/** Generate and return the next transient Id64String in the sequence. */
|
|
284
280
|
getNext(): Id64String;
|
|
285
281
|
/** Preview the transient Id64String that will be returned by the next call to [[getNext]].
|
package/lib/cjs/Id.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Id.d.ts","sourceRoot":"","sources":["../../src/Id.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,U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AAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7C;IAED,mEAAmE;IACnE,SAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE/C;IAED,iCAAiC;IACjC,SAAgB,WAAW,IAAI,UAAU,CAOxC;IAED;;;;;;;OAOG;IACH,SAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAkBvD;CACF"}
|
package/lib/cjs/Id.js
CHANGED
|
@@ -420,11 +420,11 @@ var Id64;
|
|
|
420
420
|
* @public
|
|
421
421
|
*/
|
|
422
422
|
class Uint32Set {
|
|
423
|
+
_map = new Map();
|
|
423
424
|
/** Construct a new Uint32Set.
|
|
424
425
|
* @param ids If supplied, all of the specified Ids will be added to the new set.
|
|
425
426
|
*/
|
|
426
427
|
constructor(ids) {
|
|
427
|
-
this._map = new Map();
|
|
428
428
|
if (undefined !== ids)
|
|
429
429
|
this.addIds(ids);
|
|
430
430
|
}
|
|
@@ -485,8 +485,11 @@ var Id64;
|
|
|
485
485
|
/** Remove an Id from the set. */
|
|
486
486
|
delete(low, high) {
|
|
487
487
|
const set = this._map.get(high);
|
|
488
|
-
if (undefined !== set)
|
|
488
|
+
if (undefined !== set) {
|
|
489
489
|
set.delete(low);
|
|
490
|
+
if (set.size === 0)
|
|
491
|
+
this._map.delete(high);
|
|
492
|
+
}
|
|
490
493
|
}
|
|
491
494
|
/** Returns true if the set contains the specified Id. */
|
|
492
495
|
has(low, high) {
|
|
@@ -535,9 +538,7 @@ var Id64;
|
|
|
535
538
|
* @public
|
|
536
539
|
*/
|
|
537
540
|
class Uint32Map {
|
|
538
|
-
|
|
539
|
-
this._map = new Map();
|
|
540
|
-
}
|
|
541
|
+
_map = new Map();
|
|
541
542
|
/** Remove all entries from the map. */
|
|
542
543
|
clear() { this._map.clear(); }
|
|
543
544
|
/** Find an entry in the map by Id. */
|
|
@@ -588,6 +589,9 @@ function validateLocalId(num) {
|
|
|
588
589
|
* @public
|
|
589
590
|
*/
|
|
590
591
|
class TransientIdSequence {
|
|
592
|
+
/** The starting local Id provided to the constructor. The sequence begins at `initialLocalId + 1`. */
|
|
593
|
+
initialLocalId;
|
|
594
|
+
_localId;
|
|
591
595
|
/** Constructor.
|
|
592
596
|
* @param initialLocalId The starting local Id. The local Id of the first [[Id64String]] generated by [[getNext]] will be `initialLocalId + 1`.
|
|
593
597
|
*/
|
|
@@ -603,12 +607,6 @@ class TransientIdSequence {
|
|
|
603
607
|
get currentLocalId() {
|
|
604
608
|
return this._localId;
|
|
605
609
|
}
|
|
606
|
-
/** Generate and return the next transient Id64String in the sequence.
|
|
607
|
-
* @deprecated in 3.x. Use [[getNext]].
|
|
608
|
-
*/
|
|
609
|
-
get next() {
|
|
610
|
-
return this.getNext();
|
|
611
|
-
}
|
|
612
610
|
/** Generate and return the next transient Id64String in the sequence. */
|
|
613
611
|
getNext() {
|
|
614
612
|
return Id64.fromLocalAndBriefcaseIds(++this._localId, 0xffffff);
|