@bentley/bentleyjs-core
Advanced tools
Comparing version 1.14.1 to 2.0.0
@@ -5,2 +5,50 @@ { | ||
{ | ||
"version": "2.0.0", | ||
"tag": "@bentley/bentleyjs-core_v2.0.0", | ||
"date": "Wed, 06 May 2020 13:17:49 GMT", | ||
"comments": { | ||
"none": [ | ||
{ | ||
"comment": "Monitor progress of downloading briefcases, ability to cancel download of briefcases. " | ||
}, | ||
{ | ||
"comment": "Update Config.App documentation to reflect the removal of the config.json file" | ||
}, | ||
{ | ||
"comment": "Added ContextDoesNotExist error" | ||
}, | ||
{ | ||
"comment": "BUG273249" | ||
}, | ||
{ | ||
"comment": "Updated docs. " | ||
}, | ||
{ | ||
"comment": "Updated error text. " | ||
}, | ||
{ | ||
"comment": "added raw log method that bypass catogory check" | ||
}, | ||
{ | ||
"comment": "order imports." | ||
}, | ||
{ | ||
"comment": "Add a type guard for `IDisposable`" | ||
}, | ||
{ | ||
"comment": "Add Config class previously hosted in imodeljs-clients" | ||
}, | ||
{ | ||
"comment": "Upgrade to Rush 5.23.2" | ||
}, | ||
{ | ||
"comment": "Added ReadonlySortedArray." | ||
}, | ||
{ | ||
"comment": "Remove support for the iModel.js module system by no longer delivering modules." | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"version": "1.14.1", | ||
@@ -69,3 +117,3 @@ "tag": "@bentley/bentleyjs-core_v1.14.1", | ||
{ | ||
"comment": "fix warnings from static analysis" | ||
"comment": "Fix warnings from static analysis" | ||
}, | ||
@@ -148,3 +196,3 @@ { | ||
{ | ||
"comment": "added OneAtATimeActivity class" | ||
"comment": "Added OneAtATimeActivity class" | ||
}, | ||
@@ -170,3 +218,3 @@ { | ||
{ | ||
"comment": "added Id64.getFirst to get the first value of an Id64Arg" | ||
"comment": "Added Id64.getFirst to get the first value of an Id64Arg" | ||
}, | ||
@@ -183,3 +231,3 @@ { | ||
{ | ||
"comment": "add property accessor for empty Guid" | ||
"comment": "Add property accessor for empty Guid" | ||
} | ||
@@ -211,3 +259,3 @@ ] | ||
{ | ||
"comment": "Logging fixes. " | ||
"comment": "Logging fixes." | ||
}, | ||
@@ -266,3 +314,3 @@ { | ||
{ | ||
"comment": "upgrade to TypeScript 3.2.2" | ||
"comment": "Upgrade to TypeScript 3.2.2" | ||
} | ||
@@ -441,3 +489,3 @@ ] | ||
{ | ||
"comment": "changes to debug utilities. " | ||
"comment": "Changes to debug utilities. " | ||
}, | ||
@@ -444,0 +492,0 @@ { |
# Change Log - @bentley/bentleyjs-core | ||
This log was last generated on Wed, 22 Apr 2020 19:04:00 GMT and should not be manually modified. | ||
This log was last generated on Wed, 06 May 2020 13:17:49 GMT and should not be manually modified. | ||
## 2.0.0 | ||
Wed, 06 May 2020 13:17:49 GMT | ||
### Updates | ||
- Monitor progress of downloading briefcases, ability to cancel download of briefcases. | ||
- Update Config.App documentation to reflect the removal of the config.json file | ||
- Added ContextDoesNotExist error | ||
- BUG273249 | ||
- Updated docs. | ||
- Updated error text. | ||
- added raw log method that bypass catogory check | ||
- order imports. | ||
- Add a type guard for `IDisposable` | ||
- Add Config class previously hosted in imodeljs-clients | ||
- Upgrade to Rush 5.23.2 | ||
- Added ReadonlySortedArray. | ||
- Remove support for the iModel.js module system by no longer delivering modules. | ||
## 1.14.1 | ||
@@ -47,3 +66,3 @@ Wed, 22 Apr 2020 19:04:00 GMT | ||
- Added non-static wait and executeAfter to BeDuration | ||
- fix warnings from static analysis | ||
- Fix warnings from static analysis | ||
- Added `BeDuration.race` for common timeout operations. | ||
@@ -98,3 +117,3 @@ | ||
- added OneAtATimeActivity class | ||
- Added OneAtATimeActivity class | ||
- Introduced AsyncMutex - a utility to run async blocks of code in sequence. | ||
@@ -109,7 +128,7 @@ - Update to TypeScript 3.5 | ||
- RPC system now accepts only basic values (primitives, "interface" objects, and binary). | ||
- added Id64.getFirst to get the first value of an Id64Arg | ||
- Added Id64.getFirst to get the first value of an Id64Arg | ||
- Added an error for seed file initialization timeout | ||
- Switched from iModelHub Project API to Context API | ||
- Refactored and simplified implementation of IModelDb.open | ||
- add property accessor for empty Guid | ||
- Add property accessor for empty Guid | ||
@@ -126,3 +145,3 @@ ## 0.191.0 | ||
- Logged the fields in ClientRequestContext | ||
- Logging fixes. | ||
- Logging fixes. | ||
- Put sourcemap in npm package. | ||
@@ -151,3 +170,3 @@ - Fixed logger to not mutate incoming objects. | ||
- Save BUILD_SEMVER to globally accessible map | ||
- upgrade to TypeScript 3.2.2 | ||
- Upgrade to TypeScript 3.2.2 | ||
@@ -276,3 +295,3 @@ ## 0.188.0 | ||
- changes to debug utilities. | ||
- Changes to debug utilities. | ||
- Fluentd Bunnyan Logger added | ||
@@ -279,0 +298,0 @@ |
@@ -101,3 +101,4 @@ /** @packageDocumentation | ||
VersionNotFound = 131077, | ||
CannotApplyChanges = 131078 | ||
CannotApplyChanges = 131078, | ||
DownloadCancelled = 131079 | ||
} | ||
@@ -294,2 +295,3 @@ /** RpcInterface status codes | ||
FailedToGetAssetMembers = 102446, | ||
ContextDoesNotExist = 102447, | ||
UndefinedArgumentError = 102657, | ||
@@ -311,2 +313,16 @@ InvalidArgumentError = 102658, | ||
} | ||
/** iModel.js Extensions | ||
* @beta | ||
*/ | ||
export declare enum ExtensionStatus { | ||
Success = 0, | ||
EXTENSIONSTATUS_BASE = 143360, | ||
UnknownError = 143361, | ||
BadRequest = 143362, | ||
ExtensionNotFound = 143363, | ||
BadExtension = 143364, | ||
ExtensionAlreadyExists = 143365, | ||
UploadError = 143366, | ||
DownloadError = 143367 | ||
} | ||
/** When you want to associate an explanatory message with an error status value. | ||
@@ -313,0 +329,0 @@ * @beta Internal? |
@@ -112,2 +112,3 @@ "use strict"; | ||
BriefcaseStatus[BriefcaseStatus["CannotApplyChanges"] = 131078] = "CannotApplyChanges"; | ||
BriefcaseStatus[BriefcaseStatus["DownloadCancelled"] = 131079] = "DownloadCancelled"; | ||
})(BriefcaseStatus = exports.BriefcaseStatus || (exports.BriefcaseStatus = {})); | ||
@@ -310,2 +311,3 @@ /** RpcInterface status codes | ||
IModelHubStatus[IModelHubStatus["FailedToGetAssetMembers"] = 102446] = "FailedToGetAssetMembers"; | ||
IModelHubStatus[IModelHubStatus["ContextDoesNotExist"] = 102447] = "ContextDoesNotExist"; | ||
// Errors that are returned for incorrect iModelHub request. | ||
@@ -329,2 +331,17 @@ IModelHubStatus[IModelHubStatus["UndefinedArgumentError"] = 102657] = "UndefinedArgumentError"; | ||
})(AuthStatus = exports.AuthStatus || (exports.AuthStatus = {})); | ||
/** iModel.js Extensions | ||
* @beta | ||
*/ | ||
var ExtensionStatus; | ||
(function (ExtensionStatus) { | ||
ExtensionStatus[ExtensionStatus["Success"] = 0] = "Success"; | ||
ExtensionStatus[ExtensionStatus["EXTENSIONSTATUS_BASE"] = 143360] = "EXTENSIONSTATUS_BASE"; | ||
ExtensionStatus[ExtensionStatus["UnknownError"] = 143361] = "UnknownError"; | ||
ExtensionStatus[ExtensionStatus["BadRequest"] = 143362] = "BadRequest"; | ||
ExtensionStatus[ExtensionStatus["ExtensionNotFound"] = 143363] = "ExtensionNotFound"; | ||
ExtensionStatus[ExtensionStatus["BadExtension"] = 143364] = "BadExtension"; | ||
ExtensionStatus[ExtensionStatus["ExtensionAlreadyExists"] = 143365] = "ExtensionAlreadyExists"; | ||
ExtensionStatus[ExtensionStatus["UploadError"] = 143366] = "UploadError"; | ||
ExtensionStatus[ExtensionStatus["DownloadError"] = 143367] = "DownloadError"; | ||
})(ExtensionStatus = exports.ExtensionStatus || (exports.ExtensionStatus = {})); | ||
/** The error type thrown by this module. `BentleyError` subclasses `Error` to add an `errorNumber` member. See [[IModelStatus]] for `errorNumber` values. | ||
@@ -521,6 +538,7 @@ * @public | ||
case BriefcaseStatus.VersionNotFound: return "VersionNotFound"; | ||
case BriefcaseStatus.DownloadCancelled: return "DownloadCancelled"; | ||
// RpcInterface | ||
case RpcInterfaceStatus.IncompatibleVersion: return "RpcInterfaceStatus.IncompatibleVersion"; | ||
// ChangeSetStatus | ||
case ChangeSetStatus.ApplyError: return "Error applying a change set when reversing or reinstating it"; | ||
case ChangeSetStatus.ApplyError: return "Error applying a change set"; | ||
case ChangeSetStatus.ChangeTrackingNotEnabled: return "Change tracking has not been enabled. The ChangeSet API mandates this"; | ||
@@ -631,2 +649,3 @@ case ChangeSetStatus.CorruptedChangeStream: return "Contents of the change stream are corrupted and does not match the ChangeSet"; | ||
case IModelHubStatus.DatabaseOperationFailed: return "Database operation has failed"; | ||
case IModelHubStatus.ContextDoesNotExist: return "Context does not exist"; | ||
// errors that are returned for incorrect iModelHub request. | ||
@@ -641,2 +660,9 @@ case IModelHubStatus.UndefinedArgumentError: return "Undefined argument"; | ||
case AuthStatus.Error: return "Authorization error"; | ||
// errors returned by iModel.js Extension client | ||
case ExtensionStatus.UnknownError: return "Unknown error from backend"; | ||
case ExtensionStatus.BadExtension: return "Bad file extension"; | ||
case ExtensionStatus.BadRequest: return "Bad request"; | ||
case ExtensionStatus.ExtensionAlreadyExists: return "Extension with the given name and version already exists"; | ||
case ExtensionStatus.ExtensionNotFound: return "Extension not found"; | ||
case ExtensionStatus.UploadError: return "Failed to upload file"; | ||
// Unexpected cases | ||
@@ -643,0 +669,0 @@ case IModelStatus.Success: |
@@ -10,2 +10,3 @@ export * from "./Assert"; | ||
export * from "./Compare"; | ||
export * from "./Config"; | ||
export * from "./Dictionary"; | ||
@@ -36,2 +37,6 @@ export * from "./Disposable"; | ||
/** | ||
* @docs-group-description Configuration | ||
* Class for easily managing configuration variables for an iModel.js application. | ||
*/ | ||
/** | ||
* @docs-group-description Errors | ||
@@ -38,0 +43,0 @@ * Classes for working with errors. |
@@ -19,2 +19,3 @@ "use strict"; | ||
__export(require("./Compare")); | ||
__export(require("./Config")); | ||
__export(require("./Dictionary")); | ||
@@ -34,7 +35,2 @@ __export(require("./Disposable")); | ||
__export(require("./Time")); | ||
if ((typeof (BUILD_SEMVER) !== "undefined") && (typeof window !== "undefined") && window) { | ||
if (!window.iModelJsVersions) | ||
window.iModelJsVersions = new Map(); | ||
window.iModelJsVersions.set("bentleyjs-core", BUILD_SEMVER); | ||
} | ||
/** @packageDocumentation | ||
@@ -51,2 +47,6 @@ * @module Utils | ||
/** | ||
* @docs-group-description Configuration | ||
* Class for easily managing configuration variables for an iModel.js application. | ||
*/ | ||
/** | ||
* @docs-group-description Errors | ||
@@ -53,0 +53,0 @@ * Classes for working with errors. |
@@ -22,5 +22,5 @@ /** @packageDocumentation | ||
* passed an instance of the subclass: | ||
* [[AuthorizedClientRequestContext]]. | ||
* [AuthorizedClientRequestContext]($itwin-client) | ||
* @see [ClientRequestContext rules]($docs/learning/backend/managingclientrequestcontext.md). | ||
* @see [[AuthorizedClientRequestContext]] | ||
* @see [AuthorizedClientRequestContext]($itwin-client) | ||
* @public | ||
@@ -27,0 +27,0 @@ */ |
@@ -15,5 +15,5 @@ "use strict"; | ||
* passed an instance of the subclass: | ||
* [[AuthorizedClientRequestContext]]. | ||
* [AuthorizedClientRequestContext]($itwin-client) | ||
* @see [ClientRequestContext rules]($docs/learning/backend/managingclientrequestcontext.md). | ||
* @see [[AuthorizedClientRequestContext]] | ||
* @see [AuthorizedClientRequestContext]($itwin-client) | ||
* @public | ||
@@ -20,0 +20,0 @@ */ |
/** @packageDocumentation | ||
* @module Collections | ||
*/ | ||
import { OrderedComparator } from "./Compare"; | ||
import { CloneFunction } from "./SortedArray"; | ||
import { OrderedComparator } from "./Compare"; | ||
/** | ||
@@ -7,0 +7,0 @@ * Represents an entry in a [[Dictionary]]. |
@@ -25,2 +25,7 @@ /** @packageDocumentation | ||
} | ||
/** | ||
* A type guard that checks whether the given argument implements `IDisposable` interface | ||
* @public | ||
*/ | ||
export declare function isIDisposable(obj: unknown): obj is IDisposable; | ||
/** Convenience function for disposing of a disposable object that may be undefined. | ||
@@ -27,0 +32,0 @@ * This is primarily used to simplify implementations of [[IDisposable.dispose]]. |
@@ -10,2 +10,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* A type guard that checks whether the given argument implements `IDisposable` interface | ||
* @public | ||
*/ | ||
function isIDisposable(obj) { | ||
return !!obj && (obj instanceof Object) && !!obj.dispose && (typeof obj.dispose === "function"); | ||
} | ||
exports.isIDisposable = isIDisposable; | ||
/** Convenience function for disposing of a disposable object that may be undefined. | ||
@@ -12,0 +20,0 @@ * This is primarily used to simplify implementations of [[IDisposable.dispose]]. |
@@ -16,13 +16,2 @@ "use strict"; | ||
/** | ||
* Imports the specified module only if it's running in electron | ||
* @param moduleName | ||
* @internal | ||
*/ | ||
function requireInElectronRenderer(moduleName) { | ||
if (!exports.isElectronRenderer) | ||
return undefined; | ||
const realRequire = (typeof __non_webpack_require__ !== "undefined") ? __non_webpack_require__ : require; | ||
return realRequire(moduleName); | ||
} | ||
/** | ||
* Utility to wrap import of the electron module | ||
@@ -32,3 +21,3 @@ * @note The value is set to undefined if not running in Electron. | ||
*/ | ||
exports.electronRenderer = requireInElectronRenderer("electron"); | ||
exports.electronRenderer = (exports.isElectronRenderer) ? require("electron") : undefined; // tslint:disable-line:no-var-requires | ||
//# sourceMappingURL=ElectronUtils.js.map |
/** @packageDocumentation | ||
* @module Collections | ||
*/ | ||
import { OrderedComparator } from "./Compare"; | ||
import { CloneFunction } from "./SortedArray"; | ||
import { OrderedComparator } from "./Compare"; | ||
/** Associates a value of type T with an index representing its insertion order in an IndexMap<T> | ||
@@ -7,0 +7,0 @@ * @public |
@@ -5,4 +5,4 @@ /** @packageDocumentation | ||
import { GetMetaDataFunction } from "./BentleyError"; | ||
import { ClientRequestContext } from "./ClientRequestContext"; | ||
import { IDisposable } from "./Disposable"; | ||
import { ClientRequestContext } from "./ClientRequestContext"; | ||
/** Defines the *signature* for a log function. | ||
@@ -55,2 +55,7 @@ * @public | ||
static initialize(logError: LogFunction | undefined, logWarning?: LogFunction | undefined, logInfo?: LogFunction | undefined, logTrace?: LogFunction | undefined): void; | ||
/** | ||
* Gets raw callbacks which can be use to forward logging | ||
* @internal | ||
*/ | ||
static logRaw(level: LogLevel, category: string, message: string, getMetaData?: GetMetaDataFunction): void; | ||
/** Initialize the logger streams to the console. Should be called at application initialization time. */ | ||
@@ -57,0 +62,0 @@ static initializeToConsole(): void; |
@@ -11,4 +11,4 @@ "use strict"; | ||
const BentleyError_1 = require("./BentleyError"); | ||
const BentleyLoggerCategory_1 = require("./BentleyLoggerCategory"); | ||
const ClientRequestContext_1 = require("./ClientRequestContext"); | ||
const BentleyLoggerCategory_1 = require("./BentleyLoggerCategory"); | ||
/** Use to categorize logging messages by severity. | ||
@@ -44,2 +44,26 @@ * @public | ||
} | ||
/** | ||
* Gets raw callbacks which can be use to forward logging | ||
* @internal | ||
*/ | ||
static logRaw(level, category, message, getMetaData) { | ||
switch (level) { | ||
case LogLevel.Error: | ||
if (this._logError) | ||
this._logError(category, message, getMetaData); | ||
break; | ||
case LogLevel.Info: | ||
if (this._logInfo) | ||
this._logInfo(category, message, getMetaData); | ||
break; | ||
case LogLevel.Trace: | ||
if (this._logTrace) | ||
this._logTrace(category, message, getMetaData); | ||
break; | ||
case LogLevel.Warning: | ||
if (this._logWarning) | ||
this._logWarning(category, message, getMetaData); | ||
break; | ||
} | ||
} | ||
/** Initialize the logger streams to the console. Should be called at application initialization time. */ | ||
@@ -46,0 +70,0 @@ static initializeToConsole() { |
/** @packageDocumentation | ||
* @module Collections | ||
*/ | ||
import { OrderedComparator } from "./Compare"; | ||
import { CloneFunction } from "./SortedArray"; | ||
import { OrderedComparator } from "./Compare"; | ||
/** @public */ | ||
@@ -7,0 +7,0 @@ export declare type ComputePriorityFunction<T> = (value: T) => number; |
@@ -32,8 +32,5 @@ /** @packageDocumentation | ||
/** | ||
* Maintains an array of some type T in sorted order. The ordering is specified by a function supplied | ||
* by the user. | ||
* By default, only unique elements are permitted; attempting to insert a new element that compares | ||
* as equal to an element already in the array will not modify the contents of the array. | ||
* | ||
* This allows a SortedArray<T> to behave like a Set<T> where T is an object and equality is determined | ||
* A read-only view of an array of some type T sorted according to some user-supplied criterion. | ||
* Duplicate elements may be present, though sub-types may enforce uniqueness of elements. | ||
* In the absence of duplicates, a ReadonlySortedArray<T> can behave like a Set<T> where T is an object and equality is determined | ||
* by some criterion other than object identity. | ||
@@ -44,4 +41,2 @@ * | ||
* | ||
* The user can also specify how the SortedArray takes ownership of inserted values, e.g., by cloning them. | ||
* | ||
* The comparison function must meet the following criteria, given 'lhs' and 'rhs' of type T: | ||
@@ -54,7 +49,8 @@ * - If lhs is equal to rhs, returns 0 | ||
* | ||
* Modifying an element in a way that affects the comparison function will produce unpredictable results, the | ||
* most likely of which is that the array will cease to be sorted. | ||
* Note that the array is read-only only from the perspective of its public interface. Mutation methods are defined for internal use by sub-types. | ||
* | ||
* @see [[SortedArray]] for a general-purpose mutable sorted array. | ||
* @public | ||
*/ | ||
export declare class SortedArray<T> implements Iterable<T> { | ||
export declare class ReadonlySortedArray<T> implements Iterable<T> { | ||
protected _array: T[]; | ||
@@ -65,3 +61,3 @@ protected readonly _compare: OrderedComparator<T>; | ||
/** | ||
* Construct a new SortedArray<T>. | ||
* Construct a new ReadonlySortedArray<T>. | ||
* @param compare The function used to compare elements within the array. | ||
@@ -71,3 +67,3 @@ * @param allowDuplicates If true, multiple values comparing equal may exist in the array. | ||
*/ | ||
constructor(compare: OrderedComparator<T>, allowDuplicates?: boolean, clone?: CloneFunction<T>); | ||
protected constructor(compare: OrderedComparator<T>, allowDuplicates?: boolean, clone?: CloneFunction<T>); | ||
/** The number of elements in the array */ | ||
@@ -77,33 +73,5 @@ get length(): number; | ||
get isEmpty(): boolean; | ||
/** Clears the contents of the sorted array. */ | ||
clear(): void; | ||
/** Returns an iterator over the contents of the array in sorted order, suitable for use in `for-of` loops. */ | ||
[Symbol.iterator](): Iterator<T>; | ||
/** Extracts the sorted array as a T[] and empties the contents of this SortedArray. | ||
* @returns the contents of this SortedArray as a T[]. | ||
*/ | ||
extractArray(): T[]; | ||
/** | ||
* Attempts to insert a new value into the array at a position determined by the ordering. | ||
* The behavior differs based on whether or not duplicate elements are permitted. | ||
* If duplicates are **not** permitted, then: | ||
* - If an equivalent element already exists in the array, nothing will be inserted and the index of the existing element will be returned. | ||
* - Otherwise, the element is inserted and its index is returned. | ||
* If duplicates **are** permitted, then: | ||
* - The element will be inserted in a correct position based on the sorting criterion; | ||
* - The position of the element relative to other elements comparing as equal to it is unspecified; and | ||
* - The actual index of the newly-inserted element is returned. | ||
* If the element is to be inserted, then the supplied value will be passed to the clone function supplied to the constructor and the result will be inserted into the array. | ||
* @param value The value to insert | ||
* @param onInsert The optional callback method to call if insertion occurs with the inserted value | ||
* @returns the index in the array of the newly-inserted value, or, if duplicates are not permitted and an equivalent value already exists, the index of the equivalent value. | ||
*/ | ||
insert(value: T, onInsert?: (value: T) => any): number; | ||
/** | ||
* Removes the first occurrence of a value comparing equal to the specified value from the array. | ||
* @param value The value of the element to delete | ||
* @returns the index of the deleted value, or -1 if no such element exists. | ||
*/ | ||
remove(value: T): number; | ||
/** | ||
* Looks up the index of an element comparing equal to the specified value using binary search. | ||
@@ -145,3 +113,93 @@ * @param value The value to search for | ||
}; | ||
/** Clears the contents of the sorted array. */ | ||
protected _clear(): void; | ||
/** Extracts the sorted array as a T[] and empties the contents of this ReadonlySortedArray. | ||
* @returns the contents of this ReadonlySortedArray as a T[]. | ||
*/ | ||
protected _extractArray(): T[]; | ||
/** | ||
* Attempts to insert a new value into the array at a position determined by the ordering. | ||
* The behavior differs based on whether or not duplicate elements are permitted. | ||
* If duplicates are **not** permitted, then: | ||
* - If an equivalent element already exists in the array, nothing will be inserted and the index of the existing element will be returned. | ||
* - Otherwise, the element is inserted and its index is returned. | ||
* If duplicates **are** permitted, then: | ||
* - The element will be inserted in a correct position based on the sorting criterion; | ||
* - The position of the element relative to other elements comparing as equal to it is unspecified; and | ||
* - The actual index of the newly-inserted element is returned. | ||
* If the element is to be inserted, then the supplied value will be passed to the clone function supplied to the constructor and the result will be inserted into the array. | ||
* @param value The value to insert | ||
* @param onInsert The optional callback method to call if insertion occurs with the inserted value | ||
* @returns the index in the array of the newly-inserted value, or, if duplicates are not permitted and an equivalent value already exists, the index of the equivalent value. | ||
*/ | ||
protected _insert(value: T, onInsert?: (value: T) => any): number; | ||
/** | ||
* Removes the first occurrence of a value comparing equal to the specified value from the array. | ||
* @param value The value of the element to delete | ||
* @returns the index of the deleted value, or -1 if no such element exists. | ||
*/ | ||
protected _remove(value: T): number; | ||
} | ||
/** | ||
* Maintains an array of some type T in sorted order. The ordering is specified by a function supplied | ||
* by the user. | ||
* By default, only unique elements are permitted; attempting to insert a new element that compares | ||
* as equal to an element already in the array will not modify the contents of the array. | ||
* | ||
* This allows a SortedArray<T> to behave like a Set<T> where T is an object and equality is determined | ||
* by some criterion other than object identity. | ||
* | ||
* Because the array is always sorted, querying for the presence of an element is performed using binary | ||
* search, which is more efficient than a linear search for reasonably large arrays. | ||
* | ||
* The user can also specify how the SortedArray takes ownership of inserted values, e.g., by cloning them. | ||
* | ||
* The comparison function must meet the following criteria, given 'lhs' and 'rhs' of type T: | ||
* - If lhs is equal to rhs, returns 0 | ||
* - If lhs is less than rhs, returns a negative value | ||
* - If lhs is greater than rhs, returns a positive value | ||
* - If compare(lhs, rhs) returns 0, then compare(rhs, lhs) must also return 0 | ||
* - If compare(lhs, rhs) returns a negative value, then compare(rhs, lhs) must return a positive value, and vice versa. | ||
* | ||
* Modifying an element in a way that affects the comparison function will produce unpredictable results, the | ||
* most likely of which is that the array will cease to be sorted. | ||
* @public | ||
*/ | ||
export declare class SortedArray<T> extends ReadonlySortedArray<T> { | ||
/** | ||
* Construct a new SortedArray<T>. | ||
* @param compare The function used to compare elements within the array. | ||
* @param allowDuplicates If true, multiple values comparing equal may exist in the array. | ||
* @param clone The function invoked to clone a new element for insertion into the array. The default implementation simply returns its input. | ||
*/ | ||
constructor(compare: OrderedComparator<T>, allowDuplicates?: boolean, clone?: CloneFunction<T>); | ||
/** Clears the contents of the sorted array. */ | ||
clear(): void; | ||
/** Extracts the sorted array as a T[] and empties the contents of this SortedArray. | ||
* @returns the contents of this SortedArray as a T[]. | ||
*/ | ||
extractArray(): T[]; | ||
/** | ||
* Attempts to insert a new value into the array at a position determined by the ordering. | ||
* The behavior differs based on whether or not duplicate elements are permitted. | ||
* If duplicates are **not** permitted, then: | ||
* - If an equivalent element already exists in the array, nothing will be inserted and the index of the existing element will be returned. | ||
* - Otherwise, the element is inserted and its index is returned. | ||
* If duplicates **are** permitted, then: | ||
* - The element will be inserted in a correct position based on the sorting criterion; | ||
* - The position of the element relative to other elements comparing as equal to it is unspecified; and | ||
* - The actual index of the newly-inserted element is returned. | ||
* If the element is to be inserted, then the supplied value will be passed to the clone function supplied to the constructor and the result will be inserted into the array. | ||
* @param value The value to insert | ||
* @param onInsert The optional callback method to call if insertion occurs with the inserted value | ||
* @returns the index in the array of the newly-inserted value, or, if duplicates are not permitted and an equivalent value already exists, the index of the equivalent value. | ||
*/ | ||
insert(value: T, onInsert?: (value: T) => any): number; | ||
/** | ||
* Removes the first occurrence of a value comparing equal to the specified value from the array. | ||
* @param value The value of the element to delete | ||
* @returns the index of the deleted value, or -1 if no such element exists. | ||
*/ | ||
remove(value: T): number; | ||
} | ||
//# sourceMappingURL=SortedArray.d.ts.map |
@@ -44,8 +44,5 @@ "use strict"; | ||
/** | ||
* Maintains an array of some type T in sorted order. The ordering is specified by a function supplied | ||
* by the user. | ||
* By default, only unique elements are permitted; attempting to insert a new element that compares | ||
* as equal to an element already in the array will not modify the contents of the array. | ||
* | ||
* This allows a SortedArray<T> to behave like a Set<T> where T is an object and equality is determined | ||
* A read-only view of an array of some type T sorted according to some user-supplied criterion. | ||
* Duplicate elements may be present, though sub-types may enforce uniqueness of elements. | ||
* In the absence of duplicates, a ReadonlySortedArray<T> can behave like a Set<T> where T is an object and equality is determined | ||
* by some criterion other than object identity. | ||
@@ -56,4 +53,2 @@ * | ||
* | ||
* The user can also specify how the SortedArray takes ownership of inserted values, e.g., by cloning them. | ||
* | ||
* The comparison function must meet the following criteria, given 'lhs' and 'rhs' of type T: | ||
@@ -66,9 +61,10 @@ * - If lhs is equal to rhs, returns 0 | ||
* | ||
* Modifying an element in a way that affects the comparison function will produce unpredictable results, the | ||
* most likely of which is that the array will cease to be sorted. | ||
* Note that the array is read-only only from the perspective of its public interface. Mutation methods are defined for internal use by sub-types. | ||
* | ||
* @see [[SortedArray]] for a general-purpose mutable sorted array. | ||
* @public | ||
*/ | ||
class SortedArray { | ||
class ReadonlySortedArray { | ||
/** | ||
* Construct a new SortedArray<T>. | ||
* Construct a new ReadonlySortedArray<T>. | ||
* @param compare The function used to compare elements within the array. | ||
@@ -88,10 +84,55 @@ * @param allowDuplicates If true, multiple values comparing equal may exist in the array. | ||
get isEmpty() { return 0 === this.length; } | ||
/** Clears the contents of the sorted array. */ | ||
clear() { this._array.length = 0; } | ||
/** Returns an iterator over the contents of the array in sorted order, suitable for use in `for-of` loops. */ | ||
[Symbol.iterator]() { return this._array[Symbol.iterator](); } | ||
/** Extracts the sorted array as a T[] and empties the contents of this SortedArray. | ||
* @returns the contents of this SortedArray as a T[]. | ||
/** | ||
* Looks up the index of an element comparing equal to the specified value using binary search. | ||
* @param value The value to search for | ||
* @returns the index of the first equivalent element in the array, or -1 if no such element exists. | ||
*/ | ||
extractArray() { | ||
indexOf(value) { | ||
const bound = this.lowerBound(value); | ||
return bound.equal ? bound.index : -1; | ||
} | ||
/** | ||
* Returns true if this array contains at least one value comparing equal to the specified value. | ||
* @param value The value to search for | ||
* @returns true if an equivalent element exists in the array. | ||
*/ | ||
contains(value) { | ||
return -1 !== this.indexOf(value); | ||
} | ||
/** | ||
* Looks up an element comparing equal to the specified value using binary search. | ||
* @param value The value to search for | ||
* @returns the first equivalent element in the array, or undefined if no such element exists. | ||
*/ | ||
findEqual(value) { | ||
const index = this.indexOf(value); | ||
return -1 !== index ? this._array[index] : undefined; | ||
} | ||
/** | ||
* Looks up an element by its index in the array. | ||
* @param index The array index | ||
* @returns the element corresponding to that position in the array, or undefined if the supplied index exceeds the length of the array. | ||
*/ | ||
get(index) { return index < this.length ? this._array[index] : undefined; } | ||
/** Apply a function to each element in the array, in sorted order. | ||
* @param func The function to be applied. | ||
*/ | ||
forEach(func) { | ||
for (let i = 0; i < this.length; i++) | ||
func(this._array[i]); | ||
} | ||
/** | ||
* Computes the position at which the specified value should be inserted to maintain sorted order. | ||
* @param value The value whose position is to be computed. | ||
* @returns an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent element already exists at that index. | ||
*/ | ||
lowerBound(value) { return lowerBound(value, this._array, this._compare); } | ||
/** Clears the contents of the sorted array. */ | ||
_clear() { this._array.length = 0; } | ||
/** Extracts the sorted array as a T[] and empties the contents of this ReadonlySortedArray. | ||
* @returns the contents of this ReadonlySortedArray as a T[]. | ||
*/ | ||
_extractArray() { | ||
const result = this._array; | ||
@@ -116,3 +157,3 @@ this._array = []; | ||
*/ | ||
insert(value, onInsert) { | ||
_insert(value, onInsert) { | ||
const bound = this.lowerBound(value); | ||
@@ -130,3 +171,3 @@ if (!bound.equal || this._allowDuplicates) | ||
*/ | ||
remove(value) { | ||
_remove(value) { | ||
const bound = this.lowerBound(value); | ||
@@ -141,49 +182,69 @@ if (bound.equal) { | ||
} | ||
} | ||
exports.ReadonlySortedArray = ReadonlySortedArray; | ||
/** | ||
* Maintains an array of some type T in sorted order. The ordering is specified by a function supplied | ||
* by the user. | ||
* By default, only unique elements are permitted; attempting to insert a new element that compares | ||
* as equal to an element already in the array will not modify the contents of the array. | ||
* | ||
* This allows a SortedArray<T> to behave like a Set<T> where T is an object and equality is determined | ||
* by some criterion other than object identity. | ||
* | ||
* Because the array is always sorted, querying for the presence of an element is performed using binary | ||
* search, which is more efficient than a linear search for reasonably large arrays. | ||
* | ||
* The user can also specify how the SortedArray takes ownership of inserted values, e.g., by cloning them. | ||
* | ||
* The comparison function must meet the following criteria, given 'lhs' and 'rhs' of type T: | ||
* - If lhs is equal to rhs, returns 0 | ||
* - If lhs is less than rhs, returns a negative value | ||
* - If lhs is greater than rhs, returns a positive value | ||
* - If compare(lhs, rhs) returns 0, then compare(rhs, lhs) must also return 0 | ||
* - If compare(lhs, rhs) returns a negative value, then compare(rhs, lhs) must return a positive value, and vice versa. | ||
* | ||
* Modifying an element in a way that affects the comparison function will produce unpredictable results, the | ||
* most likely of which is that the array will cease to be sorted. | ||
* @public | ||
*/ | ||
class SortedArray extends ReadonlySortedArray { | ||
/** | ||
* Looks up the index of an element comparing equal to the specified value using binary search. | ||
* @param value The value to search for | ||
* @returns the index of the first equivalent element in the array, or -1 if no such element exists. | ||
* Construct a new SortedArray<T>. | ||
* @param compare The function used to compare elements within the array. | ||
* @param allowDuplicates If true, multiple values comparing equal may exist in the array. | ||
* @param clone The function invoked to clone a new element for insertion into the array. The default implementation simply returns its input. | ||
*/ | ||
indexOf(value) { | ||
const bound = this.lowerBound(value); | ||
return bound.equal ? bound.index : -1; | ||
constructor(compare, allowDuplicates = false, clone = shallowClone) { | ||
super(compare, allowDuplicates, clone); | ||
} | ||
/** | ||
* Returns true if this array contains at least one value comparing equal to the specified value. | ||
* @param value The value to search for | ||
* @returns true if an equivalent element exists in the array. | ||
/** Clears the contents of the sorted array. */ | ||
clear() { this._clear(); } | ||
/** Extracts the sorted array as a T[] and empties the contents of this SortedArray. | ||
* @returns the contents of this SortedArray as a T[]. | ||
*/ | ||
contains(value) { | ||
return -1 !== this.indexOf(value); | ||
} | ||
extractArray() { return this._extractArray(); } | ||
/** | ||
* Looks up an element comparing equal to the specified value using binary search. | ||
* @param value The value to search for | ||
* @returns the first equivalent element in the array, or undefined if no such element exists. | ||
* Attempts to insert a new value into the array at a position determined by the ordering. | ||
* The behavior differs based on whether or not duplicate elements are permitted. | ||
* If duplicates are **not** permitted, then: | ||
* - If an equivalent element already exists in the array, nothing will be inserted and the index of the existing element will be returned. | ||
* - Otherwise, the element is inserted and its index is returned. | ||
* If duplicates **are** permitted, then: | ||
* - The element will be inserted in a correct position based on the sorting criterion; | ||
* - The position of the element relative to other elements comparing as equal to it is unspecified; and | ||
* - The actual index of the newly-inserted element is returned. | ||
* If the element is to be inserted, then the supplied value will be passed to the clone function supplied to the constructor and the result will be inserted into the array. | ||
* @param value The value to insert | ||
* @param onInsert The optional callback method to call if insertion occurs with the inserted value | ||
* @returns the index in the array of the newly-inserted value, or, if duplicates are not permitted and an equivalent value already exists, the index of the equivalent value. | ||
*/ | ||
findEqual(value) { | ||
const index = this.indexOf(value); | ||
return -1 !== index ? this._array[index] : undefined; | ||
} | ||
insert(value, onInsert) { return this._insert(value, onInsert); } | ||
/** | ||
* Looks up an element by its index in the array. | ||
* @param index The array index | ||
* @returns the element corresponding to that position in the array, or undefined if the supplied index exceeds the length of the array. | ||
* Removes the first occurrence of a value comparing equal to the specified value from the array. | ||
* @param value The value of the element to delete | ||
* @returns the index of the deleted value, or -1 if no such element exists. | ||
*/ | ||
get(index) { return index < this.length ? this._array[index] : undefined; } | ||
/** Apply a function to each element in the array, in sorted order. | ||
* @param func The function to be applied. | ||
*/ | ||
forEach(func) { | ||
for (let i = 0; i < this.length; i++) | ||
func(this._array[i]); | ||
} | ||
/** | ||
* Computes the position at which the specified value should be inserted to maintain sorted order. | ||
* @param value The value whose position is to be computed. | ||
* @returns an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent element already exists at that index. | ||
*/ | ||
lowerBound(value) { return lowerBound(value, this._array, this._compare); } | ||
remove(value) { return this._remove(value); } | ||
} | ||
exports.SortedArray = SortedArray; | ||
//# sourceMappingURL=SortedArray.js.map |
{ | ||
"name": "@bentley/bentleyjs-core", | ||
"version": "1.14.1", | ||
"version": "2.0.0", | ||
"description": "Bentley JavaScript core components", | ||
"main": "lib/bentleyjs-core.js", | ||
"typings": "lib/bentleyjs-core", | ||
"imodeljsSharedLibrary": true, | ||
"license": "MIT", | ||
@@ -13,7 +14,7 @@ "repository": { | ||
"scripts": { | ||
"build": "buildIModelJsModule", | ||
"clean": "rimraf lib .rush package-deps.json", | ||
"extract-api": "node ./node_modules/@bentley/build-tools/scripts/extract-api.js --entry=bentleyjs-core", | ||
"test": "node ./node_modules/@bentley/build-tools/scripts/test.js", | ||
"docs": "node ./node_modules/@bentley/build-tools/scripts/docs.js --json=../../generated-docs/core/bentleyjs-core/file.json --tsIndexFile=bentleyjs-core.ts --onlyJson %TYPEDOC_THEME%", | ||
"build": "tsc 1>&2", | ||
"clean": "rimraf lib .rush/temp/package-deps*.json", | ||
"extract-api": "betools extract-api --entry=bentleyjs-core", | ||
"test": "betools test", | ||
"docs": "betools docs --json=../../generated-docs/core/bentleyjs-core/file.json --tsIndexFile=bentleyjs-core.ts --onlyJson", | ||
"cover": "nyc npm test", | ||
@@ -23,12 +24,2 @@ "cover:docs": "node ./node_modules/@bentley/build-tools/scripts/docscoverage.js", | ||
}, | ||
"iModelJs": { | ||
"buildModule": { | ||
"type": "system", | ||
"webpack": { | ||
"dest": "./lib/module", | ||
"entry": "./lib/bentleyjs-core.js", | ||
"bundleName": "bentleyjs-core" | ||
} | ||
} | ||
}, | ||
"keywords": [ | ||
@@ -44,4 +35,3 @@ "Bentley", | ||
"devDependencies": { | ||
"@bentley/build-tools": "1.14.1", | ||
"@bentley/webpack-tools": "1.14.1", | ||
"@bentley/build-tools": "2.0.0", | ||
"@types/chai": "^4.1.4", | ||
@@ -54,3 +44,3 @@ "@types/chai-as-promised": "^7", | ||
"mocha": "^5.2.0", | ||
"rimraf": "^2.6.2", | ||
"rimraf": "^3.0.2", | ||
"tslint": "^5.11.0", | ||
@@ -57,0 +47,0 @@ "tslint-etc": "^1.5.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
14
106
1
1
491970
7082