@itwin/core-bentley 5.1.0 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +11 -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/Id.js.map +1 -1
  15. package/lib/cjs/IndexMap.js.map +1 -1
  16. package/lib/cjs/JsonSchema.js.map +1 -1
  17. package/lib/cjs/JsonUtils.js.map +1 -1
  18. package/lib/cjs/LRUMap.js.map +1 -1
  19. package/lib/cjs/Logger.js.map +1 -1
  20. package/lib/cjs/ObservableSet.js.map +1 -1
  21. package/lib/cjs/OneAtATimeAction.js.map +1 -1
  22. package/lib/cjs/OrderedId64Iterable.js.map +1 -1
  23. package/lib/cjs/OrderedSet.js.map +1 -1
  24. package/lib/cjs/PriorityQueue.js.map +1 -1
  25. package/lib/cjs/ProcessDetector.js.map +1 -1
  26. package/lib/cjs/SortedArray.js.map +1 -1
  27. package/lib/cjs/StatusCategory.js.map +1 -1
  28. package/lib/cjs/StringUtils.js.map +1 -1
  29. package/lib/cjs/Time.js.map +1 -1
  30. package/lib/cjs/Tracing.js.map +1 -1
  31. package/lib/cjs/TupleKeyedMap.js.map +1 -1
  32. package/lib/cjs/TypedArrayBuilder.js.map +1 -1
  33. package/lib/cjs/UnexpectedErrors.js.map +1 -1
  34. package/lib/cjs/UtilityTypes.js.map +1 -1
  35. package/lib/cjs/YieldManager.js.map +1 -1
  36. package/lib/cjs/core-bentley.js.map +1 -1
  37. package/lib/cjs/internal/BeSQLiteInternal.js.map +1 -1
  38. package/lib/cjs/internal/RepositoryStatus.js.map +1 -1
  39. package/lib/cjs/internal/cross-package.js.map +1 -1
  40. package/lib/cjs/partitionArray.js.map +1 -1
  41. package/lib/esm/AccessToken.js.map +1 -1
  42. package/lib/esm/Assert.js.map +1 -1
  43. package/lib/esm/BeEvent.js.map +1 -1
  44. package/lib/esm/BeSQLite.js.map +1 -1
  45. package/lib/esm/BentleyError.js.map +1 -1
  46. package/lib/esm/BentleyLoggerCategory.js.map +1 -1
  47. package/lib/esm/ByteStream.js.map +1 -1
  48. package/lib/esm/ClassUtils.js.map +1 -1
  49. package/lib/esm/Compare.js.map +1 -1
  50. package/lib/esm/CompressedId64Set.js.map +1 -1
  51. package/lib/esm/Dictionary.js.map +1 -1
  52. package/lib/esm/Disposable.js.map +1 -1
  53. package/lib/esm/Id.js.map +1 -1
  54. package/lib/esm/IndexMap.js.map +1 -1
  55. package/lib/esm/JsonSchema.js.map +1 -1
  56. package/lib/esm/JsonUtils.js.map +1 -1
  57. package/lib/esm/LRUMap.js.map +1 -1
  58. package/lib/esm/Logger.js.map +1 -1
  59. package/lib/esm/ObservableSet.js.map +1 -1
  60. package/lib/esm/OneAtATimeAction.js.map +1 -1
  61. package/lib/esm/OrderedId64Iterable.js.map +1 -1
  62. package/lib/esm/OrderedSet.js.map +1 -1
  63. package/lib/esm/PriorityQueue.js.map +1 -1
  64. package/lib/esm/ProcessDetector.js.map +1 -1
  65. package/lib/esm/SortedArray.js.map +1 -1
  66. package/lib/esm/StatusCategory.js.map +1 -1
  67. package/lib/esm/StringUtils.js.map +1 -1
  68. package/lib/esm/Time.js.map +1 -1
  69. package/lib/esm/Tracing.js.map +1 -1
  70. package/lib/esm/TupleKeyedMap.js.map +1 -1
  71. package/lib/esm/TypedArrayBuilder.js.map +1 -1
  72. package/lib/esm/UnexpectedErrors.js.map +1 -1
  73. package/lib/esm/UtilityTypes.js.map +1 -1
  74. package/lib/esm/YieldManager.js.map +1 -1
  75. package/lib/esm/core-bentley.js.map +1 -1
  76. package/lib/esm/internal/BeSQLiteInternal.js.map +1 -1
  77. package/lib/esm/internal/RepositoryStatus.js.map +1 -1
  78. package/lib/esm/internal/cross-package.js.map +1 -1
  79. package/lib/esm/partitionArray.js.map +1 -1
  80. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"IndexMap.js","sourceRoot":"","sources":["../../src/IndexMap.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAAwE;AAExE;;GAEG;AACH,MAAa,YAAY;IACP,KAAK,CAAI;IACT,KAAK,CAAS;IAE9B,YAAmB,KAAQ,EAAE,KAAa;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AARD,oCAQC;AAED;;;;;GAKG;AACH,MAAa,QAAQ;IACT,MAAM,GAA2B,EAAE,CAAC;IAC3B,cAAc,CAAuB;IACrC,MAAM,CAAmB;IACzB,YAAY,CAAS;IAExC;;;;;OAKG;IACH,YAAmB,OAA6B,EAAE,cAAsB,MAAM,CAAC,gBAAgB,EAAE,QAA0B,0BAAY;QACrI,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED,yCAAyC;IACzC,IAAW,MAAM,KAAa,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,yEAAyE;IACzE,IAAW,MAAM,KAAc,OAAO,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzE,oDAAoD;IACpD,IAAW,OAAO,KAAc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C,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnL,+IAA+I;IACxI,OAAO;QACZ,MAAM,KAAK,GAAQ,EAAE,CAAC;QACtB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM;YAC7B,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;QAEnC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA9ED,4BA8EC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Collections\r\n */\r\n\r\nimport { OrderedComparator } from \"./Compare\";\r\nimport { CloneFunction, lowerBound, shallowClone } from \"./SortedArray\";\r\n\r\n/** Associates a value of type T with an index representing its insertion order in an IndexMap<T>\r\n * @public\r\n */\r\nexport class IndexedValue<T> {\r\n public readonly value: T;\r\n public readonly index: number;\r\n\r\n public constructor(value: T, index: number) {\r\n this.value = value;\r\n this.index = index;\r\n }\r\n}\r\n\r\n/**\r\n * Maintains a set of unique elements in sorted order and retains the insertion order of each.\r\n * The uniqueness of the elements is determined by a comparison routine supplied by the user.\r\n * The user may also supply a maximum size, beyond which insertions will fail.\r\n * @public\r\n */\r\nexport class IndexMap<T> {\r\n protected _array: Array<IndexedValue<T>> = [];\r\n protected readonly _compareValues: OrderedComparator<T>;\r\n protected readonly _clone: CloneFunction<T>;\r\n protected readonly _maximumSize: number;\r\n\r\n /**\r\n * Construct a new IndexMap<T>.\r\n * @param compare The function used to compare elements within the map.\r\n * @param maximumSize The maximum number of elements permitted in the IndexMap. The maximum index of an element is maximumSize-1.\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>, maximumSize: number = Number.MAX_SAFE_INTEGER, clone: CloneFunction<T> = shallowClone) {\r\n this._compareValues = compare;\r\n this._clone = clone;\r\n this._maximumSize = maximumSize;\r\n }\r\n\r\n /** The number of elements in the map. */\r\n public get length(): number { return this._array.length; }\r\n\r\n /** Returns true if the maximum number of elements have been inserted. */\r\n public get isFull(): boolean { return this.length >= this._maximumSize; }\r\n\r\n /** Returns true if the map contains no elements. */\r\n public get isEmpty(): boolean { return 0 === this.length; }\r\n\r\n /** Removes all elements from the map. */\r\n public clear(): void { this._array = []; }\r\n\r\n /** Attempt to insert a new value into the map.\r\n * If an equivalent element already exists in the map, the corresponding index is returned.\r\n * If the map is full, nothing is inserted and -1 is returned.\r\n * Otherwise:\r\n * The new element is mapped to the next-available index (that is, the length of the map prior to insertion of this new element);\r\n * the value is cloned using the function supplied to the IndexMap constructor;\r\n * the cloned result is inserted into the map; and\r\n * the index of the new element is returned.\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 of the equivalent element in the map, or -1 if the map is full and no equivalent element exists.\r\n */\r\n public insert(value: T, onInsert?: (value: T) => any): number {\r\n const bound = this.lowerBound(value);\r\n if (bound.equal)\r\n return this._array[bound.index].index;\r\n else if (this.isFull)\r\n return -1;\r\n\r\n const entry = new IndexedValue<T>(this._clone(value), this._array.length);\r\n\r\n if (undefined !== onInsert)\r\n onInsert(entry.value);\r\n\r\n this._array.splice(bound.index, 0, entry);\r\n return entry.index;\r\n }\r\n\r\n /**\r\n * Finds the index of an element equivalent to the supplied value.\r\n * @param value the value to find\r\n * @returns the index of an equivalent element in the map, 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 ? this._array[bound.index].index : -1;\r\n }\r\n\r\n protected lowerBound(value: T): { index: number, equal: boolean } { return lowerBound(value, this._array, (lhs: T, rhs: IndexedValue<T>) => this._compareValues(lhs, rhs.value)); }\r\n\r\n /** Return an array of the elements in this map in which the array index of each element corresponds to the index assigned to it by the map. */\r\n public toArray(): T[] {\r\n const array: T[] = [];\r\n for (const entry of this._array)\r\n array[entry.index] = entry.value;\r\n\r\n return array;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"IndexMap.js","sourceRoot":"","sources":["../../src/IndexMap.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAAwE;AAExE;;GAEG;AACH,MAAa,YAAY;IACP,KAAK,CAAI;IACT,KAAK,CAAS;IAE9B,YAAmB,KAAQ,EAAE,KAAa;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AARD,oCAQC;AAED;;;;;GAKG;AACH,MAAa,QAAQ;IACT,MAAM,GAA2B,EAAE,CAAC;IAC3B,cAAc,CAAuB;IACrC,MAAM,CAAmB;IACzB,YAAY,CAAS;IAExC;;;;;OAKG;IACH,YAAmB,OAA6B,EAAE,cAAsB,MAAM,CAAC,gBAAgB,EAAE,QAA0B,0BAAY;QACrI,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED,yCAAyC;IACzC,IAAW,MAAM,KAAa,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,yEAAyE;IACzE,IAAW,MAAM,KAAc,OAAO,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzE,oDAAoD;IACpD,IAAW,OAAO,KAAc,OAAO,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE3D,yCAAyC;IAClC,KAAK,KAAW,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;IAE1C;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,KAAQ,EAAE,QAA4B;QAClD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,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K,CAAC;IACf,CAAC;CACF;AA9ED,4BA8EC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Collections\n */\n\nimport { OrderedComparator } from \"./Compare\";\nimport { CloneFunction, lowerBound, shallowClone } from \"./SortedArray\";\n\n/** Associates a value of type T with an index representing its insertion order in an IndexMap<T>\n * @public\n */\nexport class IndexedValue<T> {\n public readonly value: T;\n public readonly index: number;\n\n public constructor(value: T, index: number) {\n this.value = value;\n this.index = index;\n }\n}\n\n/**\n * Maintains a set of unique elements in sorted order and retains the insertion order of each.\n * The uniqueness of the elements is determined by a comparison routine supplied by the user.\n * The user may also supply a maximum size, beyond which insertions will fail.\n * @public\n */\nexport class IndexMap<T> {\n protected _array: Array<IndexedValue<T>> = [];\n protected readonly _compareValues: OrderedComparator<T>;\n protected readonly _clone: CloneFunction<T>;\n protected readonly _maximumSize: number;\n\n /**\n * Construct a new IndexMap<T>.\n * @param compare The function used to compare elements within the map.\n * @param maximumSize The maximum number of elements permitted in the IndexMap. The maximum index of an element is maximumSize-1.\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>, maximumSize: number = Number.MAX_SAFE_INTEGER, clone: CloneFunction<T> = shallowClone) {\n this._compareValues = compare;\n this._clone = clone;\n this._maximumSize = maximumSize;\n }\n\n /** The number of elements in the map. */\n public get length(): number { return this._array.length; }\n\n /** Returns true if the maximum number of elements have been inserted. */\n public get isFull(): boolean { return this.length >= this._maximumSize; }\n\n /** Returns true if the map contains no elements. */\n public get isEmpty(): boolean { return 0 === this.length; }\n\n /** Removes all elements from the map. */\n public clear(): void { this._array = []; }\n\n /** Attempt to insert a new value into the map.\n * If an equivalent element already exists in the map, the corresponding index is returned.\n * If the map is full, nothing is inserted and -1 is returned.\n * Otherwise:\n * The new element is mapped to the next-available index (that is, the length of the map prior to insertion of this new element);\n * the value is cloned using the function supplied to the IndexMap constructor;\n * the cloned result is inserted into the map; and\n * the index of the new element is returned.\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 of the equivalent element in the map, or -1 if the map is full and no equivalent element exists.\n */\n public insert(value: T, onInsert?: (value: T) => any): number {\n const bound = this.lowerBound(value);\n if (bound.equal)\n return this._array[bound.index].index;\n else if (this.isFull)\n return -1;\n\n const entry = new IndexedValue<T>(this._clone(value), this._array.length);\n\n if (undefined !== onInsert)\n onInsert(entry.value);\n\n this._array.splice(bound.index, 0, entry);\n return entry.index;\n }\n\n /**\n * Finds the index of an element equivalent to the supplied value.\n * @param value the value to find\n * @returns the index of an equivalent element in the map, or -1 if no such element exists.\n */\n public indexOf(value: T): number {\n const bound = this.lowerBound(value);\n return bound.equal ? this._array[bound.index].index : -1;\n }\n\n protected lowerBound(value: T): { index: number, equal: boolean } { return lowerBound(value, this._array, (lhs: T, rhs: IndexedValue<T>) => this._compareValues(lhs, rhs.value)); }\n\n /** Return an array of the elements in this map in which the array index of each element corresponds to the index assigned to it by the map. */\n public toArray(): T[] {\n const array: T[] = [];\n for (const entry of this._array)\n array[entry.index] = entry.value;\n\n return array;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"JsonSchema.js","sourceRoot":"","sources":["../../src/JsonSchema.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG","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 Json\r\n */\r\n\r\n// adapted from https://github.com/microsoft/vscode Copyright (c) 2015 - present Microsoft Corporation\r\n\r\n/** @public */\r\nexport type JSONSchemaTypeName = \"string\" | \"number\" | \"integer\" | \"boolean\" | \"null\" | \"array\" | \"object\";\r\n\r\n/** @public */\r\nexport type JSONSchemaType = string | number | boolean | object | JSONSchemaType[];\r\n\r\n/** @public */\r\nexport interface JSONSchema {\r\n id?: string;\r\n $id?: string;\r\n $schema?: string;\r\n type?: JSONSchemaTypeName | JSONSchemaTypeName[];\r\n title?: string;\r\n default?: JSONSchemaType;\r\n definitions?: JSONSchemaMap;\r\n description?: string;\r\n properties?: JSONSchemaMap;\r\n patternProperties?: JSONSchemaMap;\r\n additionalProperties?: boolean | JSONSchema;\r\n minProperties?: number;\r\n maxProperties?: number;\r\n dependencies?: JSONSchemaMap | { [prop: string]: string[] };\r\n items?: JSONSchema | JSONSchema[];\r\n minItems?: number;\r\n maxItems?: number;\r\n uniqueItems?: boolean;\r\n additionalItems?: boolean | JSONSchema;\r\n pattern?: string;\r\n minLength?: number;\r\n maxLength?: number;\r\n minimum?: number;\r\n maximum?: number;\r\n exclusiveMinimum?: boolean | number;\r\n exclusiveMaximum?: boolean | number;\r\n multipleOf?: number;\r\n required?: string[];\r\n $ref?: string;\r\n anyOf?: JSONSchema[];\r\n allOf?: JSONSchema[];\r\n oneOf?: JSONSchema[];\r\n not?: JSONSchema;\r\n enum?: JSONSchemaType[];\r\n format?: string;\r\n\r\n // schema draft 06\r\n const?: any;\r\n contains?: JSONSchema;\r\n propertyNames?: JSONSchema;\r\n\r\n // schema draft 07\r\n $comment?: string;\r\n if?: JSONSchema;\r\n then?: JSONSchema;\r\n else?: JSONSchema;\r\n\r\n // VS Code extensions\r\n defaultSnippets?: JSONSchemaSnippet[];\r\n errorMessage?: string;\r\n patternErrorMessage?: string;\r\n deprecationMessage?: string;\r\n markdownDeprecationMessage?: string;\r\n enumDescriptions?: string[];\r\n markdownEnumDescriptions?: string[];\r\n markdownDescription?: string;\r\n doNotSuggest?: boolean;\r\n suggestSortText?: string;\r\n allowComments?: boolean;\r\n allowTrailingCommas?: boolean;\r\n}\r\n\r\n/** @public */\r\nexport interface JSONSchemaMap {\r\n [name: string]: JSONSchema;\r\n}\r\n\r\n/** @public */\r\nexport interface JSONSchemaSnippet {\r\n label?: string;\r\n description?: string;\r\n body?: any; // a object that will be JSON stringified\r\n bodyText?: string; // an already stringified JSON object that can contain new lines (\\n) and tabs (\\t)\r\n}\r\n"]}
1
+ {"version":3,"file":"JsonSchema.js","sourceRoot":"","sources":["../../src/JsonSchema.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG","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 Json\n */\n\n// adapted from https://github.com/microsoft/vscode Copyright (c) 2015 - present Microsoft Corporation\n\n/** @public */\nexport type JSONSchemaTypeName = \"string\" | \"number\" | \"integer\" | \"boolean\" | \"null\" | \"array\" | \"object\";\n\n/** @public */\nexport type JSONSchemaType = string | number | boolean | object | JSONSchemaType[];\n\n/** @public */\nexport interface JSONSchema {\n id?: string;\n $id?: string;\n $schema?: string;\n type?: JSONSchemaTypeName | JSONSchemaTypeName[];\n title?: string;\n default?: JSONSchemaType;\n definitions?: JSONSchemaMap;\n description?: string;\n properties?: JSONSchemaMap;\n patternProperties?: JSONSchemaMap;\n additionalProperties?: boolean | JSONSchema;\n minProperties?: number;\n maxProperties?: number;\n dependencies?: JSONSchemaMap | { [prop: string]: string[] };\n items?: JSONSchema | JSONSchema[];\n minItems?: number;\n maxItems?: number;\n uniqueItems?: boolean;\n additionalItems?: boolean | JSONSchema;\n pattern?: string;\n minLength?: number;\n maxLength?: number;\n minimum?: number;\n maximum?: number;\n exclusiveMinimum?: boolean | number;\n exclusiveMaximum?: boolean | number;\n multipleOf?: number;\n required?: string[];\n $ref?: string;\n anyOf?: JSONSchema[];\n allOf?: JSONSchema[];\n oneOf?: JSONSchema[];\n not?: JSONSchema;\n enum?: JSONSchemaType[];\n format?: string;\n\n // schema draft 06\n const?: any;\n contains?: JSONSchema;\n propertyNames?: JSONSchema;\n\n // schema draft 07\n $comment?: string;\n if?: JSONSchema;\n then?: JSONSchema;\n else?: JSONSchema;\n\n // VS Code extensions\n defaultSnippets?: JSONSchemaSnippet[];\n errorMessage?: string;\n patternErrorMessage?: string;\n deprecationMessage?: string;\n markdownDeprecationMessage?: string;\n enumDescriptions?: string[];\n markdownEnumDescriptions?: string[];\n markdownDescription?: string;\n doNotSuggest?: boolean;\n suggestSortText?: string;\n allowComments?: boolean;\n allowTrailingCommas?: boolean;\n}\n\n/** @public */\nexport interface JSONSchemaMap {\n [name: string]: JSONSchema;\n}\n\n/** @public */\nexport interface JSONSchemaSnippet {\n label?: string;\n description?: string;\n body?: any; // a object that will be JSON stringified\n bodyText?: string; // an already stringified JSON object that can contain new lines (\\n) and tabs (\\t)\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"JsonUtils.js","sourceRoot":"","sources":["../../src/JsonUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;GAEG;AACH,IAAiB,SAAS,CAgJzB;AAhJD,WAAiB,SAAS;IACxB;;;;OAIG;IACH,SAAgB,MAAM,CAAC,IAAS,EAAE,UAAU,GAAG,KAAK;QAClD,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC;IAFe,gBAAM,SAErB,CAAA;IACD;;;;OAIG;IACH,SAAgB,KAAK,CAAC,IAAS,EAAE,UAAU,GAAG,CAAC;QAC7C,OAAO,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IACpE,CAAC;IAFe,eAAK,QAEpB,CAAA;IACD;;;;OAIG;IACH,SAAgB,QAAQ,CAAC,IAAS,EAAE,UAAU,GAAG,CAAC;QAChD,OAAO,CAAC,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,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YAC9C,OAAO,GAAG,CAAC;QACb,CAAC;QAED,wBAAwB;QACxB,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YACzC,IAAI,YAAY,KAAK,SAAS;gBAC5B,GAAG,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;IA3Be,kBAAQ,WA2BvB,CAAA;AAEH,CAAC,EAhJgB,SAAS,yBAAT,SAAS,QAgJzB","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 Json\r\n */\r\n\r\n/** Utility functions for converting from JSON objects, with default values.\r\n * @public\r\n */\r\nexport namespace JsonUtils {\r\n /** Get a value as a boolean.\r\n * @param json the input JSON object\r\n * @param defaultVal default value if json cannot be converted to boolean\r\n * @returns the value of json as a boolean, or default value\r\n */\r\n export function asBool(json: any, defaultVal = false): boolean {\r\n return isNullOrUndefined(json) ? defaultVal : !!json;\r\n }\r\n /** Get a value as an integer.\r\n * @param json the input JSON object\r\n * @param defaultVal default value if json cannot be converted to integer\r\n * @returns the value of json as an integer, or default value\r\n */\r\n export function asInt(json: any, defaultVal = 0): number {\r\n return (typeof json === \"number\") ? Math.trunc(json) : defaultVal;\r\n }\r\n /** Get a value as a double.\r\n * @param json the input JSON object\r\n * @param defaultVal default value if json cannot be converted to double\r\n * @returns the value of json as a double, or default value\r\n */\r\n export function asDouble(json: any, defaultVal = 0): number {\r\n return (typeof json === \"number\") ? json : defaultVal;\r\n }\r\n /** Get a value as a string.\r\n * @param json the input JSON object\r\n * @param defaultVal default value if json cannot be converted to string\r\n * @returns the value of json as a string, or default value\r\n */\r\n export function asString(json: any, defaultVal = \"\"): string {\r\n return isNullOrUndefined(json) ? defaultVal : json.toString();\r\n }\r\n\r\n /** Get a value as an array.\r\n * @param json the input JSON object\r\n * @returns the input JSON object if it is an array, otherwise undefined\r\n */\r\n export function asArray(json: any): any {\r\n return Array.isArray(json) ? json : undefined;\r\n }\r\n\r\n /** Get a value as an object.\r\n * @param json the input JSON object\r\n * @returns the input JSON object if it is an object, otherwise undefined\r\n */\r\n export function asObject(json: any): any {\r\n return \"object\" === typeof json ? json : undefined;\r\n }\r\n\r\n /** Set or remove a number on a json object, given a key name, a value, and a default value. Sets `json[key] = val` if val is *not* equal to the default,\r\n * otherwise `delete json[key]`. This is used to omit values from JSON strings that are of known defaults.\r\n * @param json the JSON object to affect\r\n * @param key the name of the member to set or remove\r\n * @param val the value to set\r\n * @param defaultVal the default value.\r\n */\r\n export function setOrRemoveNumber(json: any, key: string, val: number, defaultVal: number) {\r\n if (val === defaultVal)\r\n delete json[key];\r\n else\r\n json[key] = val;\r\n }\r\n\r\n /** Set or remove a boolean on a json object, given a key name, a value, and a default value. Sets `json[key] = val` if val is *not* equal to the default,\r\n * otherwise `delete json[key]`. This is used to omit values from JSON strings that are of known defaults.\r\n * @param json the JSON object to affect\r\n * @param key the name of the member to set or remove\r\n * @param val the value to set\r\n * @param defaultVal the default value.\r\n */\r\n export function setOrRemoveBoolean(json: any, key: string, val: boolean, defaultVal: boolean) {\r\n if (val === defaultVal)\r\n delete json[key];\r\n else\r\n json[key] = val;\r\n }\r\n\r\n /** Returns `true` if `json` is a non-null object. */\r\n export function isObject(json: unknown): json is { [key: string]: unknown } {\r\n return json !== null && \"object\" === typeof json;\r\n }\r\n\r\n /** Determine if a Javascript object is equivalent to `{}`.\r\n * @param json The JSON object to test.\r\n * @returns true if `json` is an Object with no keys.\r\n */\r\n export function isEmptyObject(json: any): boolean {\r\n return isObject(json) && 0 === Object.keys(json).length;\r\n }\r\n\r\n /** Determine if the input is undefined or an empty Javascript object.\r\n * @param json The JSON object to test.\r\n * @returns true if `json` is undefined or is an Object with no keys (equivalent to `{}`).\r\n */\r\n export function isEmptyObjectOrUndefined(json: any): boolean {\r\n return undefined === json || isEmptyObject(json);\r\n }\r\n\r\n function isNullOrUndefined(json: any): boolean {\r\n return null === json || undefined === json;\r\n }\r\n\r\n /** Determine if the input is a non-empty Javascript object.\r\n * @param value The value to test.\r\n * @returns true if `value` is an Object with at least one key.\r\n */\r\n export function isNonEmptyObject(value: any): value is object {\r\n return !isEmptyObjectOrUndefined(value);\r\n }\r\n\r\n /**\r\n * Convert the input object into a \"pure\" JavaScript object, with only instances of \"object\" or primitives in the returned value.\r\n * Works recursively for object members, and over arrays entries. Calls \"toJSON\" on any members that implement it.\r\n */\r\n export function toObject(val: any): any {\r\n if (typeof val === \"boolean\" || typeof val === \"number\" || typeof val === \"string\")\r\n return val;\r\n\r\n if (typeof val !== \"object\")\r\n return undefined;\r\n\r\n // See if the object has toJSON() function defined.\r\n if (typeof val.toJSON !== \"undefined\")\r\n return toObject(val.toJSON());\r\n\r\n // if it's an array, convert each member.\r\n if (Array.isArray(val)) {\r\n const arr = new Array(val.length);\r\n val.forEach((el, i) => arr[i] = toObject(el));\r\n return arr;\r\n }\r\n\r\n // Convert each property\r\n const out: any = {};\r\n Object.getOwnPropertyNames(val).forEach((prop) => {\r\n const transformVal = toObject(val[prop]);\r\n if (transformVal !== undefined)\r\n out[prop] = transformVal;\r\n });\r\n\r\n return out;\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"JsonUtils.js","sourceRoot":"","sources":["../../src/JsonUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH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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 Json\n */\n\n/** Utility functions for converting from JSON objects, with default values.\n * @public\n */\nexport namespace JsonUtils {\n /** Get a value as a boolean.\n * @param json the input JSON object\n * @param defaultVal default value if json cannot be converted to boolean\n * @returns the value of json as a boolean, or default value\n */\n export function asBool(json: any, defaultVal = false): boolean {\n return isNullOrUndefined(json) ? defaultVal : !!json;\n }\n /** Get a value as an integer.\n * @param json the input JSON object\n * @param defaultVal default value if json cannot be converted to integer\n * @returns the value of json as an integer, or default value\n */\n export function asInt(json: any, defaultVal = 0): number {\n return (typeof json === \"number\") ? Math.trunc(json) : defaultVal;\n }\n /** Get a value as a double.\n * @param json the input JSON object\n * @param defaultVal default value if json cannot be converted to double\n * @returns the value of json as a double, or default value\n */\n export function asDouble(json: any, defaultVal = 0): number {\n return (typeof json === \"number\") ? json : defaultVal;\n }\n /** Get a value as a string.\n * @param json the input JSON object\n * @param defaultVal default value if json cannot be converted to string\n * @returns the value of json as a string, or default value\n */\n export function asString(json: any, defaultVal = \"\"): string {\n return isNullOrUndefined(json) ? defaultVal : json.toString();\n }\n\n /** Get a value as an array.\n * @param json the input JSON object\n * @returns the input JSON object if it is an array, otherwise undefined\n */\n export function asArray(json: any): any {\n return Array.isArray(json) ? json : undefined;\n }\n\n /** Get a value as an object.\n * @param json the input JSON object\n * @returns the input JSON object if it is an object, otherwise undefined\n */\n export function asObject(json: any): any {\n return \"object\" === typeof json ? json : undefined;\n }\n\n /** Set or remove a number on a json object, given a key name, a value, and a default value. Sets `json[key] = val` if val is *not* equal to the default,\n * otherwise `delete json[key]`. This is used to omit values from JSON strings that are of known defaults.\n * @param json the JSON object to affect\n * @param key the name of the member to set or remove\n * @param val the value to set\n * @param defaultVal the default value.\n */\n export function setOrRemoveNumber(json: any, key: string, val: number, defaultVal: number) {\n if (val === defaultVal)\n delete json[key];\n else\n json[key] = val;\n }\n\n /** Set or remove a boolean on a json object, given a key name, a value, and a default value. Sets `json[key] = val` if val is *not* equal to the default,\n * otherwise `delete json[key]`. This is used to omit values from JSON strings that are of known defaults.\n * @param json the JSON object to affect\n * @param key the name of the member to set or remove\n * @param val the value to set\n * @param defaultVal the default value.\n */\n export function setOrRemoveBoolean(json: any, key: string, val: boolean, defaultVal: boolean) {\n if (val === defaultVal)\n delete json[key];\n else\n json[key] = val;\n }\n\n /** Returns `true` if `json` is a non-null object. */\n export function isObject(json: unknown): json is { [key: string]: unknown } {\n return json !== null && \"object\" === typeof json;\n }\n\n /** Determine if a Javascript object is equivalent to `{}`.\n * @param json The JSON object to test.\n * @returns true if `json` is an Object with no keys.\n */\n export function isEmptyObject(json: any): boolean {\n return isObject(json) && 0 === Object.keys(json).length;\n }\n\n /** Determine if the input is undefined or an empty Javascript object.\n * @param json The JSON object to test.\n * @returns true if `json` is undefined or is an Object with no keys (equivalent to `{}`).\n */\n export function isEmptyObjectOrUndefined(json: any): boolean {\n return undefined === json || isEmptyObject(json);\n }\n\n function isNullOrUndefined(json: any): boolean {\n return null === json || undefined === json;\n }\n\n /** Determine if the input is a non-empty Javascript object.\n * @param value The value to test.\n * @returns true if `value` is an Object with at least one key.\n */\n export function isNonEmptyObject(value: any): value is object {\n return !isEmptyObjectOrUndefined(value);\n }\n\n /**\n * Convert the input object into a \"pure\" JavaScript object, with only instances of \"object\" or primitives in the returned value.\n * Works recursively for object members, and over arrays entries. Calls \"toJSON\" on any members that implement it.\n */\n export function toObject(val: any): any {\n if (typeof val === \"boolean\" || typeof val === \"number\" || typeof val === \"string\")\n return val;\n\n if (typeof val !== \"object\")\n return undefined;\n\n // See if the object has toJSON() function defined.\n if (typeof val.toJSON !== \"undefined\")\n return toObject(val.toJSON());\n\n // if it's an array, convert each member.\n if (Array.isArray(val)) {\n const arr = new Array(val.length);\n val.forEach((el, i) => arr[i] = toObject(el));\n return arr;\n }\n\n // Convert each property\n const out: any = {};\n Object.getOwnPropertyNames(val).forEach((prop) => {\n const transformVal = toObject(val[prop]);\n if (transformVal !== undefined)\n out[prop] = transformVal;\n });\n\n return out;\n }\n\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"LRUMap.js","sourceRoot":"","sources":["../../src/LRUMap.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,6CAA0C;AAE1C;;;;GAIG;AAEH;;GAEG;AACH,MAAa,KAAK;IAGG;IAAe;IAF3B,KAAK,CAAe;IACpB,KAAK,CAAe;IAC3B,YAAmB,GAAM,EAAS,KAAQ;QAAvB,QAAG,GAAH,GAAG,CAAG;QAAS,UAAK,GAAL,KAAK,CAAG;IAAI,CAAC;CAChD;AAJD,sBAIC;AAED,MAAM,aAAa;IACT,MAAM,CAA0B;IACxC,YAAY,WAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;IACM,IAAI;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,GAAG;YACN,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC;QACxB,MAAM,GAAG,GAAW,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IACrC,CAAC;CACF;AAED,MAAM,WAAW;IACP,MAAM,CAA0B;IACxC,YAAY,WAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;IACM,IAAI;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,GAAG;YACN,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAC1C,IAAI,CA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AAC,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,OAAO,KAAK,EAAE,CAAC;YACb,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YAChD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACtB,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IAED,sCAAsC;IAC/B,QAAQ;QACb,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,OAAO,KAAK,EAAE,CAAC;YACb,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3C,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YACpB,IAAI,KAAK,EAAE,CAAC;gBACV,CAAC,IAAI,KAAK,CAAC;YACb,CAAC;QACH,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA3PD,4BA2PC;AAED;;GAEG;AACH,MAAa,MAAa,SAAQ,QAAc;IAC9C;;OAEG;IACH,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,EAAE,IAAI,GAAG,EAAkB,CAAC,CAAC;IAC1C,CAAC;CACF;AAPD,wBAOC;AAED;;GAEG;AACH,MAAa,aAAoB,SAAQ,QAAc;IACrD;;;;OAIG;IACH,YAAY,KAAa,EAAE,WAAiC;QAC1D,KAAK,CAAC,KAAK,EAAE,IAAI,uBAAU,CAAiB,WAAW,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF;AATD,sCASC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 { Dictionary } from \"./Dictionary\";\r\n\r\n/**\r\n * Derived from:\r\n * Licensed under MIT. Copyright (c) 2010 Rasmus Andersson <http://hunch.se/>\r\n * See README.md at https://github.com/rsms/js-lru for details.\r\n */\r\n\r\n/** An entry holds the key and value, and pointers to any older and newer entries.\r\n * @public\r\n */\r\nexport class Entry<K, V> {\r\n public newer?: Entry<K, V>;\r\n public older?: Entry<K, V>;\r\n constructor(public key: K, public value: V) { }\r\n}\r\n\r\nclass EntryIterator<K, V> implements Iterator<[K, V] | undefined> {\r\n private _entry: Entry<K, V> | undefined;\r\n constructor(oldestEntry: Entry<K, V>) {\r\n this._entry = oldestEntry;\r\n }\r\n public next() {\r\n const ent = this._entry;\r\n if (!ent)\r\n return { done: true, value: undefined };\r\n this._entry = ent.newer;\r\n const val: [K, V] = [ent.key, ent.value];\r\n return { done: false, value: val };\r\n }\r\n}\r\n\r\nclass KeyIterator<K, V> implements Iterator<K | undefined> {\r\n private _entry: Entry<K, V> | undefined;\r\n constructor(oldestEntry: Entry<K, V>) {\r\n this._entry = oldestEntry;\r\n }\r\n public next() {\r\n const ent = this._entry;\r\n if (!ent)\r\n return { done: true, value: undefined };\r\n this._entry = ent.newer;\r\n return { done: false, value: ent.key };\r\n }\r\n}\r\n\r\nclass ValueIterator<K, V> implements Iterator<V | undefined> {\r\n private _entry: Entry<K, V> | undefined;\r\n constructor(oldestEntry: Entry<K, V>) {\r\n this._entry = oldestEntry;\r\n }\r\n public next() {\r\n const ent = this._entry;\r\n if (!ent)\r\n return { done: true, value: undefined };\r\n this._entry = ent.newer;\r\n return { done: false, value: ent.value };\r\n }\r\n}\r\n\r\n/** The interface that must be satisfied by the underlying container type used by a LRUCache.\r\n * Compatible with a [[Dictionary]] or a standard Map.\r\n * @public\r\n */\r\nexport interface EntryContainer<K, V> {\r\n readonly size: number;\r\n clear(): void;\r\n get(key: K): Entry<K, V> | undefined;\r\n set(key: K, value: Entry<K, V>): void;\r\n has(key: K): boolean;\r\n delete(key: K): void;\r\n}\r\n\r\n/**\r\n * A mapping of a key/value pairs, where the size of the cache can be limited.\r\n *\r\n * When entries are inserted, if the cache is \"full\", the\r\n * least-recently-used (LRU) value is dropped. When entries are retrieved, they are moved to the front of the LRU list.\r\n *\r\n * Illustration of the design:\r\n *\r\n * ```\r\n *\r\n * entry entry entry entry\r\n * ______ ______ ______ ______\r\n * | head |.newer => | |.newer => | |.newer => | tail |\r\n * | A | | B | | C | | D |\r\n * |______| <= older.|______| <= older.|______| <= older.|______|\r\n *\r\n * removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\r\n * ```\r\n * @public\r\n */\r\nexport class LRUCache<K, V> {\r\n private _container: EntryContainer<K, V>;\r\n\r\n /** Current number of items */\r\n public size: number;\r\n\r\n /** Maximum number of items this cache can hold */\r\n public limit: number;\r\n\r\n /** Least recently-used entry. Invalidated when cache is modified. */\r\n public oldest?: Entry<K, V>;\r\n\r\n /** Most recently-used entry. Invalidated when cache is modified. */\r\n public newest?: Entry<K, V>;\r\n\r\n /**\r\n * Construct a new LRUCache to hold up to `limit` entries.\r\n */\r\n public constructor(limit: number, container: EntryContainer<K, V>) {\r\n this.size = 0;\r\n this.limit = limit;\r\n this.oldest = this.newest = undefined;\r\n this._container = container;\r\n }\r\n\r\n private markEntryAsUsed(entry: Entry<K, V>) {\r\n if (entry === this.newest)\r\n return; // Already the most recently used entry, so no need to update the list\r\n\r\n // HEAD--------------TAIL\r\n // <.older .newer>\r\n // <--- add direction --\r\n // A B C <D> E\r\n if (entry.newer) {\r\n if (entry === this.oldest) {\r\n this.oldest = entry.newer;\r\n }\r\n entry.newer.older = entry.older; // C <-- E.\r\n }\r\n if (entry.older) {\r\n entry.older.newer = entry.newer; // C. --> E\r\n }\r\n entry.newer = undefined; // D --x\r\n entry.older = this.newest; // D. --> E\r\n if (this.newest) {\r\n this.newest.newer = entry; // E. <-- D\r\n }\r\n this.newest = entry;\r\n }\r\n\r\n /** Replace all values in this cache with key-value pairs (2-element Arrays) from provided iterable. */\r\n public assign(entries: Iterable<[K, V]>): void {\r\n let entry;\r\n let limit = this.limit || Number.MAX_VALUE;\r\n this._container.clear();\r\n const it = entries[Symbol.iterator]();\r\n for (let itv = it.next(); !itv.done; itv = it.next()) {\r\n const e = new Entry(itv.value[0], itv.value[1]);\r\n this._container.set(e.key, e);\r\n if (!entry) {\r\n this.oldest = e;\r\n } else {\r\n entry.newer = e;\r\n e.older = entry;\r\n }\r\n entry = e;\r\n if (limit-- === 0) {\r\n throw new Error(\"overflow\");\r\n }\r\n }\r\n this.newest = entry;\r\n this.size = this._container.size;\r\n }\r\n\r\n /** Get and register recent use of <key>.\r\n * Returns the value associated with <key> or undefined if not in cache.\r\n */\r\n public get(key: K): V | undefined {\r\n // First, find our cache entry\r\n const entry = this._container.get(key);\r\n if (!entry)\r\n return; // Not cached. Sorry.\r\n // As <key> was found in the cache, register it as being requested recently\r\n this.markEntryAsUsed(entry);\r\n return entry.value;\r\n }\r\n\r\n /** Put <value> into the cache associated with <key>. Replaces any existing entry with the same key.\r\n * @returns `this`.\r\n */\r\n public set(key: K, value: V): LRUCache<K, V> {\r\n let entry = this._container.get(key);\r\n if (entry) {\r\n // update existing\r\n entry.value = value;\r\n this.markEntryAsUsed(entry);\r\n return this;\r\n }\r\n\r\n // new entry\r\n this._container.set(key, (entry = new Entry(key, value)));\r\n\r\n if (this.newest) {\r\n // link previous tail to the new tail (entry)\r\n this.newest.newer = entry;\r\n entry.older = this.newest;\r\n } else {\r\n // we're first in\r\n this.oldest = entry;\r\n }\r\n\r\n // add new entry to the end of the linked list -- it is now the freshest entry.\r\n this.newest = entry;\r\n ++this.size;\r\n if (this.size > this.limit) {\r\n // we hit the limit -- remove the head\r\n this.shift();\r\n }\r\n return this;\r\n }\r\n\r\n /** Purge the least recently used (oldest) entry from the cache.\r\n * @returns The removed entry or undefined if the cache was empty.\r\n */\r\n public shift(): [K, V] | undefined {\r\n const entry = this.oldest;\r\n if (entry) {\r\n if (entry.newer) {\r\n // advance the list\r\n this.oldest = entry.newer;\r\n this.oldest.older = undefined;\r\n } else {\r\n // the cache is exhausted\r\n this.oldest = undefined;\r\n this.newest = undefined;\r\n }\r\n // Remove last strong reference to <entry> and remove links from the purged\r\n // entry being returned:\r\n entry.newer = entry.older = undefined;\r\n this._container.delete(entry.key);\r\n --this.size;\r\n return [entry.key, entry.value];\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Access value for `key` without registering recent use. Useful if you do not\r\n * want to change the state of the cache, but only \"peek\" at it.\r\n * @returns The value associated with `key` if found, or undefined if not found.\r\n */\r\n public find(key: K): V | undefined {\r\n const e = this._container.get(key);\r\n return e ? e.value : undefined;\r\n }\r\n\r\n /** Check if there's a value for key in the cache without registering recent use. */\r\n public has(key: K): boolean {\r\n return this._container.has(key);\r\n }\r\n\r\n /** Remove entry `key` from cache and return its value.\r\n * @returns The removed value, or undefined if not found.\r\n */\r\n public delete(key: K): V | undefined {\r\n const entry = this._container.get(key);\r\n if (!entry)\r\n return;\r\n\r\n this._container.delete(entry.key);\r\n if (entry.newer && entry.older) {\r\n // re-link the older entry with the newer entry\r\n entry.older.newer = entry.newer;\r\n entry.newer.older = entry.older;\r\n } else if (entry.newer) {\r\n // remove the link to us\r\n entry.newer.older = undefined;\r\n // link the newer entry to head\r\n this.oldest = entry.newer;\r\n } else if (entry.older) {\r\n // remove the link to us\r\n entry.older.newer = undefined;\r\n // link the newer entry to head\r\n this.newest = entry.older;\r\n } else { // if(entry.older === undefined && entry.newer === undefined) {\r\n this.oldest = this.newest = undefined;\r\n }\r\n\r\n this.size--;\r\n return entry.value;\r\n }\r\n\r\n /** Removes all entries */\r\n public clear(): void {\r\n // Note: clearing links should be safe, as we don't expose live links to user\r\n this.oldest = this.newest = undefined;\r\n this.size = 0;\r\n this._container.clear();\r\n }\r\n\r\n /** Returns an iterator over all keys, starting with the oldest. */\r\n public keys(): Iterator<K | undefined> | undefined {\r\n return this.oldest ? new KeyIterator(this.oldest) : undefined;\r\n }\r\n\r\n /** Returns an iterator over all values, starting with the oldest. */\r\n public values(): Iterator<V | undefined> | undefined {\r\n return this.oldest ? new ValueIterator(this.oldest) : undefined;\r\n }\r\n\r\n /** Returns an iterator over all entries, starting with the oldest. */\r\n public entries(): Iterator<[K, V] | undefined> | undefined {\r\n return this.oldest ? new EntryIterator(this.oldest) : undefined;\r\n }\r\n\r\n /** Call `fun` for each entry, starting with the oldest entry. */\r\n public forEach(fun: (value: V, key: K, m: LRUCache<K, V>) => void, thisObj?: any): void {\r\n if (typeof thisObj !== \"object\") {\r\n thisObj = this; // eslint-disable-line @typescript-eslint/no-this-alias\r\n }\r\n let entry = this.oldest;\r\n while (entry) {\r\n fun.call(thisObj, entry.value, entry.key, this);\r\n entry = entry.newer;\r\n }\r\n }\r\n\r\n /** Returns a JSON (array) representation */\r\n public toJSON(): Array<{ key: K, value: V }> {\r\n const s = new Array(this.size);\r\n let i = 0;\r\n let entry = this.oldest;\r\n while (entry) {\r\n s[i++] = { key: entry.key, value: entry.value };\r\n entry = entry.newer;\r\n }\r\n return s;\r\n }\r\n\r\n /** Returns a String representation */\r\n public toString(): string {\r\n let s = \"\";\r\n let entry = this.oldest;\r\n while (entry) {\r\n s += `${String(entry.key)}:${entry.value}`;\r\n entry = entry.newer;\r\n if (entry) {\r\n s += \" < \";\r\n }\r\n }\r\n return s;\r\n }\r\n}\r\n\r\n/** A [[LRUCache]] using a standard Map as its internal storage.\r\n * @public\r\n */\r\nexport class LRUMap<K, V> extends LRUCache<K, V> {\r\n /**\r\n * Construct a new LRUMap to hold up to `limit` entries.\r\n */\r\n constructor(limit: number) {\r\n super(limit, new Map<K, Entry<K, V>>());\r\n }\r\n}\r\n\r\n/** A [[LRUCache]] using a [[Dictionary]] as its internal storage, permitting custom key comparison logic.\r\n * @public\r\n */\r\nexport class LRUDictionary<K, V> extends LRUCache<K, V> {\r\n /**\r\n * Construct a new LRUDictionary to hold up to `limit` entries.\r\n * @param limit The maximum number of entries permitted in the dictionary.\r\n * @param compareKeys The function used to compare keys within the dictionary.\r\n */\r\n constructor(limit: number, compareKeys: OrderedComparator<K>) {\r\n super(limit, new Dictionary<K, Entry<K, V>>(compareKeys));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"LRUMap.js","sourceRoot":"","sources":["../../src/LRUMap.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,6CAA0C;AAE1C;;;;GAIG;AAEH;;GAEG;AACH,MAAa,KAAK;IAGG;IAAe;IAF3B,KAAK,CAAe;IACpB,KAAK,CAAe;IAC3B,YAAmB,GAAM,EAAS,KAAQ;QAAvB,QAAG,GAAH,GAAG,CAAG;QAAS,UAAK,GAAL,KAAK,CAAG;IAAI,CAAC;CAChD;AAJD,sBAIC;AAED,MAAM,aAAa;IACT,MAAM,CAA0B;IACxC,YAAY,WAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;IACM,IAAI;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,GAAG;YACN,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC;QACxB,MAAM,GAAG,GAAW,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IACrC,CAAC;CACF;AAED,MAAM,WAAW;IACP,MAAM,CAA0B;IACxC,YAAY,WAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;IAC5B,CAAC;IACM,IAAI;QACT,MAAM,GAAG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I,uBAAU,CAAiB,WAAW,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF;AATD,sCASC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Collections\n */\n\nimport { OrderedComparator } from \"./Compare\";\nimport { Dictionary } from \"./Dictionary\";\n\n/**\n * Derived from:\n * Licensed under MIT. Copyright (c) 2010 Rasmus Andersson <http://hunch.se/>\n * See README.md at https://github.com/rsms/js-lru for details.\n */\n\n/** An entry holds the key and value, and pointers to any older and newer entries.\n * @public\n */\nexport class Entry<K, V> {\n public newer?: Entry<K, V>;\n public older?: Entry<K, V>;\n constructor(public key: K, public value: V) { }\n}\n\nclass EntryIterator<K, V> implements Iterator<[K, V] | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n const val: [K, V] = [ent.key, ent.value];\n return { done: false, value: val };\n }\n}\n\nclass KeyIterator<K, V> implements Iterator<K | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n return { done: false, value: ent.key };\n }\n}\n\nclass ValueIterator<K, V> implements Iterator<V | undefined> {\n private _entry: Entry<K, V> | undefined;\n constructor(oldestEntry: Entry<K, V>) {\n this._entry = oldestEntry;\n }\n public next() {\n const ent = this._entry;\n if (!ent)\n return { done: true, value: undefined };\n this._entry = ent.newer;\n return { done: false, value: ent.value };\n }\n}\n\n/** The interface that must be satisfied by the underlying container type used by a LRUCache.\n * Compatible with a [[Dictionary]] or a standard Map.\n * @public\n */\nexport interface EntryContainer<K, V> {\n readonly size: number;\n clear(): void;\n get(key: K): Entry<K, V> | undefined;\n set(key: K, value: Entry<K, V>): void;\n has(key: K): boolean;\n delete(key: K): void;\n}\n\n/**\n * A mapping of a key/value pairs, where the size of the cache can be limited.\n *\n * When entries are inserted, if the cache is \"full\", the\n * least-recently-used (LRU) value is dropped. When entries are retrieved, they are moved to the front of the LRU list.\n *\n * Illustration of the design:\n *\n * ```\n *\n * entry entry entry entry\n * ______ ______ ______ ______\n * | head |.newer => | |.newer => | |.newer => | tail |\n * | A | | B | | C | | D |\n * |______| <= older.|______| <= older.|______| <= older.|______|\n *\n * removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n * ```\n * @public\n */\nexport class LRUCache<K, V> {\n private _container: EntryContainer<K, V>;\n\n /** Current number of items */\n public size: number;\n\n /** Maximum number of items this cache can hold */\n public limit: number;\n\n /** Least recently-used entry. Invalidated when cache is modified. */\n public oldest?: Entry<K, V>;\n\n /** Most recently-used entry. Invalidated when cache is modified. */\n public newest?: Entry<K, V>;\n\n /**\n * Construct a new LRUCache to hold up to `limit` entries.\n */\n public constructor(limit: number, container: EntryContainer<K, V>) {\n this.size = 0;\n this.limit = limit;\n this.oldest = this.newest = undefined;\n this._container = container;\n }\n\n private markEntryAsUsed(entry: Entry<K, V>) {\n if (entry === this.newest)\n return; // Already the most recently used entry, so no need to update the list\n\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C <D> E\n if (entry.newer) {\n if (entry === this.oldest) {\n this.oldest = entry.newer;\n }\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older) {\n entry.older.newer = entry.newer; // C. --> E\n }\n entry.newer = undefined; // D --x\n entry.older = this.newest; // D. --> E\n if (this.newest) {\n this.newest.newer = entry; // E. <-- D\n }\n this.newest = entry;\n }\n\n /** Replace all values in this cache with key-value pairs (2-element Arrays) from provided iterable. */\n public assign(entries: Iterable<[K, V]>): void {\n let entry;\n let limit = this.limit || Number.MAX_VALUE;\n this._container.clear();\n const it = entries[Symbol.iterator]();\n for (let itv = it.next(); !itv.done; itv = it.next()) {\n const e = new Entry(itv.value[0], itv.value[1]);\n this._container.set(e.key, e);\n if (!entry) {\n this.oldest = e;\n } else {\n entry.newer = e;\n e.older = entry;\n }\n entry = e;\n if (limit-- === 0) {\n throw new Error(\"overflow\");\n }\n }\n this.newest = entry;\n this.size = this._container.size;\n }\n\n /** Get and register recent use of <key>.\n * Returns the value associated with <key> or undefined if not in cache.\n */\n public get(key: K): V | undefined {\n // First, find our cache entry\n const entry = this._container.get(key);\n if (!entry)\n return; // Not cached. Sorry.\n // As <key> was found in the cache, register it as being requested recently\n this.markEntryAsUsed(entry);\n return entry.value;\n }\n\n /** Put <value> into the cache associated with <key>. Replaces any existing entry with the same key.\n * @returns `this`.\n */\n public set(key: K, value: V): LRUCache<K, V> {\n let entry = this._container.get(key);\n if (entry) {\n // update existing\n entry.value = value;\n this.markEntryAsUsed(entry);\n return this;\n }\n\n // new entry\n this._container.set(key, (entry = new Entry(key, value)));\n\n if (this.newest) {\n // link previous tail to the new tail (entry)\n this.newest.newer = entry;\n entry.older = this.newest;\n } else {\n // we're first in\n this.oldest = entry;\n }\n\n // add new entry to the end of the linked list -- it is now the freshest entry.\n this.newest = entry;\n ++this.size;\n if (this.size > this.limit) {\n // we hit the limit -- remove the head\n this.shift();\n }\n return this;\n }\n\n /** Purge the least recently used (oldest) entry from the cache.\n * @returns The removed entry or undefined if the cache was empty.\n */\n public shift(): [K, V] | undefined {\n const entry = this.oldest;\n if (entry) {\n if (entry.newer) {\n // advance the list\n this.oldest = entry.newer;\n this.oldest.older = undefined;\n } else {\n // the cache is exhausted\n this.oldest = undefined;\n this.newest = undefined;\n }\n // Remove last strong reference to <entry> and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n this._container.delete(entry.key);\n --this.size;\n return [entry.key, entry.value];\n }\n return undefined;\n }\n\n /** Access value for `key` without registering recent use. Useful if you do not\n * want to change the state of the cache, but only \"peek\" at it.\n * @returns The value associated with `key` if found, or undefined if not found.\n */\n public find(key: K): V | undefined {\n const e = this._container.get(key);\n return e ? e.value : undefined;\n }\n\n /** Check if there's a value for key in the cache without registering recent use. */\n public has(key: K): boolean {\n return this._container.has(key);\n }\n\n /** Remove entry `key` from cache and return its value.\n * @returns The removed value, or undefined if not found.\n */\n public delete(key: K): V | undefined {\n const entry = this._container.get(key);\n if (!entry)\n return;\n\n this._container.delete(entry.key);\n if (entry.newer && entry.older) {\n // re-link the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.oldest = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.newest = entry.older;\n } else { // if(entry.older === undefined && entry.newer === undefined) {\n this.oldest = this.newest = undefined;\n }\n\n this.size--;\n return entry.value;\n }\n\n /** Removes all entries */\n public clear(): void {\n // Note: clearing links should be safe, as we don't expose live links to user\n this.oldest = this.newest = undefined;\n this.size = 0;\n this._container.clear();\n }\n\n /** Returns an iterator over all keys, starting with the oldest. */\n public keys(): Iterator<K | undefined> | undefined {\n return this.oldest ? new KeyIterator(this.oldest) : undefined;\n }\n\n /** Returns an iterator over all values, starting with the oldest. */\n public values(): Iterator<V | undefined> | undefined {\n return this.oldest ? new ValueIterator(this.oldest) : undefined;\n }\n\n /** Returns an iterator over all entries, starting with the oldest. */\n public entries(): Iterator<[K, V] | undefined> | undefined {\n return this.oldest ? new EntryIterator(this.oldest) : undefined;\n }\n\n /** Call `fun` for each entry, starting with the oldest entry. */\n public forEach(fun: (value: V, key: K, m: LRUCache<K, V>) => void, thisObj?: any): void {\n if (typeof thisObj !== \"object\") {\n thisObj = this; // eslint-disable-line @typescript-eslint/no-this-alias\n }\n let entry = this.oldest;\n while (entry) {\n fun.call(thisObj, entry.value, entry.key, this);\n entry = entry.newer;\n }\n }\n\n /** Returns a JSON (array) representation */\n public toJSON(): Array<{ key: K, value: V }> {\n const s = new Array(this.size);\n let i = 0;\n let entry = this.oldest;\n while (entry) {\n s[i++] = { key: entry.key, value: entry.value };\n entry = entry.newer;\n }\n return s;\n }\n\n /** Returns a String representation */\n public toString(): string {\n let s = \"\";\n let entry = this.oldest;\n while (entry) {\n s += `${String(entry.key)}:${entry.value}`;\n entry = entry.newer;\n if (entry) {\n s += \" < \";\n }\n }\n return s;\n }\n}\n\n/** A [[LRUCache]] using a standard Map as its internal storage.\n * @public\n */\nexport class LRUMap<K, V> extends LRUCache<K, V> {\n /**\n * Construct a new LRUMap to hold up to `limit` entries.\n */\n constructor(limit: number) {\n super(limit, new Map<K, Entry<K, V>>());\n }\n}\n\n/** A [[LRUCache]] using a [[Dictionary]] as its internal storage, permitting custom key comparison logic.\n * @public\n */\nexport class LRUDictionary<K, V> extends LRUCache<K, V> {\n /**\n * Construct a new LRUDictionary to hold up to `limit` entries.\n * @param limit The maximum number of entries permitted in the dictionary.\n * @param compareKeys The function used to compare keys within the dictionary.\n */\n constructor(limit: number, compareKeys: OrderedComparator<K>) {\n super(limit, new Dictionary<K, Entry<K, V>>(compareKeys));\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AACpC,iDAA6E;AAC7E,mEAAgE;AAOhE;;GAEG;AACH,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,wBAAR,QAAQ,QAWnB;AAmCD;;;GAGG;AACH,MAAa,MAAM;IACP,MAAM,CAAC,SAAS,CAA0B;IAC1C,MAAM,CAAC,WAA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E1B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,6CAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/E,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;YACzB,OAAO;QACT,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,6CAAqB,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,UAAU,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,6CAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC;YAC5E,OAAO;QAET,MAAM,CAAC,OAAO,CAAC,6CAAqB,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,UAAU,MAAM,EAAE,GAAG,EAAE;YAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,2BAAY,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;;AAxCH,gCAyCC","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
+ {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AACpC,iDAA6E;AAC7E,mEAAgE;AAOhE;;GAEG;AACH,IAAY,QAWX;AAX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ACxH,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;;AAxCH,gCAyCC","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 +1 @@
1
- {"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AAEpC;;GAEG;AACH,MAAa,aAAiB,SAAQ,GAAM;IAC1C,iDAAiD;IACjC,OAAO,GAAG,IAAI,iBAAO,EAAqB,CAAC;IAC3D,qDAAqD;IACrC,SAAS,GAAG,IAAI,iBAAO,EAAqB,CAAC;IAC7D,qDAAqD;IACrC,SAAS,GAAG,IAAI,iBAAO,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;AA7CD,sCA6CC","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();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AAEpC;;GAEG;AACH,MAAa,aAAiB,SAAQ,GAAM;IAC1C,iDAAiD;IACjC,OAAO,GAAG,IAAI,iBAAO,EAAqB,CAAC;IAC3D,qDAAqD;IACrC,SAAS,GAAG,IAAI,iBAAO,EAAqB,CAAC;IAC7D,qDAAqD;IACrC,SAAS,GAAG,IAAI,iBAAO,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;AA7CD,sCA6CC","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 +1 @@
1
- {"version":3,"file":"OneAtATimeAction.js","sourceRoot":"","sources":["../../src/OneAtATimeAction.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iDAA8C;AAE9C,YAAY;AACZ,MAAa,cAAe,SAAQ,KAAK;CAAI;AAA7C,wCAA6C;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,KAAK,CAAO;IAAI,CAAC;IAEnF,0GAA0G;IACnG,KAAK,CAAC,IAAI,CAAC,GAAW;QAC3B,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxC,IAAI,CAAC,OAAO,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC;YAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,oFAAoF;IAC7E,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,OAAO,CAAC,2BAAY,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,6EAA6E;QAChI,CA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CAAC;CACF;AAxCD,4CAwCC","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
+ {"version":3,"file":"OneAtATimeAction.js","sourceRoot":"","sources":["../../src/OneAt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ChB,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;AAxCD,4CAwCC","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 +1 @@
1
- {"version":3,"file":"OrderedId64Iterable.js","sourceRoot":"","sources":["../../src/OrderedId64Iterable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qCAAkC;AAOlC;;;;;;;GAOG;AACH,IAAiB,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,GA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AM,IAAI,GAAG,IAAI,CAAC;gBAClB,SAAS;YACX,CAAC;YAED,IAAI,KAAK,GAAG,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,mCAAnB,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 }\r\n}\r\n"]}
1
+ {"version":3,"file":"OrderedId64Iterable.js","sourceRoot":"","sources":["../../src/OrderedId64Iterable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qCAAkC;AAOlC;;;;;;;GAOG;AACH,IAAiB,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,CAAC,CAAC;IACX,CAAC;IAVe,2BAAO,UAUtB,CAAA;IAED;;;;;;OAMG;IACH,SAAgB,SAAS,CAAC,GAAc;QACtC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC;IACb,CAAC;IAHe,6BAAS,YAGxB,CAAA;IAED;;OAEG;IACH,SAAgB,YAAY,CAAC,IAAyB,EAAE,IAAyB;QAC/E,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,SAAS,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,UAAU,GAAG,SAAS,CAAC,IAAI,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AiClC,CAAA;AACH,CAAC,EAxOgB,mBAAmB,mCAAnB,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 +1 @@
1
- {"version":3,"file":"OrderedSet.js","sourceRoot":"","sources":["../../src/OrderedSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAAyE;AAEzE;;;;GAIG;AACH,MAAa,kBAAkB;IACV,MAAM,CAAiB;IAE1C;;;OAGG;IACH,YAAmB,OAA6B,EAAE,QAA0B,0BAAY;QACtF,IAAI,CAAC,MAAM,GAAG,IAAI,yBAAW,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;AAzBD,gDAyBC;AAED;;GAEG;AACH,MAAa,UAAc,SAAQ,kBAAqB;IACtD;;;OAGG;IACH,YAAmB,OAA6B,EAAE,QAA0B,0BAAY;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;AAxBD,gCAwBC","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
+ {"version":3,"file":"OrderedSet.js","sourceRoot":"","sources":["../../src/OrderedSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAAyE;AAEzE;;;;GAIG;AACH,MAAa,kBAAkB;IACV,MAAM,CAAiB;IAE1C;;;OAGG;IACH,YAAmB,OAA6B,EAAE,QAA0B,0BAAY;QACtF,IAAI,CAAC,MAAM,GAAG,IAAI,yBAAW,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;AAzBD,gDAyBC;AAED;;GAEG;AACH,MAAa,UAAc,SAAQ,kBAAqB;IACtD;;;OAGG;IACH,YAAmB,OAA6B,EAAE,QAA0B,0BAAY;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;AAxBD,gCAwBC","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 +1 @@
1
- {"version":3,"file":"PriorityQueue.js","sourceRoot":"","sources":["../../src/PriorityQueue.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAA4D;AAK5D;;;;GAIG;AACH,MAAa,aAAa;IACd,MAAM,GAAQ,EAAE,CAAC;IACR,QAAQ,CAAuB;IAC/B,MAAM,CAAmB;IAE5C;;;;;OAKG;IACH,YAAmB,OAA6B,EAAE,QAA0B,0BAAY;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,MAAM,CAAC,C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a;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;AA/ID,sCA+IC","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\n return this._array[index];\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PriorityQueue.js","sourceRoot":"","sources":["../../src/PriorityQueue.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAA4D;AAK5D;;;;GAIG;AACH,MAAa,aAAa;IACd,MAAM,GAAQ,EAAE,CAAC;IACR,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B,CAAC;iBAAM,CAAC;gBACN,MAAM;YACR,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAQ;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,2FAA2F;IAC3F,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,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;AA/ID,sCA+IC","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"]}