@itwin/core-bentley 3.6.0-dev.8 → 4.0.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/AccessToken.d.ts +5 -3
- package/lib/cjs/AccessToken.d.ts.map +1 -1
- package/lib/cjs/AccessToken.js.map +1 -1
- package/lib/cjs/BentleyError.d.ts +10 -10
- package/lib/cjs/BentleyError.js +9 -9
- package/lib/cjs/BentleyError.js.map +1 -1
- package/lib/cjs/ByteStream.d.ts +25 -9
- package/lib/cjs/ByteStream.d.ts.map +1 -1
- package/lib/cjs/ByteStream.js +26 -10
- package/lib/cjs/ByteStream.js.map +1 -1
- package/lib/cjs/Id.d.ts +9 -1
- package/lib/cjs/Id.d.ts.map +1 -1
- package/lib/cjs/Id.js +15 -1
- package/lib/cjs/Id.js.map +1 -1
- package/lib/cjs/TypedArrayBuilder.d.ts +64 -6
- package/lib/cjs/TypedArrayBuilder.d.ts.map +1 -1
- package/lib/cjs/TypedArrayBuilder.js +79 -5
- package/lib/cjs/TypedArrayBuilder.js.map +1 -1
- package/lib/cjs/UtilityTypes.d.ts +0 -4
- package/lib/cjs/UtilityTypes.d.ts.map +1 -1
- package/lib/cjs/UtilityTypes.js.map +1 -1
- package/lib/cjs/core-bentley.d.ts +0 -1
- package/lib/cjs/core-bentley.d.ts.map +1 -1
- package/lib/cjs/core-bentley.js +0 -1
- package/lib/cjs/core-bentley.js.map +1 -1
- package/lib/esm/AccessToken.d.ts +5 -3
- package/lib/esm/AccessToken.d.ts.map +1 -1
- package/lib/esm/AccessToken.js.map +1 -1
- package/lib/esm/BentleyError.d.ts +10 -10
- package/lib/esm/BentleyError.js +9 -9
- package/lib/esm/BentleyError.js.map +1 -1
- package/lib/esm/ByteStream.d.ts +25 -9
- package/lib/esm/ByteStream.d.ts.map +1 -1
- package/lib/esm/ByteStream.js +26 -10
- package/lib/esm/ByteStream.js.map +1 -1
- package/lib/esm/Id.d.ts +9 -1
- package/lib/esm/Id.d.ts.map +1 -1
- package/lib/esm/Id.js +15 -1
- package/lib/esm/Id.js.map +1 -1
- package/lib/esm/TypedArrayBuilder.d.ts +64 -6
- package/lib/esm/TypedArrayBuilder.d.ts.map +1 -1
- package/lib/esm/TypedArrayBuilder.js +77 -4
- package/lib/esm/TypedArrayBuilder.js.map +1 -1
- package/lib/esm/UtilityTypes.d.ts +0 -4
- package/lib/esm/UtilityTypes.d.ts.map +1 -1
- package/lib/esm/UtilityTypes.js.map +1 -1
- package/lib/esm/core-bentley.d.ts +0 -1
- package/lib/esm/core-bentley.d.ts.map +1 -1
- package/lib/esm/core-bentley.js +0 -1
- package/lib/esm/core-bentley.js.map +1 -1
- package/package.json +3 -3
- package/lib/cjs/AsyncMutex.d.ts +0 -27
- package/lib/cjs/AsyncMutex.d.ts.map +0 -1
- package/lib/cjs/AsyncMutex.js +0 -44
- package/lib/cjs/AsyncMutex.js.map +0 -1
- package/lib/esm/AsyncMutex.d.ts +0 -27
- package/lib/esm/AsyncMutex.d.ts.map +0 -1
- package/lib/esm/AsyncMutex.js +0 -40
- package/lib/esm/AsyncMutex.js.map +0 -1
package/lib/esm/Id.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Id.js","sourceRoot":"","sources":["../../src/Id.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA4BH,SAAS,KAAK,CAAC,GAAW;IACxB,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,0BAA0B,CAAC,GAAW,EAAE,KAAa;IAC5D,OAAO,mBAAmB,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAChD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C;IAlBe,cAAS,YAkBxB,CAAA;AACH,CAAC,EAvDgB,IAAI,KAAJ,IAAI,QAuDpB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Ids\r\n */\r\n\r\n/** A string containing a well-formed string representation of an [Id64]($core-bentley).\r\n * See [Working with Ids]($docs/learning/common/Id64.md).\r\n * @public\r\n */\r\nexport type Id64String = string;\r\n\r\n/** A string containing a well-formed string representation of a [Guid]($core-bentley).\r\n * @public\r\n */\r\nexport type GuidString = string;\r\n\r\n/** A set of [[Id64String]]s.\r\n * @public\r\n */\r\nexport type Id64Set = Set<Id64String>;\r\n\r\n/** An array of [[Id64String]]s.\r\n * @public\r\n */\r\nexport type Id64Array = Id64String[];\r\n\r\n/** Used as an argument to a function that can accept one or more [[Id64String]]s.\r\n * @public\r\n */\r\nexport type Id64Arg = Id64String | Id64Set | Id64Array;\r\n\r\nfunction toHex(str: string): number {\r\n const v = parseInt(str, 16);\r\n return Number.isNaN(v) ? 0 : v;\r\n}\r\n\r\nfunction isLowerCaseNonZeroHexDigit(str: string, index: number) {\r\n return isLowerCaseHexDigit(str, index, false);\r\n}\r\n\r\nfunction isLowerCaseHexDigit(str: string, index: number, allowZero: boolean = true): boolean {\r\n const charCode = str.charCodeAt(index);\r\n const minDecimalDigit = allowZero ? 0x30 : 0x31; // '0' or '1'...\r\n return (charCode >= minDecimalDigit && charCode <= 0x39) || (charCode >= 0x61 && charCode <= 0x66); // '0'-'9, 'a' -'f'\r\n}\r\n\r\nfunction isValidHexString(id: string, startIndex: number, len: number) {\r\n if (len === 0)\r\n return false;\r\n\r\n // No leading zeroes...\r\n if (!isLowerCaseNonZeroHexDigit(id, startIndex))\r\n return false;\r\n\r\n // ...followed by len-1 lowercase hexadecimal digits.\r\n for (let i = 1; i < len; i++)\r\n if (!isLowerCaseHexDigit(id, startIndex + i))\r\n return false;\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * The Id64 namespace provides facilities for working with 64-bit identifiers. These Ids are stored as 64-bit integers inside an [[IModelDb]], but must be represented\r\n * as strings in JavaScript because JavaScript does not intrinsically support 64-bit integers.\r\n *\r\n * The [[Id64String]] type alias is used to indicate function arguments, return types, and variables which are known to contain a well-formed representation of a 64-bit Id.\r\n *\r\n * See [Working with Ids]($docs/learning/common/Id64.md) for a detailed description and code examples.\r\n * @public\r\n */\r\nexport namespace Id64 {\r\n /** Extract the \"local\" Id portion of an Id64String, contained in the lower 40 bits of the 64-bit value. */\r\n export function getLocalId(id: Id64String): number {\r\n if (isInvalid(id))\r\n return 0;\r\n\r\n const len = id.length;\r\n const start = (len > 12) ? (len - 10) : 2;\r\n return toHex(id.slice(start));\r\n }\r\n\r\n /** Extract the briefcase Id portion of an Id64String, contained in the upper 24 bits of the 64-bit value. */\r\n export function getBriefcaseId(id: Id64String): number {\r\n if (isInvalid(id))\r\n return 0;\r\n\r\n const len = id.length;\r\n return (len <= 12) ? 0 : toHex(id.slice(2, len - 10));\r\n }\r\n\r\n /** Create an Id64String from its JSON representation.\r\n * @param prop The JSON representation of an Id.\r\n * @returns A well-formed Id string.\r\n * @note if the input is undefined, the result is \"0\", indicating an invalid Id.\r\n * @note if the input is not undefined, the result is the same as that of [[Id64.fromString]].\r\n */\r\n export function fromJSON(prop?: string): Id64String {\r\n return typeof prop === \"string\" ? Id64.fromString(prop) : Id64.invalid;\r\n }\r\n\r\n /** Given a string value, attempt to normalize it into a well-formed Id string.\r\n * If the input is already a well-formed Id string, it is returned unmodified.\r\n * Otherwise, the input is trimmed of leading and trailing whitespace, converted to lowercase, and an attempt is made to parse it as a 64-bit hexadecimal integer.\r\n * If parsing succeeds the normalized result is returned; otherwise the result is \"0\", indicating an invalid Id.\r\n *\r\n * For a description of \"well-formed\", see [Working with Ids]($docs/learning/common/Id64.md).\r\n */\r\n export function fromString(val: string): Id64String {\r\n // NB: in case this is called from JavaScript, we must check the run-time type...\r\n if (typeof val !== \"string\")\r\n return invalid;\r\n\r\n // Skip the common case in which the input is already a well-formed Id string\r\n if (Id64.isId64(val))\r\n return val;\r\n\r\n // Attempt to normalize the input into a well-formed Id string\r\n val = val.toLowerCase().trim();\r\n const len = val.length;\r\n if (len < 2 || val[0] !== \"0\" || val[1] !== \"x\")\r\n return invalid;\r\n\r\n let low = 0;\r\n let high = 0;\r\n let start = 2;\r\n if (len > 12) {\r\n start = (len - 10);\r\n high = toHex(val.slice(2, start));\r\n }\r\n\r\n low = toHex(val.slice(start));\r\n return fromLocalAndBriefcaseIds(low, high);\r\n }\r\n\r\n // Used when constructing local ID portion of Id64String. Performance optimization.\r\n const _localIdPrefixByLocalIdLength = [ // eslint-disable-line @typescript-eslint/naming-convention\r\n \"0000000000\",\r\n \"000000000\",\r\n \"00000000\",\r\n \"0000000\",\r\n \"000000\",\r\n \"00000\",\r\n \"0000\",\r\n \"000\",\r\n \"00\",\r\n \"0\",\r\n \"\",\r\n ];\r\n\r\n /** Produce an Id string from a local and briefcase Id.\r\n * @param localId The non-zero local Id as an unsigned 40-bit integer.\r\n * @param briefcaseId The briefcase Id as an unsigned 24-bit integer.\r\n * @returns an Id64String containing the hexadecimal string representation of the unsigned 64-bit integer which would result from the\r\n * operation `localId | (briefcaseId << 40)`, or an invalid Id \"0\" if the inputs are invalid.\r\n */\r\n export function fromLocalAndBriefcaseIds(localId: number, briefcaseId: number): Id64String {\r\n // NB: Yes, we must check the run-time type...\r\n if (typeof localId !== \"number\" || typeof briefcaseId !== \"number\")\r\n return invalid;\r\n\r\n localId = Math.floor(localId);\r\n if (0 === localId)\r\n return invalid;\r\n\r\n briefcaseId = Math.floor(briefcaseId);\r\n const lowStr = localId.toString(16);\r\n return `0x${(briefcaseId === 0) ? lowStr : (briefcaseId.toString(16) + (_localIdPrefixByLocalIdLength[lowStr.length] + lowStr))}`;\r\n }\r\n\r\n // Used as a buffer when converting a pair of 32-bit integers to an Id64String. Significant performance optimization.\r\n const scratchCharCodes = [\r\n 0x30, // \"0\"\r\n 0x78, // \"x\"\r\n 0x30, // \"0\"\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n ];\r\n\r\n // Convert 4-bit unsigned integer to char code representing lower-case hexadecimal digit.\r\n function uint4ToCharCode(uint4: number): number {\r\n return uint4 + (uint4 < 10 ? 0x30 : 0x57);\r\n }\r\n\r\n // Convert char code representing lower-case hexadecimal digit to 4-bit unsigned integer.\r\n function charCodeToUint4(char: number): number {\r\n return char - (char >= 0x57 ? 0x57 : 0x30);\r\n }\r\n\r\n // Convert a substring to a uint32. This is twice as fast as using Number.parseInt().\r\n function substringToUint32(id: Id64String, start: number, end: number): number {\r\n let uint32 = 0;\r\n for (let i = start; i < end; i++) {\r\n const uint4 = charCodeToUint4(id.charCodeAt(i));\r\n const shift = (end - i - 1) << 2;\r\n const mask = uint4 << shift;\r\n uint32 = (uint32 | mask) >>> 0; // >>> 0 to force unsigned because javascript\r\n }\r\n\r\n return uint32;\r\n }\r\n\r\n /** Create an Id64String from a pair of unsigned 32-bit integers.\r\n * @param lowBytes The lower 4 bytes of the Id\r\n * @param highBytes The upper 4 bytes of the Id\r\n * @returns an Id64String containing the hexadecimal string representation of the unsigned 64-bit integer which would result from the\r\n * operation `lowBytes | (highBytes << 32)`.\r\n * @see [[Id64.fromUint32PairObject]] if you have a [[Id64.Uint32Pair]] object.\r\n */\r\n export function fromUint32Pair(lowBytes: number, highBytes: number): Id64String {\r\n const localIdLow = lowBytes >>> 0;\r\n const localIdHigh = (highBytes & 0x000000ff) * (0xffffffff + 1); // aka (highBytes & 0xff) << 32\r\n const localId = localIdLow + localIdHigh; // aka localIdLow | localIdHigh\r\n if (0 === localId)\r\n return invalid;\r\n\r\n // Need to omit or preserve leading zeroes...\r\n const buffer = scratchCharCodes;\r\n let index = 2;\r\n for (let i = 7; i >= 0; i--) {\r\n const shift = i << 2;\r\n const mask = 0xf << shift;\r\n const uint4 = (highBytes & mask) >>> shift;\r\n if (index > 2 || 0 !== uint4)\r\n buffer[index++] = uint4ToCharCode(uint4);\r\n }\r\n\r\n for (let i = 7; i >= 0; i--) {\r\n const shift = i << 2;\r\n const mask = 0xf << shift;\r\n const uint4 = (lowBytes & mask) >>> shift;\r\n if (index > 2 || 0 !== uint4)\r\n buffer[index++] = uint4ToCharCode(uint4);\r\n }\r\n\r\n if (buffer.length !== index)\r\n buffer.length = index;\r\n\r\n return String.fromCharCode(...scratchCharCodes);\r\n }\r\n\r\n /** Create an Id64String from a [[Id64.Uint32Pair]].\r\n * @see [[Id64.fromUint32Pair]].\r\n */\r\n export function fromUint32PairObject(pair: Uint32Pair): Id64String {\r\n return fromUint32Pair(pair.lower, pair.upper);\r\n }\r\n\r\n /** Returns true if the inputs represent two halves of a valid 64-bit Id.\r\n * @see [[Id64.Uint32Pair]].\r\n */\r\n export function isValidUint32Pair(lowBytes: number, highBytes: number): boolean {\r\n // Detect local ID of zero\r\n return 0 !== lowBytes || 0 !== (highBytes & 0x000000ff);\r\n }\r\n\r\n /** Represents an [[Id64]] as a pair of unsigned 32-bit integers. Because Javascript lacks efficient support for 64-bit integers,\r\n * this representation can be useful in performance-sensitive code like the render loop.\r\n * @see [[Id64.getUint32Pair]] to convert an [[Id64String]] to a Uint32Pair.\r\n * @see [[Id64.fromUint32Pair]] to convert a Uint32Pair to an [[Id64String]].\r\n * @see [[Id64.Uint32Set]] and [[Id64.Uint32Map]] for collections based on Uint32Pairs.\r\n */\r\n export interface Uint32Pair {\r\n /** The lower 4 bytes of the 64-bit integer. */\r\n lower: number;\r\n /** The upper 4 bytes of the 64-bit integer. */\r\n upper: number;\r\n }\r\n\r\n /** Convert an Id64String to a 64-bit unsigned integer represented as a pair of unsigned 32-bit integers.\r\n * @param id The well-formed string representation of a 64-bit Id.\r\n * @param out Used as the return value if supplied; otherwise a new object is returned.\r\n * @returns An object containing the parsed lower and upper 32-bit integers comprising the 64-bit Id.\r\n */\r\n export function getUint32Pair(id: Id64String, out?: Uint32Pair): Uint32Pair {\r\n if (!out)\r\n out = { lower: 0, upper: 0 };\r\n\r\n out.lower = getLowerUint32(id);\r\n out.upper = getUpperUint32(id);\r\n return out;\r\n }\r\n\r\n /** Extract an unsigned 32-bit integer from the lower 4 bytes of an Id64String. */\r\n export function getLowerUint32(id: Id64String): number {\r\n if (isInvalid(id))\r\n return 0;\r\n\r\n const end = id.length;\r\n const start = end > 10 ? end - 8 : 2;\r\n return substringToUint32(id, start, end);\r\n }\r\n\r\n /** Extract an unsigned 32-bit integer from the upper 4 bytes of an Id64String. */\r\n export function getUpperUint32(id: Id64String): number {\r\n const len = id.length;\r\n if (len <= 10 || isInvalid(id))\r\n return 0;\r\n\r\n return substringToUint32(id, 2, len - 8);\r\n }\r\n\r\n /** Convert an [[Id64Arg]] into an [[Id64Set]].\r\n *\r\n * This method can be used by functions that accept an Id64Arg to conveniently process the value(s). For example:\r\n * ```ts\r\n * public addCategories(arg: Id64Arg) { Id64.toIdSet(arg).forEach((id) => this.categories.add(id)); }\r\n * ```\r\n *\r\n * Alternatively, to avoid allocating a new Id64Set, use [[Id64.iterable]].\r\n *\r\n * @param arg The Ids to convert to an Id64Set.\r\n * @param makeCopy If true, and the input is already an Id64Set, returns a deep copy of the input.\r\n * @returns An Id64Set containing the set of [[Id64String]]s represented by the Id64Arg.\r\n */\r\n export function toIdSet(arg: Id64Arg, makeCopy: boolean = false): Id64Set {\r\n if (arg instanceof Set)\r\n return makeCopy ? new Set<string>(arg) : arg;\r\n\r\n const ids = new Set<Id64String>();\r\n if (typeof arg === \"string\")\r\n ids.add(arg);\r\n else if (Array.isArray(arg)) {\r\n arg.forEach((id: Id64String) => {\r\n if (typeof id === \"string\")\r\n ids.add(id);\r\n });\r\n }\r\n\r\n return ids;\r\n }\r\n\r\n /** Obtain iterator over the specified Ids.\r\n * @see [[Id64.iterable]].\r\n */\r\n export function* iterator(ids: Id64Arg): Iterator<Id64String> {\r\n if (typeof ids === \"string\") {\r\n yield ids;\r\n } else {\r\n for (const id of ids)\r\n yield id;\r\n }\r\n }\r\n\r\n /** Obtain an iterable over the specified Ids. Example usage:\r\n * ```ts\r\n * const ids = [\"0x123\", \"0xfed\"];\r\n * for (const id of Id64.iterable(ids))\r\n * console.log(id);\r\n * ```\r\n */\r\n export function iterable(ids: Id64Arg): Iterable<Id64String> {\r\n return {\r\n [Symbol.iterator]: () => iterator(ids),\r\n };\r\n }\r\n\r\n /** Return the first [[Id64String]] of an [[Id64Arg]]. */\r\n export function getFirst(arg: Id64Arg): Id64String {\r\n return typeof arg === \"string\" ? arg : (Array.isArray(arg) ? arg[0] : arg.values().next().value);\r\n }\r\n\r\n /** Return the number of [[Id64String]]s represented by an [[Id64Arg]]. */\r\n export function sizeOf(arg: Id64Arg): number {\r\n return typeof arg === \"string\" ? 1 : (Array.isArray(arg) ? arg.length : arg.size);\r\n }\r\n\r\n /** Returns true if the [[Id64Arg]] contains the specified Id. */\r\n export function has(arg: Id64Arg, id: Id64String): boolean {\r\n if (typeof arg === \"string\")\r\n return arg === id;\r\n if (Array.isArray(arg))\r\n return -1 !== arg.indexOf(id);\r\n\r\n return arg.has(id);\r\n }\r\n\r\n /** The string representation of an invalid Id. */\r\n export const invalid = \"0\";\r\n\r\n /** Determine if the supplied id string represents a transient Id.\r\n * @param id A well-formed Id string.\r\n * @returns true if the Id represents a transient Id.\r\n * @note This method assumes the input is a well-formed Id string.\r\n * @see [[Id64.isTransientId64]]\r\n * @see [[TransientIdSequence]]\r\n */\r\n export function isTransient(id: Id64String): boolean {\r\n // A transient Id is of the format \"0xffffffxxxxxxxxxx\" where the leading 6 digits indicate an invalid briefcase Id.\r\n return 18 === id.length && id.startsWith(\"0xffffff\");\r\n }\r\n\r\n /** Determine if the input is a well-formed [[Id64String]] and represents a transient Id.\r\n * @see [[Id64.isTransient]]\r\n * @see [[Id64.isId64]]\r\n * @see [[TransientIdSequence]]\r\n */\r\n export function isTransientId64(id: string): boolean {\r\n return isValidId64(id) && isTransient(id);\r\n }\r\n\r\n /** Determine if the input is a well-formed [[Id64String]].\r\n *\r\n * For a description of \"well-formed\", see [Working with Ids]($docs/learning/common/Id64.md).\r\n * @see [[Id64.isValidId64]]\r\n */\r\n export function isId64(id: string): boolean {\r\n const len = id.length;\r\n if (0 === len || 18 < len)\r\n return false;\r\n\r\n if (\"0\" !== id[0])\r\n return false;\r\n\r\n // Well-formed invalid Id: \"0\"\r\n if (1 === len)\r\n return true;\r\n\r\n // Valid Ids begin with \"0x\" followed by at least one lower-case hexadecimal digit.\r\n if (2 === len || \"x\" !== id[1])\r\n return false;\r\n\r\n // If briefcase Id is present, it occupies at least one digit, followed by 10 digits for local Id\r\n let localIdStart = 2;\r\n if (len > 12) {\r\n localIdStart = len - 10;\r\n\r\n // Verify briefcase Id\r\n if (!isValidHexString(id, 2, localIdStart - 2))\r\n return false;\r\n\r\n // Skip leading zeroes in local Id\r\n for (let i = localIdStart; i < len; i++) {\r\n if (0x30 !== id.charCodeAt(i)) // '0'\r\n break;\r\n else\r\n localIdStart++;\r\n }\r\n\r\n if (localIdStart >= len)\r\n return false;\r\n }\r\n\r\n return isValidHexString(id, localIdStart, len - localIdStart);\r\n }\r\n\r\n /** Returns true if the input is not equal to the representation of an invalid Id.\r\n * @note This method assumes the input is a well-formed Id string.\r\n * @see [[Id64.isInvalid]]\r\n * @see [[Id64.isValidId64]]\r\n */\r\n export function isValid(id: Id64String): boolean {\r\n return Id64.invalid !== id;\r\n }\r\n\r\n /** Returns true if the input is a well-formed [[Id64String]] representing a valid Id.\r\n * @see [[Id64.isValid]]\r\n * @see [[Id64.isId64]]\r\n */\r\n export function isValidId64(id: string): boolean {\r\n return Id64.invalid !== id && Id64.isId64(id);\r\n }\r\n\r\n /** Returns true if the input is a well-formed [[Id64String]] representing an invalid Id.\r\n * @see [[Id64.isValid]]\r\n */\r\n export function isInvalid(id: Id64String): boolean {\r\n return Id64.invalid === id;\r\n }\r\n\r\n /** A specialized replacement for Set<Id64String> optimized for performance-critical code which represents large sets of [[Id64]]s as pairs of\r\n * 32-bit integers.\r\n * The internal representation is a Map<number, Set<number>> where the Map key is the upper 4 bytes of the IDs and the Set elements are the lower 4 bytes of the IDs.\r\n * Because the upper 4 bytes store the 24-bit briefcase ID plus the upper 8 bits of the local ID, there will be a very small distribution of unique Map keys.\r\n * To further optimize this data type, the following assumptions are made regarding the { lower, upper } inputs, and no validation is performed to confirm them:\r\n * - The inputs are unsigned 32-bit integers;\r\n * - The inputs represent a valid Id64String (e.g., local ID is not zero).\r\n * @see [[Id64.Uint32Map]] for a similarly-optimized replacement for Map<Id64String, T>\r\n * @public\r\n */\r\n export class Uint32Set {\r\n protected readonly _map = new Map<number, Set<number>>();\r\n\r\n /** Construct a new Uint32Set.\r\n * @param ids If supplied, all of the specified Ids will be added to the new set.\r\n */\r\n public constructor(ids?: Id64Arg) {\r\n if (undefined !== ids)\r\n this.addIds(ids);\r\n }\r\n\r\n /** Remove all contents of this set. */\r\n public clear(): void {\r\n this._map.clear();\r\n }\r\n\r\n /** Add an Id to the set. */\r\n public addId(id: Id64String): void {\r\n this.add(Id64.getLowerUint32(id), Id64.getUpperUint32(id));\r\n }\r\n\r\n /** Add any number of Ids to the set. */\r\n public addIds(ids: Id64Arg): void {\r\n for (const id of Id64.iterable(ids))\r\n this.addId(id);\r\n }\r\n\r\n /** Returns true if the set contains the specified Id. */\r\n public hasId(id: Id64String): boolean { return this.has(Id64.getLowerUint32(id), Id64.getUpperUint32(id)); }\r\n\r\n /** Add an Id to the set. */\r\n public add(low: number, high: number): void {\r\n let set = this._map.get(high);\r\n if (undefined === set) {\r\n set = new Set<number>();\r\n this._map.set(high, set);\r\n }\r\n\r\n set.add(low);\r\n }\r\n\r\n /** Remove an Id from the set. */\r\n public deleteId(id: Id64String): void {\r\n this.delete(Id64.getLowerUint32(id), Id64.getUpperUint32(id));\r\n }\r\n\r\n /** Remove any number of Ids from the set. */\r\n public deleteIds(ids: Id64Arg): void {\r\n for (const id of Id64.iterable(ids))\r\n this.deleteId(id);\r\n }\r\n\r\n /** Remove an Id from the set. */\r\n public delete(low: number, high: number): void {\r\n const set = this._map.get(high);\r\n if (undefined !== set)\r\n set.delete(low);\r\n }\r\n\r\n /** Returns true if the set contains the specified Id. */\r\n public has(low: number, high: number): boolean {\r\n const set = this._map.get(high);\r\n return undefined !== set && set.has(low);\r\n }\r\n\r\n /** Returns true if the set contains the Id specified by `pair`. */\r\n public hasPair(pair: Uint32Pair): boolean {\r\n return this.has(pair.lower, pair.upper);\r\n }\r\n\r\n /** Returns true if the set contains no Ids. */\r\n public get isEmpty(): boolean { return 0 === this._map.size; }\r\n\r\n /** Returns the number of Ids contained in the set. */\r\n public get size(): number {\r\n let size = 0;\r\n for (const entry of this._map)\r\n size += entry[1].size;\r\n\r\n return size;\r\n }\r\n\r\n /** Populates and returns an array of all Ids contained in the set. */\r\n public toId64Array(): Id64Array {\r\n const ids: Id64Array = [];\r\n for (const entry of this._map)\r\n for (const low of entry[1])\r\n ids.push(Id64.fromUint32Pair(low, entry[0]));\r\n\r\n return ids;\r\n }\r\n\r\n /** Populates and returns a set of all Ids contained in the set. */\r\n public toId64Set(): Id64Set {\r\n const ids = new Set<string>();\r\n for (const entry of this._map)\r\n for (const low of entry[1])\r\n ids.add(Id64.fromUint32Pair(low, entry[0]));\r\n\r\n return ids;\r\n }\r\n\r\n /** Execute a function against each Id in this set. */\r\n public forEach(func: (lo: number, hi: number) => void): void {\r\n for (const entry of this._map)\r\n for (const lo of entry[1])\r\n func(lo, entry[0]);\r\n }\r\n }\r\n\r\n /** A specialized replacement for Map<Id64String, T> optimized for performance-critical code.\r\n * @see [[Id64.Uint32Set]] for implementation details.\r\n * @public\r\n */\r\n export class Uint32Map<T> {\r\n protected readonly _map = new Map<number, Map<number, T>>();\r\n\r\n /** Remove all entries from the map. */\r\n public clear(): void { this._map.clear(); }\r\n /** Find an entry in the map by Id. */\r\n public getById(id: Id64String): T | undefined { return this.get(Id64.getLowerUint32(id), Id64.getUpperUint32(id)); }\r\n /** Set an entry in the map by Id. */\r\n public setById(id: Id64String, value: T): void { this.set(Id64.getLowerUint32(id), Id64.getUpperUint32(id), value); }\r\n\r\n /** Set an entry in the map by Id components. */\r\n public set(low: number, high: number, value: T): void {\r\n let map = this._map.get(high);\r\n if (undefined === map) {\r\n map = new Map<number, T>();\r\n this._map.set(high, map);\r\n }\r\n\r\n map.set(low, value);\r\n }\r\n\r\n /** Get an entry from the map by Id components. */\r\n public get(low: number, high: number): T | undefined {\r\n const map = this._map.get(high);\r\n return undefined !== map ? map.get(low) : undefined;\r\n }\r\n\r\n /** Returns true if the map contains no entries. */\r\n public get isEmpty(): boolean { return 0 === this._map.size; }\r\n /** Returns the number of entries in the map. */\r\n public get size(): number {\r\n let size = 0;\r\n for (const entry of this._map)\r\n size += entry[1].size;\r\n\r\n return size;\r\n }\r\n\r\n /** Execute a function against each entry in this map. */\r\n public forEach(func: (lo: number, hi: number, value: T) => void): void {\r\n for (const outerEntry of this._map)\r\n for (const innerEntry of outerEntry[1])\r\n func(innerEntry[0], outerEntry[0], innerEntry[1]);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Generates unique [[Id64String]] values in sequence, which are guaranteed not to conflict with Ids associated with persistent elements or models.\r\n * This is useful for associating stable, non-persistent identifiers with things like [Decorator]($frontend)s.\r\n * A TransientIdSequence can generate a maximum of (2^40)-2 unique Ids.\r\n * @public\r\n */\r\nexport class TransientIdSequence {\r\n private _localId: number = 0;\r\n\r\n /** Generate and return the next transient Id64String in the sequence. */\r\n public get next(): Id64String { return Id64.fromLocalAndBriefcaseIds(++this._localId, 0xffffff); }\r\n}\r\n\r\n/**\r\n * The Guid namespace provides facilities for working with GUID strings using the \"8-4-4-4-12\" pattern.\r\n *\r\n * The [[GuidString]] type alias is used to indicate function arguments, return types, and variables which are known to\r\n * be in the GUID format.\r\n * @public\r\n */\r\nexport namespace Guid {\r\n const uuidPattern = new RegExp(\"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\");\r\n\r\n /** Represents the empty Guid 00000000-0000-0000-0000-000000000000 */\r\n export const empty: GuidString = \"00000000-0000-0000-0000-000000000000\";\r\n\r\n /** Determine whether the input string is \"guid-like\". That is, it follows the 8-4-4-4-12 pattern. This does not enforce\r\n * that the string is actually in valid UUID format.\r\n */\r\n export function isGuid(value: string): boolean {\r\n return uuidPattern.test(value);\r\n }\r\n\r\n /** Determine whether the input string is a valid V4 Guid string */\r\n export function isV4Guid(value: string): boolean {\r\n return /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/.test(value);\r\n }\r\n\r\n /** Create a new V4 Guid value */\r\n export function createValue(): GuidString {\r\n // https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\r\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\r\n const r = Math.random() * 16 | 0;\r\n const v = c === \"x\" ? r : (r & 0x3 | 0x8);\r\n return v.toString(16);\r\n });\r\n }\r\n\r\n /**\r\n * Normalize a Guid string if possible. Normalization consists of:\r\n * - Convert all characters to lower case\r\n * - Trim any leading or trailing whitespace\r\n * - Convert to the standard Guid format \"8-4-4-4-12\", repositioning the '-' characters as necessary, presuming there are exactly 32 hexadecimal digits.\r\n * @param value Input value that represents a Guid\r\n * @returns Normalized representation of the Guid string. If the normalization fails, return the *original* value unmodified (Note: it is *not* a valid Guid)\r\n */\r\n export function normalize(value: GuidString): GuidString {\r\n const lowerValue = value.toLowerCase().trim();\r\n\r\n // Return if it's already formatted to be a Guid\r\n if (isGuid(lowerValue))\r\n return lowerValue;\r\n\r\n // Remove any existing \"-\" characters and position them properly, if there remains exactly 32 hexadecimal digits\r\n const noDashValue = lowerValue.replace(/-/g, \"\");\r\n const noDashPattern = /^([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})$/;\r\n if (noDashPattern.test(noDashValue)) {\r\n return noDashValue.replace(noDashPattern,\r\n (_match: string, p1: string, p2: string, p3: string, p4: string, p5: string) =>\r\n `${p1}-${p2}-${p3}-${p4}-${p5}`);\r\n }\r\n\r\n // Return unmodified string - (note: it is *not* a valid Guid)\r\n return value;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Id.js","sourceRoot":"","sources":["../../src/Id.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA4BH,SAAS,KAAK,CAAC,GAAW;IACxB,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,0BAA0B,CAAC,GAAW,EAAE,KAAa;IAC5D,OAAO,mBAAmB,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAW,EAAE,KAAa,EAAE,YAAqB,IAAI;IAChF,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,gBAAgB;IACjE,OAAO,CAAC,QAAQ,IAAI,eAAe,IAAI,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,IAAI,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,oBAAoB;AAC1H,CAAC;AAED,SAAS,gBA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C,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACnE,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YACjC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;YAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAPe,gBAAW,cAO1B,CAAA;IAED;;;;;;;OAOG;IACH,SAAgB,SAAS,CAAC,KAAiB;QACzC,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;QAE9C,gDAAgD;QAChD,IAAI,MAAM,CAAC,UAAU,CAAC;YACpB,OAAO,UAAU,CAAC;QAEpB,gHAAgH;QAChH,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACjD,MAAM,aAAa,GAAG,sEAAsE,CAAC;QAC7F,IAAI,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;YACnC,OAAO,WAAW,CAAC,OAAO,CAAC,aAAa,EACtC,CAAC,MAAc,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAE,CAC7E,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;SACtC;QAED,8DAA8D;QAC9D,OAAO,KAAK,CAAC;IACf,CAAC;IAlBe,cAAS,YAkBxB,CAAA;AACH,CAAC,EAvDgB,IAAI,KAAJ,IAAI,QAuDpB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Ids\r\n */\r\n\r\n/** A string containing a well-formed string representation of an [Id64]($core-bentley).\r\n * See [Working with Ids]($docs/learning/common/Id64.md).\r\n * @public\r\n */\r\nexport type Id64String = string;\r\n\r\n/** A string containing a well-formed string representation of a [Guid]($core-bentley).\r\n * @public\r\n */\r\nexport type GuidString = string;\r\n\r\n/** A set of [[Id64String]]s.\r\n * @public\r\n */\r\nexport type Id64Set = Set<Id64String>;\r\n\r\n/** An array of [[Id64String]]s.\r\n * @public\r\n */\r\nexport type Id64Array = Id64String[];\r\n\r\n/** Used as an argument to a function that can accept one or more [[Id64String]]s.\r\n * @public\r\n */\r\nexport type Id64Arg = Id64String | Id64Set | Id64Array;\r\n\r\nfunction toHex(str: string): number {\r\n const v = parseInt(str, 16);\r\n return Number.isNaN(v) ? 0 : v;\r\n}\r\n\r\nfunction isLowerCaseNonZeroHexDigit(str: string, index: number) {\r\n return isLowerCaseHexDigit(str, index, false);\r\n}\r\n\r\nfunction isLowerCaseHexDigit(str: string, index: number, allowZero: boolean = true): boolean {\r\n const charCode = str.charCodeAt(index);\r\n const minDecimalDigit = allowZero ? 0x30 : 0x31; // '0' or '1'...\r\n return (charCode >= minDecimalDigit && charCode <= 0x39) || (charCode >= 0x61 && charCode <= 0x66); // '0'-'9, 'a' -'f'\r\n}\r\n\r\nfunction isValidHexString(id: string, startIndex: number, len: number) {\r\n if (len === 0)\r\n return false;\r\n\r\n // No leading zeroes...\r\n if (!isLowerCaseNonZeroHexDigit(id, startIndex))\r\n return false;\r\n\r\n // ...followed by len-1 lowercase hexadecimal digits.\r\n for (let i = 1; i < len; i++)\r\n if (!isLowerCaseHexDigit(id, startIndex + i))\r\n return false;\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * The Id64 namespace provides facilities for working with 64-bit identifiers. These Ids are stored as 64-bit integers inside an [[IModelDb]], but must be represented\r\n * as strings in JavaScript because JavaScript does not intrinsically support 64-bit integers.\r\n *\r\n * The [[Id64String]] type alias is used to indicate function arguments, return types, and variables which are known to contain a well-formed representation of a 64-bit Id.\r\n *\r\n * See [Working with Ids]($docs/learning/common/Id64.md) for a detailed description and code examples.\r\n * @public\r\n */\r\nexport namespace Id64 {\r\n /** Extract the \"local\" Id portion of an Id64String, contained in the lower 40 bits of the 64-bit value. */\r\n export function getLocalId(id: Id64String): number {\r\n if (isInvalid(id))\r\n return 0;\r\n\r\n const len = id.length;\r\n const start = (len > 12) ? (len - 10) : 2;\r\n return toHex(id.slice(start));\r\n }\r\n\r\n /** Extract the briefcase Id portion of an Id64String, contained in the upper 24 bits of the 64-bit value. */\r\n export function getBriefcaseId(id: Id64String): number {\r\n if (isInvalid(id))\r\n return 0;\r\n\r\n const len = id.length;\r\n return (len <= 12) ? 0 : toHex(id.slice(2, len - 10));\r\n }\r\n\r\n /** Create an Id64String from its JSON representation.\r\n * @param prop The JSON representation of an Id.\r\n * @returns A well-formed Id string.\r\n * @note if the input is undefined, the result is \"0\", indicating an invalid Id.\r\n * @note if the input is not undefined, the result is the same as that of [[Id64.fromString]].\r\n */\r\n export function fromJSON(prop?: string): Id64String {\r\n return typeof prop === \"string\" ? Id64.fromString(prop) : Id64.invalid;\r\n }\r\n\r\n /** Given a string value, attempt to normalize it into a well-formed Id string.\r\n * If the input is already a well-formed Id string, it is returned unmodified.\r\n * Otherwise, the input is trimmed of leading and trailing whitespace, converted to lowercase, and an attempt is made to parse it as a 64-bit hexadecimal integer.\r\n * If parsing succeeds the normalized result is returned; otherwise the result is \"0\", indicating an invalid Id.\r\n *\r\n * For a description of \"well-formed\", see [Working with Ids]($docs/learning/common/Id64.md).\r\n */\r\n export function fromString(val: string): Id64String {\r\n // NB: in case this is called from JavaScript, we must check the run-time type...\r\n if (typeof val !== \"string\")\r\n return invalid;\r\n\r\n // Skip the common case in which the input is already a well-formed Id string\r\n if (Id64.isId64(val))\r\n return val;\r\n\r\n // Attempt to normalize the input into a well-formed Id string\r\n val = val.toLowerCase().trim();\r\n const len = val.length;\r\n if (len < 2 || val[0] !== \"0\" || val[1] !== \"x\")\r\n return invalid;\r\n\r\n let low = 0;\r\n let high = 0;\r\n let start = 2;\r\n if (len > 12) {\r\n start = (len - 10);\r\n high = toHex(val.slice(2, start));\r\n }\r\n\r\n low = toHex(val.slice(start));\r\n return fromLocalAndBriefcaseIds(low, high);\r\n }\r\n\r\n // Used when constructing local ID portion of Id64String. Performance optimization.\r\n const _localIdPrefixByLocalIdLength = [ // eslint-disable-line @typescript-eslint/naming-convention\r\n \"0000000000\",\r\n \"000000000\",\r\n \"00000000\",\r\n \"0000000\",\r\n \"000000\",\r\n \"00000\",\r\n \"0000\",\r\n \"000\",\r\n \"00\",\r\n \"0\",\r\n \"\",\r\n ];\r\n\r\n /** Produce an Id string from a local and briefcase Id.\r\n * @param localId The non-zero local Id as an unsigned 40-bit integer.\r\n * @param briefcaseId The briefcase Id as an unsigned 24-bit integer.\r\n * @returns an Id64String containing the hexadecimal string representation of the unsigned 64-bit integer which would result from the\r\n * operation `localId | (briefcaseId << 40)`, or an invalid Id \"0\" if the inputs are invalid.\r\n */\r\n export function fromLocalAndBriefcaseIds(localId: number, briefcaseId: number): Id64String {\r\n // NB: Yes, we must check the run-time type...\r\n if (typeof localId !== \"number\" || typeof briefcaseId !== \"number\")\r\n return invalid;\r\n\r\n localId = Math.floor(localId);\r\n if (0 === localId)\r\n return invalid;\r\n\r\n briefcaseId = Math.floor(briefcaseId);\r\n const lowStr = localId.toString(16);\r\n return `0x${(briefcaseId === 0) ? lowStr : (briefcaseId.toString(16) + (_localIdPrefixByLocalIdLength[lowStr.length] + lowStr))}`;\r\n }\r\n\r\n // Used as a buffer when converting a pair of 32-bit integers to an Id64String. Significant performance optimization.\r\n const scratchCharCodes = [\r\n 0x30, // \"0\"\r\n 0x78, // \"x\"\r\n 0x30, // \"0\"\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n 0x30,\r\n ];\r\n\r\n // Convert 4-bit unsigned integer to char code representing lower-case hexadecimal digit.\r\n function uint4ToCharCode(uint4: number): number {\r\n return uint4 + (uint4 < 10 ? 0x30 : 0x57);\r\n }\r\n\r\n // Convert char code representing lower-case hexadecimal digit to 4-bit unsigned integer.\r\n function charCodeToUint4(char: number): number {\r\n return char - (char >= 0x57 ? 0x57 : 0x30);\r\n }\r\n\r\n // Convert a substring to a uint32. This is twice as fast as using Number.parseInt().\r\n function substringToUint32(id: Id64String, start: number, end: number): number {\r\n let uint32 = 0;\r\n for (let i = start; i < end; i++) {\r\n const uint4 = charCodeToUint4(id.charCodeAt(i));\r\n const shift = (end - i - 1) << 2;\r\n const mask = uint4 << shift;\r\n uint32 = (uint32 | mask) >>> 0; // >>> 0 to force unsigned because javascript\r\n }\r\n\r\n return uint32;\r\n }\r\n\r\n /** Create an Id64String from a pair of unsigned 32-bit integers.\r\n * @param lowBytes The lower 4 bytes of the Id\r\n * @param highBytes The upper 4 bytes of the Id\r\n * @returns an Id64String containing the hexadecimal string representation of the unsigned 64-bit integer which would result from the\r\n * operation `lowBytes | (highBytes << 32)`.\r\n * @see [[Id64.fromUint32PairObject]] if you have a [[Id64.Uint32Pair]] object.\r\n */\r\n export function fromUint32Pair(lowBytes: number, highBytes: number): Id64String {\r\n const localIdLow = lowBytes >>> 0;\r\n const localIdHigh = (highBytes & 0x000000ff) * (0xffffffff + 1); // aka (highBytes & 0xff) << 32\r\n const localId = localIdLow + localIdHigh; // aka localIdLow | localIdHigh\r\n if (0 === localId)\r\n return invalid;\r\n\r\n // Need to omit or preserve leading zeroes...\r\n const buffer = scratchCharCodes;\r\n let index = 2;\r\n for (let i = 7; i >= 0; i--) {\r\n const shift = i << 2;\r\n const mask = 0xf << shift;\r\n const uint4 = (highBytes & mask) >>> shift;\r\n if (index > 2 || 0 !== uint4)\r\n buffer[index++] = uint4ToCharCode(uint4);\r\n }\r\n\r\n for (let i = 7; i >= 0; i--) {\r\n const shift = i << 2;\r\n const mask = 0xf << shift;\r\n const uint4 = (lowBytes & mask) >>> shift;\r\n if (index > 2 || 0 !== uint4)\r\n buffer[index++] = uint4ToCharCode(uint4);\r\n }\r\n\r\n if (buffer.length !== index)\r\n buffer.length = index;\r\n\r\n return String.fromCharCode(...scratchCharCodes);\r\n }\r\n\r\n /** Create an Id64String from a [[Id64.Uint32Pair]].\r\n * @see [[Id64.fromUint32Pair]].\r\n */\r\n export function fromUint32PairObject(pair: Uint32Pair): Id64String {\r\n return fromUint32Pair(pair.lower, pair.upper);\r\n }\r\n\r\n /** Returns true if the inputs represent two halves of a valid 64-bit Id.\r\n * @see [[Id64.Uint32Pair]].\r\n */\r\n export function isValidUint32Pair(lowBytes: number, highBytes: number): boolean {\r\n // Detect local ID of zero\r\n return 0 !== lowBytes || 0 !== (highBytes & 0x000000ff);\r\n }\r\n\r\n /** Represents an [[Id64]] as a pair of unsigned 32-bit integers. Because Javascript lacks efficient support for 64-bit integers,\r\n * this representation can be useful in performance-sensitive code like the render loop.\r\n * @see [[Id64.getUint32Pair]] to convert an [[Id64String]] to a Uint32Pair.\r\n * @see [[Id64.fromUint32Pair]] to convert a Uint32Pair to an [[Id64String]].\r\n * @see [[Id64.Uint32Set]] and [[Id64.Uint32Map]] for collections based on Uint32Pairs.\r\n */\r\n export interface Uint32Pair {\r\n /** The lower 4 bytes of the 64-bit integer. */\r\n lower: number;\r\n /** The upper 4 bytes of the 64-bit integer. */\r\n upper: number;\r\n }\r\n\r\n /** Convert an Id64String to a 64-bit unsigned integer represented as a pair of unsigned 32-bit integers.\r\n * @param id The well-formed string representation of a 64-bit Id.\r\n * @param out Used as the return value if supplied; otherwise a new object is returned.\r\n * @returns An object containing the parsed lower and upper 32-bit integers comprising the 64-bit Id.\r\n */\r\n export function getUint32Pair(id: Id64String, out?: Uint32Pair): Uint32Pair {\r\n if (!out)\r\n out = { lower: 0, upper: 0 };\r\n\r\n out.lower = getLowerUint32(id);\r\n out.upper = getUpperUint32(id);\r\n return out;\r\n }\r\n\r\n /** Extract an unsigned 32-bit integer from the lower 4 bytes of an Id64String. */\r\n export function getLowerUint32(id: Id64String): number {\r\n if (isInvalid(id))\r\n return 0;\r\n\r\n const end = id.length;\r\n const start = end > 10 ? end - 8 : 2;\r\n return substringToUint32(id, start, end);\r\n }\r\n\r\n /** Extract an unsigned 32-bit integer from the upper 4 bytes of an Id64String. */\r\n export function getUpperUint32(id: Id64String): number {\r\n const len = id.length;\r\n if (len <= 10 || isInvalid(id))\r\n return 0;\r\n\r\n return substringToUint32(id, 2, len - 8);\r\n }\r\n\r\n /** Convert an [[Id64Arg]] into an [[Id64Set]].\r\n *\r\n * This method can be used by functions that accept an Id64Arg to conveniently process the value(s). For example:\r\n * ```ts\r\n * public addCategories(arg: Id64Arg) { Id64.toIdSet(arg).forEach((id) => this.categories.add(id)); }\r\n * ```\r\n *\r\n * Alternatively, to avoid allocating a new Id64Set, use [[Id64.iterable]].\r\n *\r\n * @param arg The Ids to convert to an Id64Set.\r\n * @param makeCopy If true, and the input is already an Id64Set, returns a deep copy of the input.\r\n * @returns An Id64Set containing the set of [[Id64String]]s represented by the Id64Arg.\r\n */\r\n export function toIdSet(arg: Id64Arg, makeCopy: boolean = false): Id64Set {\r\n if (arg instanceof Set)\r\n return makeCopy ? new Set<string>(arg) : arg;\r\n\r\n const ids = new Set<Id64String>();\r\n if (typeof arg === \"string\")\r\n ids.add(arg);\r\n else if (Array.isArray(arg)) {\r\n arg.forEach((id: Id64String) => {\r\n if (typeof id === \"string\")\r\n ids.add(id);\r\n });\r\n }\r\n\r\n return ids;\r\n }\r\n\r\n /** Obtain iterator over the specified Ids.\r\n * @see [[Id64.iterable]].\r\n */\r\n export function* iterator(ids: Id64Arg): Iterator<Id64String> {\r\n if (typeof ids === \"string\") {\r\n yield ids;\r\n } else {\r\n for (const id of ids)\r\n yield id;\r\n }\r\n }\r\n\r\n /** Obtain an iterable over the specified Ids. Example usage:\r\n * ```ts\r\n * const ids = [\"0x123\", \"0xfed\"];\r\n * for (const id of Id64.iterable(ids))\r\n * console.log(id);\r\n * ```\r\n */\r\n export function iterable(ids: Id64Arg): Iterable<Id64String> {\r\n return {\r\n [Symbol.iterator]: () => iterator(ids),\r\n };\r\n }\r\n\r\n /** Return the first [[Id64String]] of an [[Id64Arg]]. */\r\n export function getFirst(arg: Id64Arg): Id64String {\r\n return typeof arg === \"string\" ? arg : (Array.isArray(arg) ? arg[0] : arg.values().next().value);\r\n }\r\n\r\n /** Return the number of [[Id64String]]s represented by an [[Id64Arg]]. */\r\n export function sizeOf(arg: Id64Arg): number {\r\n return typeof arg === \"string\" ? 1 : (Array.isArray(arg) ? arg.length : arg.size);\r\n }\r\n\r\n /** Returns true if the [[Id64Arg]] contains the specified Id. */\r\n export function has(arg: Id64Arg, id: Id64String): boolean {\r\n if (typeof arg === \"string\")\r\n return arg === id;\r\n if (Array.isArray(arg))\r\n return -1 !== arg.indexOf(id);\r\n\r\n return arg.has(id);\r\n }\r\n\r\n /** The string representation of an invalid Id. */\r\n export const invalid = \"0\";\r\n\r\n /** Determine if the supplied id string represents a transient Id.\r\n * @param id A well-formed Id string.\r\n * @returns true if the Id represents a transient Id.\r\n * @note This method assumes the input is a well-formed Id string.\r\n * @see [[Id64.isTransientId64]]\r\n * @see [[TransientIdSequence]]\r\n */\r\n export function isTransient(id: Id64String): boolean {\r\n // A transient Id is of the format \"0xffffffxxxxxxxxxx\" where the leading 6 digits indicate an invalid briefcase Id.\r\n return 18 === id.length && id.startsWith(\"0xffffff\");\r\n }\r\n\r\n /** Determine if the input is a well-formed [[Id64String]] and represents a transient Id.\r\n * @see [[Id64.isTransient]]\r\n * @see [[Id64.isId64]]\r\n * @see [[TransientIdSequence]]\r\n */\r\n export function isTransientId64(id: string): boolean {\r\n return isValidId64(id) && isTransient(id);\r\n }\r\n\r\n /** Determine if the input is a well-formed [[Id64String]].\r\n *\r\n * For a description of \"well-formed\", see [Working with Ids]($docs/learning/common/Id64.md).\r\n * @see [[Id64.isValidId64]]\r\n */\r\n export function isId64(id: string): boolean {\r\n const len = id.length;\r\n if (0 === len || 18 < len)\r\n return false;\r\n\r\n if (\"0\" !== id[0])\r\n return false;\r\n\r\n // Well-formed invalid Id: \"0\"\r\n if (1 === len)\r\n return true;\r\n\r\n // Valid Ids begin with \"0x\" followed by at least one lower-case hexadecimal digit.\r\n if (2 === len || \"x\" !== id[1])\r\n return false;\r\n\r\n // If briefcase Id is present, it occupies at least one digit, followed by 10 digits for local Id\r\n let localIdStart = 2;\r\n if (len > 12) {\r\n localIdStart = len - 10;\r\n\r\n // Verify briefcase Id\r\n if (!isValidHexString(id, 2, localIdStart - 2))\r\n return false;\r\n\r\n // Skip leading zeroes in local Id\r\n for (let i = localIdStart; i < len; i++) {\r\n if (0x30 !== id.charCodeAt(i)) // '0'\r\n break;\r\n else\r\n localIdStart++;\r\n }\r\n\r\n if (localIdStart >= len)\r\n return false;\r\n }\r\n\r\n return isValidHexString(id, localIdStart, len - localIdStart);\r\n }\r\n\r\n /** Returns true if the input is not equal to the representation of an invalid Id.\r\n * @note This method assumes the input is a well-formed Id string.\r\n * @see [[Id64.isInvalid]]\r\n * @see [[Id64.isValidId64]]\r\n */\r\n export function isValid(id: Id64String): boolean {\r\n return Id64.invalid !== id;\r\n }\r\n\r\n /** Returns true if the input is a well-formed [[Id64String]] representing a valid Id.\r\n * @see [[Id64.isValid]]\r\n * @see [[Id64.isId64]]\r\n */\r\n export function isValidId64(id: string): boolean {\r\n return Id64.invalid !== id && Id64.isId64(id);\r\n }\r\n\r\n /** Returns true if the input is a well-formed [[Id64String]] representing an invalid Id.\r\n * @see [[Id64.isValid]]\r\n */\r\n export function isInvalid(id: Id64String): boolean {\r\n return Id64.invalid === id;\r\n }\r\n\r\n /** A specialized replacement for Set<Id64String> optimized for performance-critical code which represents large sets of [[Id64]]s as pairs of\r\n * 32-bit integers.\r\n * The internal representation is a Map<number, Set<number>> where the Map key is the upper 4 bytes of the IDs and the Set elements are the lower 4 bytes of the IDs.\r\n * Because the upper 4 bytes store the 24-bit briefcase ID plus the upper 8 bits of the local ID, there will be a very small distribution of unique Map keys.\r\n * To further optimize this data type, the following assumptions are made regarding the { lower, upper } inputs, and no validation is performed to confirm them:\r\n * - The inputs are unsigned 32-bit integers;\r\n * - The inputs represent a valid Id64String (e.g., local ID is not zero).\r\n * @see [[Id64.Uint32Map]] for a similarly-optimized replacement for Map<Id64String, T>\r\n * @public\r\n */\r\n export class Uint32Set {\r\n protected readonly _map = new Map<number, Set<number>>();\r\n\r\n /** Construct a new Uint32Set.\r\n * @param ids If supplied, all of the specified Ids will be added to the new set.\r\n */\r\n public constructor(ids?: Id64Arg) {\r\n if (undefined !== ids)\r\n this.addIds(ids);\r\n }\r\n\r\n /** Remove all contents of this set. */\r\n public clear(): void {\r\n this._map.clear();\r\n }\r\n\r\n /** Add an Id to the set. */\r\n public addId(id: Id64String): void {\r\n this.add(Id64.getLowerUint32(id), Id64.getUpperUint32(id));\r\n }\r\n\r\n /** Add any number of Ids to the set. */\r\n public addIds(ids: Id64Arg): void {\r\n for (const id of Id64.iterable(ids))\r\n this.addId(id);\r\n }\r\n\r\n /** Returns true if the set contains the specified Id. */\r\n public hasId(id: Id64String): boolean { return this.has(Id64.getLowerUint32(id), Id64.getUpperUint32(id)); }\r\n\r\n /** Add an Id to the set. */\r\n public add(low: number, high: number): void {\r\n let set = this._map.get(high);\r\n if (undefined === set) {\r\n set = new Set<number>();\r\n this._map.set(high, set);\r\n }\r\n\r\n set.add(low);\r\n }\r\n\r\n /** Remove an Id from the set. */\r\n public deleteId(id: Id64String): void {\r\n this.delete(Id64.getLowerUint32(id), Id64.getUpperUint32(id));\r\n }\r\n\r\n /** Remove any number of Ids from the set. */\r\n public deleteIds(ids: Id64Arg): void {\r\n for (const id of Id64.iterable(ids))\r\n this.deleteId(id);\r\n }\r\n\r\n /** Remove an Id from the set. */\r\n public delete(low: number, high: number): void {\r\n const set = this._map.get(high);\r\n if (undefined !== set)\r\n set.delete(low);\r\n }\r\n\r\n /** Returns true if the set contains the specified Id. */\r\n public has(low: number, high: number): boolean {\r\n const set = this._map.get(high);\r\n return undefined !== set && set.has(low);\r\n }\r\n\r\n /** Returns true if the set contains the Id specified by `pair`. */\r\n public hasPair(pair: Uint32Pair): boolean {\r\n return this.has(pair.lower, pair.upper);\r\n }\r\n\r\n /** Returns true if the set contains no Ids. */\r\n public get isEmpty(): boolean { return 0 === this._map.size; }\r\n\r\n /** Returns the number of Ids contained in the set. */\r\n public get size(): number {\r\n let size = 0;\r\n for (const entry of this._map)\r\n size += entry[1].size;\r\n\r\n return size;\r\n }\r\n\r\n /** Populates and returns an array of all Ids contained in the set. */\r\n public toId64Array(): Id64Array {\r\n const ids: Id64Array = [];\r\n for (const entry of this._map)\r\n for (const low of entry[1])\r\n ids.push(Id64.fromUint32Pair(low, entry[0]));\r\n\r\n return ids;\r\n }\r\n\r\n /** Populates and returns a set of all Ids contained in the set. */\r\n public toId64Set(): Id64Set {\r\n const ids = new Set<string>();\r\n for (const entry of this._map)\r\n for (const low of entry[1])\r\n ids.add(Id64.fromUint32Pair(low, entry[0]));\r\n\r\n return ids;\r\n }\r\n\r\n /** Execute a function against each Id in this set. */\r\n public forEach(func: (lo: number, hi: number) => void): void {\r\n for (const entry of this._map)\r\n for (const lo of entry[1])\r\n func(lo, entry[0]);\r\n }\r\n }\r\n\r\n /** A specialized replacement for Map<Id64String, T> optimized for performance-critical code.\r\n * @see [[Id64.Uint32Set]] for implementation details.\r\n * @public\r\n */\r\n export class Uint32Map<T> {\r\n protected readonly _map = new Map<number, Map<number, T>>();\r\n\r\n /** Remove all entries from the map. */\r\n public clear(): void { this._map.clear(); }\r\n /** Find an entry in the map by Id. */\r\n public getById(id: Id64String): T | undefined { return this.get(Id64.getLowerUint32(id), Id64.getUpperUint32(id)); }\r\n /** Set an entry in the map by Id. */\r\n public setById(id: Id64String, value: T): void { this.set(Id64.getLowerUint32(id), Id64.getUpperUint32(id), value); }\r\n\r\n /** Set an entry in the map by Id components. */\r\n public set(low: number, high: number, value: T): void {\r\n let map = this._map.get(high);\r\n if (undefined === map) {\r\n map = new Map<number, T>();\r\n this._map.set(high, map);\r\n }\r\n\r\n map.set(low, value);\r\n }\r\n\r\n /** Get an entry from the map by Id components. */\r\n public get(low: number, high: number): T | undefined {\r\n const map = this._map.get(high);\r\n return undefined !== map ? map.get(low) : undefined;\r\n }\r\n\r\n /** Returns true if the map contains no entries. */\r\n public get isEmpty(): boolean { return 0 === this._map.size; }\r\n /** Returns the number of entries in the map. */\r\n public get size(): number {\r\n let size = 0;\r\n for (const entry of this._map)\r\n size += entry[1].size;\r\n\r\n return size;\r\n }\r\n\r\n /** Execute a function against each entry in this map. */\r\n public forEach(func: (lo: number, hi: number, value: T) => void): void {\r\n for (const outerEntry of this._map)\r\n for (const innerEntry of outerEntry[1])\r\n func(innerEntry[0], outerEntry[0], innerEntry[1]);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Generates unique [[Id64String]] values in sequence, which are guaranteed not to conflict with Ids associated with persistent elements or models.\r\n * This is useful for associating stable, non-persistent identifiers with things like [Decorator]($frontend)s.\r\n * A TransientIdSequence can generate a maximum of (2^40)-2 unique Ids.\r\n * @public\r\n */\r\nexport class TransientIdSequence {\r\n private _localId: number = 0;\r\n\r\n /** Generate and return the next transient Id64String in the sequence.\r\n * @deprecated in 3.x. Use [[getNext]].\r\n */\r\n public get next(): Id64String {\r\n return this.getNext();\r\n }\r\n\r\n /** Generate and return the next transient Id64String in the sequence. */\r\n public getNext(): Id64String {\r\n return Id64.fromLocalAndBriefcaseIds(++this._localId, 0xffffff);\r\n }\r\n\r\n /** Preview the transient Id64String that will be returned by the next call to [[getNext]].\r\n * This is primarily useful for tests.\r\n */\r\n public peekNext(): Id64String {\r\n return Id64.fromLocalAndBriefcaseIds(this._localId + 1, 0xffffff);\r\n }\r\n}\r\n\r\n/**\r\n * The Guid namespace provides facilities for working with GUID strings using the \"8-4-4-4-12\" pattern.\r\n *\r\n * The [[GuidString]] type alias is used to indicate function arguments, return types, and variables which are known to\r\n * be in the GUID format.\r\n * @public\r\n */\r\nexport namespace Guid {\r\n const uuidPattern = new RegExp(\"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\");\r\n\r\n /** Represents the empty Guid 00000000-0000-0000-0000-000000000000 */\r\n export const empty: GuidString = \"00000000-0000-0000-0000-000000000000\";\r\n\r\n /** Determine whether the input string is \"guid-like\". That is, it follows the 8-4-4-4-12 pattern. This does not enforce\r\n * that the string is actually in valid UUID format.\r\n */\r\n export function isGuid(value: string): boolean {\r\n return uuidPattern.test(value);\r\n }\r\n\r\n /** Determine whether the input string is a valid V4 Guid string */\r\n export function isV4Guid(value: string): boolean {\r\n return /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/.test(value);\r\n }\r\n\r\n /** Create a new V4 Guid value */\r\n export function createValue(): GuidString {\r\n // https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript\r\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\r\n const r = Math.random() * 16 | 0;\r\n const v = c === \"x\" ? r : (r & 0x3 | 0x8);\r\n return v.toString(16);\r\n });\r\n }\r\n\r\n /**\r\n * Normalize a Guid string if possible. Normalization consists of:\r\n * - Convert all characters to lower case\r\n * - Trim any leading or trailing whitespace\r\n * - Convert to the standard Guid format \"8-4-4-4-12\", repositioning the '-' characters as necessary, presuming there are exactly 32 hexadecimal digits.\r\n * @param value Input value that represents a Guid\r\n * @returns Normalized representation of the Guid string. If the normalization fails, return the *original* value unmodified (Note: it is *not* a valid Guid)\r\n */\r\n export function normalize(value: GuidString): GuidString {\r\n const lowerValue = value.toLowerCase().trim();\r\n\r\n // Return if it's already formatted to be a Guid\r\n if (isGuid(lowerValue))\r\n return lowerValue;\r\n\r\n // Remove any existing \"-\" characters and position them properly, if there remains exactly 32 hexadecimal digits\r\n const noDashValue = lowerValue.replace(/-/g, \"\");\r\n const noDashPattern = /^([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})$/;\r\n if (noDashPattern.test(noDashValue)) {\r\n return noDashValue.replace(noDashPattern,\r\n (_match: string, p1: string, p2: string, p3: string, p4: string, p5: string) =>\r\n `${p1}-${p2}-${p3}-${p4}-${p5}`);\r\n }\r\n\r\n // Return unmodified string - (note: it is *not* a valid Guid)\r\n return value;\r\n }\r\n}\r\n"]}
|
|
@@ -20,7 +20,12 @@ export interface TypedArrayBuilderOptions {
|
|
|
20
20
|
*/
|
|
21
21
|
initialCapacity?: number;
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
23
|
+
/** A [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) containing unsigned 8-, 16-, or 32-bit integers.
|
|
24
|
+
* @see [[UintArrayBuilder]] to construct such an array.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare type UintArray = Uint8Array | Uint16Array | Uint32Array;
|
|
28
|
+
/** Incrementally builds a [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) of unsigned 8-, 16-, or 32-bit integers.
|
|
24
29
|
* Sometimes you wish to populate a `TypedArray`, but you don't know how many elements you will need.
|
|
25
30
|
* `TypedArray` requires you to specify the size upon construction, and does not permit you to change the size later.
|
|
26
31
|
*
|
|
@@ -31,11 +36,12 @@ export interface TypedArrayBuilderOptions {
|
|
|
31
36
|
*
|
|
32
37
|
* Once you've finished adding elements, you can obtain the finished `TypedArray` via [[toTypedArray]].
|
|
33
38
|
* @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], and [[Uint32ArrayBuilder]] to build specific types of arrays.
|
|
39
|
+
* @see [[UintArrayBuilder]] when you don't know the maximum number of bytes required for each element in the array.
|
|
34
40
|
* @public
|
|
35
41
|
*/
|
|
36
|
-
export declare class TypedArrayBuilder<T extends
|
|
42
|
+
export declare class TypedArrayBuilder<T extends UintArray> {
|
|
37
43
|
/** The constructor for the specific type of array being populated. */
|
|
38
|
-
protected
|
|
44
|
+
protected _constructor: Constructor<T>;
|
|
39
45
|
/** The underlying typed array, to be reallocated and copied when its capacity is exceeded. */
|
|
40
46
|
protected _data: T;
|
|
41
47
|
/** The number of elements added to the array so far. */
|
|
@@ -76,23 +82,75 @@ export declare class TypedArrayBuilder<T extends Uint8Array | Uint16Array | Uint
|
|
|
76
82
|
* @public
|
|
77
83
|
*/
|
|
78
84
|
export declare class Uint8ArrayBuilder extends TypedArrayBuilder<Uint8Array> {
|
|
79
|
-
/**
|
|
85
|
+
/** See [[TypedArrayBuilder]] constructor. */
|
|
80
86
|
constructor(options?: TypedArrayBuilderOptions);
|
|
81
87
|
}
|
|
82
88
|
/** A [[TypedArrayBuilder]] for producing a [Uint16Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array).
|
|
83
89
|
* @public
|
|
84
90
|
*/
|
|
85
91
|
export declare class Uint16ArrayBuilder extends TypedArrayBuilder<Uint16Array> {
|
|
86
|
-
/**
|
|
92
|
+
/** See [[TypedArrayBuilder]] constructor. */
|
|
87
93
|
constructor(options?: TypedArrayBuilderOptions);
|
|
88
94
|
}
|
|
89
95
|
/** A [[TypedArrayBuilder]] for producing a [Uint32Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array).
|
|
90
96
|
* @public
|
|
91
97
|
*/
|
|
92
98
|
export declare class Uint32ArrayBuilder extends TypedArrayBuilder<Uint32Array> {
|
|
93
|
-
/**
|
|
99
|
+
/** See [[TypedArrayBuilder]] constructor. */
|
|
94
100
|
constructor(options?: TypedArrayBuilderOptions);
|
|
95
101
|
/** Obtain a view of the finished array as an array of bytes. */
|
|
96
102
|
toUint8Array(includeUnusedCapacity?: boolean): Uint8Array;
|
|
97
103
|
}
|
|
104
|
+
/** Options used to construct a [[UintArrayBuilder]].
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
export interface UintArrayBuilderOptions extends TypedArrayBuilderOptions {
|
|
108
|
+
/** The type of the initial empty `TypedArray` created by the builder. For example, if you know that you will be adding values larger than
|
|
109
|
+
* 255 to the array, specify `{ initialType: Uint16Array }` to avoid replacing the otherwise default `Uint8Array` when the first such value is added.
|
|
110
|
+
* Default: `Uint8Array`.
|
|
111
|
+
*/
|
|
112
|
+
initialType?: typeof Uint8Array | typeof Uint16Array | typeof Uint32Array;
|
|
113
|
+
}
|
|
114
|
+
/** A [[TypedArrayBuilder]] that can populate a [[UintArray]] with the minimum
|
|
115
|
+
* [bytes per element](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT) required.
|
|
116
|
+
*
|
|
117
|
+
* By default, the underlying array is a `Uint8Array`, though this can be configured via [[UintArrayBuilderOptions.initialType]].
|
|
118
|
+
* As values are added to the array, if the bytes per element supported by the underlying array is too small to hold one of the new values, the array is
|
|
119
|
+
* reallocated to a type large enough to hold all of the new values. For example, the following produces a `Uint8Array` because all values are less than 256:
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* const builder = new UintArrayBuilder();
|
|
123
|
+
* builder.append([1, 2, 254, 255]);
|
|
124
|
+
* const array = builder.toTypedArray();
|
|
125
|
+
* assert(array instanceof Uint8Array);
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* However, the following produces a `Uint16Array` because one of the values is larger than 255 but none are larger than 65,535:
|
|
129
|
+
*
|
|
130
|
+
* ```ts
|
|
131
|
+
* const builder = new UintArrayBuilder();
|
|
132
|
+
* builder.append([1, 255, 257, 65535]);
|
|
133
|
+
* const array = builder.toTypedArray();
|
|
134
|
+
* assert(array instanceof Uint16Array);
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], or [[Uint32ArrayBuilder]] if you know the number of bytes you want to allocate for each element in the array.
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
export declare class UintArrayBuilder extends TypedArrayBuilder<UintArray> {
|
|
141
|
+
constructor(options?: UintArrayBuilderOptions);
|
|
142
|
+
/** The number of bytes (1, 2, or 4) currently allocated per element by the underlying array.
|
|
143
|
+
* This may change as larger values are added to the array.
|
|
144
|
+
*/
|
|
145
|
+
get bytesPerElement(): number;
|
|
146
|
+
/** Ensures that the underlying array is of a type that can contain the largest value in `newValues`.
|
|
147
|
+
* For example, if `_data` is a `Uint16Array` and `newValues` contains any value(s) larger than 65,535, it will be replaced with a `Uint32Array`.
|
|
148
|
+
* This method is invoked by [[push]] and [[append]].
|
|
149
|
+
*/
|
|
150
|
+
protected ensureBytesPerElement(newValues: Iterable<number>): void;
|
|
151
|
+
/** See [[TypedArrayBuilder.push]]. */
|
|
152
|
+
push(value: number): void;
|
|
153
|
+
/** See [[TypedArrayBuilder.append]]. */
|
|
154
|
+
append(values: UintArray): void;
|
|
155
|
+
}
|
|
98
156
|
//# sourceMappingURL=TypedArrayBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedArrayBuilder.d.ts","sourceRoot":"","sources":["../../src/TypedArrayBuilder.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED
|
|
1
|
+
{"version":3,"file":"TypedArrayBuilder.d.ts","sourceRoot":"","sources":["../../src/TypedArrayBuilder.ts"],"names":[],"mappings":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E,wBAAwB;CAGtD;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,iBAAiB,CAAC,WAAW,CAAC;IACpE,6CAA6C;gBAC1B,OAAO,CAAC,EAAE,wBAAwB;CAGtD;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,iBAAiB,CAAC,WAAW,CAAC;IACpE,6CAA6C;gBAC1B,OAAO,CAAC,EAAE,wBAAwB;IAIrD,gEAAgE;IACzD,YAAY,CAAC,qBAAqB,UAAQ,GAAG,UAAU;CAM/D;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,UAAU,GAAG,OAAO,WAAW,GAAG,OAAO,WAAW,CAAC;CAC3E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,SAAS,CAAC;gBAC7C,OAAO,CAAC,EAAE,uBAAuB;IAIpD;;OAEG;IACH,IAAW,eAAe,IAAI,MAAM,CAEnC;IAED;;;OAGG;IACH,SAAS,CAAC,qBAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI;IAuBlE,sCAAsC;IACtB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKzC,wCAAwC;IACxB,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;CAIhD"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module Collections
|
|
7
7
|
*/
|
|
8
8
|
import { assert } from "./Assert";
|
|
9
|
-
/** Incrementally builds a [TypedArray] of unsigned 8-, 16-, or 32-bit integers.
|
|
9
|
+
/** Incrementally builds a [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) of unsigned 8-, 16-, or 32-bit integers.
|
|
10
10
|
* Sometimes you wish to populate a `TypedArray`, but you don't know how many elements you will need.
|
|
11
11
|
* `TypedArray` requires you to specify the size upon construction, and does not permit you to change the size later.
|
|
12
12
|
*
|
|
@@ -17,6 +17,7 @@ import { assert } from "./Assert";
|
|
|
17
17
|
*
|
|
18
18
|
* Once you've finished adding elements, you can obtain the finished `TypedArray` via [[toTypedArray]].
|
|
19
19
|
* @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], and [[Uint32ArrayBuilder]] to build specific types of arrays.
|
|
20
|
+
* @see [[UintArrayBuilder]] when you don't know the maximum number of bytes required for each element in the array.
|
|
20
21
|
* @public
|
|
21
22
|
*/
|
|
22
23
|
export class TypedArrayBuilder {
|
|
@@ -96,7 +97,7 @@ export class TypedArrayBuilder {
|
|
|
96
97
|
* @public
|
|
97
98
|
*/
|
|
98
99
|
export class Uint8ArrayBuilder extends TypedArrayBuilder {
|
|
99
|
-
/**
|
|
100
|
+
/** See [[TypedArrayBuilder]] constructor. */
|
|
100
101
|
constructor(options) {
|
|
101
102
|
super(Uint8Array, options);
|
|
102
103
|
}
|
|
@@ -105,7 +106,7 @@ export class Uint8ArrayBuilder extends TypedArrayBuilder {
|
|
|
105
106
|
* @public
|
|
106
107
|
*/
|
|
107
108
|
export class Uint16ArrayBuilder extends TypedArrayBuilder {
|
|
108
|
-
/**
|
|
109
|
+
/** See [[TypedArrayBuilder]] constructor. */
|
|
109
110
|
constructor(options) {
|
|
110
111
|
super(Uint16Array, options);
|
|
111
112
|
}
|
|
@@ -114,7 +115,7 @@ export class Uint16ArrayBuilder extends TypedArrayBuilder {
|
|
|
114
115
|
* @public
|
|
115
116
|
*/
|
|
116
117
|
export class Uint32ArrayBuilder extends TypedArrayBuilder {
|
|
117
|
-
/**
|
|
118
|
+
/** See [[TypedArrayBuilder]] constructor. */
|
|
118
119
|
constructor(options) {
|
|
119
120
|
super(Uint32Array, options);
|
|
120
121
|
}
|
|
@@ -125,4 +126,76 @@ export class Uint32ArrayBuilder extends TypedArrayBuilder {
|
|
|
125
126
|
return new Uint8Array(this._data.buffer, 0, this.length * 4);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
129
|
+
/** A [[TypedArrayBuilder]] that can populate a [[UintArray]] with the minimum
|
|
130
|
+
* [bytes per element](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT) required.
|
|
131
|
+
*
|
|
132
|
+
* By default, the underlying array is a `Uint8Array`, though this can be configured via [[UintArrayBuilderOptions.initialType]].
|
|
133
|
+
* As values are added to the array, if the bytes per element supported by the underlying array is too small to hold one of the new values, the array is
|
|
134
|
+
* reallocated to a type large enough to hold all of the new values. For example, the following produces a `Uint8Array` because all values are less than 256:
|
|
135
|
+
*
|
|
136
|
+
* ```ts
|
|
137
|
+
* const builder = new UintArrayBuilder();
|
|
138
|
+
* builder.append([1, 2, 254, 255]);
|
|
139
|
+
* const array = builder.toTypedArray();
|
|
140
|
+
* assert(array instanceof Uint8Array);
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* However, the following produces a `Uint16Array` because one of the values is larger than 255 but none are larger than 65,535:
|
|
144
|
+
*
|
|
145
|
+
* ```ts
|
|
146
|
+
* const builder = new UintArrayBuilder();
|
|
147
|
+
* builder.append([1, 255, 257, 65535]);
|
|
148
|
+
* const array = builder.toTypedArray();
|
|
149
|
+
* assert(array instanceof Uint16Array);
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], or [[Uint32ArrayBuilder]] if you know the number of bytes you want to allocate for each element in the array.
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
export class UintArrayBuilder extends TypedArrayBuilder {
|
|
156
|
+
constructor(options) {
|
|
157
|
+
var _a;
|
|
158
|
+
super((_a = options === null || options === void 0 ? void 0 : options.initialType) !== null && _a !== void 0 ? _a : Uint8Array, options);
|
|
159
|
+
}
|
|
160
|
+
/** The number of bytes (1, 2, or 4) currently allocated per element by the underlying array.
|
|
161
|
+
* This may change as larger values are added to the array.
|
|
162
|
+
*/
|
|
163
|
+
get bytesPerElement() {
|
|
164
|
+
return this._data.BYTES_PER_ELEMENT;
|
|
165
|
+
}
|
|
166
|
+
/** Ensures that the underlying array is of a type that can contain the largest value in `newValues`.
|
|
167
|
+
* For example, if `_data` is a `Uint16Array` and `newValues` contains any value(s) larger than 65,535, it will be replaced with a `Uint32Array`.
|
|
168
|
+
* This method is invoked by [[push]] and [[append]].
|
|
169
|
+
*/
|
|
170
|
+
ensureBytesPerElement(newValues) {
|
|
171
|
+
const curBytesPerElem = this.bytesPerElement;
|
|
172
|
+
assert(curBytesPerElem === 1 || curBytesPerElem === 2 || curBytesPerElem === 4);
|
|
173
|
+
if (curBytesPerElem >= 4)
|
|
174
|
+
return;
|
|
175
|
+
let neededBytesPerElem = curBytesPerElem;
|
|
176
|
+
for (const value of newValues) {
|
|
177
|
+
if (value > 0xffff) {
|
|
178
|
+
neededBytesPerElem = 4;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
else if (value > 0xff) {
|
|
182
|
+
neededBytesPerElem = 2;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (neededBytesPerElem <= curBytesPerElem)
|
|
186
|
+
return;
|
|
187
|
+
this._constructor = neededBytesPerElem === 1 ? Uint8Array : (neededBytesPerElem === 2 ? Uint16Array : Uint32Array);
|
|
188
|
+
this._data = new this._constructor(this._data);
|
|
189
|
+
}
|
|
190
|
+
/** See [[TypedArrayBuilder.push]]. */
|
|
191
|
+
push(value) {
|
|
192
|
+
this.ensureBytesPerElement([value]);
|
|
193
|
+
super.push(value);
|
|
194
|
+
}
|
|
195
|
+
/** See [[TypedArrayBuilder.append]]. */
|
|
196
|
+
append(values) {
|
|
197
|
+
this.ensureBytesPerElement(values);
|
|
198
|
+
super.append(values);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
128
201
|
//# sourceMappingURL=TypedArrayBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypedArrayBuil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,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9C,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,iBAA6B;IAClE,8CAA8C;IAC9C,YAAmB,OAAkC;QACnD,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAA8B;IACpE,8CAA8C;IAC9C,YAAmB,OAAkC;QACnD,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAA8B;IACpE,8CAA8C;IAC9C,YAAmB,OAAkC;QACnD,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,gEAAgE;IACzD,YAAY,CAAC,qBAAqB,GAAG,KAAK;QAC/C,IAAI,qBAAqB;YACvB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE3C,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Collections\r\n */\r\n\r\nimport { Constructor } from \"./UtilityTypes\";\r\nimport { assert } from \"./Assert\";\r\n\r\n/** Options used to construct a [[TypedArrayBuilder]].\r\n * @public\r\n */\r\nexport interface TypedArrayBuilderOptions {\r\n /** Controls how much additional memory is allocated when the TypedArray needs to be resized to accomodate more elements.\r\n * [[TypedArrayBuilder.ensureCapacity]] multiplies the required capacity by this factor to determine the new capacity.\r\n * Default: 1.5\r\n * Minimum: 1.0, which causes the TypedArray to allocate exactly the space it needs each time it is resized.\r\n */\r\n growthFactor?: number;\r\n /** The number of elements to allocate memory for in the TypedArray when creating the builder.\r\n * If you know the minimum number of elements you intend to add to the builder, you should specify that as the\r\n * initial capacity to avoid reallocations when populating the array.\r\n * Default: 0.\r\n * Minimum: 0.\r\n */\r\n initialCapacity?: number;\r\n}\r\n\r\n/** Incrementally builds a [TypedArray] of unsigned 8-, 16-, or 32-bit integers.\r\n * Sometimes you wish to populate a `TypedArray`, but you don't know how many elements you will need.\r\n * `TypedArray` requires you to specify the size upon construction, and does not permit you to change the size later.\r\n *\r\n * `TypedArrayBuilder` manages a `TypedArray`, permitting you to [[push]] and [[append]] elements to it. It exposes two \"size\" properties\":\r\n * - [[capacity]], the number of elements it has currently allocated space for - i.e., the length of the underlying TypedArray; and\r\n * - [[length]], the number of elements that have so far been added to it, which is never bigger than [[capacity]].\r\n * When [[capacity]] is exceeded, a new, bigger TypedArray is allocated and the contents of the previous array are copied over to it.\r\n *\r\n * Once you've finished adding elements, you can obtain the finished `TypedArray` via [[toTypedArray]].\r\n * @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], and [[Uint32ArrayBuilder]] to build specific types of arrays.\r\n * @public\r\n */\r\nexport class TypedArrayBuilder<T extends Uint8Array | Uint16Array | Uint32Array> {\r\n /** The constructor for the specific type of array being populated. */\r\n protected readonly _constructor: Constructor<T>;\r\n /** The underlying typed array, to be reallocated and copied when its capacity is exceeded. */\r\n protected _data: T;\r\n /** The number of elements added to the array so far. */\r\n protected _length: number;\r\n /** Multiplier applied to required capacity by [[ensureCapacity]]. */\r\n public readonly growthFactor: number;\r\n\r\n /** Constructs a new builder from the specified options, with a [[length]] of zero. */\r\n protected constructor(constructor: Constructor<T>, options?: TypedArrayBuilderOptions) {\r\n this._constructor = constructor;\r\n this._data = new constructor(options?.initialCapacity ?? 0);\r\n this.growthFactor = Math.max(1.0, options?.growthFactor ?? 1.5);\r\n this._length = 0;\r\n }\r\n\r\n /** The number of elements currently in the array. */\r\n public get length(): number {\r\n return this._length;\r\n }\r\n\r\n /** The number of elements that can fit into the memory currently allocated for the array. */\r\n public get capacity(): number {\r\n return this._data.length;\r\n }\r\n\r\n /** Like [TypedArray.at](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/at),\r\n * returns the element at the specified index, with negative integers counting back from the end of the array.\r\n * @note It is your responsibility to ensure the index falls within the bounds of the array.\r\n */\r\n public at(index: number): number {\r\n if (index < 0)\r\n index = this.length - index;\r\n\r\n const value = this._data[index];\r\n assert(value !== undefined, \"index out of bounds\");\r\n return value;\r\n }\r\n\r\n /** Ensure that [[capacity]] is at least equal to `newCapacity`.\r\n * This is used internally by methods like [[push]] and [[append]] to ensure the array has room for the element(s) to be added.\r\n * It can also be useful when you know you intend to add some number of additional elements, to minimize reallocations.\r\n *\r\n * If `newCapacity` is not greater than the current [[capacity]], this function does nothing.\r\n * Otherwise, it allocates a new `TypedArray` with room for `newCapacity * growthFactor` elements, and copies the contents of the previous `TypedArray` into it.\r\n * [[length]] remains unchanged; [[capacity]] reflects the size of the new TypeArray.\r\n */\r\n public ensureCapacity(newCapacity: number): number {\r\n if (this.capacity >= newCapacity)\r\n return this.capacity;\r\n\r\n assert(this.growthFactor >= 1.0);\r\n newCapacity = Math.ceil(newCapacity * this.growthFactor);\r\n const prevData = this._data;\r\n this._data = new this._constructor(newCapacity);\r\n this._data.set(prevData, 0);\r\n\r\n assert(this.capacity === newCapacity);\r\n return this.capacity;\r\n }\r\n\r\n /** Append the specified value, resizing if necessary. */\r\n public push(value: number): void {\r\n this.ensureCapacity(this.length + 1);\r\n this._data[this.length] = value;\r\n ++this._length;\r\n }\r\n\r\n /** Append an array of values, resizing (at most once) if necessary. */\r\n public append(values: T): void {\r\n const newLength = this.length + values.length;\r\n this.ensureCapacity(newLength);\r\n this._data.set(values, this.length);\r\n this._length = newLength;\r\n }\r\n\r\n /** Obtain the finished array.\r\n * @param includeUnusedCapacity If true, the length of the returned array will be equal to [[capacity]], with extra bytes initialized to zero; otherwise, the\r\n * returned array's length will be equal to [[length]].\r\n */\r\n public toTypedArray(includeUnusedCapacity = false): T {\r\n if (includeUnusedCapacity)\r\n return this._data;\r\n\r\n const subarray = this._data.subarray(0, this.length);\r\n assert(subarray instanceof this._constructor);\r\n assert(subarray.buffer === this._data.buffer);\r\n return subarray;\r\n }\r\n}\r\n\r\n/** A [[TypedArrayBuilder]] for producing a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).\r\n * @public\r\n */\r\nexport class Uint8ArrayBuilder extends TypedArrayBuilder<Uint8Array> {\r\n /** @see [[TypedArrayBuilder]] constructor. */\r\n public constructor(options?: TypedArrayBuilderOptions) {\r\n super(Uint8Array, options);\r\n }\r\n}\r\n\r\n/** A [[TypedArrayBuilder]] for producing a [Uint16Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array).\r\n * @public\r\n */\r\nexport class Uint16ArrayBuilder extends TypedArrayBuilder<Uint16Array> {\r\n /** @see [[TypedArrayBuilder]] constructor. */\r\n public constructor(options?: TypedArrayBuilderOptions) {\r\n super(Uint16Array, options);\r\n }\r\n}\r\n\r\n/** A [[TypedArrayBuilder]] for producing a [Uint32Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array).\r\n * @public\r\n */\r\nexport class Uint32ArrayBuilder extends TypedArrayBuilder<Uint32Array> {\r\n /** @see [[TypedArrayBuilder]] constructor. */\r\n public constructor(options?: TypedArrayBuilderOptions) {\r\n super(Uint32Array, options);\r\n }\r\n\r\n /** Obtain a view of the finished array as an array of bytes. */\r\n public toUint8Array(includeUnusedCapacity = false): Uint8Array {\r\n if (includeUnusedCapacity)\r\n return new Uint8Array(this._data.buffer);\r\n\r\n return new Uint8Array(this._data.buffer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tC,CAAC;IAED;;;OAGG;IACO,qBAAqB,CAAC,SAA2B;QACzD,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC7C,MAAM,CAAC,eAAe,KAAK,CAAC,IAAI,eAAe,KAAK,CAAC,IAAI,eAAe,KAAK,CAAC,CAAC,CAAC;QAChF,IAAI,eAAe,IAAI,CAAC;YACtB,OAAO;QAET,IAAI,kBAAkB,GAAG,eAAe,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE;YAC7B,IAAI,KAAK,GAAG,MAAM,EAAE;gBAClB,kBAAkB,GAAG,CAAC,CAAC;gBACvB,MAAM;aACP;iBAAM,IAAI,KAAK,GAAG,IAAI,EAAE;gBACvB,kBAAkB,GAAG,CAAC,CAAC;aACxB;SACF;QAED,IAAI,kBAAkB,IAAI,eAAe;YACvC,OAAO;QAET,IAAI,CAAC,YAAY,GAAG,kBAAkB,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,kBAAkB,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QACnH,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IAED,sCAAsC;IACtB,IAAI,CAAC,KAAa;QAChC,IAAI,CAAC,qBAAqB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,wCAAwC;IACxB,MAAM,CAAC,MAAiB;QACtC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;QACnC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Collections\r\n */\r\n\r\nimport { Constructor } from \"./UtilityTypes\";\r\nimport { assert } from \"./Assert\";\r\n\r\n/** Options used to construct a [[TypedArrayBuilder]].\r\n * @public\r\n */\r\nexport interface TypedArrayBuilderOptions {\r\n /** Controls how much additional memory is allocated when the TypedArray needs to be resized to accomodate more elements.\r\n * [[TypedArrayBuilder.ensureCapacity]] multiplies the required capacity by this factor to determine the new capacity.\r\n * Default: 1.5\r\n * Minimum: 1.0, which causes the TypedArray to allocate exactly the space it needs each time it is resized.\r\n */\r\n growthFactor?: number;\r\n /** The number of elements to allocate memory for in the TypedArray when creating the builder.\r\n * If you know the minimum number of elements you intend to add to the builder, you should specify that as the\r\n * initial capacity to avoid reallocations when populating the array.\r\n * Default: 0.\r\n * Minimum: 0.\r\n */\r\n initialCapacity?: number;\r\n}\r\n\r\n/** A [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) containing unsigned 8-, 16-, or 32-bit integers.\r\n * @see [[UintArrayBuilder]] to construct such an array.\r\n * @public\r\n */\r\nexport type UintArray = Uint8Array | Uint16Array | Uint32Array;\r\n\r\n/** Incrementally builds a [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) of unsigned 8-, 16-, or 32-bit integers.\r\n * Sometimes you wish to populate a `TypedArray`, but you don't know how many elements you will need.\r\n * `TypedArray` requires you to specify the size upon construction, and does not permit you to change the size later.\r\n *\r\n * `TypedArrayBuilder` manages a `TypedArray`, permitting you to [[push]] and [[append]] elements to it. It exposes two \"size\" properties\":\r\n * - [[capacity]], the number of elements it has currently allocated space for - i.e., the length of the underlying TypedArray; and\r\n * - [[length]], the number of elements that have so far been added to it, which is never bigger than [[capacity]].\r\n * When [[capacity]] is exceeded, a new, bigger TypedArray is allocated and the contents of the previous array are copied over to it.\r\n *\r\n * Once you've finished adding elements, you can obtain the finished `TypedArray` via [[toTypedArray]].\r\n * @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], and [[Uint32ArrayBuilder]] to build specific types of arrays.\r\n * @see [[UintArrayBuilder]] when you don't know the maximum number of bytes required for each element in the array.\r\n * @public\r\n */\r\nexport class TypedArrayBuilder<T extends UintArray> {\r\n /** The constructor for the specific type of array being populated. */\r\n protected _constructor: Constructor<T>;\r\n /** The underlying typed array, to be reallocated and copied when its capacity is exceeded. */\r\n protected _data: T;\r\n /** The number of elements added to the array so far. */\r\n protected _length: number;\r\n /** Multiplier applied to required capacity by [[ensureCapacity]]. */\r\n public readonly growthFactor: number;\r\n\r\n /** Constructs a new builder from the specified options, with a [[length]] of zero. */\r\n protected constructor(constructor: Constructor<T>, options?: TypedArrayBuilderOptions) {\r\n this._constructor = constructor;\r\n this._data = new constructor(options?.initialCapacity ?? 0);\r\n this.growthFactor = Math.max(1.0, options?.growthFactor ?? 1.5);\r\n this._length = 0;\r\n }\r\n\r\n /** The number of elements currently in the array. */\r\n public get length(): number {\r\n return this._length;\r\n }\r\n\r\n /** The number of elements that can fit into the memory currently allocated for the array. */\r\n public get capacity(): number {\r\n return this._data.length;\r\n }\r\n\r\n /** Like [TypedArray.at](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/at),\r\n * returns the element at the specified index, with negative integers counting back from the end of the array.\r\n * @note It is your responsibility to ensure the index falls within the bounds of the array.\r\n */\r\n public at(index: number): number {\r\n if (index < 0)\r\n index = this.length - index;\r\n\r\n const value = this._data[index];\r\n assert(value !== undefined, \"index out of bounds\");\r\n return value;\r\n }\r\n\r\n /** Ensure that [[capacity]] is at least equal to `newCapacity`.\r\n * This is used internally by methods like [[push]] and [[append]] to ensure the array has room for the element(s) to be added.\r\n * It can also be useful when you know you intend to add some number of additional elements, to minimize reallocations.\r\n *\r\n * If `newCapacity` is not greater than the current [[capacity]], this function does nothing.\r\n * Otherwise, it allocates a new `TypedArray` with room for `newCapacity * growthFactor` elements, and copies the contents of the previous `TypedArray` into it.\r\n * [[length]] remains unchanged; [[capacity]] reflects the size of the new TypeArray.\r\n */\r\n public ensureCapacity(newCapacity: number): number {\r\n if (this.capacity >= newCapacity)\r\n return this.capacity;\r\n\r\n assert(this.growthFactor >= 1.0);\r\n newCapacity = Math.ceil(newCapacity * this.growthFactor);\r\n const prevData = this._data;\r\n this._data = new this._constructor(newCapacity);\r\n this._data.set(prevData, 0);\r\n\r\n assert(this.capacity === newCapacity);\r\n return this.capacity;\r\n }\r\n\r\n /** Append the specified value, resizing if necessary. */\r\n public push(value: number): void {\r\n this.ensureCapacity(this.length + 1);\r\n this._data[this.length] = value;\r\n ++this._length;\r\n }\r\n\r\n /** Append an array of values, resizing (at most once) if necessary. */\r\n public append(values: T): void {\r\n const newLength = this.length + values.length;\r\n this.ensureCapacity(newLength);\r\n this._data.set(values, this.length);\r\n this._length = newLength;\r\n }\r\n\r\n /** Obtain the finished array.\r\n * @param includeUnusedCapacity If true, the length of the returned array will be equal to [[capacity]], with extra bytes initialized to zero; otherwise, the\r\n * returned array's length will be equal to [[length]].\r\n */\r\n public toTypedArray(includeUnusedCapacity = false): T {\r\n if (includeUnusedCapacity)\r\n return this._data;\r\n\r\n const subarray = this._data.subarray(0, this.length);\r\n assert(subarray instanceof this._constructor);\r\n assert(subarray.buffer === this._data.buffer);\r\n return subarray;\r\n }\r\n}\r\n\r\n/** A [[TypedArrayBuilder]] for producing a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).\r\n * @public\r\n */\r\nexport class Uint8ArrayBuilder extends TypedArrayBuilder<Uint8Array> {\r\n /** See [[TypedArrayBuilder]] constructor. */\r\n public constructor(options?: TypedArrayBuilderOptions) {\r\n super(Uint8Array, options);\r\n }\r\n}\r\n\r\n/** A [[TypedArrayBuilder]] for producing a [Uint16Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array).\r\n * @public\r\n */\r\nexport class Uint16ArrayBuilder extends TypedArrayBuilder<Uint16Array> {\r\n /** See [[TypedArrayBuilder]] constructor. */\r\n public constructor(options?: TypedArrayBuilderOptions) {\r\n super(Uint16Array, options);\r\n }\r\n}\r\n\r\n/** A [[TypedArrayBuilder]] for producing a [Uint32Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array).\r\n * @public\r\n */\r\nexport class Uint32ArrayBuilder extends TypedArrayBuilder<Uint32Array> {\r\n /** See [[TypedArrayBuilder]] constructor. */\r\n public constructor(options?: TypedArrayBuilderOptions) {\r\n super(Uint32Array, options);\r\n }\r\n\r\n /** Obtain a view of the finished array as an array of bytes. */\r\n public toUint8Array(includeUnusedCapacity = false): Uint8Array {\r\n if (includeUnusedCapacity)\r\n return new Uint8Array(this._data.buffer);\r\n\r\n return new Uint8Array(this._data.buffer, 0, this.length * 4);\r\n }\r\n}\r\n\r\n/** Options used to construct a [[UintArrayBuilder]].\r\n * @public\r\n */\r\nexport interface UintArrayBuilderOptions extends TypedArrayBuilderOptions {\r\n /** The type of the initial empty `TypedArray` created by the builder. For example, if you know that you will be adding values larger than\r\n * 255 to the array, specify `{ initialType: Uint16Array }` to avoid replacing the otherwise default `Uint8Array` when the first such value is added.\r\n * Default: `Uint8Array`.\r\n */\r\n initialType?: typeof Uint8Array | typeof Uint16Array | typeof Uint32Array;\r\n}\r\n\r\n/** A [[TypedArrayBuilder]] that can populate a [[UintArray]] with the minimum\r\n * [bytes per element](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT) required.\r\n *\r\n * By default, the underlying array is a `Uint8Array`, though this can be configured via [[UintArrayBuilderOptions.initialType]].\r\n * As values are added to the array, if the bytes per element supported by the underlying array is too small to hold one of the new values, the array is\r\n * reallocated to a type large enough to hold all of the new values. For example, the following produces a `Uint8Array` because all values are less than 256:\r\n *\r\n * ```ts\r\n * const builder = new UintArrayBuilder();\r\n * builder.append([1, 2, 254, 255]);\r\n * const array = builder.toTypedArray();\r\n * assert(array instanceof Uint8Array);\r\n * ```\r\n *\r\n * However, the following produces a `Uint16Array` because one of the values is larger than 255 but none are larger than 65,535:\r\n *\r\n * ```ts\r\n * const builder = new UintArrayBuilder();\r\n * builder.append([1, 255, 257, 65535]);\r\n * const array = builder.toTypedArray();\r\n * assert(array instanceof Uint16Array);\r\n * ```\r\n *\r\n * @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], or [[Uint32ArrayBuilder]] if you know the number of bytes you want to allocate for each element in the array.\r\n * @public\r\n */\r\nexport class UintArrayBuilder extends TypedArrayBuilder<UintArray> {\r\n public constructor(options?: UintArrayBuilderOptions) {\r\n super(options?.initialType ?? Uint8Array, options);\r\n }\r\n\r\n /** The number of bytes (1, 2, or 4) currently allocated per element by the underlying array.\r\n * This may change as larger values are added to the array.\r\n */\r\n public get bytesPerElement(): number {\r\n return this._data.BYTES_PER_ELEMENT;\r\n }\r\n\r\n /** Ensures that the underlying array is of a type that can contain the largest value in `newValues`.\r\n * For example, if `_data` is a `Uint16Array` and `newValues` contains any value(s) larger than 65,535, it will be replaced with a `Uint32Array`.\r\n * This method is invoked by [[push]] and [[append]].\r\n */\r\n protected ensureBytesPerElement(newValues: Iterable<number>): void {\r\n const curBytesPerElem = this.bytesPerElement;\r\n assert(curBytesPerElem === 1 || curBytesPerElem === 2 || curBytesPerElem === 4);\r\n if (curBytesPerElem >= 4)\r\n return;\r\n\r\n let neededBytesPerElem = curBytesPerElem;\r\n for (const value of newValues) {\r\n if (value > 0xffff) {\r\n neededBytesPerElem = 4;\r\n break;\r\n } else if (value > 0xff) {\r\n neededBytesPerElem = 2;\r\n }\r\n }\r\n\r\n if (neededBytesPerElem <= curBytesPerElem)\r\n return;\r\n\r\n this._constructor = neededBytesPerElem === 1 ? Uint8Array : (neededBytesPerElem === 2 ? Uint16Array : Uint32Array);\r\n this._data = new this._constructor(this._data);\r\n }\r\n\r\n /** See [[TypedArrayBuilder.push]]. */\r\n public override push(value: number): void {\r\n this.ensureBytesPerElement([value]);\r\n super.push(value);\r\n }\r\n\r\n /** See [[TypedArrayBuilder.append]]. */\r\n public override append(values: UintArray): void {\r\n this.ensureBytesPerElement(values);\r\n super.append(values);\r\n }\r\n}\r\n"]}
|
|
@@ -86,10 +86,6 @@ export declare type AsyncMethodsOf<T> = {
|
|
|
86
86
|
* @public
|
|
87
87
|
*/
|
|
88
88
|
export declare type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
89
|
-
/** Extracts a subset of literals `U` from a union of literals `T` in a type-safe way.
|
|
90
|
-
* @beta
|
|
91
|
-
*/
|
|
92
|
-
export declare type ExtractLiterals<T, U extends T> = Extract<T, U>;
|
|
93
89
|
/** A runtime property omitter, makes a shallow copy of the given object without the specified properties
|
|
94
90
|
* Compatible with the typescript `Omit` mapped type:
|
|
95
91
|
* ```js
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UtilityTypes.d.ts","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,oBAAY,OAAO,CAAC,CAAC,IAAI;IACvB,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,oBAAY,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9E;;GAEG;AACH,oBAAY,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEnF;;;;;GAKG;AACH,oBAAY,WAAW,CA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,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;
|
|
1
|
+
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA2BH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AA0DD;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAA+C,CAAI,EAAE,IAAO;IAC9E,MAAM,KAAK,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,IAAI;QACpB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utils\r\n */\r\n\r\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\r\n * @public\r\n */\r\nexport type Mutable<T> = {\r\n -readonly [K in keyof T]: T[K];\r\n};\r\n\r\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\r\n * @public\r\n */\r\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\r\n\r\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\r\n * @public\r\n */\r\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\r\n\r\n/** Generically represents a class `T`, for use in type annotations.\r\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\r\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\r\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\r\n * @public\r\n */\r\nexport type Constructor<T> = new (...args: any[]) => T;\r\n\r\n/** Returns true if `obj` is an object of class `T`.\r\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\r\n * @public\r\n */\r\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\r\n return \"object\" === typeof obj && obj instanceof constructor;\r\n}\r\n\r\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\r\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\r\n * @public\r\n */\r\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\r\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\r\n}\r\n\r\n/** Extracts the names of all public properties of `T` that are not of type `function`.\r\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\r\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\r\n * so too does the type that TypeScript infers from that operator.\r\n * `get` syntax. For example:\r\n * ```ts\r\n * class Thing {\r\n * private _a = \"a\"; // a private variable\r\n * public b = \"b\"; // a public variable\r\n * public get c() { return \"c\"; } // a public property\r\n * public d() { return \"d\"; } // a public method\r\n * public e = () => \"e\"; // a public variable of type `function`\r\n * }\r\n *\r\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\r\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\r\n *\r\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\r\n * const thing1 = new Thing();\r\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\r\n * ```\r\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\r\n * @public\r\n */\r\nexport type NonFunctionPropertyNamesOf<T> = {\r\n [K in keyof T]: T[K] extends Function ? never : K;\r\n}[keyof T];\r\n\r\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\r\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\r\n * @public\r\n */\r\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\r\n\r\n/** Any function returning a Promise.\r\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\r\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\r\n * @public\r\n */\r\nexport type AsyncFunction = (...args: any) => Promise<any>;\r\n\r\n/** The members of `T` that are async functions (functions that return a promise), and no other properties\r\n * @public\r\n */\r\nexport type PickAsyncMethods<T> = { [P in keyof T]: T[P] extends AsyncFunction ? T[P] : never; };\r\n\r\n/** Extracts the names of all function properties of `T` that return a Promise.\r\n * @public\r\n */\r\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\r\n\r\n/** Extracts the type to which the Promise returned by an async function resolves.\r\n * @public\r\n */\r\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\r\n\r\n/** A runtime property omitter, makes a shallow copy of the given object without the specified properties\r\n * Compatible with the typescript `Omit` mapped type:\r\n * ```js\r\n * const testvar: Omit<{x: string, y: object}, \"y\"> = omit({x: \"hello\", y: {}}, [\"y\"]);\r\n * ```\r\n * @public\r\n */\r\nexport function omit<T extends {}, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]> {\r\n const clone = { ...t };\r\n for (const key of keys)\r\n delete clone[key];\r\n return clone;\r\n}\r\n"]}
|
|
@@ -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,
|
|
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;AAE/B;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
|
package/lib/esm/core-bentley.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
export * from "./AccessToken";
|
|
6
6
|
export * from "./Assert";
|
|
7
|
-
export * from "./AsyncMutex";
|
|
8
7
|
export * from "./BeEvent";
|
|
9
8
|
export * from "./BentleyError";
|
|
10
9
|
export * from "./BentleyLoggerCategory";
|