@itwin/core-bentley 5.4.0-dev.7 → 5.4.0

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/lib/cjs/AccessToken.js.map +1 -1
  3. package/lib/cjs/Assert.js.map +1 -1
  4. package/lib/cjs/BeEvent.js.map +1 -1
  5. package/lib/cjs/BeSQLite.js.map +1 -1
  6. package/lib/cjs/BentleyError.js.map +1 -1
  7. package/lib/cjs/BentleyLoggerCategory.js.map +1 -1
  8. package/lib/cjs/ByteStream.js.map +1 -1
  9. package/lib/cjs/ClassUtils.js.map +1 -1
  10. package/lib/cjs/Compare.js.map +1 -1
  11. package/lib/cjs/CompressedId64Set.js.map +1 -1
  12. package/lib/cjs/Dictionary.js.map +1 -1
  13. package/lib/cjs/Disposable.js.map +1 -1
  14. package/lib/cjs/Expect.js.map +1 -1
  15. package/lib/cjs/Id.js.map +1 -1
  16. package/lib/cjs/IndexMap.js.map +1 -1
  17. package/lib/cjs/JsonSchema.js.map +1 -1
  18. package/lib/cjs/JsonUtils.js.map +1 -1
  19. package/lib/cjs/LRUMap.js.map +1 -1
  20. package/lib/cjs/Logger.js.map +1 -1
  21. package/lib/cjs/ObservableSet.js.map +1 -1
  22. package/lib/cjs/OneAtATimeAction.js.map +1 -1
  23. package/lib/cjs/OrderedId64Iterable.js.map +1 -1
  24. package/lib/cjs/OrderedSet.js.map +1 -1
  25. package/lib/cjs/PriorityQueue.js.map +1 -1
  26. package/lib/cjs/ProcessDetector.js.map +1 -1
  27. package/lib/cjs/SortedArray.js.map +1 -1
  28. package/lib/cjs/StatusCategory.js.map +1 -1
  29. package/lib/cjs/StringUtils.js.map +1 -1
  30. package/lib/cjs/Time.js.map +1 -1
  31. package/lib/cjs/Tracing.js.map +1 -1
  32. package/lib/cjs/TupleKeyedMap.js.map +1 -1
  33. package/lib/cjs/TypedArrayBuilder.js.map +1 -1
  34. package/lib/cjs/UnexpectedErrors.js.map +1 -1
  35. package/lib/cjs/UtilityTypes.js.map +1 -1
  36. package/lib/cjs/YieldManager.js.map +1 -1
  37. package/lib/cjs/core-bentley.js.map +1 -1
  38. package/lib/cjs/internal/BeSQLiteInternal.js.map +1 -1
  39. package/lib/cjs/internal/RepositoryStatus.js.map +1 -1
  40. package/lib/cjs/internal/cross-package.js.map +1 -1
  41. package/lib/cjs/partitionArray.js.map +1 -1
  42. package/lib/esm/AccessToken.js.map +1 -1
  43. package/lib/esm/Assert.js.map +1 -1
  44. package/lib/esm/BeEvent.js.map +1 -1
  45. package/lib/esm/BeSQLite.js.map +1 -1
  46. package/lib/esm/BentleyError.js.map +1 -1
  47. package/lib/esm/BentleyLoggerCategory.js.map +1 -1
  48. package/lib/esm/ByteStream.js.map +1 -1
  49. package/lib/esm/ClassUtils.js.map +1 -1
  50. package/lib/esm/Compare.js.map +1 -1
  51. package/lib/esm/CompressedId64Set.js.map +1 -1
  52. package/lib/esm/Dictionary.js.map +1 -1
  53. package/lib/esm/Disposable.js.map +1 -1
  54. package/lib/esm/Expect.js.map +1 -1
  55. package/lib/esm/Id.js.map +1 -1
  56. package/lib/esm/IndexMap.js.map +1 -1
  57. package/lib/esm/JsonSchema.js.map +1 -1
  58. package/lib/esm/JsonUtils.js.map +1 -1
  59. package/lib/esm/LRUMap.js.map +1 -1
  60. package/lib/esm/Logger.js.map +1 -1
  61. package/lib/esm/ObservableSet.js.map +1 -1
  62. package/lib/esm/OneAtATimeAction.js.map +1 -1
  63. package/lib/esm/OrderedId64Iterable.js.map +1 -1
  64. package/lib/esm/OrderedSet.js.map +1 -1
  65. package/lib/esm/PriorityQueue.js.map +1 -1
  66. package/lib/esm/ProcessDetector.js.map +1 -1
  67. package/lib/esm/SortedArray.js.map +1 -1
  68. package/lib/esm/StatusCategory.js.map +1 -1
  69. package/lib/esm/StringUtils.js.map +1 -1
  70. package/lib/esm/Time.js.map +1 -1
  71. package/lib/esm/Tracing.js.map +1 -1
  72. package/lib/esm/TupleKeyedMap.js.map +1 -1
  73. package/lib/esm/TypedArrayBuilder.js.map +1 -1
  74. package/lib/esm/UnexpectedErrors.js.map +1 -1
  75. package/lib/esm/UtilityTypes.js.map +1 -1
  76. package/lib/esm/YieldManager.js.map +1 -1
  77. package/lib/esm/core-bentley.js.map +1 -1
  78. package/lib/esm/internal/BeSQLiteInternal.js.map +1 -1
  79. package/lib/esm/internal/RepositoryStatus.js.map +1 -1
  80. package/lib/esm/internal/cross-package.js.map +1 -1
  81. package/lib/esm/partitionArray.js.map +1 -1
  82. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAmB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAOhE;;GAEG;AACH,MAAM,CAAN,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,wCAAwC;IACxC,yCAAK,CAAA;IACL,8BAA8B;IAC9B,uCAAI,CAAA;IACJ,4BAA4B;IAC5B,6CAAO,CAAA;IACP,6BAA6B;IAC7B,yCAAK,CAAA;IACL,+EAA+E;IAC/E,uCAAI,CAAA;AACN,CAAC,EAXW,QAAQ,KAAR,QAAQ,QAWnB;AAmCD;;;GAGG;AACH,MAAM,OAAO,MAAM;IACP,MAAM,CAAC,SAAS,CAA0B;IAC1C,MAAM,CAAC,WAAW,CAA0B;IAC5C,MAAM,CAAC,QAAQ,CAA0B;IACzC,MAAM,CAAC,SAAS,CAA0B;IAE5C,MAAM,CAAC,kBAAkB,CAAkC;IAC3D,MAAM,CAAC,eAAe,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEpE,8EAA8E;IACvE,MAAM,KAAK,iBAAiB;QACjC,iJAAi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QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC9F,IAAI,CAAC,eAAe,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,iBAAiB;IAChE,CAAC;IAEO,UAAU;QAChB,MAAM,YAAY,GAAW,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC;YAC5E,OAAO;QAET,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,UAAU,MAAM,EAAE,GAAG,EAAE;YAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,OAAO;gBACL,GAAG,KAAK,EAAE,WAAW,EAAE,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,2DAA2D;aACxH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,qGAAqG;IAC9F,OAAO;QACZ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\nimport { BeEvent } from \"./BeEvent\";\nimport { BentleyError, IModelStatus, LoggingMetaData } from \"./BentleyError\";\nimport { BentleyLoggerCategory } from \"./BentleyLoggerCategory\";\n\n/** Defines the *signature* for a log function.\n * @public\n */\nexport type LogFunction = (category: string, message: string, metaData: LoggingMetaData) => void;\n\n/** Use to categorize logging messages by severity.\n * @public\n */\nexport enum LogLevel {\n /** Tracing and debugging - low level */\n Trace,\n /** Information - mid level */\n Info,\n /** Warnings - high level */\n Warning,\n /** Errors - highest level */\n Error,\n /** Higher than any real logging level. This is used to turn a category off. */\n None,\n}\n\n/** Identifies a logging category and the LogLevel that should be used for it. The LogLevel is specified by its string name.\n * @public\n */\nexport interface LoggerCategoryAndLevel {\n category: string;\n logLevel: string;\n}\n\n/** Specifies logging levels, including the default logging level and a set of categories and levels for them.\n * @public\n */\nexport interface LoggerLevelsConfig {\n defaultLevel?: string;\n categoryLevels?: LoggerCategoryAndLevel[];\n}\n\n/** A global set of metadata that should be included with every log message.\n * You can provide an object representing the metadata, or a function to be invoked to obtain the metadata object each\n * time a message is logged.\n * Each key-value pair of the object will be stringified and combined with the log message's per-call metadata.\n * The keys you provide to each method is used solely to identify your entries so that you can later update or delete them - these keys\n * are **not** included in log messages. Don't modify or remove metadata associated with keys that belong to someone else.\n * @note Each extra bit of metadata adds cost and overhead to the logging system. Avoid adding unnecessary or unnecessarily verbose metadata.\n * @see [[Logger.staticMetaData]] to access the global metadata.\n * @beta\n */\nexport interface StaticLoggerMetaData {\n /** Add or update some metadata to be included with every logged message. */\n set(key: string, metadata: LoggingMetaData): void;\n /** Remove metadata previously [[set]] using the specified `key`, so it will no longer be included with every logged message. */\n delete(key: string): void;\n}\n\n/** Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control\n * how or if the logged information is displayed or collected. See [Learning about Logging]($docs/learning/common/Logging.md).\n * @public\n */\nexport class Logger {\n protected static _logError: LogFunction | undefined;\n protected static _logWarning: LogFunction | undefined;\n protected static _logInfo: LogFunction | undefined;\n protected static _logTrace: LogFunction | undefined;\n\n private static _onLogLevelChanged: BeEvent<() => void> | undefined;\n private static _staticMetaData = new Map<string, LoggingMetaData>();\n\n /** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */\n public static get onLogLevelChanged(): BeEvent<() => void> {\n // We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.\n if (undefined === Logger._onLogLevelChanged) {\n Logger._onLogLevelChanged = new BeEvent<() => void>();\n }\n\n return Logger._onLogLevelChanged;\n }\n\n private static _categoryFilter: { [categoryName: string]: LogLevel | undefined } = {};\n\n /** Maps category names to the least severe level at which messages in that category should be displayed,\n * or `undefined` if a minimum has not been defined.\n * @see [[setLevel]] to change the minimum logging level for a category.\n */\n public static get categoryFilter(): Readonly<{ [categoryName: string]: LogLevel | undefined }> {\n // NOTE: this property is accessed by native code.\n return this._categoryFilter;\n }\n\n private static _minLevel: LogLevel | undefined;\n\n /** The least severe level at which messages should be displayed by default.\n * @see [[setLevelDefault]] to change this default.\n * @see [[setLevel]] to override this default for specific categories.\n */\n public static get minLevel(): LogLevel | undefined {\n // NOTE: this property is accessed by native code. */\n return this._minLevel;\n }\n\n /** Should the call stack be included when an exception is logged? */\n public static logExceptionCallstacks = false;\n\n /** Contains metadata that should be included with every logged message.\n * @beta\n */\n public static get staticMetaData(): StaticLoggerMetaData {\n return this._staticMetaData;\n }\n\n /** Initialize the logger streams. Should be called at application initialization time. */\n public static initialize(logError?: LogFunction, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void {\n Logger._logError = logError;\n Logger._logWarning = logWarning;\n Logger._logInfo = logInfo;\n Logger._logTrace = logTrace;\n Logger.turnOffLevelDefault();\n Logger.turnOffCategories();\n }\n\n /** Initialize the logger to output to the console. */\n public static initializeToConsole(): void {\n const logConsole = (level: string) => (category: string, message: string, metaData: LoggingMetaData) =>\n console.log(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`); // eslint-disable-line no-console\n\n Logger.initialize(logConsole(\"Error\"), logConsole(\"Warning\"), logConsole(\"Info\"), logConsole(\"Trace\"));\n }\n\n /** merge the supplied metadata with all static metadata into one object */\n public static getMetaData(metaData?: LoggingMetaData): object {\n const metaObj = {};\n for (const meta of this._staticMetaData) {\n const val = BentleyError.getMetaData(meta[1]);\n if (val)\n Object.assign(metaObj, val);\n }\n Object.assign(metaObj, BentleyError.getMetaData(metaData)); // do this last so user supplied values take precedence\n return metaObj;\n }\n\n /** stringify the metadata for a log message by merging the supplied metadata with all static metadata into one object that is then `JSON.stringify`ed. */\n public static stringifyMetaData(metaData?: LoggingMetaData): string {\n const metaObj = this.getMetaData(metaData);\n return Object.keys(metaObj).length > 0 ? JSON.stringify(metaObj) : \"\";\n }\n\n /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */\n public static setLevelDefault(minLevel: LogLevel): void {\n this._minLevel = minLevel;\n this.onLogLevelChanged.raiseEvent();\n }\n\n /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the\n * specified category should be displayed.\n */\n public static setLevel(category: string, minLevel: LogLevel) {\n Logger._categoryFilter[category] = minLevel;\n this.onLogLevelChanged.raiseEvent();\n }\n\n /** Interpret a string as the name of a LogLevel */\n public static parseLogLevel(str: string): LogLevel {\n switch (str.toUpperCase()) {\n case \"EXCEPTION\": return LogLevel.Error;\n case \"FATAL\": return LogLevel.Error;\n case \"ERROR\": return LogLevel.Error;\n case \"WARNING\": return LogLevel.Warning;\n case \"INFO\": return LogLevel.Info;\n case \"TRACE\": return LogLevel.Trace;\n case \"DEBUG\": return LogLevel.Trace;\n }\n return LogLevel.None;\n }\n\n /** Set the log level for multiple categories at once. Also see [[validateProps]] */\n public static configureLevels(cfg: LoggerLevelsConfig) {\n Logger.validateProps(cfg);\n if (cfg.defaultLevel !== undefined) {\n this.setLevelDefault(Logger.parseLogLevel(cfg.defaultLevel));\n }\n if (cfg.categoryLevels !== undefined) {\n for (const cl of cfg.categoryLevels) {\n this.setLevel(cl.category, Logger.parseLogLevel(cl.logLevel));\n }\n }\n }\n\n private static isLogLevel(v: string) {\n return LogLevel.hasOwnProperty(v);\n }\n\n /** Check that the specified object is a valid LoggerLevelsConfig. This is useful when reading a config from a .json file. */\n public static validateProps(config: any) {\n const validProps = [\"defaultLevel\", \"categoryLevels\"];\n for (const prop of Object.keys(config)) {\n if (!validProps.includes(prop))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig - unrecognized property: ${prop}`);\n if (prop === \"defaultLevel\") {\n if (!Logger.isLogLevel(config.defaultLevel))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.defaultLevel must be a LogLevel. Invalid value: ${JSON.stringify(config.defaultLevel)}`);\n } else if (prop === \"categoryLevels\") {\n const value = config[prop];\n if (!Array.isArray(value))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels must be an array. Invalid value: ${JSON.stringify(value)}`);\n for (const item of config[prop]) {\n if (!item.hasOwnProperty(\"category\") || !item.hasOwnProperty(\"logLevel\"))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item must be a LoggerCategoryAndLevel {category: logLevel:}. Invalid value: ${JSON.stringify(item)}`);\n if (!Logger.isLogLevel(item.logLevel))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item's logLevel property must be a LogLevel. Invalid value: ${JSON.stringify(item.logLevel)}`);\n }\n }\n }\n }\n\n /** Get the minimum logging level for the specified category. */\n public static getLevel(category: string): LogLevel | undefined {\n // Prefer the level set for this category specifically\n const minLevelForThisCategory = Logger.categoryFilter[category];\n if (minLevelForThisCategory !== undefined)\n return minLevelForThisCategory;\n\n // Fall back on the level set for the parent of this category.\n const parent = category.lastIndexOf(\".\");\n if (parent !== -1)\n return Logger.getLevel(category.slice(0, parent));\n\n // Fall back on the default level.\n return Logger.minLevel;\n }\n\n /** Turns off the least severe level at which messages should be displayed by default.\n * This turns off logging for all messages for which no category minimum level is defined.\n */\n public static turnOffLevelDefault(): void {\n Logger._minLevel = undefined;\n }\n\n /** Turns off all category level filters previously defined with [[Logger.setLevel]].\n */\n public static turnOffCategories(): void {\n Logger._categoryFilter = {};\n }\n\n /** Check if messages in the specified category should be displayed at this level of severity. */\n public static isEnabled(category: string, level: LogLevel): boolean {\n const minLevel = Logger.getLevel(category);\n return (minLevel !== undefined) && (level >= minLevel);\n }\n\n /** Log the specified message to the **error** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logError(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))\n Logger._logError(category, message, metaData);\n }\n\n private static getExceptionMessage(err: unknown): string {\n if (err === undefined) {\n return \"Error: err is undefined.\";\n }\n if (err === null) {\n return \"Error: err is null.\";\n }\n const stack = Logger.logExceptionCallstacks ? `\\n${BentleyError.getErrorStack(err)}` : \"\";\n return BentleyError.getErrorMessage(err) + stack;\n }\n\n /** Log the specified exception.\n * For legacy [[BentleyError]] exceptions, the special \"exceptionType\" property will be added as metadata. Otherwise, all enumerable members of the exception are logged as metadata.\n * @param category The category of the message.\n * @param err The exception object.\n * @param log The logger output function to use - defaults to Logger.logError\n */\n public static logException(category: string, err: any, log: LogFunction = (_category, message, metaData) => Logger.logError(_category, message, metaData)): void {\n log(category, Logger.getExceptionMessage(err), () => {\n // For backwards compatibility, log BentleyError old way\n if (BentleyError.isError(err))\n return { ...BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? \"<Unknown>\" };\n\n // return a copy of the error, with non-enumerable members `message` and `stack` removed, as \"metadata\" for log.\n return { ...err };\n });\n }\n\n /** Log the specified message to the **warning** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logWarning(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logWarning && Logger.isEnabled(category, LogLevel.Warning))\n Logger._logWarning(category, message, metaData);\n }\n\n /** Log the specified message to the **info** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logInfo(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logInfo && Logger.isEnabled(category, LogLevel.Info))\n Logger._logInfo(category, message, metaData);\n }\n\n /** Log the specified message to the **trace** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logTrace(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logTrace && Logger.isEnabled(category, LogLevel.Trace))\n Logger._logTrace(category, message, metaData);\n }\n}\n\n/** Simple performance diagnostics utility.\n * It measures the time from construction to disposal. On disposal it logs the routine name along with\n * the duration in milliseconds.\n * It also logs the routine name at construction time so that nested calls can be disambiguated.\n *\n * The timings are logged using the log category **Performance** and log severity [[LogLevel.INFO]].\n * Enable those, if you want to capture timings.\n * @public\n */\nexport class PerfLogger implements Disposable {\n private static _severity: LogLevel = LogLevel.Info;\n\n private _operation: string;\n private _metaData?: LoggingMetaData;\n private _startTimeStamp: number;\n\n public constructor(operation: string, metaData?: LoggingMetaData) {\n this._operation = operation;\n this._metaData = metaData;\n\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity)) {\n this._startTimeStamp = 0;\n return;\n }\n\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},START`, this._metaData);\n this._startTimeStamp = new Date().getTime(); // take timestamp\n }\n\n private logMessage(): void {\n const endTimeStamp: number = new Date().getTime();\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity))\n return;\n\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},END`, () => {\n const mdata = this._metaData ? BentleyError.getMetaData(this._metaData) : {};\n return {\n ...mdata, TimeElapsed: endTimeStamp - this._startTimeStamp, // eslint-disable-line @typescript-eslint/naming-convention\n };\n });\n }\n\n public [Symbol.dispose](): void {\n this.logMessage();\n }\n\n /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */\n public dispose(): void {\n this[Symbol.dispose]();\n }\n}\n\n"]}
1
+ {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAA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AAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,OAAO;gBACL,GAAG,KAAK,EAAE,WAAW,EAAE,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,2DAA2D;aACxH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,qGAAqG;IAC9F,OAAO;QACZ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,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 Logging\r\n */\r\n\r\nimport { BeEvent } from \"./BeEvent\";\r\nimport { BentleyError, IModelStatus, LoggingMetaData } from \"./BentleyError\";\r\nimport { BentleyLoggerCategory } from \"./BentleyLoggerCategory\";\r\n\r\n/** Defines the *signature* for a log function.\r\n * @public\r\n */\r\nexport type LogFunction = (category: string, message: string, metaData: LoggingMetaData) => void;\r\n\r\n/** Use to categorize logging messages by severity.\r\n * @public\r\n */\r\nexport enum LogLevel {\r\n /** Tracing and debugging - low level */\r\n Trace,\r\n /** Information - mid level */\r\n Info,\r\n /** Warnings - high level */\r\n Warning,\r\n /** Errors - highest level */\r\n Error,\r\n /** Higher than any real logging level. This is used to turn a category off. */\r\n None,\r\n}\r\n\r\n/** Identifies a logging category and the LogLevel that should be used for it. The LogLevel is specified by its string name.\r\n * @public\r\n */\r\nexport interface LoggerCategoryAndLevel {\r\n category: string;\r\n logLevel: string;\r\n}\r\n\r\n/** Specifies logging levels, including the default logging level and a set of categories and levels for them.\r\n * @public\r\n */\r\nexport interface LoggerLevelsConfig {\r\n defaultLevel?: string;\r\n categoryLevels?: LoggerCategoryAndLevel[];\r\n}\r\n\r\n/** A global set of metadata that should be included with every log message.\r\n * You can provide an object representing the metadata, or a function to be invoked to obtain the metadata object each\r\n * time a message is logged.\r\n * Each key-value pair of the object will be stringified and combined with the log message's per-call metadata.\r\n * The keys you provide to each method is used solely to identify your entries so that you can later update or delete them - these keys\r\n * are **not** included in log messages. Don't modify or remove metadata associated with keys that belong to someone else.\r\n * @note Each extra bit of metadata adds cost and overhead to the logging system. Avoid adding unnecessary or unnecessarily verbose metadata.\r\n * @see [[Logger.staticMetaData]] to access the global metadata.\r\n * @beta\r\n */\r\nexport interface StaticLoggerMetaData {\r\n /** Add or update some metadata to be included with every logged message. */\r\n set(key: string, metadata: LoggingMetaData): void;\r\n /** Remove metadata previously [[set]] using the specified `key`, so it will no longer be included with every logged message. */\r\n delete(key: string): void;\r\n}\r\n\r\n/** Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control\r\n * how or if the logged information is displayed or collected. See [Learning about Logging]($docs/learning/common/Logging.md).\r\n * @public\r\n */\r\nexport class Logger {\r\n protected static _logError: LogFunction | undefined;\r\n protected static _logWarning: LogFunction | undefined;\r\n protected static _logInfo: LogFunction | undefined;\r\n protected static _logTrace: LogFunction | undefined;\r\n\r\n private static _onLogLevelChanged: BeEvent<() => void> | undefined;\r\n private static _staticMetaData = new Map<string, LoggingMetaData>();\r\n\r\n /** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */\r\n public static get onLogLevelChanged(): BeEvent<() => void> {\r\n // We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.\r\n if (undefined === Logger._onLogLevelChanged) {\r\n Logger._onLogLevelChanged = new BeEvent<() => void>();\r\n }\r\n\r\n return Logger._onLogLevelChanged;\r\n }\r\n\r\n private static _categoryFilter: { [categoryName: string]: LogLevel | undefined } = {};\r\n\r\n /** Maps category names to the least severe level at which messages in that category should be displayed,\r\n * or `undefined` if a minimum has not been defined.\r\n * @see [[setLevel]] to change the minimum logging level for a category.\r\n */\r\n public static get categoryFilter(): Readonly<{ [categoryName: string]: LogLevel | undefined }> {\r\n // NOTE: this property is accessed by native code.\r\n return this._categoryFilter;\r\n }\r\n\r\n private static _minLevel: LogLevel | undefined;\r\n\r\n /** The least severe level at which messages should be displayed by default.\r\n * @see [[setLevelDefault]] to change this default.\r\n * @see [[setLevel]] to override this default for specific categories.\r\n */\r\n public static get minLevel(): LogLevel | undefined {\r\n // NOTE: this property is accessed by native code. */\r\n return this._minLevel;\r\n }\r\n\r\n /** Should the call stack be included when an exception is logged? */\r\n public static logExceptionCallstacks = false;\r\n\r\n /** Contains metadata that should be included with every logged message.\r\n * @beta\r\n */\r\n public static get staticMetaData(): StaticLoggerMetaData {\r\n return this._staticMetaData;\r\n }\r\n\r\n /** Initialize the logger streams. Should be called at application initialization time. */\r\n public static initialize(logError?: LogFunction, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void {\r\n Logger._logError = logError;\r\n Logger._logWarning = logWarning;\r\n Logger._logInfo = logInfo;\r\n Logger._logTrace = logTrace;\r\n Logger.turnOffLevelDefault();\r\n Logger.turnOffCategories();\r\n }\r\n\r\n /** Initialize the logger to output to the console. */\r\n public static initializeToConsole(): void {\r\n const logConsole = (level: string) => (category: string, message: string, metaData: LoggingMetaData) =>\r\n console.log(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`); // eslint-disable-line no-console\r\n\r\n Logger.initialize(logConsole(\"Error\"), logConsole(\"Warning\"), logConsole(\"Info\"), logConsole(\"Trace\"));\r\n }\r\n\r\n /** merge the supplied metadata with all static metadata into one object */\r\n public static getMetaData(metaData?: LoggingMetaData): object {\r\n const metaObj = {};\r\n for (const meta of this._staticMetaData) {\r\n const val = BentleyError.getMetaData(meta[1]);\r\n if (val)\r\n Object.assign(metaObj, val);\r\n }\r\n Object.assign(metaObj, BentleyError.getMetaData(metaData)); // do this last so user supplied values take precedence\r\n return metaObj;\r\n }\r\n\r\n /** stringify the metadata for a log message by merging the supplied metadata with all static metadata into one object that is then `JSON.stringify`ed. */\r\n public static stringifyMetaData(metaData?: LoggingMetaData): string {\r\n const metaObj = this.getMetaData(metaData);\r\n return Object.keys(metaObj).length > 0 ? JSON.stringify(metaObj) : \"\";\r\n }\r\n\r\n /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */\r\n public static setLevelDefault(minLevel: LogLevel): void {\r\n this._minLevel = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the\r\n * specified category should be displayed.\r\n */\r\n public static setLevel(category: string, minLevel: LogLevel) {\r\n Logger._categoryFilter[category] = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Interpret a string as the name of a LogLevel */\r\n public static parseLogLevel(str: string): LogLevel {\r\n switch (str.toUpperCase()) {\r\n case \"EXCEPTION\": return LogLevel.Error;\r\n case \"FATAL\": return LogLevel.Error;\r\n case \"ERROR\": return LogLevel.Error;\r\n case \"WARNING\": return LogLevel.Warning;\r\n case \"INFO\": return LogLevel.Info;\r\n case \"TRACE\": return LogLevel.Trace;\r\n case \"DEBUG\": return LogLevel.Trace;\r\n }\r\n return LogLevel.None;\r\n }\r\n\r\n /** Set the log level for multiple categories at once. Also see [[validateProps]] */\r\n public static configureLevels(cfg: LoggerLevelsConfig) {\r\n Logger.validateProps(cfg);\r\n if (cfg.defaultLevel !== undefined) {\r\n this.setLevelDefault(Logger.parseLogLevel(cfg.defaultLevel));\r\n }\r\n if (cfg.categoryLevels !== undefined) {\r\n for (const cl of cfg.categoryLevels) {\r\n this.setLevel(cl.category, Logger.parseLogLevel(cl.logLevel));\r\n }\r\n }\r\n }\r\n\r\n private static isLogLevel(v: string) {\r\n return LogLevel.hasOwnProperty(v);\r\n }\r\n\r\n /** Check that the specified object is a valid LoggerLevelsConfig. This is useful when reading a config from a .json file. */\r\n public static validateProps(config: any) {\r\n const validProps = [\"defaultLevel\", \"categoryLevels\"];\r\n for (const prop of Object.keys(config)) {\r\n if (!validProps.includes(prop))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig - unrecognized property: ${prop}`);\r\n if (prop === \"defaultLevel\") {\r\n if (!Logger.isLogLevel(config.defaultLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.defaultLevel must be a LogLevel. Invalid value: ${JSON.stringify(config.defaultLevel)}`);\r\n } else if (prop === \"categoryLevels\") {\r\n const value = config[prop];\r\n if (!Array.isArray(value))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels must be an array. Invalid value: ${JSON.stringify(value)}`);\r\n for (const item of config[prop]) {\r\n if (!item.hasOwnProperty(\"category\") || !item.hasOwnProperty(\"logLevel\"))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item must be a LoggerCategoryAndLevel {category: logLevel:}. Invalid value: ${JSON.stringify(item)}`);\r\n if (!Logger.isLogLevel(item.logLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item's logLevel property must be a LogLevel. Invalid value: ${JSON.stringify(item.logLevel)}`);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Get the minimum logging level for the specified category. */\r\n public static getLevel(category: string): LogLevel | undefined {\r\n // Prefer the level set for this category specifically\r\n const minLevelForThisCategory = Logger.categoryFilter[category];\r\n if (minLevelForThisCategory !== undefined)\r\n return minLevelForThisCategory;\r\n\r\n // Fall back on the level set for the parent of this category.\r\n const parent = category.lastIndexOf(\".\");\r\n if (parent !== -1)\r\n return Logger.getLevel(category.slice(0, parent));\r\n\r\n // Fall back on the default level.\r\n return Logger.minLevel;\r\n }\r\n\r\n /** Turns off the least severe level at which messages should be displayed by default.\r\n * This turns off logging for all messages for which no category minimum level is defined.\r\n */\r\n public static turnOffLevelDefault(): void {\r\n Logger._minLevel = undefined;\r\n }\r\n\r\n /** Turns off all category level filters previously defined with [[Logger.setLevel]].\r\n */\r\n public static turnOffCategories(): void {\r\n Logger._categoryFilter = {};\r\n }\r\n\r\n /** Check if messages in the specified category should be displayed at this level of severity. */\r\n public static isEnabled(category: string, level: LogLevel): boolean {\r\n const minLevel = Logger.getLevel(category);\r\n return (minLevel !== undefined) && (level >= minLevel);\r\n }\r\n\r\n /** Log the specified message to the **error** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logError(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))\r\n Logger._logError(category, message, metaData);\r\n }\r\n\r\n private static getExceptionMessage(err: unknown): string {\r\n if (err === undefined) {\r\n return \"Error: err is undefined.\";\r\n }\r\n if (err === null) {\r\n return \"Error: err is null.\";\r\n }\r\n const stack = Logger.logExceptionCallstacks ? `\\n${BentleyError.getErrorStack(err)}` : \"\";\r\n return BentleyError.getErrorMessage(err) + stack;\r\n }\r\n\r\n /** Log the specified exception.\r\n * For legacy [[BentleyError]] exceptions, the special \"exceptionType\" property will be added as metadata. Otherwise, all enumerable members of the exception are logged as metadata.\r\n * @param category The category of the message.\r\n * @param err The exception object.\r\n * @param log The logger output function to use - defaults to Logger.logError\r\n */\r\n public static logException(category: string, err: any, log: LogFunction = (_category, message, metaData) => Logger.logError(_category, message, metaData)): void {\r\n log(category, Logger.getExceptionMessage(err), () => {\r\n // For backwards compatibility, log BentleyError old way\r\n if (BentleyError.isError(err))\r\n return { ...BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? \"<Unknown>\" };\r\n\r\n // return a copy of the error, with non-enumerable members `message` and `stack` removed, as \"metadata\" for log.\r\n return { ...err };\r\n });\r\n }\r\n\r\n /** Log the specified message to the **warning** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logWarning(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logWarning && Logger.isEnabled(category, LogLevel.Warning))\r\n Logger._logWarning(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **info** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logInfo(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logInfo && Logger.isEnabled(category, LogLevel.Info))\r\n Logger._logInfo(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **trace** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logTrace(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logTrace && Logger.isEnabled(category, LogLevel.Trace))\r\n Logger._logTrace(category, message, metaData);\r\n }\r\n}\r\n\r\n/** Simple performance diagnostics utility.\r\n * It measures the time from construction to disposal. On disposal it logs the routine name along with\r\n * the duration in milliseconds.\r\n * It also logs the routine name at construction time so that nested calls can be disambiguated.\r\n *\r\n * The timings are logged using the log category **Performance** and log severity [[LogLevel.INFO]].\r\n * Enable those, if you want to capture timings.\r\n * @public\r\n */\r\nexport class PerfLogger implements Disposable {\r\n private static _severity: LogLevel = LogLevel.Info;\r\n\r\n private _operation: string;\r\n private _metaData?: LoggingMetaData;\r\n private _startTimeStamp: number;\r\n\r\n public constructor(operation: string, metaData?: LoggingMetaData) {\r\n this._operation = operation;\r\n this._metaData = metaData;\r\n\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity)) {\r\n this._startTimeStamp = 0;\r\n return;\r\n }\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},START`, this._metaData);\r\n this._startTimeStamp = new Date().getTime(); // take timestamp\r\n }\r\n\r\n private logMessage(): void {\r\n const endTimeStamp: number = new Date().getTime();\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity))\r\n return;\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},END`, () => {\r\n const mdata = this._metaData ? BentleyError.getMetaData(this._metaData) : {};\r\n return {\r\n ...mdata, TimeElapsed: endTimeStamp - this._startTimeStamp, // eslint-disable-line @typescript-eslint/naming-convention\r\n };\r\n });\r\n }\r\n\r\n public [Symbol.dispose](): void {\r\n this.logMessage();\r\n }\r\n\r\n /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */\r\n public dispose(): void {\r\n this[Symbol.dispose]();\r\n }\r\n}\r\n\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,aAAiB,SAAQ,GAAM;IAC1C,iDAAiD;IACjC,OAAO,GAAG,IAAI,OAAO,EAAqB,CAAC;IAC3D,qDAAqD;IACrC,SAAS,GAAG,IAAI,OAAO,EAAqB,CAAC;IAC7D,qDAAqD;IACrC,SAAS,GAAG,IAAI,OAAO,EAAc,CAAC;IAEtD;;OAEG;IACH,YAAmB,QAAkC;QACnD,4EAA4E;QAC5E,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,IAAI,CAAC,GAAG,GAAG,CAAC,IAAO,EAAE,EAAE;YACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;YAC3B,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;gBACxB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAEhC,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACa,MAAM,CAAC,IAAO;QAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG;YACL,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAElC,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACa,KAAK;QACnB,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Collections\n */\n\nimport { BeEvent } from \"./BeEvent\";\n\n/** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.\n * @public\n */\nexport class ObservableSet<T> extends Set<T> {\n /** Emitted after `item` is added to this set. */\n public readonly onAdded = new BeEvent<(item: T) => void>();\n /** Emitted after `item` is deleted from this set. */\n public readonly onDeleted = new BeEvent<(item: T) => void>();\n /** Emitted after this set's contents are cleared. */\n public readonly onCleared = new BeEvent<() => void>();\n\n /** Construct a new ObservableSet.\n * @param elements Optional elements with which to populate the new set.\n */\n public constructor(elements?: Iterable<T> | undefined) {\n // NB: Set constructor will invoke add(). Do not override until initialized.\n super(elements);\n\n this.add = (item: T) => {\n const prevSize = this.size;\n const ret = super.add(item);\n if (this.size !== prevSize)\n this.onAdded.raiseEvent(item);\n\n return ret;\n };\n }\n\n /** Invokes [Set.delete](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete), raising\n * the [[onDeleted]] event if the item was removed from the set.\n */\n public override delete(item: T): boolean {\n const ret = super.delete(item);\n if (ret)\n this.onDeleted.raiseEvent(item);\n\n return ret;\n }\n\n /** If this set is not already empty, invokes [Set.clear](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)\n * and raises the [[onCleared]] event.\n */\n public override clear(): void {\n if (0 !== this.size) {\n super.clear();\n this.onCleared.raiseEvent();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,aAAiB,SAAQ,GAAM;IAC1C,iDAAiD;IACjC,OAAO,GAAG,IAAI,OAAO,EAAqB,CAAC;IAC3D,qDAAqD;IACrC,SAAS,GAAG,IAAI,OAAO,EAAqB,CAAC;IAC7D,qDAAqD;IACrC,SAAS,GAAG,IAAI,OAAO,EAAc,CAAC;IAEtD;;OAEG;IACH,YAAmB,QAAkC;QACnD,4EAA4E;QAC5E,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,IAAI,CAAC,GAAG,GAAG,CAAC,IAAO,EAAE,EAAE;YACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;YAC3B,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;gBACxB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAEhC,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACa,MAAM,CAAC,IAAO;QAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG;YACL,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAElC,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACa,KAAK;QACnB,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;QAC9B,CAAC;IACH,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 { BeEvent } from \"./BeEvent\";\r\n\r\n/** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.\r\n * @public\r\n */\r\nexport class ObservableSet<T> extends Set<T> {\r\n /** Emitted after `item` is added to this set. */\r\n public readonly onAdded = new BeEvent<(item: T) => void>();\r\n /** Emitted after `item` is deleted from this set. */\r\n public readonly onDeleted = new BeEvent<(item: T) => void>();\r\n /** Emitted after this set's contents are cleared. */\r\n public readonly onCleared = new BeEvent<() => void>();\r\n\r\n /** Construct a new ObservableSet.\r\n * @param elements Optional elements with which to populate the new set.\r\n */\r\n public constructor(elements?: Iterable<T> | undefined) {\r\n // NB: Set constructor will invoke add(). Do not override until initialized.\r\n super(elements);\r\n\r\n this.add = (item: T) => {\r\n const prevSize = this.size;\r\n const ret = super.add(item);\r\n if (this.size !== prevSize)\r\n this.onAdded.raiseEvent(item);\r\n\r\n return ret;\r\n };\r\n }\r\n\r\n /** Invokes [Set.delete](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete), raising\r\n * the [[onDeleted]] event if the item was removed from the set.\r\n */\r\n public override delete(item: T): boolean {\r\n const ret = super.delete(item);\r\n if (ret)\r\n this.onDeleted.raiseEvent(item);\r\n\r\n return ret;\r\n }\r\n\r\n /** If this set is not already empty, invokes [Set.clear](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)\r\n * and raises the [[onCleared]] event.\r\n */\r\n public override clear(): void {\r\n if (0 !== this.size) {\r\n super.clear();\r\n this.onCleared.raiseEvent();\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AAiC;IACtC,GAAG,CAAS;IAEnB;;OAEG;IACH,YAAY,GAAmC,EAAE,GAAG,GAAG,WAAW;QAChE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,GAAG,IAAW;QACjC,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAI,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,0CAA0C;QACpG,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,8FAA8F;QAEpI,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC,CAAC,8BAA8B;YAC9D,IAAI,IAAI,CAAC,QAAQ,EAAE,8FAA8F;gBAC/G,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,iEAAiE;YAC5F,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,uCAAuC;YAC7D,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,8DAA8D;QAC/E,CAAC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC;QACvB,CAAC;gBAAS,CAAC;YACT,2DAA2D;YAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,2CAA2C;YACzE,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,gBAAgB;YAC3C,IAAI,IAAI,CAAC,OAAO;gBACd,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,8DAA8D;QACxF,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\nimport { BentleyError } from \"./BentleyError\";\n\n/** @beta */\nexport class AbandonedError extends Error { }\n\n/**\n * An object that returns a Promise when you call [[init]], but supplies a way to abandon the promise if it is no longer relevant.\n * When you call abandon, the promise will be rejected. You must supply a [[run]] method to the constructor that\n * creates the real Promise for the underlying action. Notice that to use this class there are really two\n * Promises involved that are chained together. That makes this class less efficient than just using a Promise directly.\n */\nclass PromiseWithAbandon<T> {\n /** Method to abandon the Promise created by [[init]] while it is outstanding. The promise will be rejected. */\n public abandon!: (msg?: string) => void;\n private _resolve!: (val: any) => void;\n\n /** Create a PromiseWithAbandon. After this call you must call [[init]] to create the underlying Promise.\n * @param _run The method that creates the underlying Promise.\n * @param _args An array of args to be passed to run when [[start]] is called.\n */\n constructor(private _run: (...args: any[]) => Promise<T>, private _args: any[]) { }\n\n /** Create a Promise that is chained to the underlying Promise, but is connected to the abandon method. */\n public async init(msg: string): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n this.abandon = (message?: string) => reject(new AbandonedError(message ?? msg));\n this._resolve = resolve;\n });\n }\n\n /** Call the [[run]] method supplied to the ctor to start the underlying Promise. */\n public async start() {\n try {\n this._resolve(await this._run(...this._args));\n } catch (err) {\n this.abandon(BentleyError.getErrorMessage(err)); // turn all errors from execution into abandoned errors, but keep the message\n }\n }\n}\n\n/**\n * Orchestrator of a one-at-a-time activity. This concept is useful only for *replaceable* operations (that is, operations where subsequent requests replace and obviate\n * the need for previous requests. E.g. over slow HTTP connections, without this class, the stream of requests can overwhelm the connection, and cause the HTTP\n * request queue to grow such that the delay to service new requests is unbounded.\n *\n * With this class, we issue the initial request immediately. When the second request arrives before the first one completes, it becomes *pending*. If subsequent\n * requests arrive with a pending request, the current pending request is *abandoned* (its Promise is rejected) and the new request becomes pending.\n * When the active request completes, the pending request (if present) is started. In this manner there will only ever be one outstanding HTTP request for this type\n * of operation, but the first and last request will always eventually complete.\n * @beta\n */\nexport class OneAtATimeAction<T> {\n private _active?: PromiseWithAbandon<T>;\n private _pending?: PromiseWithAbandon<T>;\n private _run: (...args: any[]) => Promise<T>;\n public msg: string;\n\n /** Ctor for OneAtATimePromise.\n * @param run The method that performs an action that creates the Promise.\n */\n constructor(run: (...args: any[]) => Promise<T>, msg = \"abandoned\") {\n this._run = run;\n this.msg = msg;\n }\n\n /** Add a new request to this OneAtATimePromise. The request will only run when no other outstanding requests are active.\n * @note Callers of this method *must* handle AbandonedError rejections.\n */\n public async request(...args: any[]): Promise<T> {\n const entry = new PromiseWithAbandon<T>(this._run, args); // create an \"abandon-able promise\" object\n const promise = entry.init(this.msg); // create the Promise from PromiseWithAbandon. Note: this must be called before we call start.\n\n if (this._active !== undefined) { // is there an active request?\n if (this._pending) // yes. If there is also a pending request, this one replaces it and previous one is abandoned\n this._pending.abandon(); // rejects previous call to this method, throwing AbandonedError.\n this._pending = entry;\n } else {\n this._active = entry; // this is the first request, start it.\n entry.start(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n try {\n return await promise;\n } finally {\n // do all of this whether promise was fulfilled or rejected\n this._active = this._pending; // see if there's a pending request waiting\n this._pending = undefined; // clear pending\n if (this._active)\n this._active.start(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n}\n"]}
1
+ {"version":3,"file":"OneAtATimeAction.js","sourceRoot":"","sources":["../../src/OneAtATimeAction.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,YAAY;AACZ,MAAM,OAAO,cAAe,SAAQ,KAAK;CAAI;AAE7C;;;;;GAKG;AACH,MAAM,kBAAkB;IASF;IAA8C;IARlE,+GAA+G;IACxG,OAAO,CAA0B;IAChC,QAAQ,CAAsB;IAEtC;;;OAGG;IACH,YAAoB,IAAoC,EAAU,KAAY;QAA1D,SAAI,GAAJ,IAAI,CAAgC;QAAU,UAAK,GAAL,KAA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,EAAE,CAAC,CAAC,8BAA8B;YAC9D,IAAI,IAAI,CAAC,QAAQ,EAAE,8FAA8F;gBAC/G,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,iEAAiE;YAC5F,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,uCAAuC;YAC7D,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,8DAA8D;QAC/E,CAAC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC;QACvB,CAAC;gBAAS,CAAC;YACT,2DAA2D;YAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,2CAA2C;YACzE,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,gBAAgB;YAC3C,IAAI,IAAI,CAAC,OAAO;gBACd,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,8DAA8D;QACxF,CAAC;IACH,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 Utils\r\n */\r\n\r\nimport { BentleyError } from \"./BentleyError\";\r\n\r\n/** @beta */\r\nexport class AbandonedError extends Error { }\r\n\r\n/**\r\n * An object that returns a Promise when you call [[init]], but supplies a way to abandon the promise if it is no longer relevant.\r\n * When you call abandon, the promise will be rejected. You must supply a [[run]] method to the constructor that\r\n * creates the real Promise for the underlying action. Notice that to use this class there are really two\r\n * Promises involved that are chained together. That makes this class less efficient than just using a Promise directly.\r\n */\r\nclass PromiseWithAbandon<T> {\r\n /** Method to abandon the Promise created by [[init]] while it is outstanding. The promise will be rejected. */\r\n public abandon!: (msg?: string) => void;\r\n private _resolve!: (val: any) => void;\r\n\r\n /** Create a PromiseWithAbandon. After this call you must call [[init]] to create the underlying Promise.\r\n * @param _run The method that creates the underlying Promise.\r\n * @param _args An array of args to be passed to run when [[start]] is called.\r\n */\r\n constructor(private _run: (...args: any[]) => Promise<T>, private _args: any[]) { }\r\n\r\n /** Create a Promise that is chained to the underlying Promise, but is connected to the abandon method. */\r\n public async init(msg: string): Promise<T> {\r\n return new Promise<T>((resolve, reject) => {\r\n this.abandon = (message?: string) => reject(new AbandonedError(message ?? msg));\r\n this._resolve = resolve;\r\n });\r\n }\r\n\r\n /** Call the [[run]] method supplied to the ctor to start the underlying Promise. */\r\n public async start() {\r\n try {\r\n this._resolve(await this._run(...this._args));\r\n } catch (err) {\r\n this.abandon(BentleyError.getErrorMessage(err)); // turn all errors from execution into abandoned errors, but keep the message\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Orchestrator of a one-at-a-time activity. This concept is useful only for *replaceable* operations (that is, operations where subsequent requests replace and obviate\r\n * the need for previous requests. E.g. over slow HTTP connections, without this class, the stream of requests can overwhelm the connection, and cause the HTTP\r\n * request queue to grow such that the delay to service new requests is unbounded.\r\n *\r\n * With this class, we issue the initial request immediately. When the second request arrives before the first one completes, it becomes *pending*. If subsequent\r\n * requests arrive with a pending request, the current pending request is *abandoned* (its Promise is rejected) and the new request becomes pending.\r\n * When the active request completes, the pending request (if present) is started. In this manner there will only ever be one outstanding HTTP request for this type\r\n * of operation, but the first and last request will always eventually complete.\r\n * @beta\r\n */\r\nexport class OneAtATimeAction<T> {\r\n private _active?: PromiseWithAbandon<T>;\r\n private _pending?: PromiseWithAbandon<T>;\r\n private _run: (...args: any[]) => Promise<T>;\r\n public msg: string;\r\n\r\n /** Ctor for OneAtATimePromise.\r\n * @param run The method that performs an action that creates the Promise.\r\n */\r\n constructor(run: (...args: any[]) => Promise<T>, msg = \"abandoned\") {\r\n this._run = run;\r\n this.msg = msg;\r\n }\r\n\r\n /** Add a new request to this OneAtATimePromise. The request will only run when no other outstanding requests are active.\r\n * @note Callers of this method *must* handle AbandonedError rejections.\r\n */\r\n public async request(...args: any[]): Promise<T> {\r\n const entry = new PromiseWithAbandon<T>(this._run, args); // create an \"abandon-able promise\" object\r\n const promise = entry.init(this.msg); // create the Promise from PromiseWithAbandon. Note: this must be called before we call start.\r\n\r\n if (this._active !== undefined) { // is there an active request?\r\n if (this._pending) // yes. If there is also a pending request, this one replaces it and previous one is abandoned\r\n this._pending.abandon(); // rejects previous call to this method, throwing AbandonedError.\r\n this._pending = entry;\r\n } else {\r\n this._active = entry; // this is the first request, start it.\r\n entry.start(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n try {\r\n return await promise;\r\n } finally {\r\n // do all of this whether promise was fulfilled or rejected\r\n this._active = this._pending; // see if there's a pending request waiting\r\n this._pending = undefined; // clear pending\r\n if (this._active)\r\n this._active.start(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"OrderedId64Iterable.js","sourceRoot":"","sources":["../../src/OrderedId64Iterable.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOlC;;;;;;;GAOG;AACH,MAAM,KAAW,mBAAmB,CAwOnC;AAxOD,WAAiB,mBAAmB;IAClC;;;;;;OAMG;IACH,SAAgB,OAAO,CAAC,GAAe,EAAE,GAAe;QACtD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;YAC3B,OAAO,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,+GAA+G;QAC/G,0BAA0B;QAC1B,IAAI,GAAG,KAAK,GAAG;YACb,OAAO,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5B,OAAO,CA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,CAAC;YAC7B,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC/B,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;gBACnC,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;gBAC9B,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;oBACpB,MAAM,IAAI,GAAG,IAAI,CAAC;oBAClB,SAAS;gBACX,CAAC;gBAED,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;gBACzB,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC7B,CAAC;YAED,IAAI,GAAG,GAAG,CAAC;gBACT,MAAM,IAAI,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;IAjCgB,sCAAkB,qBAiClC,CAAA;AACH,CAAC,EAxOgB,mBAAmB,KAAnB,mBAAmB,QAwOnC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Ids\n */\n\nimport { assert } from \"./Assert\";\nimport { CompressedId64Set } from \"./CompressedId64Set\";\nimport { Id64Array, Id64String } from \"./Id\";\n\n/** @public */\nexport type OrderedId64Iterable = Iterable<Id64String>;\n\n/** A collection of **valid** [[Id64String]]s sorted in ascending order by the unsigned 64-bit integer value of the Ids.\n * This ordering is a requirement for several groups of APIs including [[CompressedId64Set]].\n * When used as input to a function, duplicate Ids are ignored; when returned as a function output, no duplicates are present.\n * @see [[CompressedId64Set]] for a compact string representation of such an ordered collection.\n * @see [[OrderedId64Iterable.compare]] for a function that compares Ids based on this criterion.\n * @see [[OrderedId64Array]] for a mutable implementation.\n * @public\n */\nexport namespace OrderedId64Iterable { // eslint-disable-line @typescript-eslint/no-redeclare\n /** An ordered comparison of [[Id64String]]s suitable for use with sorting routines like\n * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) and sorted containers\n * like [[SortedArray]] and [[Dictionary]]. The comparison compares the 64-bit numerical values of the two Ids, returning a negative number if lhs < rhs,\n * a positive number if lhs > rhs, or zero if lhs == rhs.\n * The default string comparison is fine (and more efficient) when numerical ordering is not required; use this instead if you want e.g., \"0x100\" to be greater than \"0xf\".\n * @see [[OrderedId64Iterable.sortArray]] for a convenient way to sort an array of Id64Strings.\n */\n export function compare(lhs: Id64String, rhs: Id64String): number {\n if (lhs.length !== rhs.length)\n return lhs.length < rhs.length ? -1 : 1;\n\n // This is faster than localeCompare(). Unclear why there is no string.compare() - would be generally useful in\n // array sort functions...\n if (lhs !== rhs)\n return lhs < rhs ? -1 : 1;\n\n return 0;\n }\n\n /** Sort an array of [[Id64String]]s **in-place** in ascending order by their 64-bit numerical values.\n * @see [[OrderedId64Iterable.compare]] for the comparison routine used.\n * @returns the input array.\n * @note This function returns its input for consistency with Javascript's\n * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) method.\n * It **does not** create a **new** array.\n */\n export function sortArray(ids: Id64Array): Id64Array {\n ids.sort((x, y) => compare(x, y));\n return ids;\n }\n\n /** Given two ordered collections of [[Id64String]]s, determine whether they are identical sets. Duplicate Ids are ignored.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function areEqualSets(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): boolean {\n const leftIter = uniqueIterator(ids1);\n const rightIter = uniqueIterator(ids2);\n let leftState = leftIter.next();\n let rightState = rightIter.next();\n\n while (!leftState.done && !rightState.done) {\n const left = leftState.value;\n const right = rightState.value;\n if (0 !== compare(left, right))\n return false;\n\n leftState = leftIter.next();\n rightState = rightIter.next();\n }\n\n if (leftState.done && rightState.done)\n return true;\n\n return false;\n }\n\n /** Given an ordered collection of [[Id64String]]s, determine if it contains any Ids.\n * @param ids A well-formed, ordered collection of zero or more valid Ids.\n * @returns true if the input represents an empty set of Ids. The result is unspecified if the input does not meet the criteria for the input type.\n */\n export function isEmptySet(ids: OrderedId64Iterable | CompressedId64Set): boolean {\n if (typeof ids === \"string\")\n return \"\" === ids;\n\n return true === ids[Symbol.iterator]().next().done;\n }\n\n /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered collection containing no duplicates.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function unique(ids: OrderedId64Iterable): OrderedId64Iterable {\n return { [Symbol.iterator]: () => uniqueIterator(ids) };\n }\n\n /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered iterator over the distinct Ids, eliminating duplicates.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function* uniqueIterator(ids: OrderedId64Iterable) {\n const iter = ids[Symbol.iterator]();\n let state = iter.next();\n let prev: Id64String | undefined;\n\n while (!state.done) {\n const id = state.value;\n state = iter.next();\n if (id !== prev) {\n prev = id;\n yield id;\n }\n }\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce a collection representing their union - i.e., the Ids that are present in either or both collections.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function union(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\n return { [Symbol.iterator]: () => unionIterator(ids1, ids2) };\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function intersection(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\n return { [Symbol.iterator]: () => intersectionIterator(ids1, ids2) };\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function difference(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\n return { [Symbol.iterator]: () => differenceIterator(ids1, ids2) };\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their union - i.e., the Ids that are present in either or both collections.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function* unionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\n const leftIter = ids1[Symbol.iterator]();\n const rightIter = ids2[Symbol.iterator]();\n let leftState = leftIter.next();\n let rightState = rightIter.next();\n\n let prev: string | undefined;\n while (!leftState.done || !rightState.done) {\n const left = leftState.done ? undefined : leftState.value;\n const right = rightState.done ? undefined : rightState.value;\n\n assert(undefined !== left || undefined !== right);\n if (undefined === left && undefined === right)\n break;\n\n let next: Id64String;\n if (undefined === left) {\n assert(undefined !== right);\n next = right;\n rightState = rightIter.next();\n } else if (undefined === right) {\n next = left;\n leftState = leftIter.next();\n } else {\n const cmp = compare(left, right);\n if (cmp <= 0) {\n next = left;\n leftState = leftIter.next();\n if (0 === cmp)\n rightState = rightIter.next();\n } else {\n next = right;\n rightState = rightIter.next();\n }\n }\n\n if (prev === next)\n continue;\n\n prev = next;\n yield next;\n }\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function* intersectionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\n const leftIter = ids1[Symbol.iterator]();\n const rightIter = ids2[Symbol.iterator]();\n let leftState = leftIter.next();\n let rightState = rightIter.next();\n\n let prev: string | undefined;\n while (!leftState.done && !rightState.done) {\n const left = leftState.value;\n leftState = leftIter.next();\n if (left === prev)\n continue;\n\n prev = left;\n\n let right = rightState.value;\n let cmp = compare(left, right);\n while (cmp > 0) {\n rightState = rightIter.next();\n if (rightState.done)\n return;\n\n right = rightState.value;\n cmp = compare(left, right);\n }\n\n if (0 === cmp)\n yield left;\n }\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function* differenceIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\n const leftIter = ids1[Symbol.iterator]();\n const rightIter = ids2[Symbol.iterator]();\n let leftState = leftIter.next();\n let rightState = rightIter.next();\n\n let prev: string | undefined;\n while (!leftState.done) {\n const left = leftState.value;\n leftState = leftIter.next();\n if (left === prev)\n continue;\n else if (rightState.done) {\n yield prev = left;\n continue;\n }\n\n let right = rightState.value;\n let cmp = compare(left, right);\n while (cmp > 0 && !rightState.done) {\n rightState = rightIter.next();\n if (rightState.done) {\n yield prev = left;\n continue;\n }\n\n right = rightState.value;\n cmp = compare(left, right);\n }\n\n if (cmp < 0)\n yield prev = left;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"OrderedId64Iterable.js","sourceRoot":"","sources":["../../src/OrderedId64Iterable.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOlC;;;;;;;GAOG;AACH,MAAM,KAAW,mBAAmB,CAwOnC;AAxOD,WAAiB,mBAAmB;IAClC;;;;;;OAMG;IACH,SAAgB,OAAO,CAAC,GAAe,EAAE,GAAe;QACtD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;YAC3B,OAAO,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,+GAA+G;QAC/G,0BAA0B;QAC1B,IAAI,GAAG,KAAK,GAAG;YACb,OAAO,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CA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G,UAAU,CAAC,KAAK,CAAC;YAC7B,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC/B,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;gBACnC,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;gBAC9B,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;oBACpB,MAAM,IAAI,GAAG,IAAI,CAAC;oBAClB,SAAS;gBACX,CAAC;gBAED,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;gBACzB,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC7B,CAAC;YAED,IAAI,GAAG,GAAG,CAAC;gBACT,MAAM,IAAI,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;IAjCgB,sCAAkB,qBAiClC,CAAA;AACH,CAAC,EAxOgB,mBAAmB,KAAnB,mBAAmB,QAwOnC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Ids\r\n */\r\n\r\nimport { assert } from \"./Assert\";\r\nimport { CompressedId64Set } from \"./CompressedId64Set\";\r\nimport { Id64Array, Id64String } from \"./Id\";\r\n\r\n/** @public */\r\nexport type OrderedId64Iterable = Iterable<Id64String>;\r\n\r\n/** A collection of **valid** [[Id64String]]s sorted in ascending order by the unsigned 64-bit integer value of the Ids.\r\n * This ordering is a requirement for several groups of APIs including [[CompressedId64Set]].\r\n * When used as input to a function, duplicate Ids are ignored; when returned as a function output, no duplicates are present.\r\n * @see [[CompressedId64Set]] for a compact string representation of such an ordered collection.\r\n * @see [[OrderedId64Iterable.compare]] for a function that compares Ids based on this criterion.\r\n * @see [[OrderedId64Array]] for a mutable implementation.\r\n * @public\r\n */\r\nexport namespace OrderedId64Iterable { // eslint-disable-line @typescript-eslint/no-redeclare\r\n /** An ordered comparison of [[Id64String]]s suitable for use with sorting routines like\r\n * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) and sorted containers\r\n * like [[SortedArray]] and [[Dictionary]]. The comparison compares the 64-bit numerical values of the two Ids, returning a negative number if lhs < rhs,\r\n * a positive number if lhs > rhs, or zero if lhs == rhs.\r\n * The default string comparison is fine (and more efficient) when numerical ordering is not required; use this instead if you want e.g., \"0x100\" to be greater than \"0xf\".\r\n * @see [[OrderedId64Iterable.sortArray]] for a convenient way to sort an array of Id64Strings.\r\n */\r\n export function compare(lhs: Id64String, rhs: Id64String): number {\r\n if (lhs.length !== rhs.length)\r\n return lhs.length < rhs.length ? -1 : 1;\r\n\r\n // This is faster than localeCompare(). Unclear why there is no string.compare() - would be generally useful in\r\n // array sort functions...\r\n if (lhs !== rhs)\r\n return lhs < rhs ? -1 : 1;\r\n\r\n return 0;\r\n }\r\n\r\n /** Sort an array of [[Id64String]]s **in-place** in ascending order by their 64-bit numerical values.\r\n * @see [[OrderedId64Iterable.compare]] for the comparison routine used.\r\n * @returns the input array.\r\n * @note This function returns its input for consistency with Javascript's\r\n * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) method.\r\n * It **does not** create a **new** array.\r\n */\r\n export function sortArray(ids: Id64Array): Id64Array {\r\n ids.sort((x, y) => compare(x, y));\r\n return ids;\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, determine whether they are identical sets. Duplicate Ids are ignored.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function areEqualSets(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): boolean {\r\n const leftIter = uniqueIterator(ids1);\r\n const rightIter = uniqueIterator(ids2);\r\n let leftState = leftIter.next();\r\n let rightState = rightIter.next();\r\n\r\n while (!leftState.done && !rightState.done) {\r\n const left = leftState.value;\r\n const right = rightState.value;\r\n if (0 !== compare(left, right))\r\n return false;\r\n\r\n leftState = leftIter.next();\r\n rightState = rightIter.next();\r\n }\r\n\r\n if (leftState.done && rightState.done)\r\n return true;\r\n\r\n return false;\r\n }\r\n\r\n /** Given an ordered collection of [[Id64String]]s, determine if it contains any Ids.\r\n * @param ids A well-formed, ordered collection of zero or more valid Ids.\r\n * @returns true if the input represents an empty set of Ids. The result is unspecified if the input does not meet the criteria for the input type.\r\n */\r\n export function isEmptySet(ids: OrderedId64Iterable | CompressedId64Set): boolean {\r\n if (typeof ids === \"string\")\r\n return \"\" === ids;\r\n\r\n return true === ids[Symbol.iterator]().next().done;\r\n }\r\n\r\n /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered collection containing no duplicates.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function unique(ids: OrderedId64Iterable): OrderedId64Iterable {\r\n return { [Symbol.iterator]: () => uniqueIterator(ids) };\r\n }\r\n\r\n /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered iterator over the distinct Ids, eliminating duplicates.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function* uniqueIterator(ids: OrderedId64Iterable) {\r\n const iter = ids[Symbol.iterator]();\r\n let state = iter.next();\r\n let prev: Id64String | undefined;\r\n\r\n while (!state.done) {\r\n const id = state.value;\r\n state = iter.next();\r\n if (id !== prev) {\r\n prev = id;\r\n yield id;\r\n }\r\n }\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce a collection representing their union - i.e., the Ids that are present in either or both collections.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function union(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\r\n return { [Symbol.iterator]: () => unionIterator(ids1, ids2) };\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function intersection(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\r\n return { [Symbol.iterator]: () => intersectionIterator(ids1, ids2) };\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function difference(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\r\n return { [Symbol.iterator]: () => differenceIterator(ids1, ids2) };\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their union - i.e., the Ids that are present in either or both collections.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function* unionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\r\n const leftIter = ids1[Symbol.iterator]();\r\n const rightIter = ids2[Symbol.iterator]();\r\n let leftState = leftIter.next();\r\n let rightState = rightIter.next();\r\n\r\n let prev: string | undefined;\r\n while (!leftState.done || !rightState.done) {\r\n const left = leftState.done ? undefined : leftState.value;\r\n const right = rightState.done ? undefined : rightState.value;\r\n\r\n assert(undefined !== left || undefined !== right);\r\n if (undefined === left && undefined === right)\r\n break;\r\n\r\n let next: Id64String;\r\n if (undefined === left) {\r\n assert(undefined !== right);\r\n next = right;\r\n rightState = rightIter.next();\r\n } else if (undefined === right) {\r\n next = left;\r\n leftState = leftIter.next();\r\n } else {\r\n const cmp = compare(left, right);\r\n if (cmp <= 0) {\r\n next = left;\r\n leftState = leftIter.next();\r\n if (0 === cmp)\r\n rightState = rightIter.next();\r\n } else {\r\n next = right;\r\n rightState = rightIter.next();\r\n }\r\n }\r\n\r\n if (prev === next)\r\n continue;\r\n\r\n prev = next;\r\n yield next;\r\n }\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function* intersectionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\r\n const leftIter = ids1[Symbol.iterator]();\r\n const rightIter = ids2[Symbol.iterator]();\r\n let leftState = leftIter.next();\r\n let rightState = rightIter.next();\r\n\r\n let prev: string | undefined;\r\n while (!leftState.done && !rightState.done) {\r\n const left = leftState.value;\r\n leftState = leftIter.next();\r\n if (left === prev)\r\n continue;\r\n\r\n prev = left;\r\n\r\n let right = rightState.value;\r\n let cmp = compare(left, right);\r\n while (cmp > 0) {\r\n rightState = rightIter.next();\r\n if (rightState.done)\r\n return;\r\n\r\n right = rightState.value;\r\n cmp = compare(left, right);\r\n }\r\n\r\n if (0 === cmp)\r\n yield left;\r\n }\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function* differenceIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\r\n const leftIter = ids1[Symbol.iterator]();\r\n const rightIter = ids2[Symbol.iterator]();\r\n let leftState = leftIter.next();\r\n let rightState = rightIter.next();\r\n\r\n let prev: string | undefined;\r\n while (!leftState.done) {\r\n const left = leftState.value;\r\n leftState = leftIter.next();\r\n if (left === prev)\r\n continue;\r\n else if (rightState.done) {\r\n yield prev = left;\r\n continue;\r\n }\r\n\r\n let right = rightState.value;\r\n let cmp = compare(left, right);\r\n while (cmp > 0 && !rightState.done) {\r\n rightState = rightIter.next();\r\n if (rightState.done) {\r\n yield prev = left;\r\n continue;\r\n }\r\n\r\n right = rightState.value;\r\n cmp = compare(left, right);\r\n }\r\n\r\n if (cmp < 0)\r\n yield prev = left;\r\n }\r\n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AK,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Collections\n */\n\nimport { OrderedComparator } from \"./Compare\";\nimport { CloneFunction, shallowClone, SortedArray } from \"./SortedArray\";\n\n/** A read-only equivalent of `Set<T>` that maintains its elements in sorted order as specified by a comparison function.\n * Iteration returns elements in the order specified by the comparison function, as opposed to `Set` which returns elements in insertion order.\n * Implemented in terms of [[SortedArray]].\n * @public\n */\nexport class ReadonlyOrderedSet<T> implements Iterable<T> {\n protected readonly _array: SortedArray<T>;\n\n /** Construct a new ReadonlyOrderedSet<T>.\n * @param compare The function used to compare elements within the set, determining their ordering.\n * @param clone The function invoked to clone a new element for insertion into the set. The default implementation simply returns its input.\n */\n public constructor(compare: OrderedComparator<T>, clone: CloneFunction<T> = shallowClone) {\n this._array = new SortedArray<T>(compare, false, clone);\n }\n\n /** The number of elements in the set. */\n public get size(): number {\n return this._array.length;\n }\n\n /** Returns true if `value` is present in the set. */\n public has(value: T): boolean {\n return -1 !== this._array.indexOf(value);\n }\n\n /** Iterate over the elements in sorted order (as opposed to `Set`'s iterator, which returns elements in insertion order). */\n public [Symbol.iterator](): Iterator<T> {\n return this._array[Symbol.iterator]();\n }\n}\n\n/** A mutable [[ReadonlyOrderedSet]].\n * @public\n */\nexport class OrderedSet<T> extends ReadonlyOrderedSet<T> {\n /** Construct a new OrderedSet<T>.\n * @param compare The function used to compare elements within the set, determining their ordering.\n * @param clone The function invoked to clone a new element for insertion into the set. The default implementation simply returns its input.\n */\n public constructor(compare: OrderedComparator<T>, clone: CloneFunction<T> = shallowClone) {\n super(compare, clone);\n }\n\n /** Remove all elements from the set. */\n public clear(): void {\n this._array.clear();\n }\n\n /** Add the specified element to the set. Returns this set. */\n public add(value: T): this {\n this._array.insert(value);\n return this;\n }\n\n /** Removes the specified element from the set. Returns `true` if the element was present. */\n public delete(value: T): boolean {\n return -1 !== this._array.remove(value);\n }\n}\n"]}
1
+ {"version":3,"file":"OrderedSet.js","sourceRoot":"","sources":["../../src/OrderedSet.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAiB,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEzE;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IACV,MAAM,CAAiB;IAE1C;;;OAGG;IACH,YAAmB,OAA6B,EAAE,QAA0B,YAAY;QACtF,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAI,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;IAED,yCAAyC;IACzC,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,qDAAqD;IAC9C,GAAG,CAAC,KAAQ;QACjB,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,6HAA6H;IACtH,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,UAAc,SAAQ,kBAAqB;IACtD;;;OAGG;IACH,YAAmB,OAA6B,EAAE,QAA0B,YAAY;QACtF,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,wCAAwC;IACjC,KAAK;QACV,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,8DAA8D;IACvD,GAAG,CAAC,KAAQ;QACjB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6FAA6F;IACtF,MAAM,CAAC,KAAQ;QACpB,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1C,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 { OrderedComparator } from \"./Compare\";\r\nimport { CloneFunction, shallowClone, SortedArray } from \"./SortedArray\";\r\n\r\n/** A read-only equivalent of `Set<T>` that maintains its elements in sorted order as specified by a comparison function.\r\n * Iteration returns elements in the order specified by the comparison function, as opposed to `Set` which returns elements in insertion order.\r\n * Implemented in terms of [[SortedArray]].\r\n * @public\r\n */\r\nexport class ReadonlyOrderedSet<T> implements Iterable<T> {\r\n protected readonly _array: SortedArray<T>;\r\n\r\n /** Construct a new ReadonlyOrderedSet<T>.\r\n * @param compare The function used to compare elements within the set, determining their ordering.\r\n * @param clone The function invoked to clone a new element for insertion into the set. The default implementation simply returns its input.\r\n */\r\n public constructor(compare: OrderedComparator<T>, clone: CloneFunction<T> = shallowClone) {\r\n this._array = new SortedArray<T>(compare, false, clone);\r\n }\r\n\r\n /** The number of elements in the set. */\r\n public get size(): number {\r\n return this._array.length;\r\n }\r\n\r\n /** Returns true if `value` is present in the set. */\r\n public has(value: T): boolean {\r\n return -1 !== this._array.indexOf(value);\r\n }\r\n\r\n /** Iterate over the elements in sorted order (as opposed to `Set`'s iterator, which returns elements in insertion order). */\r\n public [Symbol.iterator](): Iterator<T> {\r\n return this._array[Symbol.iterator]();\r\n }\r\n}\r\n\r\n/** A mutable [[ReadonlyOrderedSet]].\r\n * @public\r\n */\r\nexport class OrderedSet<T> extends ReadonlyOrderedSet<T> {\r\n /** Construct a new OrderedSet<T>.\r\n * @param compare The function used to compare elements within the set, determining their ordering.\r\n * @param clone The function invoked to clone a new element for insertion into the set. The default implementation simply returns its input.\r\n */\r\n public constructor(compare: OrderedComparator<T>, clone: CloneFunction<T> = shallowClone) {\r\n super(compare, clone);\r\n }\r\n\r\n /** Remove all elements from the set. */\r\n public clear(): void {\r\n this._array.clear();\r\n }\r\n\r\n /** Add the specified element to the set. Returns this set. */\r\n public add(value: T): this {\r\n this._array.insert(value);\r\n return this;\r\n }\r\n\r\n /** Removes the specified element from the set. Returns `true` if the element was present. */\r\n public delete(value: T): boolean {\r\n return -1 !== this._array.remove(value);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PriorityQueue.js","sourceRoot":"","sources":["../../src/PriorityQueue.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAiB,YAAY,EAAE,MAAM,eAAe,CAAC;AAK5D;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACd,MAAM,GAAQ,EAAE,CAAC;IACR,QAAQ,CAAuB;IAC/B,MAAM,CAAmB;IAE5C;;;;;OAKG;IACH,YAAmB,OAA6B,EAAE,QAA0B,YAAY;QACtF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,yCAAyC;IACzC,IAAW,MAAM,KAAa,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,oDAAoD;IACpD,IAAW,OAAO,KAAc,OAAO,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE3D,4FAA4F;IACrF,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAkB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAExE,KAAK,CAAC,CAAS,EAAE,CAAS;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,MA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,CAAC,KAAa;QAC1B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM;YACnC,OAAO,SAAS,CAAC;QAEnB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAErB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,KAAa;QAC3B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM;YACnC,OAAO,SAAS,CAAC;;YAEjB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Collections\n */\n\nimport { OrderedComparator } from \"./Compare\";\nimport { CloneFunction, shallowClone } from \"./SortedArray\";\n\n/** @public */\nexport type ComputePriorityFunction<T> = (value: T) => number;\n\n/**\n * A [priority queue](https://en.wikipedia.org/wiki/Priority_queue) implemented as a heap array.\n * The queue is ordered by an [[OrderedComparator]] function supplied by the user such that the value in the queue that compares less than all other values is always located at the front of the queue.\n * @public\n */\nexport class PriorityQueue<T> implements Iterable<T> {\n protected _array: T[] = [];\n protected readonly _compare: OrderedComparator<T>;\n protected readonly _clone: CloneFunction<T>;\n\n /**\n * Constructor\n * @param compare The function used to compare values in the queue. If `compare(x, y)` returns a negative value, then x is placed before y in the queue.\n * @param clone The function used to clone a value for insertion onto the queue. The default implementation simply returns its input.\n * @note If the criterion which control the result of the `compare` function changes, then [[PriorityQueue.sort]] should be used to reorder the queue according to the new criterion.\n */\n public constructor(compare: OrderedComparator<T>, clone: CloneFunction<T> = shallowClone) {\n this._compare = compare;\n this._clone = clone;\n }\n\n /** The number of values in the queue. */\n public get length(): number { return this._array.length; }\n\n /** Returns true if the queue contains no values. */\n public get isEmpty(): boolean { return 0 === this.length; }\n\n /** Returns an iterator over the contents of the heap suitable for use in `for-of` loops. */\n public [Symbol.iterator](): Iterator<T> { return this._array[Symbol.iterator](); }\n\n protected _swap(a: number, b: number) {\n const temp = this._array[a];\n this._array[a] = this._array[b];\n this._array[b] = temp;\n }\n\n protected _heapify(index: number): void {\n let candidate = -1;\n while (true) {\n const right = 2 * (index + 1);\n const left = right - 1;\n if (left < this.length && this._compare(this._array[left], this._array[index]) < 0)\n candidate = left;\n else\n candidate = index;\n\n if (right < this.length && this._compare(this._array[right], this._array[candidate]) < 0)\n candidate = right;\n\n if (candidate !== index) {\n this._swap(candidate, index);\n index = candidate;\n } else {\n break;\n }\n }\n }\n\n /**\n * Reorders the queue. This function should only (and *always*) be called when the criteria governing the ordering of items on the queue have changed.\n * For example, a priority queue containing graphics sorted by their distance from the camera would need to be reordered when the position of the camera changes.\n */\n public sort(): void {\n for (let i = Math.ceil(this.length / 2); i >= 0; i--)\n this._heapify(i);\n }\n\n /**\n * Pushes a value onto the queue according to the sorting criterion.\n * @param value The value to insert\n * @returns The inserted value, cloned according to the [[CloneFunction]] supplied to this queue's constructor.\n */\n public push(value: T): T {\n const clone = this._clone(value);\n\n let index = this.length;\n this._array.push(clone);\n\n while (index !== 0) {\n const parent = Math.floor((index - 1) / 2);\n if (this._compare(this._array[index], this._array[parent]) < 0) {\n this._swap(index, parent);\n index = parent;\n } else {\n break;\n }\n }\n\n return clone;\n }\n\n /** Pushes a value onto the back of the queue without making any attempt to enforce ordering.\n * After using this function, you must manually invoke sort() to ensure the queue is sorted again.\n * @param value The value to append\n * @returns The appended value, cloned according to the [[CloneFunction]] supplied to this queue's constructor.\n */\n public append(value: T): T {\n const clone = this._clone(value);\n this._array.push(clone);\n return clone;\n }\n\n /** Returns the element at the front of the queue, or `undefined` if the queue is empty. */\n public get front(): T | undefined {\n return this._peek(0);\n }\n\n /**\n * Removes the front-most element off of the queue and returns it.\n * @returns The front-most element, or undefined if the queue is empty.\n */\n public pop(): T | undefined {\n return this._pop(0);\n }\n\n /** Removes all values from the queue. */\n public clear(): void {\n this._array.length = 0;\n }\n\n /**\n * Removes the value at the specified index from the queue and reorders the queue.\n * @param index The index of the value to remove\n * @returns the value at the specified index, or undefined if the index is out of range.\n */\n protected _pop(index: number): T | undefined {\n if (index < 0 || index >= this.length)\n return undefined;\n\n const root = this._array[index];\n this._swap(index, this.length - 1);\n this._array.length--;\n\n this._heapify(index);\n return root;\n }\n\n /**\n * Returns the value at the specified index in the queue.\n * @param index The index of the value to retrieve\n * @returns the value at the specified index, or undefined if the index is out of range.\n */\n protected _peek(index: number): T | undefined {\n if (index < 0 || index >= this.length)\n return undefined;\n else\n return this._array[index];\n }\n}\n"]}
1
+ {"version":3,"file":"PriorityQueue.js","sourceRoot":"","sources":["../../src/PriorityQueue.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAiB,YAAY,EAAE,MAAM,eAAe,CAAC;AAK5D;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACd,MAAM,GAAQ,EAAE,CAAC;IACR,QAAQ,CAAuB;IAC/B,MAAM,CAAmB;IAE5C;;;;;OAKG;IACH,YAAmB,OAA6B,EAAE,QAA0B,YAAY;QACtF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,yCAAyC;IACzC,IAAW,MAAM,KAAa,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,oDAAoD;IACpD,IAAW,OAAO,KAAc,OAAO,CAAC,KAAK,IAAI,CAAC,MAAM,CA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C,CAAC,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,GAAG;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAED,yCAAyC;IAClC,KAAK;QACV,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACO,IAAI,CAAC,KAAa;QAC1B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM;YACnC,OAAO,SAAS,CAAC;QAEnB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAErB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,KAAa;QAC3B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM;YACnC,OAAO,SAAS,CAAC;;YAEjB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,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 { OrderedComparator } from \"./Compare\";\r\nimport { CloneFunction, shallowClone } from \"./SortedArray\";\r\n\r\n/** @public */\r\nexport type ComputePriorityFunction<T> = (value: T) => number;\r\n\r\n/**\r\n * A [priority queue](https://en.wikipedia.org/wiki/Priority_queue) implemented as a heap array.\r\n * The queue is ordered by an [[OrderedComparator]] function supplied by the user such that the value in the queue that compares less than all other values is always located at the front of the queue.\r\n * @public\r\n */\r\nexport class PriorityQueue<T> implements Iterable<T> {\r\n protected _array: T[] = [];\r\n protected readonly _compare: OrderedComparator<T>;\r\n protected readonly _clone: CloneFunction<T>;\r\n\r\n /**\r\n * Constructor\r\n * @param compare The function used to compare values in the queue. If `compare(x, y)` returns a negative value, then x is placed before y in the queue.\r\n * @param clone The function used to clone a value for insertion onto the queue. The default implementation simply returns its input.\r\n * @note If the criterion which control the result of the `compare` function changes, then [[PriorityQueue.sort]] should be used to reorder the queue according to the new criterion.\r\n */\r\n public constructor(compare: OrderedComparator<T>, clone: CloneFunction<T> = shallowClone) {\r\n this._compare = compare;\r\n this._clone = clone;\r\n }\r\n\r\n /** The number of values in the queue. */\r\n public get length(): number { return this._array.length; }\r\n\r\n /** Returns true if the queue contains no values. */\r\n public get isEmpty(): boolean { return 0 === this.length; }\r\n\r\n /** Returns an iterator over the contents of the heap suitable for use in `for-of` loops. */\r\n public [Symbol.iterator](): Iterator<T> { return this._array[Symbol.iterator](); }\r\n\r\n protected _swap(a: number, b: number) {\r\n const temp = this._array[a];\r\n this._array[a] = this._array[b];\r\n this._array[b] = temp;\r\n }\r\n\r\n protected _heapify(index: number): void {\r\n let candidate = -1;\r\n while (true) {\r\n const right = 2 * (index + 1);\r\n const left = right - 1;\r\n if (left < this.length && this._compare(this._array[left], this._array[index]) < 0)\r\n candidate = left;\r\n else\r\n candidate = index;\r\n\r\n if (right < this.length && this._compare(this._array[right], this._array[candidate]) < 0)\r\n candidate = right;\r\n\r\n if (candidate !== index) {\r\n this._swap(candidate, index);\r\n index = candidate;\r\n } else {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Reorders the queue. This function should only (and *always*) be called when the criteria governing the ordering of items on the queue have changed.\r\n * For example, a priority queue containing graphics sorted by their distance from the camera would need to be reordered when the position of the camera changes.\r\n */\r\n public sort(): void {\r\n for (let i = Math.ceil(this.length / 2); i >= 0; i--)\r\n this._heapify(i);\r\n }\r\n\r\n /**\r\n * Pushes a value onto the queue according to the sorting criterion.\r\n * @param value The value to insert\r\n * @returns The inserted value, cloned according to the [[CloneFunction]] supplied to this queue's constructor.\r\n */\r\n public push(value: T): T {\r\n const clone = this._clone(value);\r\n\r\n let index = this.length;\r\n this._array.push(clone);\r\n\r\n while (index !== 0) {\r\n const parent = Math.floor((index - 1) / 2);\r\n if (this._compare(this._array[index], this._array[parent]) < 0) {\r\n this._swap(index, parent);\r\n index = parent;\r\n } else {\r\n break;\r\n }\r\n }\r\n\r\n return clone;\r\n }\r\n\r\n /** Pushes a value onto the back of the queue without making any attempt to enforce ordering.\r\n * After using this function, you must manually invoke sort() to ensure the queue is sorted again.\r\n * @param value The value to append\r\n * @returns The appended value, cloned according to the [[CloneFunction]] supplied to this queue's constructor.\r\n */\r\n public append(value: T): T {\r\n const clone = this._clone(value);\r\n this._array.push(clone);\r\n return clone;\r\n }\r\n\r\n /** Returns the element at the front of the queue, or `undefined` if the queue is empty. */\r\n public get front(): T | undefined {\r\n return this._peek(0);\r\n }\r\n\r\n /**\r\n * Removes the front-most element off of the queue and returns it.\r\n * @returns The front-most element, or undefined if the queue is empty.\r\n */\r\n public pop(): T | undefined {\r\n return this._pop(0);\r\n }\r\n\r\n /** Removes all values from the queue. */\r\n public clear(): void {\r\n this._array.length = 0;\r\n }\r\n\r\n /**\r\n * Removes the value at the specified index from the queue and reorders the queue.\r\n * @param index The index of the value to remove\r\n * @returns the value at the specified index, or undefined if the index is out of range.\r\n */\r\n protected _pop(index: number): T | undefined {\r\n if (index < 0 || index >= this.length)\r\n return undefined;\r\n\r\n const root = this._array[index];\r\n this._swap(index, this.length - 1);\r\n this._array.length--;\r\n\r\n this._heapify(index);\r\n return root;\r\n }\r\n\r\n /**\r\n * Returns the value at the specified index in the queue.\r\n * @param index The index of the value to retrieve\r\n * @returns the value at the specified index, or undefined if the index is out of range.\r\n */\r\n protected _peek(index: number): T | undefined {\r\n if (index < 0 || index >= this.length)\r\n return undefined;\r\n else\r\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AAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAErI,gEAAgE;IACzD,MAAM,KAAK,eAAe,KAAK,OAAO,IAAI,CAAC,aAAa,IAAK,OAAO,CAAC,QAAgB,KAAK,KAAK,CAAC,CAAC,CAAC;IAEzG,oEAAoE;IAC7D,MAAM,KAAK,mBAAmB,KAAK,OAAO,IAAI,CAAC,aAAa,IAAK,OAAO,CAAC,QAAgB,KAAK,SAAS,CAAC,CAAC,CAAC;IAEjH,6CAA6C;IACtC,MAAM,KAAK,kBAAkB,KAAK,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAEnG,yEAAyE;IAClE,MAAM,KAAK,mBAAmB,KAAK,OAAO,IAAI,CAAC,qBAAqB,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;CAC3G","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ProcessDetector\n */\n\n/** Functions to determine the type of JavaScript process currently executing.\n * @public\n */\nexport class ProcessDetector {\n\n /** Is this a browser process?\n * @note this method will also return `true` for the frontend of Electron or Mobile apps. They *are* browser processes.\n */\n public static get isBrowserProcess() { return typeof window === \"object\" && typeof window.navigator === \"object\"; }\n\n /** Is this a Node process?\n * @note this means \"is this a backend process\"? It will return `true` for all backend process, including Electron and mobile apps.\n */\n public static get isNodeProcess() { return typeof process === \"object\" && undefined !== process.platform; }\n\n /** Is this process the frontend of an Electron app? */\n public static get isElectronAppFrontend() { return typeof navigator === \"object\" && navigator.userAgent.toLowerCase().indexOf(\"electron\") >= 0; }\n\n /** Is this process the backend of an Electron app? */\n public static get isElectronAppBackend() { return typeof process === \"object\" && process.versions.hasOwnProperty(\"electron\"); }\n\n /** Is this process running in an Internet Explorer or old Microsoft Edge browser? */\n public static get isIEBrowser() { return !!(document as any).documentMode || !!(window as any).StyleMedia; }\n\n /** Is this process running in a browser on an iPad?\n * @note This method will return `true` for any frontend running on an iPad, whether it is a user-launched web browser (e.g. Safari) or the frontend of a mobile app.\n */\n public static get isIPadBrowser() {\n return this.isBrowserProcess && window.navigator.platform === \"iPad\" || (window.navigator.platform === \"MacIntel\" && window.navigator.maxTouchPoints > 0 && !(\"MSStream\" in window)); /* eslint-disable-line @typescript-eslint/no-deprecated */\n }\n\n /** Is this process running in a browser on an iPhone?\n * @note This method will return `true` for any frontend running on an iPhone, whether it is a user-launched web browser (e.g. Safari) or the frontend of a mobile app.\n */\n public static get isIPhoneBrowser() { return this.isBrowserProcess && (/(iphone|ipod)/i.test(window.navigator.userAgent)); }\n\n /** Is this process running in a browser on an iOS device?\n * @note This method will return `true` for any frontend running on an iOS device, whether it is a user-launched web browser (e.g. Safari) or the frontend of a mobile app.\n */\n public static get isIOSBrowser() { return this.isIPadBrowser || this.isIPhoneBrowser; }\n\n /** Is this process running in a browser on an Android device?\n * @note This method will return `true` for any frontend running on an Android device, whether it is a user-launched web browser (e.g. Chrome) or the frontend of a mobile app.\n */\n public static get isAndroidBrowser() { return this.isBrowserProcess && /android/i.test(window.navigator.userAgent); }\n\n /** Is this process running in a browser on a mobile device?\n * @note This method will return `true` for any frontend running on a mobile device, whether it is a user-launched web browser or the frontend of a mobile app.\n */\n public static get isMobileBrowser() { return this.isIOSBrowser || this.isAndroidBrowser; }\n\n /** Is this process running in a Chromium based browser (Chrome / new Edge / Electron front end)? */\n public static get isChromium() {\n return (this.isBrowserProcess && window.navigator.userAgent.indexOf(\"Chrome\") > -1 && window.navigator.userAgent.indexOf(\"OP\") === -1) || this.isElectronAppFrontend;\n }\n\n /** Is this process the frontend of an iTwin mobile application?\n * @note this indicates that this is a browser process started by an iTwin mobile application.\n * It will return `false` when running user-launched web browsers on a mobile device.\n */\n public static get isMobileAppFrontend() { return this.isAndroidAppFrontend || this.isIOSAppFrontend; }\n\n /** Is this process the frontend of an iOS mobile application? */\n public static get isIOSAppFrontend() { return this.isBrowserProcess && window.location.hash.indexOf(\"platform=ios\") !== -1; }\n\n /** Is this process the frontend of an Android mobile application? */\n public static get isAndroidAppFrontend() { return this.isBrowserProcess && window.location.hash.indexOf(\"platform=android\") !== -1; }\n\n /** Is this process the backend of an iOS mobile application? */\n public static get isIOSAppBackend() { return this.isNodeProcess && (process.platform as any) === \"ios\"; }\n\n /** Is this process the backend of an Android mobile application? */\n public static get isAndroidAppBackend() { return this.isNodeProcess && (process.platform as any) === \"android\"; }\n\n /** Is this process a mobile app backend? */\n public static get isMobileAppBackend() { return this.isIOSAppBackend || this.isAndroidAppBackend; }\n\n /** Is this process the frontend of a native (Electron or Mobile) app? */\n public static get isNativeAppFrontend() { return this.isElectronAppFrontend || this.isMobileAppFrontend; }\n}\n"]}
1
+ {"version":3,"file":"ProcessDetector.js","sourceRoot":"","sources":["../../src/ProcessDetector.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH;;GAEG;AACH,MAAM,OAAO,eAAe;IAE1B;;OAEG;IACI,MAAM,KAAK,gBAAgB,KAAK,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC;IAEnH;;MAEE;IACK,MAAM,KAAK,aAAa,KAAK,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,SAAS,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE3G,uDAAuD;IAChD,MAAM,KAAK,qBAAqB,KAAK,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEjJ,sDAAsD;IAC/C,MAAM,KAAK,oBAAoB,KAAK,OAAO,OAAO,OAAO,KA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AC,IAAI,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,qBAAqB,CAAC;IACvK,CAAC;IAED;;;OAGG;IACI,MAAM,KAAK,mBAAmB,KAAK,OAAO,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEtG,iEAAiE;IAC1D,MAAM,KAAK,gBAAgB,KAAK,OAAO,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7H,qEAAqE;IAC9D,MAAM,KAAK,oBAAoB,KAAK,OAAO,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAErI,gEAAgE;IACzD,MAAM,KAAK,eAAe,KAAK,OAAO,IAAI,CAAC,aAAa,IAAK,OAAO,CAAC,QAAgB,KAAK,KAAK,CAAC,CAAC,CAAC;IAEzG,oEAAoE;IAC7D,MAAM,KAAK,mBAAmB,KAAK,OAAO,IAAI,CAAC,aAAa,IAAK,OAAO,CAAC,QAAgB,KAAK,SAAS,CAAC,CAAC,CAAC;IAEjH,6CAA6C;IACtC,MAAM,KAAK,kBAAkB,KAAK,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAEnG,yEAAyE;IAClE,MAAM,KAAK,mBAAmB,KAAK,OAAO,IAAI,CAAC,qBAAqB,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;CAC3G","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 ProcessDetector\r\n */\r\n\r\n/** Functions to determine the type of JavaScript process currently executing.\r\n * @public\r\n */\r\nexport class ProcessDetector {\r\n\r\n /** Is this a browser process?\r\n * @note this method will also return `true` for the frontend of Electron or Mobile apps. They *are* browser processes.\r\n */\r\n public static get isBrowserProcess() { return typeof window === \"object\" && typeof window.navigator === \"object\"; }\r\n\r\n /** Is this a Node process?\r\n * @note this means \"is this a backend process\"? It will return `true` for all backend process, including Electron and mobile apps.\r\n */\r\n public static get isNodeProcess() { return typeof process === \"object\" && undefined !== process.platform; }\r\n\r\n /** Is this process the frontend of an Electron app? */\r\n public static get isElectronAppFrontend() { return typeof navigator === \"object\" && navigator.userAgent.toLowerCase().indexOf(\"electron\") >= 0; }\r\n\r\n /** Is this process the backend of an Electron app? */\r\n public static get isElectronAppBackend() { return typeof process === \"object\" && process.versions.hasOwnProperty(\"electron\"); }\r\n\r\n /** Is this process running in an Internet Explorer or old Microsoft Edge browser? */\r\n public static get isIEBrowser() { return !!(document as any).documentMode || !!(window as any).StyleMedia; }\r\n\r\n /** Is this process running in a browser on an iPad?\r\n * @note This method will return `true` for any frontend running on an iPad, whether it is a user-launched web browser (e.g. Safari) or the frontend of a mobile app.\r\n */\r\n public static get isIPadBrowser() {\r\n return this.isBrowserProcess && window.navigator.platform === \"iPad\" || (window.navigator.platform === \"MacIntel\" && window.navigator.maxTouchPoints > 0 && !(\"MSStream\" in window)); /* eslint-disable-line @typescript-eslint/no-deprecated */\r\n }\r\n\r\n /** Is this process running in a browser on an iPhone?\r\n * @note This method will return `true` for any frontend running on an iPhone, whether it is a user-launched web browser (e.g. Safari) or the frontend of a mobile app.\r\n */\r\n public static get isIPhoneBrowser() { return this.isBrowserProcess && (/(iphone|ipod)/i.test(window.navigator.userAgent)); }\r\n\r\n /** Is this process running in a browser on an iOS device?\r\n * @note This method will return `true` for any frontend running on an iOS device, whether it is a user-launched web browser (e.g. Safari) or the frontend of a mobile app.\r\n */\r\n public static get isIOSBrowser() { return this.isIPadBrowser || this.isIPhoneBrowser; }\r\n\r\n /** Is this process running in a browser on an Android device?\r\n * @note This method will return `true` for any frontend running on an Android device, whether it is a user-launched web browser (e.g. Chrome) or the frontend of a mobile app.\r\n */\r\n public static get isAndroidBrowser() { return this.isBrowserProcess && /android/i.test(window.navigator.userAgent); }\r\n\r\n /** Is this process running in a browser on a mobile device?\r\n * @note This method will return `true` for any frontend running on a mobile device, whether it is a user-launched web browser or the frontend of a mobile app.\r\n */\r\n public static get isMobileBrowser() { return this.isIOSBrowser || this.isAndroidBrowser; }\r\n\r\n /** Is this process running in a Chromium based browser (Chrome / new Edge / Electron front end)? */\r\n public static get isChromium() {\r\n return (this.isBrowserProcess && window.navigator.userAgent.indexOf(\"Chrome\") > -1 && window.navigator.userAgent.indexOf(\"OP\") === -1) || this.isElectronAppFrontend;\r\n }\r\n\r\n /** Is this process the frontend of an iTwin mobile application?\r\n * @note this indicates that this is a browser process started by an iTwin mobile application.\r\n * It will return `false` when running user-launched web browsers on a mobile device.\r\n */\r\n public static get isMobileAppFrontend() { return this.isAndroidAppFrontend || this.isIOSAppFrontend; }\r\n\r\n /** Is this process the frontend of an iOS mobile application? */\r\n public static get isIOSAppFrontend() { return this.isBrowserProcess && window.location.hash.indexOf(\"platform=ios\") !== -1; }\r\n\r\n /** Is this process the frontend of an Android mobile application? */\r\n public static get isAndroidAppFrontend() { return this.isBrowserProcess && window.location.hash.indexOf(\"platform=android\") !== -1; }\r\n\r\n /** Is this process the backend of an iOS mobile application? */\r\n public static get isIOSAppBackend() { return this.isNodeProcess && (process.platform as any) === \"ios\"; }\r\n\r\n /** Is this process the backend of an Android mobile application? */\r\n public static get isAndroidAppBackend() { return this.isNodeProcess && (process.platform as any) === \"android\"; }\r\n\r\n /** Is this process a mobile app backend? */\r\n public static get isMobileAppBackend() { return this.isIOSAppBackend || this.isAndroidAppBackend; }\r\n\r\n /** Is this process the frontend of a native (Electron or Mobile) app? */\r\n public static get isNativeAppFrontend() { return this.isElectronAppFrontend || this.isMobileAppFrontend; }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SortedArray.js","sourceRoot":"","sources":["../../src/SortedArray.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAWH;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAI,KAAQ;IACtC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAW,KAAQ,EAAE,IAAS,EAAE,OAAgC;IACxF,OAAO,sBAAsB,CAAC,IAAI,EAAE,CAAC,OAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,sBAAsB,CAAI,IAAS,EAAE,SAAiC;IAC7E,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;IACvB,OAAO,GAAG,GAAG,IAAI,EAAE,CAAC;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,IAAI;YACZ,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;aAChC,IAAI,IAAI,GAAG,CAAC;YACf,IAAI,GAAG,GAAG,CAAC;;YAEX,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,eAWX;AAXD,WAAY,eAAe;IACzB;;OAEG;IACH,uDAAK,CAAA;IACL,mJAAm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D,qIAAqI;IACrH,KAAK,CAAC,KAAc,EAAE,GAAY;QAChD,MAAM,KAAK,GAAG,IAAI,WAAW,CAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACpF,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Collections\n */\n\nimport { OrderedComparator } from \"./Compare\";\n\n/**\n * A function that, given a value of type T, returns a copy of that value. Such functions are used by various collection classes.\n * It is up to the function to decide how deeply or shallowly the value is cloned. For example, [[shallowClone]] simply returns the input.\n * @public\n */\nexport type CloneFunction<T> = (value: T) => T;\n\n/**\n * A [[CloneFunction]] that, given a value of type T, returns the same value.\n * Useful as a default argument for functions that can alternatively accept custom logic for cloning values of object type.\n * @param value The value to clone.\n * @returns the input value.\n * @public\n */\nexport function shallowClone<T>(value: T) {\n return value;\n}\n\n/**\n * Given a sorted array, computes the position at which the specified value should be inserted into the array so that the array remains sorted.\n * @param value The value whose position is to be computed.\n * @param list An array of U already sorted according to the comparison criterion.\n * @param compare The function used to compare the value with elements in `list`.\n * @returns an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent element already exists at that index.\n * @public\n */\nexport function lowerBound<T, U = T>(value: T, list: U[], compare: OrderedComparator<T, U>): { index: number, equal: boolean } {\n return lowerBoundOfEquivalent(list, (element: U) => compare(value, element));\n}\n\nfunction lowerBoundOfEquivalent<T>(list: T[], criterion: (element: T) => number): { index: number, equal: boolean } {\n let low = 0;\n let high = list.length;\n while (low < high) {\n const mid = Math.floor((low + high) / 2);\n const comp = criterion(list[mid]);\n if (0 === comp)\n return { index: mid, equal: true };\n else if (comp < 0)\n high = mid;\n else\n low = mid + 1;\n }\n\n return { index: low, equal: false };\n}\n\n/** Describes how duplicate values are handled when inserting into a [[SortedArray]].\n * A \"duplicate\" value is one that compares equal to a value already present in the array, per the array's comparison function.\n * @public\n */\nexport enum DuplicatePolicy {\n /** The array allows duplicate values to be inserted. All duplicate values will be adjacent in the array, but the ordering between duplicate values is unspecified.\n * @note In the presence of duplicate values, functions like [[SortedArray.indexOf]] and [[SortedArray.findEqual]] will return one of the values - exactly which one is unspecified.\n */\n Allow,\n /** Duplicate values are forbidden - when attempting to insert a value equivalent to one already present, the already-present value is retained. */\n Retain,\n /** Duplicate values are forbidden - when attempting to insert a value equivalent to one already present, the already-present value is replaced by the new value.\n * This can be useful when the value type carries additional data that is not evaluated by the comparison function.\n */\n Replace,\n}\n\n/**\n * A read-only view of an array of some type T sorted according to some user-supplied criterion.\n * Duplicate elements may be present, though sub-types may enforce uniqueness of elements.\n * In the absence of duplicates, a ReadonlySortedArray<T> can behave like a Set<T> where T is an object and equality is determined\n * by some criterion other than object identity.\n *\n * Because the array is always sorted, querying for the presence of an element is performed using binary\n * search, which is more efficient than a linear search for reasonably large arrays.\n *\n * The comparison function must meet the following criteria, given 'lhs' and 'rhs' of type T:\n * - If lhs is equal to rhs, returns 0\n * - If lhs is less than rhs, returns a negative value\n * - If lhs is greater than rhs, returns a positive value\n * - If compare(lhs, rhs) returns 0, then compare(rhs, lhs) must also return 0\n * - If compare(lhs, rhs) returns a negative value, then compare(rhs, lhs) must return a positive value, and vice versa.\n *\n * Note that the array is read-only only from the perspective of its public interface. Mutation methods are defined for internal use by sub-types.\n *\n * @see [[SortedArray]] for a general-purpose mutable sorted array.\n * @public\n */\nexport class ReadonlySortedArray<T> implements Iterable<T> {\n protected _array: T[] = [];\n protected readonly _compare: OrderedComparator<T>;\n protected readonly _clone: CloneFunction<T>;\n protected readonly _duplicatePolicy: DuplicatePolicy;\n\n /**\n * Construct a new ReadonlySortedArray<T>.\n * @param compare The function used to compare elements within the array.\n * @param duplicatePolicy Policy for handling attempts to insert a value when an equivalent value already exists. If the input is a boolean, then `true` indicates [[DuplicatePolicy.Allow]], and `false` indicates [[DuplicatePolicy.Retain]].\n * @param clone The function invoked to clone a new element for insertion into the array. The default implementation simply returns its input.\n */\n protected constructor(compare: OrderedComparator<T>, duplicatePolicy: DuplicatePolicy | boolean = false, clone: CloneFunction<T> = shallowClone) {\n this._compare = compare;\n this._clone = clone;\n if (typeof duplicatePolicy === \"boolean\")\n duplicatePolicy = duplicatePolicy ? DuplicatePolicy.Allow : DuplicatePolicy.Retain;\n\n this._duplicatePolicy = duplicatePolicy;\n }\n\n /** The number of elements in the array */\n public get length(): number { return this._array.length; }\n\n /** Returns true if the array contains no elements. */\n public get isEmpty(): boolean { return 0 === this.length; }\n\n /** Returns an iterator over the contents of the array in sorted order, suitable for use in `for-of` loops. */\n public [Symbol.iterator](): Iterator<T> { return this._array[Symbol.iterator](); }\n\n /**\n * Looks up the index of an element comparing equal to the specified value using binary search.\n * @param value The value to search for\n * @returns the index of the first equivalent element found in the array, or -1 if no such element exists.\n */\n public indexOf(value: T): number {\n const bound = this.lowerBound(value);\n return bound.equal ? bound.index : -1;\n }\n\n /**\n * Returns true if this array contains at least one value comparing equal to the specified value.\n * @param value The value to search for\n * @returns true if an equivalent element exists in the array.\n */\n public contains(value: T): boolean {\n return -1 !== this.indexOf(value);\n }\n\n /**\n * Looks up an element comparing equal to the specified value using binary search.\n * @param value The value to search for\n * @returns the first equivalent element found in the array, or undefined if no such element exists.\n */\n public findEqual(value: T): T | undefined {\n const index = this.indexOf(value);\n return -1 !== index ? this._array[index] : undefined;\n }\n\n /** Find an element that compares as equivalent based on some criterion. If multiple elements are equivalent, the specific one returned is unspecified.\n * As an example, consider a `SortedArray<ModelState>` which uses `ModelState.id` as its ordering criterion. To find a model by its Id,\n * use `sortedArray.findEquivalent((element) => compareStrings(element.id, modelId))` where `modelId` is an [[Id64String]].\n * @param criterion A function accepting an element and returning 0 if it compares as equivalent, a negative number if it compares as \"less-than\", or a positive value if it compares as \"greater-than\".\n * @returns The first element found that meets the criterion, or `undefined` if no elements meet the criterion.\n * @see [[indexOfEquivalent]].\n * @public\n */\n public findEquivalent(criterion: (element: T) => number): T | undefined {\n const index = this.indexOfEquivalent(criterion);\n return -1 !== index ? this._array[index] : undefined;\n }\n\n /** Find the index of an element that compares as equivalent based on some criterion. If multiple elements are equivalent, the specific one returned is unspecified.\n * As an example, consider a `SortedArray<ModelState>` which uses `ModelState.id` as its ordering criterion. To find the index of a model by its Id,\n * use `sortedArray.indexOfEquivalent((element) => compareStrings(element.id, modelId))` where `modelId` is an [[Id64String]].\n * @param criterion A function accepting an element and returning 0 if it compares as equivalent, a negative number if the element compares as \"less-than\", or a positive value if the element compares as \"greater-than\".\n * @returns The index of the first element found that meets the criterion, or -1 if no elements meet the criterion.\n * @public\n */\n public indexOfEquivalent(criterion: (element: T) => number): number {\n // NB: Must invert the ordering.\n const bound = lowerBoundOfEquivalent(this._array, (elem: T) => 0 - criterion(elem));\n return bound.equal ? bound.index : -1;\n }\n\n /**\n * Looks up an element by its index in the array.\n * @param index The array index\n * @returns the element corresponding to that position in the array, or undefined if the supplied index exceeds the length of the array.\n */\n public get(index: number): T | undefined { return index < this.length ? this._array[index] : undefined; }\n\n /** Apply a function to each element in the array, in sorted order.\n * @param func The function to be applied.\n */\n public forEach(func: (value: T) => void): void {\n for (let i = 0; i < this.length; i++)\n func(this._array[i]);\n }\n\n /** The equivalent of [Array.slice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice). */\n public slice(start?: number, end?: number): ReadonlySortedArray<T> {\n const slice = new ReadonlySortedArray<T>(this._compare, this._duplicatePolicy, this._clone);\n slice._array = this._array.slice(start, end);\n return slice;\n }\n\n /**\n * Computes the position at which the specified value should be inserted to maintain sorted order.\n * @param value The value whose position is to be computed.\n * @returns an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent element already exists at that index.\n */\n protected lowerBound(value: T): { index: number, equal: boolean } { return lowerBound(value, this._array, this._compare); }\n\n /** Clears the contents of the sorted array. */\n protected _clear(): void { this._array.length = 0; }\n\n /** Extracts the sorted array as a T[] and empties the contents of this ReadonlySortedArray.\n * @returns the contents of this ReadonlySortedArray as a T[].\n */\n protected _extractArray(): T[] {\n const result = this._array;\n this._array = [];\n return result;\n }\n\n /**\n * Attempts to insert a new value into the array at a position determined by the ordering.\n * The behavior differs based on the array's [[DuplicatePolicy]]:\n * If duplicates are **not** permitted, then:\n * - If an equivalent element already exists in the array:\n * - [[DuplicatePolicy.Retain]]: nothing will be inserted and the index of the existing element will be returned.\n * - [[DuplicatePolicy.Replace]]: the input value will overwrite the existing element at the same index and that index will be returned.\n * - Otherwise, the element is inserted and its index is returned.\n * If duplicates **are** permitted, then:\n * - The element will be inserted in a correct position based on the sorting criterion;\n * - The position of the element relative to other elements comparing as equal to it is unspecified; and\n * - The actual index of the newly-inserted element is returned.\n * If the element is to be inserted, then the supplied value will be passed to the clone function supplied to the constructor and the result will be inserted into the array.\n * @param value The value to insert\n * @param onInsert The optional callback method to call if insertion occurs with the inserted value\n * @returns the index in the array of the newly-inserted value, or, if duplicates are not permitted and an equivalent value already exists, the index of the equivalent value.\n */\n protected _insert(value: T, onInsert?: (value: T) => any): number {\n const bound = this.lowerBound(value);\n\n if (bound.equal) {\n switch (this._duplicatePolicy) {\n case DuplicatePolicy.Retain:\n return bound.index;\n case DuplicatePolicy.Replace:\n this._array[bound.index] = this._clone(value);\n if (onInsert)\n onInsert(value);\n\n return bound.index;\n }\n }\n\n this._array.splice(bound.index, 0, this._clone(value));\n if (undefined !== onInsert)\n onInsert(value);\n\n return bound.index;\n }\n\n /**\n * Removes the first occurrence of a value comparing equal to the specified value from the array.\n * @param value The value of the element to delete\n * @returns the index of the deleted value, or -1 if no such element exists.\n */\n protected _remove(value: T): number {\n const bound = this.lowerBound(value);\n if (bound.equal) {\n this._array.splice(bound.index, 1);\n return bound.index;\n } else {\n return -1;\n }\n }\n}\n\n/**\n * Maintains an array of some type T in sorted order. The ordering is specified by a function supplied\n * by the user.\n * By default, only unique elements are permitted; attempting to insert a new element that compares\n * as equal to an element already in the array will not modify the contents of the array.\n *\n * This allows a SortedArray<T> to behave like a Set<T> where T is an object and equality is determined\n * by some criterion other than object identity.\n *\n * Because the array is always sorted, querying for the presence of an element is performed using binary\n * search, which is more efficient than a linear search for reasonably large arrays.\n *\n * The user can also specify how the SortedArray takes ownership of inserted values, e.g., by cloning them.\n *\n * The comparison function must meet the following criteria, given 'lhs' and 'rhs' of type T:\n * - If lhs is equal to rhs, returns 0\n * - If lhs is less than rhs, returns a negative value\n * - If lhs is greater than rhs, returns a positive value\n * - If compare(lhs, rhs) returns 0, then compare(rhs, lhs) must also return 0\n * - If compare(lhs, rhs) returns a negative value, then compare(rhs, lhs) must return a positive value, and vice versa.\n *\n * Modifying an element in a way that affects the comparison function will produce unpredictable results, the\n * most likely of which is that the array will cease to be sorted.\n * @public\n */\nexport class SortedArray<T> extends ReadonlySortedArray<T> {\n /**\n * Construct a new SortedArray<T>.\n * @param compare The function used to compare elements within the array.\n * @param duplicatePolicy Policy for handling attempts to insert a value when an equivalent value already exists. If the input is a boolean, then `true` indicates [[DuplicatePolicy.Allow]], and `false` indicates [[DuplicatePolicy.Retain]].\n * @param clone The function invoked to clone a new element for insertion into the array. The default implementation simply returns its input.\n */\n public constructor(compare: OrderedComparator<T>, duplicatePolicy: DuplicatePolicy | boolean = false, clone: CloneFunction<T> = shallowClone) {\n super(compare, duplicatePolicy, clone);\n }\n\n /** Clears the contents of the sorted array. */\n public clear(): void { this._clear(); }\n\n /** Extracts the sorted array as a T[] and empties the contents of this SortedArray.\n * @returns the contents of this SortedArray as a T[].\n */\n public extractArray(): T[] { return this._extractArray(); }\n\n /**\n * Attempts to insert a new value into the array at a position determined by the ordering.\n * The behavior differs based on whether or not duplicate elements are permitted.\n * If duplicates are **not** permitted, then:\n * - If an equivalent element already exists in the array, nothing will be inserted and the index of the existing element will be returned.\n * - Otherwise, the element is inserted and its index is returned.\n * If duplicates **are** permitted, then:\n * - The element will be inserted in a correct position based on the sorting criterion;\n * - The position of the element relative to other elements comparing as equal to it is unspecified; and\n * - The actual index of the newly-inserted element is returned.\n * If the element is to be inserted, then the supplied value will be passed to the clone function supplied to the constructor and the result will be inserted into the array.\n * @param value The value to insert\n * @param onInsert The optional callback method to call if insertion occurs with the inserted value\n * @returns the index in the array of the newly-inserted value, or, if duplicates are not permitted and an equivalent value already exists, the index of the equivalent value.\n */\n public insert(value: T, onInsert?: (value: T) => any): number { return this._insert(value, onInsert); }\n\n /**\n * Removes the first occurrence of a value comparing equal to the specified value from the array.\n * @param value The value of the element to delete\n * @returns the index of the deleted value, or -1 if no such element exists.\n */\n public remove(value: T): number { return this._remove(value); }\n\n /** The equivalent of [Array.slice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice). */\n public override slice(start?: number, end?: number): SortedArray<T> {\n const slice = new SortedArray<T>(this._compare, this._duplicatePolicy, this._clone);\n slice._array = this._array.slice(start, end);\n return slice;\n }\n}\n"]}
1
+ {"version":3,"file":"SortedArray.js","sourceRoot":"","sources":["../../src/SortedArray.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAWH;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAI,KAAQ;IACtC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAW,KAAQ,EAAE,IAAS,EAAE,OAAgC;IACxF,OAAO,sBAAsB,CAAC,IAAI,EAAE,CAAC,OAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,sBAAsB,CAAI,IAAS,EAAE,SAAiC;IAC7E,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,IAAI,GAAG,IAAI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AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,WAAe,SAAQ,mBAAsB;IACxD;;;;;OAKG;IACH,YAAmB,OAA6B,EAAE,kBAA6C,KAAK,EAAE,QAA0B,YAAY;QAC1I,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,+CAA+C;IACxC,KAAK,KAAW,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAEvC;;OAEG;IACI,YAAY,KAAU,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IAE3D;;;;;;;;;;;;;;OAcG;IACI,MAAM,CAAC,KAAQ,EAAE,QAA4B,IAAY,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEvG;;;;OAIG;IACI,MAAM,CAAC,KAAQ,IAAY,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE/D,qIAAqI;IACrH,KAAK,CAAC,KAAc,EAAE,GAAY;QAChD,MAAM,KAAK,GAAG,IAAI,WAAW,CAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACpF,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,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 { OrderedComparator } from \"./Compare\";\r\n\r\n/**\r\n * A function that, given a value of type T, returns a copy of that value. Such functions are used by various collection classes.\r\n * It is up to the function to decide how deeply or shallowly the value is cloned. For example, [[shallowClone]] simply returns the input.\r\n * @public\r\n */\r\nexport type CloneFunction<T> = (value: T) => T;\r\n\r\n/**\r\n * A [[CloneFunction]] that, given a value of type T, returns the same value.\r\n * Useful as a default argument for functions that can alternatively accept custom logic for cloning values of object type.\r\n * @param value The value to clone.\r\n * @returns the input value.\r\n * @public\r\n */\r\nexport function shallowClone<T>(value: T) {\r\n return value;\r\n}\r\n\r\n/**\r\n * Given a sorted array, computes the position at which the specified value should be inserted into the array so that the array remains sorted.\r\n * @param value The value whose position is to be computed.\r\n * @param list An array of U already sorted according to the comparison criterion.\r\n * @param compare The function used to compare the value with elements in `list`.\r\n * @returns an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent element already exists at that index.\r\n * @public\r\n */\r\nexport function lowerBound<T, U = T>(value: T, list: U[], compare: OrderedComparator<T, U>): { index: number, equal: boolean } {\r\n return lowerBoundOfEquivalent(list, (element: U) => compare(value, element));\r\n}\r\n\r\nfunction lowerBoundOfEquivalent<T>(list: T[], criterion: (element: T) => number): { index: number, equal: boolean } {\r\n let low = 0;\r\n let high = list.length;\r\n while (low < high) {\r\n const mid = Math.floor((low + high) / 2);\r\n const comp = criterion(list[mid]);\r\n if (0 === comp)\r\n return { index: mid, equal: true };\r\n else if (comp < 0)\r\n high = mid;\r\n else\r\n low = mid + 1;\r\n }\r\n\r\n return { index: low, equal: false };\r\n}\r\n\r\n/** Describes how duplicate values are handled when inserting into a [[SortedArray]].\r\n * A \"duplicate\" value is one that compares equal to a value already present in the array, per the array's comparison function.\r\n * @public\r\n */\r\nexport enum DuplicatePolicy {\r\n /** The array allows duplicate values to be inserted. All duplicate values will be adjacent in the array, but the ordering between duplicate values is unspecified.\r\n * @note In the presence of duplicate values, functions like [[SortedArray.indexOf]] and [[SortedArray.findEqual]] will return one of the values - exactly which one is unspecified.\r\n */\r\n Allow,\r\n /** Duplicate values are forbidden - when attempting to insert a value equivalent to one already present, the already-present value is retained. */\r\n Retain,\r\n /** Duplicate values are forbidden - when attempting to insert a value equivalent to one already present, the already-present value is replaced by the new value.\r\n * This can be useful when the value type carries additional data that is not evaluated by the comparison function.\r\n */\r\n Replace,\r\n}\r\n\r\n/**\r\n * A read-only view of an array of some type T sorted according to some user-supplied criterion.\r\n * Duplicate elements may be present, though sub-types may enforce uniqueness of elements.\r\n * In the absence of duplicates, a ReadonlySortedArray<T> can behave like a Set<T> where T is an object and equality is determined\r\n * by some criterion other than object identity.\r\n *\r\n * Because the array is always sorted, querying for the presence of an element is performed using binary\r\n * search, which is more efficient than a linear search for reasonably large arrays.\r\n *\r\n * The comparison function must meet the following criteria, given 'lhs' and 'rhs' of type T:\r\n * - If lhs is equal to rhs, returns 0\r\n * - If lhs is less than rhs, returns a negative value\r\n * - If lhs is greater than rhs, returns a positive value\r\n * - If compare(lhs, rhs) returns 0, then compare(rhs, lhs) must also return 0\r\n * - If compare(lhs, rhs) returns a negative value, then compare(rhs, lhs) must return a positive value, and vice versa.\r\n *\r\n * Note that the array is read-only only from the perspective of its public interface. Mutation methods are defined for internal use by sub-types.\r\n *\r\n * @see [[SortedArray]] for a general-purpose mutable sorted array.\r\n * @public\r\n */\r\nexport class ReadonlySortedArray<T> implements Iterable<T> {\r\n protected _array: T[] = [];\r\n protected readonly _compare: OrderedComparator<T>;\r\n protected readonly _clone: CloneFunction<T>;\r\n protected readonly _duplicatePolicy: DuplicatePolicy;\r\n\r\n /**\r\n * Construct a new ReadonlySortedArray<T>.\r\n * @param compare The function used to compare elements within the array.\r\n * @param duplicatePolicy Policy for handling attempts to insert a value when an equivalent value already exists. If the input is a boolean, then `true` indicates [[DuplicatePolicy.Allow]], and `false` indicates [[DuplicatePolicy.Retain]].\r\n * @param clone The function invoked to clone a new element for insertion into the array. The default implementation simply returns its input.\r\n */\r\n protected constructor(compare: OrderedComparator<T>, duplicatePolicy: DuplicatePolicy | boolean = false, clone: CloneFunction<T> = shallowClone) {\r\n this._compare = compare;\r\n this._clone = clone;\r\n if (typeof duplicatePolicy === \"boolean\")\r\n duplicatePolicy = duplicatePolicy ? DuplicatePolicy.Allow : DuplicatePolicy.Retain;\r\n\r\n this._duplicatePolicy = duplicatePolicy;\r\n }\r\n\r\n /** The number of elements in the array */\r\n public get length(): number { return this._array.length; }\r\n\r\n /** Returns true if the array contains no elements. */\r\n public get isEmpty(): boolean { return 0 === this.length; }\r\n\r\n /** Returns an iterator over the contents of the array in sorted order, suitable for use in `for-of` loops. */\r\n public [Symbol.iterator](): Iterator<T> { return this._array[Symbol.iterator](); }\r\n\r\n /**\r\n * Looks up the index of an element comparing equal to the specified value using binary search.\r\n * @param value The value to search for\r\n * @returns the index of the first equivalent element found in the array, or -1 if no such element exists.\r\n */\r\n public indexOf(value: T): number {\r\n const bound = this.lowerBound(value);\r\n return bound.equal ? bound.index : -1;\r\n }\r\n\r\n /**\r\n * Returns true if this array contains at least one value comparing equal to the specified value.\r\n * @param value The value to search for\r\n * @returns true if an equivalent element exists in the array.\r\n */\r\n public contains(value: T): boolean {\r\n return -1 !== this.indexOf(value);\r\n }\r\n\r\n /**\r\n * Looks up an element comparing equal to the specified value using binary search.\r\n * @param value The value to search for\r\n * @returns the first equivalent element found in the array, or undefined if no such element exists.\r\n */\r\n public findEqual(value: T): T | undefined {\r\n const index = this.indexOf(value);\r\n return -1 !== index ? this._array[index] : undefined;\r\n }\r\n\r\n /** Find an element that compares as equivalent based on some criterion. If multiple elements are equivalent, the specific one returned is unspecified.\r\n * As an example, consider a `SortedArray<ModelState>` which uses `ModelState.id` as its ordering criterion. To find a model by its Id,\r\n * use `sortedArray.findEquivalent((element) => compareStrings(element.id, modelId))` where `modelId` is an [[Id64String]].\r\n * @param criterion A function accepting an element and returning 0 if it compares as equivalent, a negative number if it compares as \"less-than\", or a positive value if it compares as \"greater-than\".\r\n * @returns The first element found that meets the criterion, or `undefined` if no elements meet the criterion.\r\n * @see [[indexOfEquivalent]].\r\n * @public\r\n */\r\n public findEquivalent(criterion: (element: T) => number): T | undefined {\r\n const index = this.indexOfEquivalent(criterion);\r\n return -1 !== index ? this._array[index] : undefined;\r\n }\r\n\r\n /** Find the index of an element that compares as equivalent based on some criterion. If multiple elements are equivalent, the specific one returned is unspecified.\r\n * As an example, consider a `SortedArray<ModelState>` which uses `ModelState.id` as its ordering criterion. To find the index of a model by its Id,\r\n * use `sortedArray.indexOfEquivalent((element) => compareStrings(element.id, modelId))` where `modelId` is an [[Id64String]].\r\n * @param criterion A function accepting an element and returning 0 if it compares as equivalent, a negative number if the element compares as \"less-than\", or a positive value if the element compares as \"greater-than\".\r\n * @returns The index of the first element found that meets the criterion, or -1 if no elements meet the criterion.\r\n * @public\r\n */\r\n public indexOfEquivalent(criterion: (element: T) => number): number {\r\n // NB: Must invert the ordering.\r\n const bound = lowerBoundOfEquivalent(this._array, (elem: T) => 0 - criterion(elem));\r\n return bound.equal ? bound.index : -1;\r\n }\r\n\r\n /**\r\n * Looks up an element by its index in the array.\r\n * @param index The array index\r\n * @returns the element corresponding to that position in the array, or undefined if the supplied index exceeds the length of the array.\r\n */\r\n public get(index: number): T | undefined { return index < this.length ? this._array[index] : undefined; }\r\n\r\n /** Apply a function to each element in the array, in sorted order.\r\n * @param func The function to be applied.\r\n */\r\n public forEach(func: (value: T) => void): void {\r\n for (let i = 0; i < this.length; i++)\r\n func(this._array[i]);\r\n }\r\n\r\n /** The equivalent of [Array.slice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice). */\r\n public slice(start?: number, end?: number): ReadonlySortedArray<T> {\r\n const slice = new ReadonlySortedArray<T>(this._compare, this._duplicatePolicy, this._clone);\r\n slice._array = this._array.slice(start, end);\r\n return slice;\r\n }\r\n\r\n /**\r\n * Computes the position at which the specified value should be inserted to maintain sorted order.\r\n * @param value The value whose position is to be computed.\r\n * @returns an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent element already exists at that index.\r\n */\r\n protected lowerBound(value: T): { index: number, equal: boolean } { return lowerBound(value, this._array, this._compare); }\r\n\r\n /** Clears the contents of the sorted array. */\r\n protected _clear(): void { this._array.length = 0; }\r\n\r\n /** Extracts the sorted array as a T[] and empties the contents of this ReadonlySortedArray.\r\n * @returns the contents of this ReadonlySortedArray as a T[].\r\n */\r\n protected _extractArray(): T[] {\r\n const result = this._array;\r\n this._array = [];\r\n return result;\r\n }\r\n\r\n /**\r\n * Attempts to insert a new value into the array at a position determined by the ordering.\r\n * The behavior differs based on the array's [[DuplicatePolicy]]:\r\n * If duplicates are **not** permitted, then:\r\n * - If an equivalent element already exists in the array:\r\n * - [[DuplicatePolicy.Retain]]: nothing will be inserted and the index of the existing element will be returned.\r\n * - [[DuplicatePolicy.Replace]]: the input value will overwrite the existing element at the same index and that index will be returned.\r\n * - Otherwise, the element is inserted and its index is returned.\r\n * If duplicates **are** permitted, then:\r\n * - The element will be inserted in a correct position based on the sorting criterion;\r\n * - The position of the element relative to other elements comparing as equal to it is unspecified; and\r\n * - The actual index of the newly-inserted element is returned.\r\n * If the element is to be inserted, then the supplied value will be passed to the clone function supplied to the constructor and the result will be inserted into the array.\r\n * @param value The value to insert\r\n * @param onInsert The optional callback method to call if insertion occurs with the inserted value\r\n * @returns the index in the array of the newly-inserted value, or, if duplicates are not permitted and an equivalent value already exists, the index of the equivalent value.\r\n */\r\n protected _insert(value: T, onInsert?: (value: T) => any): number {\r\n const bound = this.lowerBound(value);\r\n\r\n if (bound.equal) {\r\n switch (this._duplicatePolicy) {\r\n case DuplicatePolicy.Retain:\r\n return bound.index;\r\n case DuplicatePolicy.Replace:\r\n this._array[bound.index] = this._clone(value);\r\n if (onInsert)\r\n onInsert(value);\r\n\r\n return bound.index;\r\n }\r\n }\r\n\r\n this._array.splice(bound.index, 0, this._clone(value));\r\n if (undefined !== onInsert)\r\n onInsert(value);\r\n\r\n return bound.index;\r\n }\r\n\r\n /**\r\n * Removes the first occurrence of a value comparing equal to the specified value from the array.\r\n * @param value The value of the element to delete\r\n * @returns the index of the deleted value, or -1 if no such element exists.\r\n */\r\n protected _remove(value: T): number {\r\n const bound = this.lowerBound(value);\r\n if (bound.equal) {\r\n this._array.splice(bound.index, 1);\r\n return bound.index;\r\n } else {\r\n return -1;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Maintains an array of some type T in sorted order. The ordering is specified by a function supplied\r\n * by the user.\r\n * By default, only unique elements are permitted; attempting to insert a new element that compares\r\n * as equal to an element already in the array will not modify the contents of the array.\r\n *\r\n * This allows a SortedArray<T> to behave like a Set<T> where T is an object and equality is determined\r\n * by some criterion other than object identity.\r\n *\r\n * Because the array is always sorted, querying for the presence of an element is performed using binary\r\n * search, which is more efficient than a linear search for reasonably large arrays.\r\n *\r\n * The user can also specify how the SortedArray takes ownership of inserted values, e.g., by cloning them.\r\n *\r\n * The comparison function must meet the following criteria, given 'lhs' and 'rhs' of type T:\r\n * - If lhs is equal to rhs, returns 0\r\n * - If lhs is less than rhs, returns a negative value\r\n * - If lhs is greater than rhs, returns a positive value\r\n * - If compare(lhs, rhs) returns 0, then compare(rhs, lhs) must also return 0\r\n * - If compare(lhs, rhs) returns a negative value, then compare(rhs, lhs) must return a positive value, and vice versa.\r\n *\r\n * Modifying an element in a way that affects the comparison function will produce unpredictable results, the\r\n * most likely of which is that the array will cease to be sorted.\r\n * @public\r\n */\r\nexport class SortedArray<T> extends ReadonlySortedArray<T> {\r\n /**\r\n * Construct a new SortedArray<T>.\r\n * @param compare The function used to compare elements within the array.\r\n * @param duplicatePolicy Policy for handling attempts to insert a value when an equivalent value already exists. If the input is a boolean, then `true` indicates [[DuplicatePolicy.Allow]], and `false` indicates [[DuplicatePolicy.Retain]].\r\n * @param clone The function invoked to clone a new element for insertion into the array. The default implementation simply returns its input.\r\n */\r\n public constructor(compare: OrderedComparator<T>, duplicatePolicy: DuplicatePolicy | boolean = false, clone: CloneFunction<T> = shallowClone) {\r\n super(compare, duplicatePolicy, clone);\r\n }\r\n\r\n /** Clears the contents of the sorted array. */\r\n public clear(): void { this._clear(); }\r\n\r\n /** Extracts the sorted array as a T[] and empties the contents of this SortedArray.\r\n * @returns the contents of this SortedArray as a T[].\r\n */\r\n public extractArray(): T[] { return this._extractArray(); }\r\n\r\n /**\r\n * Attempts to insert a new value into the array at a position determined by the ordering.\r\n * The behavior differs based on whether or not duplicate elements are permitted.\r\n * If duplicates are **not** permitted, then:\r\n * - If an equivalent element already exists in the array, nothing will be inserted and the index of the existing element will be returned.\r\n * - Otherwise, the element is inserted and its index is returned.\r\n * If duplicates **are** permitted, then:\r\n * - The element will be inserted in a correct position based on the sorting criterion;\r\n * - The position of the element relative to other elements comparing as equal to it is unspecified; and\r\n * - The actual index of the newly-inserted element is returned.\r\n * If the element is to be inserted, then the supplied value will be passed to the clone function supplied to the constructor and the result will be inserted into the array.\r\n * @param value The value to insert\r\n * @param onInsert The optional callback method to call if insertion occurs with the inserted value\r\n * @returns the index in the array of the newly-inserted value, or, if duplicates are not permitted and an equivalent value already exists, the index of the equivalent value.\r\n */\r\n public insert(value: T, onInsert?: (value: T) => any): number { return this._insert(value, onInsert); }\r\n\r\n /**\r\n * Removes the first occurrence of a value comparing equal to the specified value from the array.\r\n * @param value The value of the element to delete\r\n * @returns the index of the deleted value, or -1 if no such element exists.\r\n */\r\n public remove(value: T): number { return this._remove(value); }\r\n\r\n /** The equivalent of [Array.slice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice). */\r\n public override slice(start?: number, end?: number): SortedArray<T> {\r\n const slice = new SortedArray<T>(this._compare, this._duplicatePolicy, this._clone);\r\n slice._array = this._array.slice(start, end);\r\n return slice;\r\n }\r\n}\r\n"]}