@itwin/core-bentley 5.1.3 → 5.2.0-dev.10
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 +1 -6
- package/lib/cjs/Expect.d.ts +23 -0
- package/lib/cjs/Expect.d.ts.map +1 -0
- package/lib/cjs/Expect.js +41 -0
- package/lib/cjs/Expect.js.map +1 -0
- package/lib/cjs/LRUMap.js +1 -1
- package/lib/cjs/LRUMap.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/Expect.d.ts +23 -0
- package/lib/esm/Expect.d.ts.map +1 -0
- package/lib/esm/Expect.js +37 -0
- package/lib/esm/Expect.js.map +1 -0
- package/lib/esm/LRUMap.js +1 -1
- package/lib/esm/LRUMap.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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
# Change Log - @itwin/core-bentley
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
4
|
-
|
|
5
|
-
## 5.1.3
|
|
6
|
-
Wed, 20 Aug 2025 13:57:10 GMT
|
|
7
|
-
|
|
8
|
-
_Version update only_
|
|
3
|
+
This log was last generated on Thu, 14 Aug 2025 19:42:13 GMT and should not be manually modified.
|
|
9
4
|
|
|
10
5
|
## 5.1.2
|
|
11
6
|
Thu, 14 Aug 2025 19:38:08 GMT
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expects that a value is defined (not undefined).
|
|
3
|
+
* @note Almost always, places that use this function should in the future be cleaned up to properly
|
|
4
|
+
* handle undefined values instead of throwing an error.
|
|
5
|
+
* @param value The value to check.
|
|
6
|
+
* @param message Optional error message to be used in thrown Error.
|
|
7
|
+
* @returns The original value if it is defined.
|
|
8
|
+
* @throws Error if the value is undefined.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function expectDefined<T>(value: T | undefined, message?: string): T;
|
|
12
|
+
/**
|
|
13
|
+
* Expects that a value is not null.
|
|
14
|
+
* @note Almost always, places that use this function should in the future be cleaned up to properly
|
|
15
|
+
* handle null values instead of throwing an error.
|
|
16
|
+
* @param value The value to check.
|
|
17
|
+
* @param message Optional error message to be used in thrown Error.
|
|
18
|
+
* @returns The original value if it is not null.
|
|
19
|
+
* @throws Error if the value is null.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare function expectNotNull<T>(value: T | null, message?: string): T;
|
|
23
|
+
//# sourceMappingURL=Expect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Expect.d.ts","sourceRoot":"","sources":["../../src/Expect.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAK1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAKrE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.expectDefined = expectDefined;
|
|
8
|
+
exports.expectNotNull = expectNotNull;
|
|
9
|
+
/**
|
|
10
|
+
* Expects that a value is defined (not undefined).
|
|
11
|
+
* @note Almost always, places that use this function should in the future be cleaned up to properly
|
|
12
|
+
* handle undefined values instead of throwing an error.
|
|
13
|
+
* @param value The value to check.
|
|
14
|
+
* @param message Optional error message to be used in thrown Error.
|
|
15
|
+
* @returns The original value if it is defined.
|
|
16
|
+
* @throws Error if the value is undefined.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
function expectDefined(value, message) {
|
|
20
|
+
if (value === undefined) {
|
|
21
|
+
throw new Error(message ?? "Expected value to be defined, but it was undefined.");
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Expects that a value is not null.
|
|
27
|
+
* @note Almost always, places that use this function should in the future be cleaned up to properly
|
|
28
|
+
* handle null values instead of throwing an error.
|
|
29
|
+
* @param value The value to check.
|
|
30
|
+
* @param message Optional error message to be used in thrown Error.
|
|
31
|
+
* @returns The original value if it is not null.
|
|
32
|
+
* @throws Error if the value is null.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
function expectNotNull(value, message) {
|
|
36
|
+
if (value === null) {
|
|
37
|
+
throw new Error(message ?? "Expected value to be not null, but it was null.");
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=Expect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Expect.js","sourceRoot":"","sources":["../../src/Expect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;AAY/F,sCAKC;AAYD,sCAKC;AAhCD;;;;;;;;;GASG;AACH,SAAgB,aAAa,CAAI,KAAoB,EAAE,OAAgB;IACrE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,qDAAqD,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,aAAa,CAAI,KAAe,EAAE,OAAgB;IAChE,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,iDAAiD,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/**\n * Expects that a value is defined (not undefined).\n * @note Almost always, places that use this function should in the future be cleaned up to properly\n * handle undefined values instead of throwing an error.\n * @param value The value to check.\n * @param message Optional error message to be used in thrown Error.\n * @returns The original value if it is defined.\n * @throws Error if the value is undefined.\n * @internal\n */\nexport function expectDefined<T>(value: T | undefined, message?: string): T {\n if (value === undefined) {\n throw new Error(message ?? \"Expected value to be defined, but it was undefined.\");\n }\n return value;\n}\n\n/**\n * Expects that a value is not null.\n * @note Almost always, places that use this function should in the future be cleaned up to properly\n * handle null values instead of throwing an error.\n * @param value The value to check.\n * @param message Optional error message to be used in thrown Error.\n * @returns The original value if it is not null.\n * @throws Error if the value is null.\n * @internal\n */\nexport function expectNotNull<T>(value: T | null, message?: string): T {\n if (value === null) {\n throw new Error(message ?? \"Expected value to be not null, but it was null.\");\n }\n return value;\n}\n"]}
|
package/lib/cjs/LRUMap.js
CHANGED
package/lib/cjs/LRUMap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LRUMap.js","sourceRoot":"","sources":["../../src/LRUMap.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,6CAA0C;AAE1C;;;;GAIG;AAEH;;GAEG;AACH,MAAa,KAAK;IAGG;IAAe;IAF3B,KAAK,CAAe;IACpB,KAAK,CAAe;IAC3B,YAAmB,GAAM,EAAS,KAAQ;QAAvB,QAAG,GA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IAED,sCAAsC;IAC/B,QAAQ;QACb,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,OAAO,KAAK,EAAE,CAAC;YACb,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3C,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YACpB,IAAI,KAAK,EAAE,CAAC;gBACV,CAAC,IAAI,KAAK,CAAC;YACb,CAAC;QACH,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA3PD,4BA2PC;AAED;;GAEG;AACH,MAAa,MAAa,SAAQ,QAAc;IAC9C;;OAEG;IACH,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,EAAE,IAAI,GAAG,EAAkB,CAAC,CAAC;IAC1C,CAAC;CACF;AAPD,wBAOC;AAED;;GAEG;AACH,MAAa,aAAoB,SAAQ,QAAc;IACrD;;;;OAIG;IACH,YAAY,KAAa,EAAE,WAAiC;QAC1D,KAAK,CAAC,KAAK,EAAE,IAAI,uBAAU,CAAiB,WAAW,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF;AATD,sCASC","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 { Dictionary } from \"./Dictionary\";\n\n/**\n * Derived from:\n * Licensed under MIT. Copyright (c) 2010 Rasmus Andersson <http://hunch.se/>\n * See README.md at https://github.com/rsms/js-lru for details.\n */\n\n/** An entry holds the key and value, and pointers to any older and newer entries.\n * @public\n */\nexport class Entry<K, V> {\n public newer?: Entry<K, V>;\n public older?: Entry<K, V>;\n constructor(public key: K, public value: V) { }\n}\n\nclass EntryIterator<K, V> implements Iterator<[K, V] | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n const val: [K, V] = [ent.key, ent.value];\n return { done: false, value: val };\n }\n}\n\nclass KeyIterator<K, V> implements Iterator<K | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n return { done: false, value: ent.key };\n }\n}\n\nclass ValueIterator<K, V> implements Iterator<V | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n return { done: false, value: ent.value };\n }\n}\n\n/** The interface that must be satisfied by the underlying container type used by a LRUCache.\n * Compatible with a [[Dictionary]] or a standard Map.\n * @public\n */\nexport interface EntryContainer<K, V> {\n readonly size: number;\n clear(): void;\n get(key: K): Entry<K, V> | undefined;\n set(key: K, value: Entry<K, V>): void;\n has(key: K): boolean;\n delete(key: K): void;\n}\n\n/**\n * A mapping of a key/value pairs, where the size of the cache can be limited.\n *\n * When entries are inserted, if the cache is \"full\", the\n * least-recently-used (LRU) value is dropped. When entries are retrieved, they are moved to the front of the LRU list.\n *\n * Illustration of the design:\n *\n * ```\n *\n * entry entry entry entry\n * ______ ______ ______ ______\n * | head |.newer => | |.newer => | |.newer => | tail |\n * | A | | B | | C | | D |\n * |______| <= older.|______| <= older.|______| <= older.|______|\n *\n * removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n * ```\n * @public\n */\nexport class LRUCache<K, V> {\n private _container: EntryContainer<K, V>;\n\n /** Current number of items */\n public size: number;\n\n /** Maximum number of items this cache can hold */\n public limit: number;\n\n /** Least recently-used entry. Invalidated when cache is modified. */\n public oldest?: Entry<K, V>;\n\n /** Most recently-used entry. Invalidated when cache is modified. */\n public newest?: Entry<K, V>;\n\n /**\n * Construct a new LRUCache to hold up to `limit` entries.\n */\n public constructor(limit: number, container: EntryContainer<K, V>) {\n this.size = 0;\n this.limit = limit;\n this.oldest = this.newest = undefined;\n this._container = container;\n }\n\n private markEntryAsUsed(entry: Entry<K, V>) {\n if (entry === this.newest)\n return; // Already the most recently used entry, so no need to update the list\n\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C <D> E\n if (entry.newer) {\n if (entry === this.oldest) {\n this.oldest = entry.newer;\n }\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older) {\n entry.older.newer = entry.newer; // C. --> E\n }\n entry.newer = undefined; // D --x\n entry.older = this.newest; // D. --> E\n if (this.newest) {\n this.newest.newer = entry; // E. <-- D\n }\n this.newest = entry;\n }\n\n /** Replace all values in this cache with key-value pairs (2-element Arrays) from provided iterable. */\n public assign(entries: Iterable<[K, V]>): void {\n let entry;\n let limit = this.limit || Number.MAX_VALUE;\n this._container.clear();\n const it = entries[Symbol.iterator]();\n for (let itv = it.next(); !itv.done; itv = it.next()) {\n const e = new Entry(itv.value[0], itv.value[1]);\n this._container.set(e.key, e);\n if (!entry) {\n this.oldest = e;\n } else {\n entry.newer = e;\n e.older = entry;\n }\n entry = e;\n if (limit-- === 0) {\n throw new Error(\"overflow\");\n }\n }\n this.newest = entry;\n this.size = this._container.size;\n }\n\n /** Get and register recent use of <key>.\n * Returns the value associated with <key> or undefined if not in cache.\n */\n public get(key: K): V | undefined {\n // First, find our cache entry\n const entry = this._container.get(key);\n if (!entry)\n return; // Not cached. Sorry.\n // As <key> was found in the cache, register it as being requested recently\n this.markEntryAsUsed(entry);\n return entry.value;\n }\n\n /** Put <value> into the cache associated with <key>. Replaces any existing entry with the same key.\n * @returns `this`.\n */\n public set(key: K, value: V): LRUCache<K, V> {\n let entry = this._container.get(key);\n if (entry) {\n // update existing\n entry.value = value;\n this.markEntryAsUsed(entry);\n return this;\n }\n\n // new entry\n this._container.set(key, (entry = new Entry(key, value)));\n\n if (this.newest) {\n // link previous tail to the new tail (entry)\n this.newest.newer = entry;\n entry.older = this.newest;\n } else {\n // we're first in\n this.oldest = entry;\n }\n\n // add new entry to the end of the linked list -- it is now the freshest entry.\n this.newest = entry;\n ++this.size;\n if (this.size > this.limit) {\n // we hit the limit -- remove the head\n this.shift();\n }\n return this;\n }\n\n /** Purge the least recently used (oldest) entry from the cache.\n * @returns The removed entry or undefined if the cache was empty.\n */\n public shift(): [K, V] | undefined {\n const entry = this.oldest;\n if (entry) {\n if (entry.newer) {\n // advance the list\n this.oldest = entry.newer;\n this.oldest.older = undefined;\n } else {\n // the cache is exhausted\n this.oldest = undefined;\n this.newest = undefined;\n }\n // Remove last strong reference to <entry> and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n this._container.delete(entry.key);\n --this.size;\n return [entry.key, entry.value];\n }\n return undefined;\n }\n\n /** Access value for `key` without registering recent use. Useful if you do not\n * want to change the state of the cache, but only \"peek\" at it.\n * @returns The value associated with `key` if found, or undefined if not found.\n */\n public find(key: K): V | undefined {\n const e = this._container.get(key);\n return e ? e.value : undefined;\n }\n\n /** Check if there's a value for key in the cache without registering recent use. */\n public has(key: K): boolean {\n return this._container.has(key);\n }\n\n /** Remove entry `key` from cache and return its value.\n * @returns The removed value, or undefined if not found.\n */\n public delete(key: K): V | undefined {\n const entry = this._container.get(key);\n if (!entry)\n return;\n\n this._container.delete(entry.key);\n if (entry.newer && entry.older) {\n // re-link the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.oldest = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.newest = entry.older;\n } else { // if(entry.older === undefined && entry.newer === undefined) {\n this.oldest = this.newest = undefined;\n }\n\n this.size--;\n return entry.value;\n }\n\n /** Removes all entries */\n public clear(): void {\n // Note: clearing links should be safe, as we don't expose live links to user\n this.oldest = this.newest = undefined;\n this.size = 0;\n this._container.clear();\n }\n\n /** Returns an iterator over all keys, starting with the oldest. */\n public keys(): Iterator<K | undefined> | undefined {\n return this.oldest ? new KeyIterator(this.oldest) : undefined;\n }\n\n /** Returns an iterator over all values, starting with the oldest. */\n public values(): Iterator<V | undefined> | undefined {\n return this.oldest ? new ValueIterator(this.oldest) : undefined;\n }\n\n /** Returns an iterator over all entries, starting with the oldest. */\n public entries(): Iterator<[K, V] | undefined> | undefined {\n return this.oldest ? new EntryIterator(this.oldest) : undefined;\n }\n\n /** Call `fun` for each entry, starting with the oldest entry. */\n public forEach(fun: (value: V, key: K, m: LRUCache<K, V>) => void, thisObj?: any): void {\n if (typeof thisObj !== \"object\") {\n thisObj = this; // eslint-disable-line @typescript-eslint/no-this-alias\n }\n let entry = this.oldest;\n while (entry) {\n fun.call(thisObj, entry.value, entry.key, this);\n entry = entry.newer;\n }\n }\n\n /** Returns a JSON (array) representation */\n public toJSON(): Array<{ key: K, value: V }> {\n const s = new Array(this.size);\n let i = 0;\n let entry = this.oldest;\n while (entry) {\n s[i++] = { key: entry.key, value: entry.value };\n entry = entry.newer;\n }\n return s;\n }\n\n /** Returns a String representation */\n public toString(): string {\n let s = \"\";\n let entry = this.oldest;\n while (entry) {\n s += `${String(entry.key)}:${entry.value}`;\n entry = entry.newer;\n if (entry) {\n s += \" < \";\n }\n }\n return s;\n }\n}\n\n/** A [[LRUCache]] using a standard Map as its internal storage.\n * @public\n */\nexport class LRUMap<K, V> extends LRUCache<K, V> {\n /**\n * Construct a new LRUMap to hold up to `limit` entries.\n */\n constructor(limit: number) {\n super(limit, new Map<K, Entry<K, V>>());\n }\n}\n\n/** A [[LRUCache]] using a [[Dictionary]] as its internal storage, permitting custom key comparison logic.\n * @public\n */\nexport class LRUDictionary<K, V> extends LRUCache<K, V> {\n /**\n * Construct a new LRUDictionary to hold up to `limit` entries.\n * @param limit The maximum number of entries permitted in the dictionary.\n * @param compareKeys The function used to compare keys within the dictionary.\n */\n constructor(limit: number, compareKeys: OrderedComparator<K>) {\n super(limit, new Dictionary<K, Entry<K, V>>(compareKeys));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LRUMap.js","sourceRoot":"","sources":["../../src/LRUMap.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,6CAA0C;AAE1C;;;;GAIG;AAEH;;GAEG;AACH,MAAa,KAAK;IAGG;IAAe;IAF3B,KAAK,CAAe;IACpB,KAAK,CAAe;IAC3B,YAAmB,GAAM,EAAS,KAAQ;QAAvB,QAAG,GAAH,GAAG,CAAG;QAAS,UAAK,GAAL,KAAK,CAAG;IAAI,CAAC;CAChD;AAJD,sBAIC;AAED,MAAM,aAAa;IACT,MAAM,CAA0B;IACxC,YAAY,WAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;IACM,IAAI;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,GAAG;YACN,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC;QACxB,MAAM,GAAG,GAAW,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IACrC,CAAC;CACF;AAED,MAAM,WAAW;IACP,MAAM,CAA0B;IACxC,YAAY,WAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;IACM,IAAI;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,GAAG;YACN,O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5D,CAAC;CACF;AATD,sCASC","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 { Dictionary } from \"./Dictionary\";\n\n/**\n * Derived from:\n * Licensed under MIT. Copyright (c) 2010 Rasmus Andersson <http://hunch.se/>\n * See README.md at https://github.com/rsms/js-lru for details.\n */\n\n/** An entry holds the key and value, and pointers to any older and newer entries.\n * @public\n */\nexport class Entry<K, V> {\n public newer?: Entry<K, V>;\n public older?: Entry<K, V>;\n constructor(public key: K, public value: V) { }\n}\n\nclass EntryIterator<K, V> implements Iterator<[K, V] | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n const val: [K, V] = [ent.key, ent.value];\n return { done: false, value: val };\n }\n}\n\nclass KeyIterator<K, V> implements Iterator<K | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n return { done: false, value: ent.key };\n }\n}\n\nclass ValueIterator<K, V> implements Iterator<V | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n return { done: false, value: ent.value };\n }\n}\n\n/** The interface that must be satisfied by the underlying container type used by a LRUCache.\n * Compatible with a [[Dictionary]] or a standard Map.\n * @public\n */\nexport interface EntryContainer<K, V> {\n readonly size: number;\n clear(): void;\n get(key: K): Entry<K, V> | undefined;\n set(key: K, value: Entry<K, V>): void;\n has(key: K): boolean;\n delete(key: K): void;\n}\n\n/**\n * A mapping of a key/value pairs, where the size of the cache can be limited.\n *\n * When entries are inserted, if the cache is \"full\", the\n * least-recently-used (LRU) value is dropped. When entries are retrieved, they are moved to the front of the LRU list.\n *\n * Illustration of the design:\n *\n * ```\n *\n * entry entry entry entry\n * ______ ______ ______ ______\n * | head |.newer => | |.newer => | |.newer => | tail |\n * | A | | B | | C | | D |\n * |______| <= older.|______| <= older.|______| <= older.|______|\n *\n * removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n * ```\n * @public\n */\nexport class LRUCache<K, V> {\n private _container: EntryContainer<K, V>;\n\n /** Current number of items */\n public size: number;\n\n /** Maximum number of items this cache can hold */\n public limit: number;\n\n /** Least recently-used entry. Invalidated when cache is modified. */\n public oldest?: Entry<K, V>;\n\n /** Most recently-used entry. Invalidated when cache is modified. */\n public newest?: Entry<K, V>;\n\n /**\n * Construct a new LRUCache to hold up to `limit` entries.\n */\n public constructor(limit: number, container: EntryContainer<K, V>) {\n this.size = 0;\n this.limit = limit;\n this.oldest = this.newest = undefined;\n this._container = container;\n }\n\n private markEntryAsUsed(entry: Entry<K, V>) {\n if (entry === this.newest)\n return; // Already the most recently used entry, so no need to update the list\n\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C <D> E\n if (entry.newer) {\n if (entry === this.oldest) {\n this.oldest = entry.newer;\n }\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older) {\n entry.older.newer = entry.newer; // C. --> E\n }\n entry.newer = undefined; // D --x\n entry.older = this.newest; // D. --> E\n if (this.newest) {\n this.newest.newer = entry; // E. <-- D\n }\n this.newest = entry;\n }\n\n /** Replace all values in this cache with key-value pairs (2-element Arrays) from provided iterable. */\n public assign(entries: Iterable<[K, V]>): void {\n let entry;\n let limit = this.limit || Number.MAX_VALUE;\n this._container.clear();\n const it = entries[Symbol.iterator]();\n for (let itv = it.next(); !itv.done; itv = it.next()) {\n const e = new Entry(itv.value[0], itv.value[1]);\n this._container.set(e.key, e);\n if (!entry) {\n this.oldest = e;\n } else {\n entry.newer = e;\n e.older = entry;\n }\n entry = e;\n if (limit-- === 0) {\n throw new Error(\"overflow\");\n }\n }\n this.newest = entry;\n this.size = this._container.size;\n }\n\n /** Get and register recent use of <key>.\n * Returns the value associated with <key> or undefined if not in cache.\n */\n public get(key: K): V | undefined {\n // First, find our cache entry\n const entry = this._container.get(key);\n if (!entry)\n return; // Not cached. Sorry.\n // As <key> was found in the cache, register it as being requested recently\n this.markEntryAsUsed(entry);\n return entry.value;\n }\n\n /** Put <value> into the cache associated with <key>. Replaces any existing entry with the same key.\n * @returns `this`.\n */\n public set(key: K, value: V): LRUCache<K, V> {\n let entry = this._container.get(key);\n if (entry) {\n // update existing\n entry.value = value;\n this.markEntryAsUsed(entry);\n return this;\n }\n\n // new entry\n this._container.set(key, (entry = new Entry(key, value)));\n\n if (this.newest) {\n // link previous tail to the new tail (entry)\n this.newest.newer = entry;\n entry.older = this.newest;\n } else {\n // we're first in\n this.oldest = entry;\n }\n\n // add new entry to the end of the linked list -- it is now the freshest entry.\n this.newest = entry;\n ++this.size;\n if (this.size > this.limit) {\n // we hit the limit -- remove the head\n this.shift();\n }\n return this;\n }\n\n /** Purge the least recently used (oldest) entry from the cache.\n * @returns The removed entry or undefined if the cache was empty.\n */\n public shift(): [K, V] | undefined {\n const entry = this.oldest;\n if (entry) {\n if (entry.newer) {\n // advance the list\n this.oldest = entry.newer;\n this.oldest.older = undefined;\n } else {\n // the cache is exhausted\n this.oldest = undefined;\n this.newest = undefined;\n }\n // Remove last strong reference to <entry> and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n this._container.delete(entry.key);\n --this.size;\n return [entry.key, entry.value];\n }\n return undefined;\n }\n\n /** Access value for `key` without registering recent use. Useful if you do not\n * want to change the state of the cache, but only \"peek\" at it.\n * @returns The value associated with `key` if found, or undefined if not found.\n */\n public find(key: K): V | undefined {\n const e = this._container.get(key);\n return e ? e.value : undefined;\n }\n\n /** Check if there's a value for key in the cache without registering recent use. */\n public has(key: K): boolean {\n return this._container.has(key);\n }\n\n /** Remove entry `key` from cache and return its value.\n * @returns The removed value, or undefined if not found.\n */\n public delete(key: K): V | undefined {\n const entry = this._container.get(key);\n if (!entry)\n return;\n\n this._container.delete(entry.key);\n if (entry.newer && entry.older) {\n // re-link the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.oldest = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.newest = entry.older;\n } else { // if(entry.older === undefined && entry.newer === undefined) {\n this.oldest = this.newest = undefined;\n }\n\n this.size--;\n return entry.value;\n }\n\n /** Removes all entries */\n public clear(): void {\n // Note: clearing links should be safe, as we don't expose live links to user\n this.oldest = this.newest = undefined;\n this.size = 0;\n this._container.clear();\n }\n\n /** Returns an iterator over all keys, starting with the oldest. */\n public keys(): Iterator<K | undefined> | undefined {\n return this.oldest ? new KeyIterator(this.oldest) : undefined;\n }\n\n /** Returns an iterator over all values, starting with the oldest. */\n public values(): Iterator<V | undefined> | undefined {\n return this.oldest ? new ValueIterator(this.oldest) : undefined;\n }\n\n /** Returns an iterator over all entries, starting with the oldest. */\n public entries(): Iterator<[K, V] | undefined> | undefined {\n return this.oldest ? new EntryIterator(this.oldest) : undefined;\n }\n\n /** Call `fun` for each entry, starting with the oldest entry. */\n public forEach(fun: (value: V, key: K, m: LRUCache<K, V>) => void, thisObj?: any): void {\n if (typeof thisObj !== \"object\") {\n thisObj = this; // eslint-disable-line @typescript-eslint/no-this-alias\n }\n let entry = this.oldest;\n while (entry) {\n fun.call(thisObj, entry.value, entry.key, this);\n entry = entry.newer;\n }\n }\n\n /** Returns a JSON (array) representation */\n public toJSON(): Array<{ key: K, value: V }> {\n const s = new Array(this.size);\n let i = 0;\n let entry = this.oldest;\n while (entry) {\n s[i++] = { key: entry.key, value: entry.value };\n entry = entry.newer;\n }\n return s;\n }\n\n /** Returns a String representation */\n public toString(): string {\n let s = \"\";\n let entry = this.oldest;\n while (entry) {\n s += `${String(entry.key)}:${String(entry.value)}`;\n entry = entry.newer;\n if (entry) {\n s += \" < \";\n }\n }\n return s;\n }\n}\n\n/** A [[LRUCache]] using a standard Map as its internal storage.\n * @public\n */\nexport class LRUMap<K, V> extends LRUCache<K, V> {\n /**\n * Construct a new LRUMap to hold up to `limit` entries.\n */\n constructor(limit: number) {\n super(limit, new Map<K, Entry<K, V>>());\n }\n}\n\n/** A [[LRUCache]] using a [[Dictionary]] as its internal storage, permitting custom key comparison logic.\n * @public\n */\nexport class LRUDictionary<K, V> extends LRUCache<K, V> {\n /**\n * Construct a new LRUDictionary to hold up to `limit` entries.\n * @param limit The maximum number of entries permitted in the dictionary.\n * @param compareKeys The function used to compare keys within the dictionary.\n */\n constructor(limit: number, compareKeys: OrderedComparator<K>) {\n super(limit, new Dictionary<K, Entry<K, V>>(compareKeys));\n }\n}\n"]}
|
|
@@ -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,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,U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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;AAG/B,cAAc,0BAA0B,CAAC;AAEzC;;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
|
@@ -31,6 +31,7 @@ __exportStar(require("./Compare"), exports);
|
|
|
31
31
|
__exportStar(require("./CompressedId64Set"), exports);
|
|
32
32
|
__exportStar(require("./Dictionary"), exports);
|
|
33
33
|
__exportStar(require("./Disposable"), exports);
|
|
34
|
+
__exportStar(require("./Expect"), exports);
|
|
34
35
|
__exportStar(require("./Id"), exports);
|
|
35
36
|
__exportStar(require("./IndexMap"), exports);
|
|
36
37
|
__exportStar(require("./JsonSchema"), 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,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,oFAAoF;AACpF,2DAAyC;AAEzC;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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*--------------------------------------------------------------------------------------------*/\nexport * from \"./AccessToken\";\nexport * from \"./Assert\";\nexport * from \"./BeEvent\";\nexport * from \"./BentleyError\";\nexport * from \"./BentleyLoggerCategory\";\nexport * from \"./StatusCategory\";\nexport * from \"./BeSQLite\";\nexport * from \"./ByteStream\";\nexport * from \"./ClassUtils\";\nexport * from \"./Compare\";\nexport * from \"./CompressedId64Set\";\nexport * from \"./Dictionary\";\nexport * from \"./Disposable\";\nexport * from \"./Id\";\nexport * from \"./IndexMap\";\nexport * from \"./JsonSchema\";\nexport * from \"./JsonUtils\";\nexport * from \"./Logger\";\nexport * from \"./LRUMap\";\nexport * from \"./ObservableSet\";\nexport * from \"./OneAtATimeAction\";\nexport * from \"./OrderedId64Iterable\";\nexport * from \"./OrderedSet\";\nexport * from \"./partitionArray\";\nexport * from \"./PriorityQueue\";\nexport * from \"./ProcessDetector\";\nexport * from \"./SortedArray\";\nexport * from \"./StringUtils\";\nexport * from \"./Time\";\nexport * from \"./Tracing\";\nexport * from \"./TupleKeyedMap\";\nexport * from \"./TypedArrayBuilder\";\nexport * from \"./UnexpectedErrors\";\nexport * from \"./UtilityTypes\";\nexport * from \"./YieldManager\";\n\n// Temporarily (until 5.0) export top-level internal APIs to avoid breaking callers.\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-bentley package contains classes to solve problems that are common for both client and server use cases.\n */\n/**\n * @docs-group-description BeSQLite\n * Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)\n */\n/**\n * @docs-group-description Errors\n * Classes for working with errors.\n */\n/**\n * @docs-group-description Events\n * Classes for raising and handling events.\n */\n/**\n * @docs-group-description Ids\n * Classes for working with unique identifiers.\n */\n/**\n * @docs-group-description Logging\n * Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)\n */\n/**\n * @docs-group-description Collections\n * Specialized, customizable collection classes like priority queues.\n */\n/**\n * @docs-group-description Json\n * utilities for dealing with Json strings and files.\n */\n/**\n * @docs-group-description Utils\n * Miscellaneous utility classes.\n */\n/**\n * @docs-group-description ProcessDetector\n * Functions for determining the type of the current JavaScript process.\n */\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,4CAA0B;AAC1B,iDAA+B;AAC/B,0DAAwC;AACxC,mDAAiC;AACjC,6CAA2B;AAC3B,+CAA6B;AAC7B,+CAA6B;AAC7B,4CAA0B;AAC1B,sDAAoC;AACpC,+CAA6B;AAC7B,+CAA6B;AAC7B,2CAAyB;AACzB,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,oFAAoF;AACpF,2DAAyC;AAEzC;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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*--------------------------------------------------------------------------------------------*/\nexport * from \"./AccessToken\";\nexport * from \"./Assert\";\nexport * from \"./BeEvent\";\nexport * from \"./BentleyError\";\nexport * from \"./BentleyLoggerCategory\";\nexport * from \"./StatusCategory\";\nexport * from \"./BeSQLite\";\nexport * from \"./ByteStream\";\nexport * from \"./ClassUtils\";\nexport * from \"./Compare\";\nexport * from \"./CompressedId64Set\";\nexport * from \"./Dictionary\";\nexport * from \"./Disposable\";\nexport * from \"./Expect\";\nexport * from \"./Id\";\nexport * from \"./IndexMap\";\nexport * from \"./JsonSchema\";\nexport * from \"./JsonUtils\";\nexport * from \"./Logger\";\nexport * from \"./LRUMap\";\nexport * from \"./ObservableSet\";\nexport * from \"./OneAtATimeAction\";\nexport * from \"./OrderedId64Iterable\";\nexport * from \"./OrderedSet\";\nexport * from \"./partitionArray\";\nexport * from \"./PriorityQueue\";\nexport * from \"./ProcessDetector\";\nexport * from \"./SortedArray\";\nexport * from \"./StringUtils\";\nexport * from \"./Time\";\nexport * from \"./Tracing\";\nexport * from \"./TupleKeyedMap\";\nexport * from \"./TypedArrayBuilder\";\nexport * from \"./UnexpectedErrors\";\nexport * from \"./UtilityTypes\";\nexport * from \"./YieldManager\";\n\n// Temporarily (until 5.0) export top-level internal APIs to avoid breaking callers.\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-bentley package contains classes to solve problems that are common for both client and server use cases.\n */\n/**\n * @docs-group-description BeSQLite\n * Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)\n */\n/**\n * @docs-group-description Errors\n * Classes for working with errors.\n */\n/**\n * @docs-group-description Events\n * Classes for raising and handling events.\n */\n/**\n * @docs-group-description Ids\n * Classes for working with unique identifiers.\n */\n/**\n * @docs-group-description Logging\n * Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)\n */\n/**\n * @docs-group-description Collections\n * Specialized, customizable collection classes like priority queues.\n */\n/**\n * @docs-group-description Json\n * utilities for dealing with Json strings and files.\n */\n/**\n * @docs-group-description Utils\n * Miscellaneous utility classes.\n */\n/**\n * @docs-group-description ProcessDetector\n * Functions for determining the type of the current JavaScript process.\n */\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expects that a value is defined (not undefined).
|
|
3
|
+
* @note Almost always, places that use this function should in the future be cleaned up to properly
|
|
4
|
+
* handle undefined values instead of throwing an error.
|
|
5
|
+
* @param value The value to check.
|
|
6
|
+
* @param message Optional error message to be used in thrown Error.
|
|
7
|
+
* @returns The original value if it is defined.
|
|
8
|
+
* @throws Error if the value is undefined.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function expectDefined<T>(value: T | undefined, message?: string): T;
|
|
12
|
+
/**
|
|
13
|
+
* Expects that a value is not null.
|
|
14
|
+
* @note Almost always, places that use this function should in the future be cleaned up to properly
|
|
15
|
+
* handle null values instead of throwing an error.
|
|
16
|
+
* @param value The value to check.
|
|
17
|
+
* @param message Optional error message to be used in thrown Error.
|
|
18
|
+
* @returns The original value if it is not null.
|
|
19
|
+
* @throws Error if the value is null.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare function expectNotNull<T>(value: T | null, message?: string): T;
|
|
23
|
+
//# sourceMappingURL=Expect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Expect.d.ts","sourceRoot":"","sources":["../../src/Expect.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAK1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAKrE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Expects that a value is defined (not undefined).
|
|
7
|
+
* @note Almost always, places that use this function should in the future be cleaned up to properly
|
|
8
|
+
* handle undefined values instead of throwing an error.
|
|
9
|
+
* @param value The value to check.
|
|
10
|
+
* @param message Optional error message to be used in thrown Error.
|
|
11
|
+
* @returns The original value if it is defined.
|
|
12
|
+
* @throws Error if the value is undefined.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export function expectDefined(value, message) {
|
|
16
|
+
if (value === undefined) {
|
|
17
|
+
throw new Error(message ?? "Expected value to be defined, but it was undefined.");
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Expects that a value is not null.
|
|
23
|
+
* @note Almost always, places that use this function should in the future be cleaned up to properly
|
|
24
|
+
* handle null values instead of throwing an error.
|
|
25
|
+
* @param value The value to check.
|
|
26
|
+
* @param message Optional error message to be used in thrown Error.
|
|
27
|
+
* @returns The original value if it is not null.
|
|
28
|
+
* @throws Error if the value is null.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export function expectNotNull(value, message) {
|
|
32
|
+
if (value === null) {
|
|
33
|
+
throw new Error(message ?? "Expected value to be not null, but it was null.");
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=Expect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Expect.js","sourceRoot":"","sources":["../../src/Expect.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAI,KAAoB,EAAE,OAAgB;IACrE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,qDAAqD,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAI,KAAe,EAAE,OAAgB;IAChE,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,iDAAiD,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/**\n * Expects that a value is defined (not undefined).\n * @note Almost always, places that use this function should in the future be cleaned up to properly\n * handle undefined values instead of throwing an error.\n * @param value The value to check.\n * @param message Optional error message to be used in thrown Error.\n * @returns The original value if it is defined.\n * @throws Error if the value is undefined.\n * @internal\n */\nexport function expectDefined<T>(value: T | undefined, message?: string): T {\n if (value === undefined) {\n throw new Error(message ?? \"Expected value to be defined, but it was undefined.\");\n }\n return value;\n}\n\n/**\n * Expects that a value is not null.\n * @note Almost always, places that use this function should in the future be cleaned up to properly\n * handle null values instead of throwing an error.\n * @param value The value to check.\n * @param message Optional error message to be used in thrown Error.\n * @returns The original value if it is not null.\n * @throws Error if the value is null.\n * @internal\n */\nexport function expectNotNull<T>(value: T | null, message?: string): T {\n if (value === null) {\n throw new Error(message ?? \"Expected value to be not null, but it was null.\");\n }\n return value;\n}\n"]}
|
package/lib/esm/LRUMap.js
CHANGED
package/lib/esm/LRUMap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LRUMap.js","sourceRoot":"","sources":["../../src/LRUMap.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;GAIG;AAEH;;GAEG;AACH,MAAM,OAAO,KAAK;IAGG;IAAe;IAF3B,KAAK,CAAe;IACpB,KAAK,CAAe;IAC3B,YAAmB,GAAM,EAAS,KAAQ;QAAvB,QAAG,GAAH,GAAG,CAAG;QAAS,UAAK,GAAL,KAAK,CAAG;IAAI,CAAC;CAChD;AAED,MAAM,aAAa;IACT,MAAM,CAA0B;IACxC,YAAY,WAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;IACM,IAAI;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,GAAG;YACN,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC;QACxB,MAAM,GAAG,GAAW,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IACrC,CAAC;CACF;AAED,MAAM,WAAW;IACP,MAAM,CAA0B;IACxC,YAAY,WAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC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,KAAK,EAAE,IAAI,UAAU,CAAiB,WAAW,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF","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 { Dictionary } from \"./Dictionary\";\n\n/**\n * Derived from:\n * Licensed under MIT. Copyright (c) 2010 Rasmus Andersson <http://hunch.se/>\n * See README.md at https://github.com/rsms/js-lru for details.\n */\n\n/** An entry holds the key and value, and pointers to any older and newer entries.\n * @public\n */\nexport class Entry<K, V> {\n public newer?: Entry<K, V>;\n public older?: Entry<K, V>;\n constructor(public key: K, public value: V) { }\n}\n\nclass EntryIterator<K, V> implements Iterator<[K, V] | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n const val: [K, V] = [ent.key, ent.value];\n return { done: false, value: val };\n }\n}\n\nclass KeyIterator<K, V> implements Iterator<K | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n return { done: false, value: ent.key };\n }\n}\n\nclass ValueIterator<K, V> implements Iterator<V | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n return { done: false, value: ent.value };\n }\n}\n\n/** The interface that must be satisfied by the underlying container type used by a LRUCache.\n * Compatible with a [[Dictionary]] or a standard Map.\n * @public\n */\nexport interface EntryContainer<K, V> {\n readonly size: number;\n clear(): void;\n get(key: K): Entry<K, V> | undefined;\n set(key: K, value: Entry<K, V>): void;\n has(key: K): boolean;\n delete(key: K): void;\n}\n\n/**\n * A mapping of a key/value pairs, where the size of the cache can be limited.\n *\n * When entries are inserted, if the cache is \"full\", the\n * least-recently-used (LRU) value is dropped. When entries are retrieved, they are moved to the front of the LRU list.\n *\n * Illustration of the design:\n *\n * ```\n *\n * entry entry entry entry\n * ______ ______ ______ ______\n * | head |.newer => | |.newer => | |.newer => | tail |\n * | A | | B | | C | | D |\n * |______| <= older.|______| <= older.|______| <= older.|______|\n *\n * removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n * ```\n * @public\n */\nexport class LRUCache<K, V> {\n private _container: EntryContainer<K, V>;\n\n /** Current number of items */\n public size: number;\n\n /** Maximum number of items this cache can hold */\n public limit: number;\n\n /** Least recently-used entry. Invalidated when cache is modified. */\n public oldest?: Entry<K, V>;\n\n /** Most recently-used entry. Invalidated when cache is modified. */\n public newest?: Entry<K, V>;\n\n /**\n * Construct a new LRUCache to hold up to `limit` entries.\n */\n public constructor(limit: number, container: EntryContainer<K, V>) {\n this.size = 0;\n this.limit = limit;\n this.oldest = this.newest = undefined;\n this._container = container;\n }\n\n private markEntryAsUsed(entry: Entry<K, V>) {\n if (entry === this.newest)\n return; // Already the most recently used entry, so no need to update the list\n\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C <D> E\n if (entry.newer) {\n if (entry === this.oldest) {\n this.oldest = entry.newer;\n }\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older) {\n entry.older.newer = entry.newer; // C. --> E\n }\n entry.newer = undefined; // D --x\n entry.older = this.newest; // D. --> E\n if (this.newest) {\n this.newest.newer = entry; // E. <-- D\n }\n this.newest = entry;\n }\n\n /** Replace all values in this cache with key-value pairs (2-element Arrays) from provided iterable. */\n public assign(entries: Iterable<[K, V]>): void {\n let entry;\n let limit = this.limit || Number.MAX_VALUE;\n this._container.clear();\n const it = entries[Symbol.iterator]();\n for (let itv = it.next(); !itv.done; itv = it.next()) {\n const e = new Entry(itv.value[0], itv.value[1]);\n this._container.set(e.key, e);\n if (!entry) {\n this.oldest = e;\n } else {\n entry.newer = e;\n e.older = entry;\n }\n entry = e;\n if (limit-- === 0) {\n throw new Error(\"overflow\");\n }\n }\n this.newest = entry;\n this.size = this._container.size;\n }\n\n /** Get and register recent use of <key>.\n * Returns the value associated with <key> or undefined if not in cache.\n */\n public get(key: K): V | undefined {\n // First, find our cache entry\n const entry = this._container.get(key);\n if (!entry)\n return; // Not cached. Sorry.\n // As <key> was found in the cache, register it as being requested recently\n this.markEntryAsUsed(entry);\n return entry.value;\n }\n\n /** Put <value> into the cache associated with <key>. Replaces any existing entry with the same key.\n * @returns `this`.\n */\n public set(key: K, value: V): LRUCache<K, V> {\n let entry = this._container.get(key);\n if (entry) {\n // update existing\n entry.value = value;\n this.markEntryAsUsed(entry);\n return this;\n }\n\n // new entry\n this._container.set(key, (entry = new Entry(key, value)));\n\n if (this.newest) {\n // link previous tail to the new tail (entry)\n this.newest.newer = entry;\n entry.older = this.newest;\n } else {\n // we're first in\n this.oldest = entry;\n }\n\n // add new entry to the end of the linked list -- it is now the freshest entry.\n this.newest = entry;\n ++this.size;\n if (this.size > this.limit) {\n // we hit the limit -- remove the head\n this.shift();\n }\n return this;\n }\n\n /** Purge the least recently used (oldest) entry from the cache.\n * @returns The removed entry or undefined if the cache was empty.\n */\n public shift(): [K, V] | undefined {\n const entry = this.oldest;\n if (entry) {\n if (entry.newer) {\n // advance the list\n this.oldest = entry.newer;\n this.oldest.older = undefined;\n } else {\n // the cache is exhausted\n this.oldest = undefined;\n this.newest = undefined;\n }\n // Remove last strong reference to <entry> and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n this._container.delete(entry.key);\n --this.size;\n return [entry.key, entry.value];\n }\n return undefined;\n }\n\n /** Access value for `key` without registering recent use. Useful if you do not\n * want to change the state of the cache, but only \"peek\" at it.\n * @returns The value associated with `key` if found, or undefined if not found.\n */\n public find(key: K): V | undefined {\n const e = this._container.get(key);\n return e ? e.value : undefined;\n }\n\n /** Check if there's a value for key in the cache without registering recent use. */\n public has(key: K): boolean {\n return this._container.has(key);\n }\n\n /** Remove entry `key` from cache and return its value.\n * @returns The removed value, or undefined if not found.\n */\n public delete(key: K): V | undefined {\n const entry = this._container.get(key);\n if (!entry)\n return;\n\n this._container.delete(entry.key);\n if (entry.newer && entry.older) {\n // re-link the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.oldest = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.newest = entry.older;\n } else { // if(entry.older === undefined && entry.newer === undefined) {\n this.oldest = this.newest = undefined;\n }\n\n this.size--;\n return entry.value;\n }\n\n /** Removes all entries */\n public clear(): void {\n // Note: clearing links should be safe, as we don't expose live links to user\n this.oldest = this.newest = undefined;\n this.size = 0;\n this._container.clear();\n }\n\n /** Returns an iterator over all keys, starting with the oldest. */\n public keys(): Iterator<K | undefined> | undefined {\n return this.oldest ? new KeyIterator(this.oldest) : undefined;\n }\n\n /** Returns an iterator over all values, starting with the oldest. */\n public values(): Iterator<V | undefined> | undefined {\n return this.oldest ? new ValueIterator(this.oldest) : undefined;\n }\n\n /** Returns an iterator over all entries, starting with the oldest. */\n public entries(): Iterator<[K, V] | undefined> | undefined {\n return this.oldest ? new EntryIterator(this.oldest) : undefined;\n }\n\n /** Call `fun` for each entry, starting with the oldest entry. */\n public forEach(fun: (value: V, key: K, m: LRUCache<K, V>) => void, thisObj?: any): void {\n if (typeof thisObj !== \"object\") {\n thisObj = this; // eslint-disable-line @typescript-eslint/no-this-alias\n }\n let entry = this.oldest;\n while (entry) {\n fun.call(thisObj, entry.value, entry.key, this);\n entry = entry.newer;\n }\n }\n\n /** Returns a JSON (array) representation */\n public toJSON(): Array<{ key: K, value: V }> {\n const s = new Array(this.size);\n let i = 0;\n let entry = this.oldest;\n while (entry) {\n s[i++] = { key: entry.key, value: entry.value };\n entry = entry.newer;\n }\n return s;\n }\n\n /** Returns a String representation */\n public toString(): string {\n let s = \"\";\n let entry = this.oldest;\n while (entry) {\n s += `${String(entry.key)}:${entry.value}`;\n entry = entry.newer;\n if (entry) {\n s += \" < \";\n }\n }\n return s;\n }\n}\n\n/** A [[LRUCache]] using a standard Map as its internal storage.\n * @public\n */\nexport class LRUMap<K, V> extends LRUCache<K, V> {\n /**\n * Construct a new LRUMap to hold up to `limit` entries.\n */\n constructor(limit: number) {\n super(limit, new Map<K, Entry<K, V>>());\n }\n}\n\n/** A [[LRUCache]] using a [[Dictionary]] as its internal storage, permitting custom key comparison logic.\n * @public\n */\nexport class LRUDictionary<K, V> extends LRUCache<K, V> {\n /**\n * Construct a new LRUDictionary to hold up to `limit` entries.\n * @param limit The maximum number of entries permitted in the dictionary.\n * @param compareKeys The function used to compare keys within the dictionary.\n */\n constructor(limit: number, compareKeys: OrderedComparator<K>) {\n super(limit, new Dictionary<K, Entry<K, V>>(compareKeys));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LRUMap.js","sourceRoot":"","sources":["../../src/LRUMap.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;GAIG;AAEH;;GAEG;AACH,MAAM,OAAO,KAAK;IAGG;IAAe;IAF3B,KAAK,CAAe;IACpB,KAAK,CAAe;IAC3B,YAAmB,GAAM,EAAS,KAAQ;QAAvB,QAAG,GAAH,GAAG,CAAG;QAAS,UAAK,GAAL,KAAK,CAAG;IAAI,CAAC;CAChD;AAED,MAAM,aAAa;IACT,MAAM,CAA0B;IACxC,YAAY,WAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;IACM,IAAI;QACT,MAAM,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I,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACnD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YACpB,IAAI,KAAK,EAAE,CAAC;gBACV,CAAC,IAAI,KAAK,CAAC;YACb,CAAC;QACH,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,MAAa,SAAQ,QAAc;IAC9C;;OAEG;IACH,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,EAAE,IAAI,GAAG,EAAkB,CAAC,CAAC;IAC1C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,aAAoB,SAAQ,QAAc;IACrD;;;;OAIG;IACH,YAAY,KAAa,EAAE,WAAiC;QAC1D,KAAK,CAAC,KAAK,EAAE,IAAI,UAAU,CAAiB,WAAW,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF","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 { Dictionary } from \"./Dictionary\";\n\n/**\n * Derived from:\n * Licensed under MIT. Copyright (c) 2010 Rasmus Andersson <http://hunch.se/>\n * See README.md at https://github.com/rsms/js-lru for details.\n */\n\n/** An entry holds the key and value, and pointers to any older and newer entries.\n * @public\n */\nexport class Entry<K, V> {\n public newer?: Entry<K, V>;\n public older?: Entry<K, V>;\n constructor(public key: K, public value: V) { }\n}\n\nclass EntryIterator<K, V> implements Iterator<[K, V] | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n const val: [K, V] = [ent.key, ent.value];\n return { done: false, value: val };\n }\n}\n\nclass KeyIterator<K, V> implements Iterator<K | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n return { done: false, value: ent.key };\n }\n}\n\nclass ValueIterator<K, V> implements Iterator<V | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n return { done: false, value: ent.value };\n }\n}\n\n/** The interface that must be satisfied by the underlying container type used by a LRUCache.\n * Compatible with a [[Dictionary]] or a standard Map.\n * @public\n */\nexport interface EntryContainer<K, V> {\n readonly size: number;\n clear(): void;\n get(key: K): Entry<K, V> | undefined;\n set(key: K, value: Entry<K, V>): void;\n has(key: K): boolean;\n delete(key: K): void;\n}\n\n/**\n * A mapping of a key/value pairs, where the size of the cache can be limited.\n *\n * When entries are inserted, if the cache is \"full\", the\n * least-recently-used (LRU) value is dropped. When entries are retrieved, they are moved to the front of the LRU list.\n *\n * Illustration of the design:\n *\n * ```\n *\n * entry entry entry entry\n * ______ ______ ______ ______\n * | head |.newer => | |.newer => | |.newer => | tail |\n * | A | | B | | C | | D |\n * |______| <= older.|______| <= older.|______| <= older.|______|\n *\n * removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n * ```\n * @public\n */\nexport class LRUCache<K, V> {\n private _container: EntryContainer<K, V>;\n\n /** Current number of items */\n public size: number;\n\n /** Maximum number of items this cache can hold */\n public limit: number;\n\n /** Least recently-used entry. Invalidated when cache is modified. */\n public oldest?: Entry<K, V>;\n\n /** Most recently-used entry. Invalidated when cache is modified. */\n public newest?: Entry<K, V>;\n\n /**\n * Construct a new LRUCache to hold up to `limit` entries.\n */\n public constructor(limit: number, container: EntryContainer<K, V>) {\n this.size = 0;\n this.limit = limit;\n this.oldest = this.newest = undefined;\n this._container = container;\n }\n\n private markEntryAsUsed(entry: Entry<K, V>) {\n if (entry === this.newest)\n return; // Already the most recently used entry, so no need to update the list\n\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C <D> E\n if (entry.newer) {\n if (entry === this.oldest) {\n this.oldest = entry.newer;\n }\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older) {\n entry.older.newer = entry.newer; // C. --> E\n }\n entry.newer = undefined; // D --x\n entry.older = this.newest; // D. --> E\n if (this.newest) {\n this.newest.newer = entry; // E. <-- D\n }\n this.newest = entry;\n }\n\n /** Replace all values in this cache with key-value pairs (2-element Arrays) from provided iterable. */\n public assign(entries: Iterable<[K, V]>): void {\n let entry;\n let limit = this.limit || Number.MAX_VALUE;\n this._container.clear();\n const it = entries[Symbol.iterator]();\n for (let itv = it.next(); !itv.done; itv = it.next()) {\n const e = new Entry(itv.value[0], itv.value[1]);\n this._container.set(e.key, e);\n if (!entry) {\n this.oldest = e;\n } else {\n entry.newer = e;\n e.older = entry;\n }\n entry = e;\n if (limit-- === 0) {\n throw new Error(\"overflow\");\n }\n }\n this.newest = entry;\n this.size = this._container.size;\n }\n\n /** Get and register recent use of <key>.\n * Returns the value associated with <key> or undefined if not in cache.\n */\n public get(key: K): V | undefined {\n // First, find our cache entry\n const entry = this._container.get(key);\n if (!entry)\n return; // Not cached. Sorry.\n // As <key> was found in the cache, register it as being requested recently\n this.markEntryAsUsed(entry);\n return entry.value;\n }\n\n /** Put <value> into the cache associated with <key>. Replaces any existing entry with the same key.\n * @returns `this`.\n */\n public set(key: K, value: V): LRUCache<K, V> {\n let entry = this._container.get(key);\n if (entry) {\n // update existing\n entry.value = value;\n this.markEntryAsUsed(entry);\n return this;\n }\n\n // new entry\n this._container.set(key, (entry = new Entry(key, value)));\n\n if (this.newest) {\n // link previous tail to the new tail (entry)\n this.newest.newer = entry;\n entry.older = this.newest;\n } else {\n // we're first in\n this.oldest = entry;\n }\n\n // add new entry to the end of the linked list -- it is now the freshest entry.\n this.newest = entry;\n ++this.size;\n if (this.size > this.limit) {\n // we hit the limit -- remove the head\n this.shift();\n }\n return this;\n }\n\n /** Purge the least recently used (oldest) entry from the cache.\n * @returns The removed entry or undefined if the cache was empty.\n */\n public shift(): [K, V] | undefined {\n const entry = this.oldest;\n if (entry) {\n if (entry.newer) {\n // advance the list\n this.oldest = entry.newer;\n this.oldest.older = undefined;\n } else {\n // the cache is exhausted\n this.oldest = undefined;\n this.newest = undefined;\n }\n // Remove last strong reference to <entry> and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n this._container.delete(entry.key);\n --this.size;\n return [entry.key, entry.value];\n }\n return undefined;\n }\n\n /** Access value for `key` without registering recent use. Useful if you do not\n * want to change the state of the cache, but only \"peek\" at it.\n * @returns The value associated with `key` if found, or undefined if not found.\n */\n public find(key: K): V | undefined {\n const e = this._container.get(key);\n return e ? e.value : undefined;\n }\n\n /** Check if there's a value for key in the cache without registering recent use. */\n public has(key: K): boolean {\n return this._container.has(key);\n }\n\n /** Remove entry `key` from cache and return its value.\n * @returns The removed value, or undefined if not found.\n */\n public delete(key: K): V | undefined {\n const entry = this._container.get(key);\n if (!entry)\n return;\n\n this._container.delete(entry.key);\n if (entry.newer && entry.older) {\n // re-link the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.oldest = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.newest = entry.older;\n } else { // if(entry.older === undefined && entry.newer === undefined) {\n this.oldest = this.newest = undefined;\n }\n\n this.size--;\n return entry.value;\n }\n\n /** Removes all entries */\n public clear(): void {\n // Note: clearing links should be safe, as we don't expose live links to user\n this.oldest = this.newest = undefined;\n this.size = 0;\n this._container.clear();\n }\n\n /** Returns an iterator over all keys, starting with the oldest. */\n public keys(): Iterator<K | undefined> | undefined {\n return this.oldest ? new KeyIterator(this.oldest) : undefined;\n }\n\n /** Returns an iterator over all values, starting with the oldest. */\n public values(): Iterator<V | undefined> | undefined {\n return this.oldest ? new ValueIterator(this.oldest) : undefined;\n }\n\n /** Returns an iterator over all entries, starting with the oldest. */\n public entries(): Iterator<[K, V] | undefined> | undefined {\n return this.oldest ? new EntryIterator(this.oldest) : undefined;\n }\n\n /** Call `fun` for each entry, starting with the oldest entry. */\n public forEach(fun: (value: V, key: K, m: LRUCache<K, V>) => void, thisObj?: any): void {\n if (typeof thisObj !== \"object\") {\n thisObj = this; // eslint-disable-line @typescript-eslint/no-this-alias\n }\n let entry = this.oldest;\n while (entry) {\n fun.call(thisObj, entry.value, entry.key, this);\n entry = entry.newer;\n }\n }\n\n /** Returns a JSON (array) representation */\n public toJSON(): Array<{ key: K, value: V }> {\n const s = new Array(this.size);\n let i = 0;\n let entry = this.oldest;\n while (entry) {\n s[i++] = { key: entry.key, value: entry.value };\n entry = entry.newer;\n }\n return s;\n }\n\n /** Returns a String representation */\n public toString(): string {\n let s = \"\";\n let entry = this.oldest;\n while (entry) {\n s += `${String(entry.key)}:${String(entry.value)}`;\n entry = entry.newer;\n if (entry) {\n s += \" < \";\n }\n }\n return s;\n }\n}\n\n/** A [[LRUCache]] using a standard Map as its internal storage.\n * @public\n */\nexport class LRUMap<K, V> extends LRUCache<K, V> {\n /**\n * Construct a new LRUMap to hold up to `limit` entries.\n */\n constructor(limit: number) {\n super(limit, new Map<K, Entry<K, V>>());\n }\n}\n\n/** A [[LRUCache]] using a [[Dictionary]] as its internal storage, permitting custom key comparison logic.\n * @public\n */\nexport class LRUDictionary<K, V> extends LRUCache<K, V> {\n /**\n * Construct a new LRUDictionary to hold up to `limit` entries.\n * @param limit The maximum number of entries permitted in the dictionary.\n * @param compareKeys The function used to compare keys within the dictionary.\n */\n constructor(limit: number, compareKeys: OrderedComparator<K>) {\n super(limit, new Dictionary<K, Entry<K, V>>(compareKeys));\n }\n}\n"]}
|
|
@@ -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,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;AAG/B,cAAc,0BAA0B,CAAC;AAEzC;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
|
|
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,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,UAAU,CAAC;AACzB,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;AAG/B,cAAc,0BAA0B,CAAC;AAEzC;;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
|
@@ -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,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,oFAAoF;AACpF,cAAc,0BAA0B,CAAC;AAEzC;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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*--------------------------------------------------------------------------------------------*/\nexport * from \"./AccessToken\";\nexport * from \"./Assert\";\nexport * from \"./BeEvent\";\nexport * from \"./BentleyError\";\nexport * from \"./BentleyLoggerCategory\";\nexport * from \"./StatusCategory\";\nexport * from \"./BeSQLite\";\nexport * from \"./ByteStream\";\nexport * from \"./ClassUtils\";\nexport * from \"./Compare\";\nexport * from \"./CompressedId64Set\";\nexport * from \"./Dictionary\";\nexport * from \"./Disposable\";\nexport * from \"./Id\";\nexport * from \"./IndexMap\";\nexport * from \"./JsonSchema\";\nexport * from \"./JsonUtils\";\nexport * from \"./Logger\";\nexport * from \"./LRUMap\";\nexport * from \"./ObservableSet\";\nexport * from \"./OneAtATimeAction\";\nexport * from \"./OrderedId64Iterable\";\nexport * from \"./OrderedSet\";\nexport * from \"./partitionArray\";\nexport * from \"./PriorityQueue\";\nexport * from \"./ProcessDetector\";\nexport * from \"./SortedArray\";\nexport * from \"./StringUtils\";\nexport * from \"./Time\";\nexport * from \"./Tracing\";\nexport * from \"./TupleKeyedMap\";\nexport * from \"./TypedArrayBuilder\";\nexport * from \"./UnexpectedErrors\";\nexport * from \"./UtilityTypes\";\nexport * from \"./YieldManager\";\n\n// Temporarily (until 5.0) export top-level internal APIs to avoid breaking callers.\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-bentley package contains classes to solve problems that are common for both client and server use cases.\n */\n/**\n * @docs-group-description BeSQLite\n * Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)\n */\n/**\n * @docs-group-description Errors\n * Classes for working with errors.\n */\n/**\n * @docs-group-description Events\n * Classes for raising and handling events.\n */\n/**\n * @docs-group-description Ids\n * Classes for working with unique identifiers.\n */\n/**\n * @docs-group-description Logging\n * Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)\n */\n/**\n * @docs-group-description Collections\n * Specialized, customizable collection classes like priority queues.\n */\n/**\n * @docs-group-description Json\n * utilities for dealing with Json strings and files.\n */\n/**\n * @docs-group-description Utils\n * Miscellaneous utility classes.\n */\n/**\n * @docs-group-description ProcessDetector\n * Functions for determining the type of the current JavaScript process.\n */\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,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,UAAU,CAAC;AACzB,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,oFAAoF;AACpF,cAAc,0BAA0B,CAAC;AAEzC;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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*--------------------------------------------------------------------------------------------*/\nexport * from \"./AccessToken\";\nexport * from \"./Assert\";\nexport * from \"./BeEvent\";\nexport * from \"./BentleyError\";\nexport * from \"./BentleyLoggerCategory\";\nexport * from \"./StatusCategory\";\nexport * from \"./BeSQLite\";\nexport * from \"./ByteStream\";\nexport * from \"./ClassUtils\";\nexport * from \"./Compare\";\nexport * from \"./CompressedId64Set\";\nexport * from \"./Dictionary\";\nexport * from \"./Disposable\";\nexport * from \"./Expect\";\nexport * from \"./Id\";\nexport * from \"./IndexMap\";\nexport * from \"./JsonSchema\";\nexport * from \"./JsonUtils\";\nexport * from \"./Logger\";\nexport * from \"./LRUMap\";\nexport * from \"./ObservableSet\";\nexport * from \"./OneAtATimeAction\";\nexport * from \"./OrderedId64Iterable\";\nexport * from \"./OrderedSet\";\nexport * from \"./partitionArray\";\nexport * from \"./PriorityQueue\";\nexport * from \"./ProcessDetector\";\nexport * from \"./SortedArray\";\nexport * from \"./StringUtils\";\nexport * from \"./Time\";\nexport * from \"./Tracing\";\nexport * from \"./TupleKeyedMap\";\nexport * from \"./TypedArrayBuilder\";\nexport * from \"./UnexpectedErrors\";\nexport * from \"./UtilityTypes\";\nexport * from \"./YieldManager\";\n\n// Temporarily (until 5.0) export top-level internal APIs to avoid breaking callers.\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-bentley package contains classes to solve problems that are common for both client and server use cases.\n */\n/**\n * @docs-group-description BeSQLite\n * Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)\n */\n/**\n * @docs-group-description Errors\n * Classes for working with errors.\n */\n/**\n * @docs-group-description Events\n * Classes for raising and handling events.\n */\n/**\n * @docs-group-description Ids\n * Classes for working with unique identifiers.\n */\n/**\n * @docs-group-description Logging\n * Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)\n */\n/**\n * @docs-group-description Collections\n * Specialized, customizable collection classes like priority queues.\n */\n/**\n * @docs-group-description Json\n * utilities for dealing with Json strings and files.\n */\n/**\n * @docs-group-description Utils\n * Miscellaneous utility classes.\n */\n/**\n * @docs-group-description ProcessDetector\n * Functions for determining the type of the current JavaScript process.\n */\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-bentley",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0-dev.10",
|
|
4
4
|
"description": "Bentley JavaScript core components",
|
|
5
5
|
"main": "lib/cjs/core-bentley.js",
|
|
6
6
|
"module": "lib/esm/core-bentley.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"rimraf": "^6.0.1",
|
|
31
31
|
"typescript": "~5.6.2",
|
|
32
32
|
"vitest": "^3.0.6",
|
|
33
|
-
"@itwin/build-tools": "5.
|
|
33
|
+
"@itwin/build-tools": "5.2.0-dev.10"
|
|
34
34
|
},
|
|
35
35
|
"nyc": {
|
|
36
36
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|