Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fluidframework/core-utils

Package Overview
Dependencies
Maintainers
2
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluidframework/core-utils - npm Package Compare versions

Comparing version 2.0.0-dev.7.4.0.215930 to 2.0.0-dev.7.4.0.216897

api-extractor-lint.json

38

api-report/core-utils.api.md

@@ -7,3 +7,3 @@ ## API Report File for "@fluidframework/core-utils"

// @public
// @internal
export function assert(condition: boolean, message: string | number): asserts condition;

@@ -14,3 +14,3 @@

// @public
// @internal
export class Deferred<T> {

@@ -24,6 +24,6 @@ constructor();

// @public
// @internal
export const delay: (timeMs: number) => Promise<void>;
// @public
// @internal
export class Heap<T> {

@@ -41,3 +41,3 @@ constructor(comp: IComparer<T>);

// @public
// @internal
export interface IComparer<T> {

@@ -48,3 +48,3 @@ compare(a: T, b: T): number;

// @public
// @internal
export interface IHeapNode<T> {

@@ -57,3 +57,3 @@ // (undocumented)

// @public
// @internal
export interface IPromiseTimer extends ITimer {

@@ -63,3 +63,3 @@ start(): Promise<IPromiseTimerResult>;

// @public (undocumented)
// @internal (undocumented)
export interface IPromiseTimerResult {

@@ -70,3 +70,3 @@ // (undocumented)

// @public (undocumented)
// @internal (undocumented)
export interface ITimer {

@@ -78,3 +78,3 @@ clear(): void;

// @public
// @internal
export class Lazy<T> {

@@ -86,3 +86,3 @@ constructor(valueGenerator: () => T);

// @public
// @internal
export class LazyPromise<T> implements Promise<T> {

@@ -100,6 +100,6 @@ // (undocumented)

// @public
// @internal
export const NumberComparer: IComparer<number>;
// @public
// @internal
export class PromiseCache<TKey, TResult> {

@@ -116,3 +116,3 @@ constructor({ expiry, removeOnError, }?: PromiseCacheOptions);

// @public
// @internal
export type PromiseCacheExpiry = {

@@ -125,3 +125,3 @@ policy: "indefinite";

// @public
// @internal
export interface PromiseCacheOptions {

@@ -132,3 +132,3 @@ expiry?: PromiseCacheExpiry;

// @public
// @internal
export class PromiseTimer implements IPromiseTimer {

@@ -144,6 +144,6 @@ constructor(defaultTimeout: number, defaultHandler: () => void);

// @public
// @internal
export function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;
// @public
// @internal
export class Timer implements ITimer {

@@ -157,3 +157,3 @@ constructor(defaultTimeout: number, defaultHandler: () => void, getCurrentTick?: () => number);

// @public
// @internal
export function unreachableCase(_: never, message?: string): never;

@@ -160,0 +160,0 @@

@@ -14,5 +14,5 @@ /*!

* use numbered error codes instead.
* @public
* @internal
*/
export declare function assert(condition: boolean, message: string | number): asserts condition;
//# sourceMappingURL=assert.d.ts.map

@@ -17,3 +17,3 @@ "use strict";

* use numbered error codes instead.
* @public
* @internal
*/

@@ -20,0 +20,0 @@ function assert(condition, message) {

@@ -1,404 +0,41 @@

/**
* A browser friendly assert library.
* Use this instead of the 'assert' package, which has a big impact on bundle sizes.
* @param condition - The condition that should be true, if the condition is false an error will be thrown.
* Only use this API when `false` indicates a logic error in the problem and thus a bug that should be fixed.
* @param message - The message to include in the error when the condition does not hold.
* A number should not be specified manually: use a string.
* Before a release, policy-check should be run, which will convert any asserts still using strings to
* use numbered error codes instead.
* @public
*/
export declare function assert(condition: boolean, message: string | number): asserts condition;
/* Excluded from this release type: assert */
/* Excluded from this release type: compareArrays */
/**
* A deferred creates a promise and the ability to resolve or reject it
* @public
*/
export declare class Deferred<T> {
private readonly p;
private res;
private rej;
private completed;
constructor();
/**
* Returns whether the underlying promise has been completed
*/
get isCompleted(): boolean;
/**
* Retrieves the underlying promise for the deferred
*
* @returns the underlying promise
*/
get promise(): Promise<T>;
/**
* Resolves the promise
*
* @param value - the value to resolve the promise with
*/
resolve(value: T | PromiseLike<T>): void;
/**
* Rejects the promise
*
* @param value - the value to reject the promise with
*/
reject(error: any): void;
}
/* Excluded from this release type: Deferred */
/**
* Returns a promise that resolves after `timeMs`.
* @param timeMs - Time in milliseconds to wait.
* @public
*/
export declare const delay: (timeMs: number) => Promise<void>;
/* Excluded from this release type: delay */
/**
* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
*/
export declare class Heap<T> {
comp: IComparer<T>;
private L;
/**
* Creates an instance of `Heap` with comparer.
* @param comp - A comparer that specify how elements are ordered.
*/
constructor(comp: IComparer<T>);
/**
* Return the smallest element in the heap as determined by the order of the comparer
*
* @returns Heap node containing the smallest element
*/
peek(): IHeapNode<T>;
/**
* Get and remove the smallest element in the heap as determined by the order of the comparer
*
* @returns The smallest value in the heap
*/
get(): T;
/**
* Add a value to the heap
*
* @param x - value to add
* @returns The heap node that contains the value
*/
add(x: T): IHeapNode<T>;
/**
* Allows for the Heap to be updated after a node's value changes.
*/
update(node: IHeapNode<T>): void;
/**
* Removes the given node from the heap.
*
* @param node - The node to remove from the heap.
*/
remove(node: IHeapNode<T>): void;
/**
* Get the number of elements in the Heap.
*
* @returns The number of elements in the Heap.
*/
count(): number;
private fixup;
private isGreaterThanParent;
private fixdown;
private swap;
}
/* Excluded from this release type: Heap */
/**
* Interface for a comparer.
* @public
*/
export declare interface IComparer<T> {
/**
* The minimum value of type T.
*/
min: T;
/**
* Compare the two value
*
* @returns 0 if the value is equal, negative number if a is smaller then b, positive number otherwise
*/
compare(a: T, b: T): number;
}
/* Excluded from this release type: IComparer */
/**
* Interface to a node in {@link Heap}.
* @public
*/
export declare interface IHeapNode<T> {
value: T;
position: number;
}
/* Excluded from this release type: IHeapNode */
/**
* Timer which offers a promise that fulfills when the timer
* completes.
* @public
*/
export declare interface IPromiseTimer extends ITimer {
/**
* Starts the timer and returns a promise that
* resolves when the timer times out or is canceled.
*/
start(): Promise<IPromiseTimerResult>;
}
/* Excluded from this release type: IPromiseTimer */
/**
* @public
*/
export declare interface IPromiseTimerResult {
timerResult: "timeout" | "cancel";
}
/* Excluded from this release type: IPromiseTimerResult */
/**
* @public
*/
export declare interface ITimer {
/**
* True if timer is currently running
*/
readonly hasTimer: boolean;
/**
* Starts the timer
*/
start(): void;
/**
* Cancels the timer if already running
*/
clear(): void;
}
/* Excluded from this release type: ITimer */
/**
* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
*/
export declare class Lazy<T> {
private readonly valueGenerator;
private _value;
private _evaluated;
/**
* Instantiates an instance of Lazy<T>.
* @param valueGenerator - The function that will generate the value when value is accessed the first time.
*/
constructor(valueGenerator: () => T);
/**
* Return true if the value as been generated, otherwise false.
*/
get evaluated(): boolean;
/**
* Get the value. If this is the first call the value will be generated.
*/
get value(): T;
}
/* Excluded from this release type: Lazy */
/**
* A lazy evaluated promise. The execute function is delayed until
* the promise is used, e.g. await, then, catch ...
* The execute function is only called once.
* All calls are then proxied to the promise returned by the execute method.
* @public
*/
export declare class LazyPromise<T> implements Promise<T> {
private readonly execute;
get [Symbol.toStringTag](): string;
private result;
constructor(execute: () => Promise<T>);
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
finally(onfinally?: (() => void) | null | undefined): Promise<T>;
private getPromise;
}
/* Excluded from this release type: LazyPromise */
/**
* A comparer for numbers.
* @public
*/
export declare const NumberComparer: IComparer<number>;
/* Excluded from this release type: NumberComparer */
/**
* A specialized cache for async work, allowing you to safely cache the promised result of some async work
* without fear of running it multiple times or losing track of errors.
* @public
*/
export declare class PromiseCache<TKey, TResult> {
private readonly cache;
private readonly gc;
private readonly removeOnError;
/**
* Create the PromiseCache with the given options, with the following defaults:
*
* expiry: indefinite, removeOnError: true for all errors
*/
constructor({ expiry, removeOnError, }?: PromiseCacheOptions);
/**
* Check if there's anything cached at the given key
*/
has(key: TKey): boolean;
/**
* Get the Promise for the given key, or undefined if it's not found.
* Extend expiry if applicable.
*/
get(key: TKey): Promise<TResult> | undefined;
/**
* Remove the Promise for the given key, returning true if it was found and removed
*/
remove(key: TKey): boolean;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
addOrGet(key: TKey, asyncFn: () => Promise<TResult>): Promise<TResult>;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
add(key: TKey, asyncFn: () => Promise<TResult>): boolean;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param value - value to store
*/
addValueOrGet(key: TKey, value: TResult): Promise<TResult>;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the value
* @param value - value to store
*/
addValue(key: TKey, value: TResult): boolean;
}
/* Excluded from this release type: PromiseCache */
/**
* Three supported expiry policies:
* - indefinite: entries don't expire and must be explicitly removed
* - absolute: entries expire after the given duration in MS, even if accessed multiple times in the mean time
* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
*/
export declare type PromiseCacheExpiry = {
policy: "indefinite";
} | {
policy: "absolute" | "sliding";
durationMs: number;
};
/* Excluded from this release type: PromiseCacheExpiry */
/**
* Options for configuring the {@link PromiseCache}
* @public
*/
export declare interface PromiseCacheOptions {
/**
* Common expiration policy for all items added to this cache
*/
expiry?: PromiseCacheExpiry;
/**
* If the stored Promise is rejected with a particular error, should the given key be removed?
*/
removeOnError?: (error: any) => boolean;
}
/* Excluded from this release type: PromiseCacheOptions */
/**
* This class is a wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the
* same handlers and timeouts, while also providing a promise that
* resolves when it times out.
* @public
*/
export declare class PromiseTimer implements IPromiseTimer {
private deferred?;
private readonly timer;
/**
* {@inheritDoc Timer.hasTimer}
*/
get hasTimer(): boolean;
constructor(defaultTimeout: number, defaultHandler: () => void);
/**
* {@inheritDoc IPromiseTimer.start}
*/
start(ms?: number, handler?: () => void): Promise<IPromiseTimerResult>;
clear(): void;
protected wrapHandler(handler: () => void): void;
}
/* Excluded from this release type: PromiseTimer */
/**
* Sets timeouts like the setTimeout function allowing timeouts to exceed the setTimeout's max timeout limit.
* Timeouts may not be exactly accurate due to browser implementations and the OS.
* https://stackoverflow.com/questions/21097421/what-is-the-reason-javascript-settimeout-is-so-inaccurate
* @param timeoutFn - Executed when the timeout expires
* @param timeoutMs - Duration of the timeout in milliseconds
* @param setTimeoutIdFn - Executed to update the timeout if multiple timeouts are required when
* timeoutMs greater than maxTimeout
* @returns The initial timeout
* @public
*/
export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;
/* Excluded from this release type: setLongTimeout */
/**
* This class is a thin wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the same
* or similar handlers and timeouts. This class supports long timeouts
* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
*/
export declare class Timer implements ITimer {
private readonly defaultTimeout;
private readonly defaultHandler;
private readonly getCurrentTick;
/**
* Returns true if the timer is running.
*/
get hasTimer(): boolean;
private runningState;
constructor(defaultTimeout: number, defaultHandler: () => void, getCurrentTick?: () => number);
/**
* Calls setTimeout and tracks the resulting timeout.
* @param ms - overrides default timeout in ms
* @param handler - overrides default handler
*/
start(ms?: number, handler?: () => void): void;
/**
* Calls clearTimeout on the underlying timeout if running.
*/
clear(): void;
/**
* Restarts the timer with the new handler and duration.
* If a new handler is passed, the original handler may
* never execute.
* This is a potentially more efficient way to clear and start
* a new timer.
* @param ms - overrides previous or default timeout in ms
* @param handler - overrides previous or default handler
*/
restart(ms?: number, handler?: () => void): void;
private startCore;
private handler;
private calculateRemainingTime;
}
/* Excluded from this release type: Timer */
/**
* This function can be used to assert at compile time that a given value has type never.
* One common usage is in the default case of a switch block,
* to ensure that all cases are explicitly handled.
*
* Example:
* ```typescript
* const bool: true | false = ...;
* switch(bool) {
* case true: {...}
* case false: {...}
* default: unreachableCase(bool);
* }
* ```
* @public
*/
export declare function unreachableCase(_: never, message?: string): never;
/* Excluded from this release type: unreachableCase */
export { }

@@ -1,404 +0,41 @@

/**
* A browser friendly assert library.
* Use this instead of the 'assert' package, which has a big impact on bundle sizes.
* @param condition - The condition that should be true, if the condition is false an error will be thrown.
* Only use this API when `false` indicates a logic error in the problem and thus a bug that should be fixed.
* @param message - The message to include in the error when the condition does not hold.
* A number should not be specified manually: use a string.
* Before a release, policy-check should be run, which will convert any asserts still using strings to
* use numbered error codes instead.
* @public
*/
export declare function assert(condition: boolean, message: string | number): asserts condition;
/* Excluded from this release type: assert */
/* Excluded from this release type: compareArrays */
/**
* A deferred creates a promise and the ability to resolve or reject it
* @public
*/
export declare class Deferred<T> {
private readonly p;
private res;
private rej;
private completed;
constructor();
/**
* Returns whether the underlying promise has been completed
*/
get isCompleted(): boolean;
/**
* Retrieves the underlying promise for the deferred
*
* @returns the underlying promise
*/
get promise(): Promise<T>;
/**
* Resolves the promise
*
* @param value - the value to resolve the promise with
*/
resolve(value: T | PromiseLike<T>): void;
/**
* Rejects the promise
*
* @param value - the value to reject the promise with
*/
reject(error: any): void;
}
/* Excluded from this release type: Deferred */
/**
* Returns a promise that resolves after `timeMs`.
* @param timeMs - Time in milliseconds to wait.
* @public
*/
export declare const delay: (timeMs: number) => Promise<void>;
/* Excluded from this release type: delay */
/**
* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
*/
export declare class Heap<T> {
comp: IComparer<T>;
private L;
/**
* Creates an instance of `Heap` with comparer.
* @param comp - A comparer that specify how elements are ordered.
*/
constructor(comp: IComparer<T>);
/**
* Return the smallest element in the heap as determined by the order of the comparer
*
* @returns Heap node containing the smallest element
*/
peek(): IHeapNode<T>;
/**
* Get and remove the smallest element in the heap as determined by the order of the comparer
*
* @returns The smallest value in the heap
*/
get(): T;
/**
* Add a value to the heap
*
* @param x - value to add
* @returns The heap node that contains the value
*/
add(x: T): IHeapNode<T>;
/**
* Allows for the Heap to be updated after a node's value changes.
*/
update(node: IHeapNode<T>): void;
/**
* Removes the given node from the heap.
*
* @param node - The node to remove from the heap.
*/
remove(node: IHeapNode<T>): void;
/**
* Get the number of elements in the Heap.
*
* @returns The number of elements in the Heap.
*/
count(): number;
private fixup;
private isGreaterThanParent;
private fixdown;
private swap;
}
/* Excluded from this release type: Heap */
/**
* Interface for a comparer.
* @public
*/
export declare interface IComparer<T> {
/**
* The minimum value of type T.
*/
min: T;
/**
* Compare the two value
*
* @returns 0 if the value is equal, negative number if a is smaller then b, positive number otherwise
*/
compare(a: T, b: T): number;
}
/* Excluded from this release type: IComparer */
/**
* Interface to a node in {@link Heap}.
* @public
*/
export declare interface IHeapNode<T> {
value: T;
position: number;
}
/* Excluded from this release type: IHeapNode */
/**
* Timer which offers a promise that fulfills when the timer
* completes.
* @public
*/
export declare interface IPromiseTimer extends ITimer {
/**
* Starts the timer and returns a promise that
* resolves when the timer times out or is canceled.
*/
start(): Promise<IPromiseTimerResult>;
}
/* Excluded from this release type: IPromiseTimer */
/**
* @public
*/
export declare interface IPromiseTimerResult {
timerResult: "timeout" | "cancel";
}
/* Excluded from this release type: IPromiseTimerResult */
/**
* @public
*/
export declare interface ITimer {
/**
* True if timer is currently running
*/
readonly hasTimer: boolean;
/**
* Starts the timer
*/
start(): void;
/**
* Cancels the timer if already running
*/
clear(): void;
}
/* Excluded from this release type: ITimer */
/**
* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
*/
export declare class Lazy<T> {
private readonly valueGenerator;
private _value;
private _evaluated;
/**
* Instantiates an instance of Lazy<T>.
* @param valueGenerator - The function that will generate the value when value is accessed the first time.
*/
constructor(valueGenerator: () => T);
/**
* Return true if the value as been generated, otherwise false.
*/
get evaluated(): boolean;
/**
* Get the value. If this is the first call the value will be generated.
*/
get value(): T;
}
/* Excluded from this release type: Lazy */
/**
* A lazy evaluated promise. The execute function is delayed until
* the promise is used, e.g. await, then, catch ...
* The execute function is only called once.
* All calls are then proxied to the promise returned by the execute method.
* @public
*/
export declare class LazyPromise<T> implements Promise<T> {
private readonly execute;
get [Symbol.toStringTag](): string;
private result;
constructor(execute: () => Promise<T>);
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
finally(onfinally?: (() => void) | null | undefined): Promise<T>;
private getPromise;
}
/* Excluded from this release type: LazyPromise */
/**
* A comparer for numbers.
* @public
*/
export declare const NumberComparer: IComparer<number>;
/* Excluded from this release type: NumberComparer */
/**
* A specialized cache for async work, allowing you to safely cache the promised result of some async work
* without fear of running it multiple times or losing track of errors.
* @public
*/
export declare class PromiseCache<TKey, TResult> {
private readonly cache;
private readonly gc;
private readonly removeOnError;
/**
* Create the PromiseCache with the given options, with the following defaults:
*
* expiry: indefinite, removeOnError: true for all errors
*/
constructor({ expiry, removeOnError, }?: PromiseCacheOptions);
/**
* Check if there's anything cached at the given key
*/
has(key: TKey): boolean;
/**
* Get the Promise for the given key, or undefined if it's not found.
* Extend expiry if applicable.
*/
get(key: TKey): Promise<TResult> | undefined;
/**
* Remove the Promise for the given key, returning true if it was found and removed
*/
remove(key: TKey): boolean;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
addOrGet(key: TKey, asyncFn: () => Promise<TResult>): Promise<TResult>;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
add(key: TKey, asyncFn: () => Promise<TResult>): boolean;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param value - value to store
*/
addValueOrGet(key: TKey, value: TResult): Promise<TResult>;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the value
* @param value - value to store
*/
addValue(key: TKey, value: TResult): boolean;
}
/* Excluded from this release type: PromiseCache */
/**
* Three supported expiry policies:
* - indefinite: entries don't expire and must be explicitly removed
* - absolute: entries expire after the given duration in MS, even if accessed multiple times in the mean time
* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
*/
export declare type PromiseCacheExpiry = {
policy: "indefinite";
} | {
policy: "absolute" | "sliding";
durationMs: number;
};
/* Excluded from this release type: PromiseCacheExpiry */
/**
* Options for configuring the {@link PromiseCache}
* @public
*/
export declare interface PromiseCacheOptions {
/**
* Common expiration policy for all items added to this cache
*/
expiry?: PromiseCacheExpiry;
/**
* If the stored Promise is rejected with a particular error, should the given key be removed?
*/
removeOnError?: (error: any) => boolean;
}
/* Excluded from this release type: PromiseCacheOptions */
/**
* This class is a wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the
* same handlers and timeouts, while also providing a promise that
* resolves when it times out.
* @public
*/
export declare class PromiseTimer implements IPromiseTimer {
private deferred?;
private readonly timer;
/**
* {@inheritDoc Timer.hasTimer}
*/
get hasTimer(): boolean;
constructor(defaultTimeout: number, defaultHandler: () => void);
/**
* {@inheritDoc IPromiseTimer.start}
*/
start(ms?: number, handler?: () => void): Promise<IPromiseTimerResult>;
clear(): void;
protected wrapHandler(handler: () => void): void;
}
/* Excluded from this release type: PromiseTimer */
/**
* Sets timeouts like the setTimeout function allowing timeouts to exceed the setTimeout's max timeout limit.
* Timeouts may not be exactly accurate due to browser implementations and the OS.
* https://stackoverflow.com/questions/21097421/what-is-the-reason-javascript-settimeout-is-so-inaccurate
* @param timeoutFn - Executed when the timeout expires
* @param timeoutMs - Duration of the timeout in milliseconds
* @param setTimeoutIdFn - Executed to update the timeout if multiple timeouts are required when
* timeoutMs greater than maxTimeout
* @returns The initial timeout
* @public
*/
export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;
/* Excluded from this release type: setLongTimeout */
/**
* This class is a thin wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the same
* or similar handlers and timeouts. This class supports long timeouts
* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
*/
export declare class Timer implements ITimer {
private readonly defaultTimeout;
private readonly defaultHandler;
private readonly getCurrentTick;
/**
* Returns true if the timer is running.
*/
get hasTimer(): boolean;
private runningState;
constructor(defaultTimeout: number, defaultHandler: () => void, getCurrentTick?: () => number);
/**
* Calls setTimeout and tracks the resulting timeout.
* @param ms - overrides default timeout in ms
* @param handler - overrides default handler
*/
start(ms?: number, handler?: () => void): void;
/**
* Calls clearTimeout on the underlying timeout if running.
*/
clear(): void;
/**
* Restarts the timer with the new handler and duration.
* If a new handler is passed, the original handler may
* never execute.
* This is a potentially more efficient way to clear and start
* a new timer.
* @param ms - overrides previous or default timeout in ms
* @param handler - overrides previous or default handler
*/
restart(ms?: number, handler?: () => void): void;
private startCore;
private handler;
private calculateRemainingTime;
}
/* Excluded from this release type: Timer */
/**
* This function can be used to assert at compile time that a given value has type never.
* One common usage is in the default case of a switch block,
* to ensure that all cases are explicitly handled.
*
* Example:
* ```typescript
* const bool: true | false = ...;
* switch(bool) {
* case true: {...}
* case false: {...}
* default: unreachableCase(bool);
* }
* ```
* @public
*/
export declare function unreachableCase(_: never, message?: string): never;
/* Excluded from this release type: unreachableCase */
export { }

@@ -1,404 +0,41 @@

/**
* A browser friendly assert library.
* Use this instead of the 'assert' package, which has a big impact on bundle sizes.
* @param condition - The condition that should be true, if the condition is false an error will be thrown.
* Only use this API when `false` indicates a logic error in the problem and thus a bug that should be fixed.
* @param message - The message to include in the error when the condition does not hold.
* A number should not be specified manually: use a string.
* Before a release, policy-check should be run, which will convert any asserts still using strings to
* use numbered error codes instead.
* @public
*/
export declare function assert(condition: boolean, message: string | number): asserts condition;
/* Excluded from this release type: assert */
/* Excluded from this release type: compareArrays */
/**
* A deferred creates a promise and the ability to resolve or reject it
* @public
*/
export declare class Deferred<T> {
private readonly p;
private res;
private rej;
private completed;
constructor();
/**
* Returns whether the underlying promise has been completed
*/
get isCompleted(): boolean;
/**
* Retrieves the underlying promise for the deferred
*
* @returns the underlying promise
*/
get promise(): Promise<T>;
/**
* Resolves the promise
*
* @param value - the value to resolve the promise with
*/
resolve(value: T | PromiseLike<T>): void;
/**
* Rejects the promise
*
* @param value - the value to reject the promise with
*/
reject(error: any): void;
}
/* Excluded from this release type: Deferred */
/**
* Returns a promise that resolves after `timeMs`.
* @param timeMs - Time in milliseconds to wait.
* @public
*/
export declare const delay: (timeMs: number) => Promise<void>;
/* Excluded from this release type: delay */
/**
* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
*/
export declare class Heap<T> {
comp: IComparer<T>;
private L;
/**
* Creates an instance of `Heap` with comparer.
* @param comp - A comparer that specify how elements are ordered.
*/
constructor(comp: IComparer<T>);
/**
* Return the smallest element in the heap as determined by the order of the comparer
*
* @returns Heap node containing the smallest element
*/
peek(): IHeapNode<T>;
/**
* Get and remove the smallest element in the heap as determined by the order of the comparer
*
* @returns The smallest value in the heap
*/
get(): T;
/**
* Add a value to the heap
*
* @param x - value to add
* @returns The heap node that contains the value
*/
add(x: T): IHeapNode<T>;
/**
* Allows for the Heap to be updated after a node's value changes.
*/
update(node: IHeapNode<T>): void;
/**
* Removes the given node from the heap.
*
* @param node - The node to remove from the heap.
*/
remove(node: IHeapNode<T>): void;
/**
* Get the number of elements in the Heap.
*
* @returns The number of elements in the Heap.
*/
count(): number;
private fixup;
private isGreaterThanParent;
private fixdown;
private swap;
}
/* Excluded from this release type: Heap */
/**
* Interface for a comparer.
* @public
*/
export declare interface IComparer<T> {
/**
* The minimum value of type T.
*/
min: T;
/**
* Compare the two value
*
* @returns 0 if the value is equal, negative number if a is smaller then b, positive number otherwise
*/
compare(a: T, b: T): number;
}
/* Excluded from this release type: IComparer */
/**
* Interface to a node in {@link Heap}.
* @public
*/
export declare interface IHeapNode<T> {
value: T;
position: number;
}
/* Excluded from this release type: IHeapNode */
/**
* Timer which offers a promise that fulfills when the timer
* completes.
* @public
*/
export declare interface IPromiseTimer extends ITimer {
/**
* Starts the timer and returns a promise that
* resolves when the timer times out or is canceled.
*/
start(): Promise<IPromiseTimerResult>;
}
/* Excluded from this release type: IPromiseTimer */
/**
* @public
*/
export declare interface IPromiseTimerResult {
timerResult: "timeout" | "cancel";
}
/* Excluded from this release type: IPromiseTimerResult */
/**
* @public
*/
export declare interface ITimer {
/**
* True if timer is currently running
*/
readonly hasTimer: boolean;
/**
* Starts the timer
*/
start(): void;
/**
* Cancels the timer if already running
*/
clear(): void;
}
/* Excluded from this release type: ITimer */
/**
* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
*/
export declare class Lazy<T> {
private readonly valueGenerator;
private _value;
private _evaluated;
/**
* Instantiates an instance of Lazy<T>.
* @param valueGenerator - The function that will generate the value when value is accessed the first time.
*/
constructor(valueGenerator: () => T);
/**
* Return true if the value as been generated, otherwise false.
*/
get evaluated(): boolean;
/**
* Get the value. If this is the first call the value will be generated.
*/
get value(): T;
}
/* Excluded from this release type: Lazy */
/**
* A lazy evaluated promise. The execute function is delayed until
* the promise is used, e.g. await, then, catch ...
* The execute function is only called once.
* All calls are then proxied to the promise returned by the execute method.
* @public
*/
export declare class LazyPromise<T> implements Promise<T> {
private readonly execute;
get [Symbol.toStringTag](): string;
private result;
constructor(execute: () => Promise<T>);
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
finally(onfinally?: (() => void) | null | undefined): Promise<T>;
private getPromise;
}
/* Excluded from this release type: LazyPromise */
/**
* A comparer for numbers.
* @public
*/
export declare const NumberComparer: IComparer<number>;
/* Excluded from this release type: NumberComparer */
/**
* A specialized cache for async work, allowing you to safely cache the promised result of some async work
* without fear of running it multiple times or losing track of errors.
* @public
*/
export declare class PromiseCache<TKey, TResult> {
private readonly cache;
private readonly gc;
private readonly removeOnError;
/**
* Create the PromiseCache with the given options, with the following defaults:
*
* expiry: indefinite, removeOnError: true for all errors
*/
constructor({ expiry, removeOnError, }?: PromiseCacheOptions);
/**
* Check if there's anything cached at the given key
*/
has(key: TKey): boolean;
/**
* Get the Promise for the given key, or undefined if it's not found.
* Extend expiry if applicable.
*/
get(key: TKey): Promise<TResult> | undefined;
/**
* Remove the Promise for the given key, returning true if it was found and removed
*/
remove(key: TKey): boolean;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
addOrGet(key: TKey, asyncFn: () => Promise<TResult>): Promise<TResult>;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
add(key: TKey, asyncFn: () => Promise<TResult>): boolean;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param value - value to store
*/
addValueOrGet(key: TKey, value: TResult): Promise<TResult>;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the value
* @param value - value to store
*/
addValue(key: TKey, value: TResult): boolean;
}
/* Excluded from this release type: PromiseCache */
/**
* Three supported expiry policies:
* - indefinite: entries don't expire and must be explicitly removed
* - absolute: entries expire after the given duration in MS, even if accessed multiple times in the mean time
* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
*/
export declare type PromiseCacheExpiry = {
policy: "indefinite";
} | {
policy: "absolute" | "sliding";
durationMs: number;
};
/* Excluded from this release type: PromiseCacheExpiry */
/**
* Options for configuring the {@link PromiseCache}
* @public
*/
export declare interface PromiseCacheOptions {
/**
* Common expiration policy for all items added to this cache
*/
expiry?: PromiseCacheExpiry;
/**
* If the stored Promise is rejected with a particular error, should the given key be removed?
*/
removeOnError?: (error: any) => boolean;
}
/* Excluded from this release type: PromiseCacheOptions */
/**
* This class is a wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the
* same handlers and timeouts, while also providing a promise that
* resolves when it times out.
* @public
*/
export declare class PromiseTimer implements IPromiseTimer {
private deferred?;
private readonly timer;
/**
* {@inheritDoc Timer.hasTimer}
*/
get hasTimer(): boolean;
constructor(defaultTimeout: number, defaultHandler: () => void);
/**
* {@inheritDoc IPromiseTimer.start}
*/
start(ms?: number, handler?: () => void): Promise<IPromiseTimerResult>;
clear(): void;
protected wrapHandler(handler: () => void): void;
}
/* Excluded from this release type: PromiseTimer */
/**
* Sets timeouts like the setTimeout function allowing timeouts to exceed the setTimeout's max timeout limit.
* Timeouts may not be exactly accurate due to browser implementations and the OS.
* https://stackoverflow.com/questions/21097421/what-is-the-reason-javascript-settimeout-is-so-inaccurate
* @param timeoutFn - Executed when the timeout expires
* @param timeoutMs - Duration of the timeout in milliseconds
* @param setTimeoutIdFn - Executed to update the timeout if multiple timeouts are required when
* timeoutMs greater than maxTimeout
* @returns The initial timeout
* @public
*/
export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;
/* Excluded from this release type: setLongTimeout */
/**
* This class is a thin wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the same
* or similar handlers and timeouts. This class supports long timeouts
* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
*/
export declare class Timer implements ITimer {
private readonly defaultTimeout;
private readonly defaultHandler;
private readonly getCurrentTick;
/**
* Returns true if the timer is running.
*/
get hasTimer(): boolean;
private runningState;
constructor(defaultTimeout: number, defaultHandler: () => void, getCurrentTick?: () => number);
/**
* Calls setTimeout and tracks the resulting timeout.
* @param ms - overrides default timeout in ms
* @param handler - overrides default handler
*/
start(ms?: number, handler?: () => void): void;
/**
* Calls clearTimeout on the underlying timeout if running.
*/
clear(): void;
/**
* Restarts the timer with the new handler and duration.
* If a new handler is passed, the original handler may
* never execute.
* This is a potentially more efficient way to clear and start
* a new timer.
* @param ms - overrides previous or default timeout in ms
* @param handler - overrides previous or default handler
*/
restart(ms?: number, handler?: () => void): void;
private startCore;
private handler;
private calculateRemainingTime;
}
/* Excluded from this release type: Timer */
/**
* This function can be used to assert at compile time that a given value has type never.
* One common usage is in the default case of a switch block,
* to ensure that all cases are explicitly handled.
*
* Example:
* ```typescript
* const bool: true | false = ...;
* switch(bool) {
* case true: {...}
* case false: {...}
* default: unreachableCase(bool);
* }
* ```
* @public
*/
export declare function unreachableCase(_: never, message?: string): never;
/* Excluded from this release type: unreachableCase */
export { }

@@ -10,3 +10,3 @@ /**

* use numbered error codes instead.
* @public
* @internal
*/

@@ -29,3 +29,3 @@ export declare function assert(condition: boolean, message: string | number): asserts condition;

* A deferred creates a promise and the ability to resolve or reject it
* @public
* @internal
*/

@@ -65,3 +65,3 @@ export declare class Deferred<T> {

* @param timeMs - Time in milliseconds to wait.
* @public
* @internal
*/

@@ -72,3 +72,3 @@ export declare const delay: (timeMs: number) => Promise<void>;

* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
* @internal
*/

@@ -126,3 +126,3 @@ export declare class Heap<T> {

* Interface for a comparer.
* @public
* @internal
*/

@@ -144,3 +144,3 @@ export declare interface IComparer<T> {

* Interface to a node in {@link Heap}.
* @public
* @internal
*/

@@ -155,3 +155,3 @@ export declare interface IHeapNode<T> {

* completes.
* @public
* @internal
*/

@@ -167,3 +167,3 @@ export declare interface IPromiseTimer extends ITimer {

/**
* @public
* @internal
*/

@@ -175,3 +175,3 @@ export declare interface IPromiseTimerResult {

/**
* @public
* @internal
*/

@@ -195,3 +195,3 @@ export declare interface ITimer {

* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
* @internal
*/

@@ -222,3 +222,3 @@ export declare class Lazy<T> {

* All calls are then proxied to the promise returned by the execute method.
* @public
* @internal
*/

@@ -238,3 +238,3 @@ export declare class LazyPromise<T> implements Promise<T> {

* A comparer for numbers.
* @public
* @internal
*/

@@ -246,3 +246,3 @@ export declare const NumberComparer: IComparer<number>;

* without fear of running it multiple times or losing track of errors.
* @public
* @internal
*/

@@ -307,3 +307,3 @@ export declare class PromiseCache<TKey, TResult> {

* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
* @internal
*/

@@ -319,3 +319,3 @@ export declare type PromiseCacheExpiry = {

* Options for configuring the {@link PromiseCache}
* @public
* @internal
*/

@@ -338,3 +338,3 @@ export declare interface PromiseCacheOptions {

* resolves when it times out.
* @public
* @internal
*/

@@ -366,3 +366,3 @@ export declare class PromiseTimer implements IPromiseTimer {

* @returns The initial timeout
* @public
* @internal
*/

@@ -376,3 +376,3 @@ export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;

* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
* @internal
*/

@@ -428,3 +428,3 @@ export declare class Timer implements ITimer {

* ```
* @public
* @internal
*/

@@ -431,0 +431,0 @@ export declare function unreachableCase(_: never, message?: string): never;

@@ -8,5 +8,5 @@ /*!

* @param timeMs - Time in milliseconds to wait.
* @public
* @internal
*/
export declare const delay: (timeMs: number) => Promise<void>;
//# sourceMappingURL=delay.d.ts.map

@@ -11,3 +11,3 @@ "use strict";

* @param timeMs - Time in milliseconds to wait.
* @public
* @internal
*/

@@ -14,0 +14,0 @@ const delay = async (timeMs) => new Promise((resolve) => setTimeout(() => resolve(), timeMs));

@@ -7,3 +7,3 @@ /*!

* Interface for a comparer.
* @public
* @internal
*/

@@ -24,3 +24,3 @@ export interface IComparer<T> {

* A comparer for numbers.
* @public
* @internal
*/

@@ -30,3 +30,3 @@ export declare const NumberComparer: IComparer<number>;

* Interface to a node in {@link Heap}.
* @public
* @internal
*/

@@ -39,3 +39,3 @@ export interface IHeapNode<T> {

* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
* @internal
*/

@@ -42,0 +42,0 @@ export declare class Heap<T> {

@@ -10,3 +10,3 @@ "use strict";

* A comparer for numbers.
* @public
* @internal
*/

@@ -26,3 +26,3 @@ exports.NumberComparer = {

* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
* @internal
*/

@@ -29,0 +29,0 @@ class Heap {

@@ -7,3 +7,3 @@ /*!

* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
* @internal
*/

@@ -33,3 +33,3 @@ export declare class Lazy<T> {

* All calls are then proxied to the promise returned by the execute method.
* @public
* @internal
*/

@@ -36,0 +36,0 @@ export declare class LazyPromise<T> implements Promise<T> {

@@ -10,3 +10,3 @@ "use strict";

* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
* @internal
*/

@@ -46,3 +46,3 @@ class Lazy {

* All calls are then proxied to the promise returned by the execute method.
* @public
* @internal
*/

@@ -49,0 +49,0 @@ class LazyPromise {

@@ -10,3 +10,3 @@ /*!

* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
* @internal
*/

@@ -21,3 +21,3 @@ export type PromiseCacheExpiry = {

* Options for configuring the {@link PromiseCache}
* @public
* @internal
*/

@@ -37,3 +37,3 @@ export interface PromiseCacheOptions {

* without fear of running it multiple times or losing track of errors.
* @public
* @internal
*/

@@ -40,0 +40,0 @@ export declare class PromiseCache<TKey, TResult> {

@@ -53,3 +53,3 @@ "use strict";

* without fear of running it multiple times or losing track of errors.
* @public
* @internal
*/

@@ -56,0 +56,0 @@ class PromiseCache {

@@ -7,3 +7,3 @@ /*!

* A deferred creates a promise and the ability to resolve or reject it
* @public
* @internal
*/

@@ -10,0 +10,0 @@ export declare class Deferred<T> {

@@ -10,3 +10,3 @@ "use strict";

* A deferred creates a promise and the ability to resolve or reject it
* @public
* @internal
*/

@@ -13,0 +13,0 @@ class Deferred {

@@ -6,3 +6,3 @@ /*!

/**
* @public
* @internal
*/

@@ -32,3 +32,3 @@ export interface ITimer {

* @returns The initial timeout
* @public
* @internal
*/

@@ -41,3 +41,3 @@ export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;

* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
* @internal
*/

@@ -79,3 +79,3 @@ export declare class Timer implements ITimer {

/**
* @public
* @internal
*/

@@ -88,3 +88,3 @@ export interface IPromiseTimerResult {

* completes.
* @public
* @internal
*/

@@ -103,3 +103,3 @@ export interface IPromiseTimer extends ITimer {

* resolves when it times out.
* @public
* @internal
*/

@@ -106,0 +106,0 @@ export declare class PromiseTimer implements IPromiseTimer {

@@ -20,3 +20,3 @@ "use strict";

* @returns The initial timeout
* @public
* @internal
*/

@@ -42,3 +42,3 @@ function setLongTimeout(timeoutFn, timeoutMs, setTimeoutIdFn) {

* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
* @internal
*/

@@ -155,3 +155,3 @@ class Timer {

* resolves when it times out.
* @public
* @internal
*/

@@ -158,0 +158,0 @@ class PromiseTimer {

@@ -19,5 +19,5 @@ /*!

* ```
* @public
* @internal
*/
export declare function unreachableCase(_: never, message?: string): never;
//# sourceMappingURL=unreachable.d.ts.map

@@ -22,3 +22,3 @@ "use strict";

* ```
* @public
* @internal
*/

@@ -25,0 +25,0 @@ function unreachableCase(_, message = "Unreachable Case") {

@@ -14,5 +14,5 @@ /*!

* use numbered error codes instead.
* @public
* @internal
*/
export declare function assert(condition: boolean, message: string | number): asserts condition;
//# sourceMappingURL=assert.d.ts.map

@@ -14,3 +14,3 @@ /*!

* use numbered error codes instead.
* @public
* @internal
*/

@@ -17,0 +17,0 @@ export function assert(condition, message) {

@@ -1,404 +0,41 @@

/**
* A browser friendly assert library.
* Use this instead of the 'assert' package, which has a big impact on bundle sizes.
* @param condition - The condition that should be true, if the condition is false an error will be thrown.
* Only use this API when `false` indicates a logic error in the problem and thus a bug that should be fixed.
* @param message - The message to include in the error when the condition does not hold.
* A number should not be specified manually: use a string.
* Before a release, policy-check should be run, which will convert any asserts still using strings to
* use numbered error codes instead.
* @public
*/
export declare function assert(condition: boolean, message: string | number): asserts condition;
/* Excluded from this release type: assert */
/* Excluded from this release type: compareArrays */
/**
* A deferred creates a promise and the ability to resolve or reject it
* @public
*/
export declare class Deferred<T> {
private readonly p;
private res;
private rej;
private completed;
constructor();
/**
* Returns whether the underlying promise has been completed
*/
get isCompleted(): boolean;
/**
* Retrieves the underlying promise for the deferred
*
* @returns the underlying promise
*/
get promise(): Promise<T>;
/**
* Resolves the promise
*
* @param value - the value to resolve the promise with
*/
resolve(value: T | PromiseLike<T>): void;
/**
* Rejects the promise
*
* @param value - the value to reject the promise with
*/
reject(error: any): void;
}
/* Excluded from this release type: Deferred */
/**
* Returns a promise that resolves after `timeMs`.
* @param timeMs - Time in milliseconds to wait.
* @public
*/
export declare const delay: (timeMs: number) => Promise<void>;
/* Excluded from this release type: delay */
/**
* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
*/
export declare class Heap<T> {
comp: IComparer<T>;
private L;
/**
* Creates an instance of `Heap` with comparer.
* @param comp - A comparer that specify how elements are ordered.
*/
constructor(comp: IComparer<T>);
/**
* Return the smallest element in the heap as determined by the order of the comparer
*
* @returns Heap node containing the smallest element
*/
peek(): IHeapNode<T>;
/**
* Get and remove the smallest element in the heap as determined by the order of the comparer
*
* @returns The smallest value in the heap
*/
get(): T;
/**
* Add a value to the heap
*
* @param x - value to add
* @returns The heap node that contains the value
*/
add(x: T): IHeapNode<T>;
/**
* Allows for the Heap to be updated after a node's value changes.
*/
update(node: IHeapNode<T>): void;
/**
* Removes the given node from the heap.
*
* @param node - The node to remove from the heap.
*/
remove(node: IHeapNode<T>): void;
/**
* Get the number of elements in the Heap.
*
* @returns The number of elements in the Heap.
*/
count(): number;
private fixup;
private isGreaterThanParent;
private fixdown;
private swap;
}
/* Excluded from this release type: Heap */
/**
* Interface for a comparer.
* @public
*/
export declare interface IComparer<T> {
/**
* The minimum value of type T.
*/
min: T;
/**
* Compare the two value
*
* @returns 0 if the value is equal, negative number if a is smaller then b, positive number otherwise
*/
compare(a: T, b: T): number;
}
/* Excluded from this release type: IComparer */
/**
* Interface to a node in {@link Heap}.
* @public
*/
export declare interface IHeapNode<T> {
value: T;
position: number;
}
/* Excluded from this release type: IHeapNode */
/**
* Timer which offers a promise that fulfills when the timer
* completes.
* @public
*/
export declare interface IPromiseTimer extends ITimer {
/**
* Starts the timer and returns a promise that
* resolves when the timer times out or is canceled.
*/
start(): Promise<IPromiseTimerResult>;
}
/* Excluded from this release type: IPromiseTimer */
/**
* @public
*/
export declare interface IPromiseTimerResult {
timerResult: "timeout" | "cancel";
}
/* Excluded from this release type: IPromiseTimerResult */
/**
* @public
*/
export declare interface ITimer {
/**
* True if timer is currently running
*/
readonly hasTimer: boolean;
/**
* Starts the timer
*/
start(): void;
/**
* Cancels the timer if already running
*/
clear(): void;
}
/* Excluded from this release type: ITimer */
/**
* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
*/
export declare class Lazy<T> {
private readonly valueGenerator;
private _value;
private _evaluated;
/**
* Instantiates an instance of Lazy<T>.
* @param valueGenerator - The function that will generate the value when value is accessed the first time.
*/
constructor(valueGenerator: () => T);
/**
* Return true if the value as been generated, otherwise false.
*/
get evaluated(): boolean;
/**
* Get the value. If this is the first call the value will be generated.
*/
get value(): T;
}
/* Excluded from this release type: Lazy */
/**
* A lazy evaluated promise. The execute function is delayed until
* the promise is used, e.g. await, then, catch ...
* The execute function is only called once.
* All calls are then proxied to the promise returned by the execute method.
* @public
*/
export declare class LazyPromise<T> implements Promise<T> {
private readonly execute;
get [Symbol.toStringTag](): string;
private result;
constructor(execute: () => Promise<T>);
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
finally(onfinally?: (() => void) | null | undefined): Promise<T>;
private getPromise;
}
/* Excluded from this release type: LazyPromise */
/**
* A comparer for numbers.
* @public
*/
export declare const NumberComparer: IComparer<number>;
/* Excluded from this release type: NumberComparer */
/**
* A specialized cache for async work, allowing you to safely cache the promised result of some async work
* without fear of running it multiple times or losing track of errors.
* @public
*/
export declare class PromiseCache<TKey, TResult> {
private readonly cache;
private readonly gc;
private readonly removeOnError;
/**
* Create the PromiseCache with the given options, with the following defaults:
*
* expiry: indefinite, removeOnError: true for all errors
*/
constructor({ expiry, removeOnError, }?: PromiseCacheOptions);
/**
* Check if there's anything cached at the given key
*/
has(key: TKey): boolean;
/**
* Get the Promise for the given key, or undefined if it's not found.
* Extend expiry if applicable.
*/
get(key: TKey): Promise<TResult> | undefined;
/**
* Remove the Promise for the given key, returning true if it was found and removed
*/
remove(key: TKey): boolean;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
addOrGet(key: TKey, asyncFn: () => Promise<TResult>): Promise<TResult>;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
add(key: TKey, asyncFn: () => Promise<TResult>): boolean;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param value - value to store
*/
addValueOrGet(key: TKey, value: TResult): Promise<TResult>;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the value
* @param value - value to store
*/
addValue(key: TKey, value: TResult): boolean;
}
/* Excluded from this release type: PromiseCache */
/**
* Three supported expiry policies:
* - indefinite: entries don't expire and must be explicitly removed
* - absolute: entries expire after the given duration in MS, even if accessed multiple times in the mean time
* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
*/
export declare type PromiseCacheExpiry = {
policy: "indefinite";
} | {
policy: "absolute" | "sliding";
durationMs: number;
};
/* Excluded from this release type: PromiseCacheExpiry */
/**
* Options for configuring the {@link PromiseCache}
* @public
*/
export declare interface PromiseCacheOptions {
/**
* Common expiration policy for all items added to this cache
*/
expiry?: PromiseCacheExpiry;
/**
* If the stored Promise is rejected with a particular error, should the given key be removed?
*/
removeOnError?: (error: any) => boolean;
}
/* Excluded from this release type: PromiseCacheOptions */
/**
* This class is a wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the
* same handlers and timeouts, while also providing a promise that
* resolves when it times out.
* @public
*/
export declare class PromiseTimer implements IPromiseTimer {
private deferred?;
private readonly timer;
/**
* {@inheritDoc Timer.hasTimer}
*/
get hasTimer(): boolean;
constructor(defaultTimeout: number, defaultHandler: () => void);
/**
* {@inheritDoc IPromiseTimer.start}
*/
start(ms?: number, handler?: () => void): Promise<IPromiseTimerResult>;
clear(): void;
protected wrapHandler(handler: () => void): void;
}
/* Excluded from this release type: PromiseTimer */
/**
* Sets timeouts like the setTimeout function allowing timeouts to exceed the setTimeout's max timeout limit.
* Timeouts may not be exactly accurate due to browser implementations and the OS.
* https://stackoverflow.com/questions/21097421/what-is-the-reason-javascript-settimeout-is-so-inaccurate
* @param timeoutFn - Executed when the timeout expires
* @param timeoutMs - Duration of the timeout in milliseconds
* @param setTimeoutIdFn - Executed to update the timeout if multiple timeouts are required when
* timeoutMs greater than maxTimeout
* @returns The initial timeout
* @public
*/
export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;
/* Excluded from this release type: setLongTimeout */
/**
* This class is a thin wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the same
* or similar handlers and timeouts. This class supports long timeouts
* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
*/
export declare class Timer implements ITimer {
private readonly defaultTimeout;
private readonly defaultHandler;
private readonly getCurrentTick;
/**
* Returns true if the timer is running.
*/
get hasTimer(): boolean;
private runningState;
constructor(defaultTimeout: number, defaultHandler: () => void, getCurrentTick?: () => number);
/**
* Calls setTimeout and tracks the resulting timeout.
* @param ms - overrides default timeout in ms
* @param handler - overrides default handler
*/
start(ms?: number, handler?: () => void): void;
/**
* Calls clearTimeout on the underlying timeout if running.
*/
clear(): void;
/**
* Restarts the timer with the new handler and duration.
* If a new handler is passed, the original handler may
* never execute.
* This is a potentially more efficient way to clear and start
* a new timer.
* @param ms - overrides previous or default timeout in ms
* @param handler - overrides previous or default handler
*/
restart(ms?: number, handler?: () => void): void;
private startCore;
private handler;
private calculateRemainingTime;
}
/* Excluded from this release type: Timer */
/**
* This function can be used to assert at compile time that a given value has type never.
* One common usage is in the default case of a switch block,
* to ensure that all cases are explicitly handled.
*
* Example:
* ```typescript
* const bool: true | false = ...;
* switch(bool) {
* case true: {...}
* case false: {...}
* default: unreachableCase(bool);
* }
* ```
* @public
*/
export declare function unreachableCase(_: never, message?: string): never;
/* Excluded from this release type: unreachableCase */
export { }

@@ -1,404 +0,41 @@

/**
* A browser friendly assert library.
* Use this instead of the 'assert' package, which has a big impact on bundle sizes.
* @param condition - The condition that should be true, if the condition is false an error will be thrown.
* Only use this API when `false` indicates a logic error in the problem and thus a bug that should be fixed.
* @param message - The message to include in the error when the condition does not hold.
* A number should not be specified manually: use a string.
* Before a release, policy-check should be run, which will convert any asserts still using strings to
* use numbered error codes instead.
* @public
*/
export declare function assert(condition: boolean, message: string | number): asserts condition;
/* Excluded from this release type: assert */
/* Excluded from this release type: compareArrays */
/**
* A deferred creates a promise and the ability to resolve or reject it
* @public
*/
export declare class Deferred<T> {
private readonly p;
private res;
private rej;
private completed;
constructor();
/**
* Returns whether the underlying promise has been completed
*/
get isCompleted(): boolean;
/**
* Retrieves the underlying promise for the deferred
*
* @returns the underlying promise
*/
get promise(): Promise<T>;
/**
* Resolves the promise
*
* @param value - the value to resolve the promise with
*/
resolve(value: T | PromiseLike<T>): void;
/**
* Rejects the promise
*
* @param value - the value to reject the promise with
*/
reject(error: any): void;
}
/* Excluded from this release type: Deferred */
/**
* Returns a promise that resolves after `timeMs`.
* @param timeMs - Time in milliseconds to wait.
* @public
*/
export declare const delay: (timeMs: number) => Promise<void>;
/* Excluded from this release type: delay */
/**
* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
*/
export declare class Heap<T> {
comp: IComparer<T>;
private L;
/**
* Creates an instance of `Heap` with comparer.
* @param comp - A comparer that specify how elements are ordered.
*/
constructor(comp: IComparer<T>);
/**
* Return the smallest element in the heap as determined by the order of the comparer
*
* @returns Heap node containing the smallest element
*/
peek(): IHeapNode<T>;
/**
* Get and remove the smallest element in the heap as determined by the order of the comparer
*
* @returns The smallest value in the heap
*/
get(): T;
/**
* Add a value to the heap
*
* @param x - value to add
* @returns The heap node that contains the value
*/
add(x: T): IHeapNode<T>;
/**
* Allows for the Heap to be updated after a node's value changes.
*/
update(node: IHeapNode<T>): void;
/**
* Removes the given node from the heap.
*
* @param node - The node to remove from the heap.
*/
remove(node: IHeapNode<T>): void;
/**
* Get the number of elements in the Heap.
*
* @returns The number of elements in the Heap.
*/
count(): number;
private fixup;
private isGreaterThanParent;
private fixdown;
private swap;
}
/* Excluded from this release type: Heap */
/**
* Interface for a comparer.
* @public
*/
export declare interface IComparer<T> {
/**
* The minimum value of type T.
*/
min: T;
/**
* Compare the two value
*
* @returns 0 if the value is equal, negative number if a is smaller then b, positive number otherwise
*/
compare(a: T, b: T): number;
}
/* Excluded from this release type: IComparer */
/**
* Interface to a node in {@link Heap}.
* @public
*/
export declare interface IHeapNode<T> {
value: T;
position: number;
}
/* Excluded from this release type: IHeapNode */
/**
* Timer which offers a promise that fulfills when the timer
* completes.
* @public
*/
export declare interface IPromiseTimer extends ITimer {
/**
* Starts the timer and returns a promise that
* resolves when the timer times out or is canceled.
*/
start(): Promise<IPromiseTimerResult>;
}
/* Excluded from this release type: IPromiseTimer */
/**
* @public
*/
export declare interface IPromiseTimerResult {
timerResult: "timeout" | "cancel";
}
/* Excluded from this release type: IPromiseTimerResult */
/**
* @public
*/
export declare interface ITimer {
/**
* True if timer is currently running
*/
readonly hasTimer: boolean;
/**
* Starts the timer
*/
start(): void;
/**
* Cancels the timer if already running
*/
clear(): void;
}
/* Excluded from this release type: ITimer */
/**
* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
*/
export declare class Lazy<T> {
private readonly valueGenerator;
private _value;
private _evaluated;
/**
* Instantiates an instance of Lazy<T>.
* @param valueGenerator - The function that will generate the value when value is accessed the first time.
*/
constructor(valueGenerator: () => T);
/**
* Return true if the value as been generated, otherwise false.
*/
get evaluated(): boolean;
/**
* Get the value. If this is the first call the value will be generated.
*/
get value(): T;
}
/* Excluded from this release type: Lazy */
/**
* A lazy evaluated promise. The execute function is delayed until
* the promise is used, e.g. await, then, catch ...
* The execute function is only called once.
* All calls are then proxied to the promise returned by the execute method.
* @public
*/
export declare class LazyPromise<T> implements Promise<T> {
private readonly execute;
get [Symbol.toStringTag](): string;
private result;
constructor(execute: () => Promise<T>);
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
finally(onfinally?: (() => void) | null | undefined): Promise<T>;
private getPromise;
}
/* Excluded from this release type: LazyPromise */
/**
* A comparer for numbers.
* @public
*/
export declare const NumberComparer: IComparer<number>;
/* Excluded from this release type: NumberComparer */
/**
* A specialized cache for async work, allowing you to safely cache the promised result of some async work
* without fear of running it multiple times or losing track of errors.
* @public
*/
export declare class PromiseCache<TKey, TResult> {
private readonly cache;
private readonly gc;
private readonly removeOnError;
/**
* Create the PromiseCache with the given options, with the following defaults:
*
* expiry: indefinite, removeOnError: true for all errors
*/
constructor({ expiry, removeOnError, }?: PromiseCacheOptions);
/**
* Check if there's anything cached at the given key
*/
has(key: TKey): boolean;
/**
* Get the Promise for the given key, or undefined if it's not found.
* Extend expiry if applicable.
*/
get(key: TKey): Promise<TResult> | undefined;
/**
* Remove the Promise for the given key, returning true if it was found and removed
*/
remove(key: TKey): boolean;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
addOrGet(key: TKey, asyncFn: () => Promise<TResult>): Promise<TResult>;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
add(key: TKey, asyncFn: () => Promise<TResult>): boolean;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param value - value to store
*/
addValueOrGet(key: TKey, value: TResult): Promise<TResult>;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the value
* @param value - value to store
*/
addValue(key: TKey, value: TResult): boolean;
}
/* Excluded from this release type: PromiseCache */
/**
* Three supported expiry policies:
* - indefinite: entries don't expire and must be explicitly removed
* - absolute: entries expire after the given duration in MS, even if accessed multiple times in the mean time
* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
*/
export declare type PromiseCacheExpiry = {
policy: "indefinite";
} | {
policy: "absolute" | "sliding";
durationMs: number;
};
/* Excluded from this release type: PromiseCacheExpiry */
/**
* Options for configuring the {@link PromiseCache}
* @public
*/
export declare interface PromiseCacheOptions {
/**
* Common expiration policy for all items added to this cache
*/
expiry?: PromiseCacheExpiry;
/**
* If the stored Promise is rejected with a particular error, should the given key be removed?
*/
removeOnError?: (error: any) => boolean;
}
/* Excluded from this release type: PromiseCacheOptions */
/**
* This class is a wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the
* same handlers and timeouts, while also providing a promise that
* resolves when it times out.
* @public
*/
export declare class PromiseTimer implements IPromiseTimer {
private deferred?;
private readonly timer;
/**
* {@inheritDoc Timer.hasTimer}
*/
get hasTimer(): boolean;
constructor(defaultTimeout: number, defaultHandler: () => void);
/**
* {@inheritDoc IPromiseTimer.start}
*/
start(ms?: number, handler?: () => void): Promise<IPromiseTimerResult>;
clear(): void;
protected wrapHandler(handler: () => void): void;
}
/* Excluded from this release type: PromiseTimer */
/**
* Sets timeouts like the setTimeout function allowing timeouts to exceed the setTimeout's max timeout limit.
* Timeouts may not be exactly accurate due to browser implementations and the OS.
* https://stackoverflow.com/questions/21097421/what-is-the-reason-javascript-settimeout-is-so-inaccurate
* @param timeoutFn - Executed when the timeout expires
* @param timeoutMs - Duration of the timeout in milliseconds
* @param setTimeoutIdFn - Executed to update the timeout if multiple timeouts are required when
* timeoutMs greater than maxTimeout
* @returns The initial timeout
* @public
*/
export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;
/* Excluded from this release type: setLongTimeout */
/**
* This class is a thin wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the same
* or similar handlers and timeouts. This class supports long timeouts
* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
*/
export declare class Timer implements ITimer {
private readonly defaultTimeout;
private readonly defaultHandler;
private readonly getCurrentTick;
/**
* Returns true if the timer is running.
*/
get hasTimer(): boolean;
private runningState;
constructor(defaultTimeout: number, defaultHandler: () => void, getCurrentTick?: () => number);
/**
* Calls setTimeout and tracks the resulting timeout.
* @param ms - overrides default timeout in ms
* @param handler - overrides default handler
*/
start(ms?: number, handler?: () => void): void;
/**
* Calls clearTimeout on the underlying timeout if running.
*/
clear(): void;
/**
* Restarts the timer with the new handler and duration.
* If a new handler is passed, the original handler may
* never execute.
* This is a potentially more efficient way to clear and start
* a new timer.
* @param ms - overrides previous or default timeout in ms
* @param handler - overrides previous or default handler
*/
restart(ms?: number, handler?: () => void): void;
private startCore;
private handler;
private calculateRemainingTime;
}
/* Excluded from this release type: Timer */
/**
* This function can be used to assert at compile time that a given value has type never.
* One common usage is in the default case of a switch block,
* to ensure that all cases are explicitly handled.
*
* Example:
* ```typescript
* const bool: true | false = ...;
* switch(bool) {
* case true: {...}
* case false: {...}
* default: unreachableCase(bool);
* }
* ```
* @public
*/
export declare function unreachableCase(_: never, message?: string): never;
/* Excluded from this release type: unreachableCase */
export { }

@@ -1,404 +0,41 @@

/**
* A browser friendly assert library.
* Use this instead of the 'assert' package, which has a big impact on bundle sizes.
* @param condition - The condition that should be true, if the condition is false an error will be thrown.
* Only use this API when `false` indicates a logic error in the problem and thus a bug that should be fixed.
* @param message - The message to include in the error when the condition does not hold.
* A number should not be specified manually: use a string.
* Before a release, policy-check should be run, which will convert any asserts still using strings to
* use numbered error codes instead.
* @public
*/
export declare function assert(condition: boolean, message: string | number): asserts condition;
/* Excluded from this release type: assert */
/* Excluded from this release type: compareArrays */
/**
* A deferred creates a promise and the ability to resolve or reject it
* @public
*/
export declare class Deferred<T> {
private readonly p;
private res;
private rej;
private completed;
constructor();
/**
* Returns whether the underlying promise has been completed
*/
get isCompleted(): boolean;
/**
* Retrieves the underlying promise for the deferred
*
* @returns the underlying promise
*/
get promise(): Promise<T>;
/**
* Resolves the promise
*
* @param value - the value to resolve the promise with
*/
resolve(value: T | PromiseLike<T>): void;
/**
* Rejects the promise
*
* @param value - the value to reject the promise with
*/
reject(error: any): void;
}
/* Excluded from this release type: Deferred */
/**
* Returns a promise that resolves after `timeMs`.
* @param timeMs - Time in milliseconds to wait.
* @public
*/
export declare const delay: (timeMs: number) => Promise<void>;
/* Excluded from this release type: delay */
/**
* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
*/
export declare class Heap<T> {
comp: IComparer<T>;
private L;
/**
* Creates an instance of `Heap` with comparer.
* @param comp - A comparer that specify how elements are ordered.
*/
constructor(comp: IComparer<T>);
/**
* Return the smallest element in the heap as determined by the order of the comparer
*
* @returns Heap node containing the smallest element
*/
peek(): IHeapNode<T>;
/**
* Get and remove the smallest element in the heap as determined by the order of the comparer
*
* @returns The smallest value in the heap
*/
get(): T;
/**
* Add a value to the heap
*
* @param x - value to add
* @returns The heap node that contains the value
*/
add(x: T): IHeapNode<T>;
/**
* Allows for the Heap to be updated after a node's value changes.
*/
update(node: IHeapNode<T>): void;
/**
* Removes the given node from the heap.
*
* @param node - The node to remove from the heap.
*/
remove(node: IHeapNode<T>): void;
/**
* Get the number of elements in the Heap.
*
* @returns The number of elements in the Heap.
*/
count(): number;
private fixup;
private isGreaterThanParent;
private fixdown;
private swap;
}
/* Excluded from this release type: Heap */
/**
* Interface for a comparer.
* @public
*/
export declare interface IComparer<T> {
/**
* The minimum value of type T.
*/
min: T;
/**
* Compare the two value
*
* @returns 0 if the value is equal, negative number if a is smaller then b, positive number otherwise
*/
compare(a: T, b: T): number;
}
/* Excluded from this release type: IComparer */
/**
* Interface to a node in {@link Heap}.
* @public
*/
export declare interface IHeapNode<T> {
value: T;
position: number;
}
/* Excluded from this release type: IHeapNode */
/**
* Timer which offers a promise that fulfills when the timer
* completes.
* @public
*/
export declare interface IPromiseTimer extends ITimer {
/**
* Starts the timer and returns a promise that
* resolves when the timer times out or is canceled.
*/
start(): Promise<IPromiseTimerResult>;
}
/* Excluded from this release type: IPromiseTimer */
/**
* @public
*/
export declare interface IPromiseTimerResult {
timerResult: "timeout" | "cancel";
}
/* Excluded from this release type: IPromiseTimerResult */
/**
* @public
*/
export declare interface ITimer {
/**
* True if timer is currently running
*/
readonly hasTimer: boolean;
/**
* Starts the timer
*/
start(): void;
/**
* Cancels the timer if already running
*/
clear(): void;
}
/* Excluded from this release type: ITimer */
/**
* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
*/
export declare class Lazy<T> {
private readonly valueGenerator;
private _value;
private _evaluated;
/**
* Instantiates an instance of Lazy<T>.
* @param valueGenerator - The function that will generate the value when value is accessed the first time.
*/
constructor(valueGenerator: () => T);
/**
* Return true if the value as been generated, otherwise false.
*/
get evaluated(): boolean;
/**
* Get the value. If this is the first call the value will be generated.
*/
get value(): T;
}
/* Excluded from this release type: Lazy */
/**
* A lazy evaluated promise. The execute function is delayed until
* the promise is used, e.g. await, then, catch ...
* The execute function is only called once.
* All calls are then proxied to the promise returned by the execute method.
* @public
*/
export declare class LazyPromise<T> implements Promise<T> {
private readonly execute;
get [Symbol.toStringTag](): string;
private result;
constructor(execute: () => Promise<T>);
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
finally(onfinally?: (() => void) | null | undefined): Promise<T>;
private getPromise;
}
/* Excluded from this release type: LazyPromise */
/**
* A comparer for numbers.
* @public
*/
export declare const NumberComparer: IComparer<number>;
/* Excluded from this release type: NumberComparer */
/**
* A specialized cache for async work, allowing you to safely cache the promised result of some async work
* without fear of running it multiple times or losing track of errors.
* @public
*/
export declare class PromiseCache<TKey, TResult> {
private readonly cache;
private readonly gc;
private readonly removeOnError;
/**
* Create the PromiseCache with the given options, with the following defaults:
*
* expiry: indefinite, removeOnError: true for all errors
*/
constructor({ expiry, removeOnError, }?: PromiseCacheOptions);
/**
* Check if there's anything cached at the given key
*/
has(key: TKey): boolean;
/**
* Get the Promise for the given key, or undefined if it's not found.
* Extend expiry if applicable.
*/
get(key: TKey): Promise<TResult> | undefined;
/**
* Remove the Promise for the given key, returning true if it was found and removed
*/
remove(key: TKey): boolean;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
addOrGet(key: TKey, asyncFn: () => Promise<TResult>): Promise<TResult>;
/**
* Try to add the result of the given asyncFn, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the async work
* @param asyncFn - the async work to do and store, if not already in progress under the given key
*/
add(key: TKey, asyncFn: () => Promise<TResult>): boolean;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns a Promise for the added or existing async work being done at that key.
* @param key - key name where to store the async work
* @param value - value to store
*/
addValueOrGet(key: TKey, value: TResult): Promise<TResult>;
/**
* Try to add the given value, without overwriting an existing cache entry at that key.
* Returns false if the cache already contained an entry at that key, and true otherwise.
* @param key - key name where to store the value
* @param value - value to store
*/
addValue(key: TKey, value: TResult): boolean;
}
/* Excluded from this release type: PromiseCache */
/**
* Three supported expiry policies:
* - indefinite: entries don't expire and must be explicitly removed
* - absolute: entries expire after the given duration in MS, even if accessed multiple times in the mean time
* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
*/
export declare type PromiseCacheExpiry = {
policy: "indefinite";
} | {
policy: "absolute" | "sliding";
durationMs: number;
};
/* Excluded from this release type: PromiseCacheExpiry */
/**
* Options for configuring the {@link PromiseCache}
* @public
*/
export declare interface PromiseCacheOptions {
/**
* Common expiration policy for all items added to this cache
*/
expiry?: PromiseCacheExpiry;
/**
* If the stored Promise is rejected with a particular error, should the given key be removed?
*/
removeOnError?: (error: any) => boolean;
}
/* Excluded from this release type: PromiseCacheOptions */
/**
* This class is a wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the
* same handlers and timeouts, while also providing a promise that
* resolves when it times out.
* @public
*/
export declare class PromiseTimer implements IPromiseTimer {
private deferred?;
private readonly timer;
/**
* {@inheritDoc Timer.hasTimer}
*/
get hasTimer(): boolean;
constructor(defaultTimeout: number, defaultHandler: () => void);
/**
* {@inheritDoc IPromiseTimer.start}
*/
start(ms?: number, handler?: () => void): Promise<IPromiseTimerResult>;
clear(): void;
protected wrapHandler(handler: () => void): void;
}
/* Excluded from this release type: PromiseTimer */
/**
* Sets timeouts like the setTimeout function allowing timeouts to exceed the setTimeout's max timeout limit.
* Timeouts may not be exactly accurate due to browser implementations and the OS.
* https://stackoverflow.com/questions/21097421/what-is-the-reason-javascript-settimeout-is-so-inaccurate
* @param timeoutFn - Executed when the timeout expires
* @param timeoutMs - Duration of the timeout in milliseconds
* @param setTimeoutIdFn - Executed to update the timeout if multiple timeouts are required when
* timeoutMs greater than maxTimeout
* @returns The initial timeout
* @public
*/
export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;
/* Excluded from this release type: setLongTimeout */
/**
* This class is a thin wrapper over setTimeout and clearTimeout which
* makes it simpler to keep track of recurring timeouts with the same
* or similar handlers and timeouts. This class supports long timeouts
* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
*/
export declare class Timer implements ITimer {
private readonly defaultTimeout;
private readonly defaultHandler;
private readonly getCurrentTick;
/**
* Returns true if the timer is running.
*/
get hasTimer(): boolean;
private runningState;
constructor(defaultTimeout: number, defaultHandler: () => void, getCurrentTick?: () => number);
/**
* Calls setTimeout and tracks the resulting timeout.
* @param ms - overrides default timeout in ms
* @param handler - overrides default handler
*/
start(ms?: number, handler?: () => void): void;
/**
* Calls clearTimeout on the underlying timeout if running.
*/
clear(): void;
/**
* Restarts the timer with the new handler and duration.
* If a new handler is passed, the original handler may
* never execute.
* This is a potentially more efficient way to clear and start
* a new timer.
* @param ms - overrides previous or default timeout in ms
* @param handler - overrides previous or default handler
*/
restart(ms?: number, handler?: () => void): void;
private startCore;
private handler;
private calculateRemainingTime;
}
/* Excluded from this release type: Timer */
/**
* This function can be used to assert at compile time that a given value has type never.
* One common usage is in the default case of a switch block,
* to ensure that all cases are explicitly handled.
*
* Example:
* ```typescript
* const bool: true | false = ...;
* switch(bool) {
* case true: {...}
* case false: {...}
* default: unreachableCase(bool);
* }
* ```
* @public
*/
export declare function unreachableCase(_: never, message?: string): never;
/* Excluded from this release type: unreachableCase */
export { }

@@ -10,3 +10,3 @@ /**

* use numbered error codes instead.
* @public
* @internal
*/

@@ -29,3 +29,3 @@ export declare function assert(condition: boolean, message: string | number): asserts condition;

* A deferred creates a promise and the ability to resolve or reject it
* @public
* @internal
*/

@@ -65,3 +65,3 @@ export declare class Deferred<T> {

* @param timeMs - Time in milliseconds to wait.
* @public
* @internal
*/

@@ -72,3 +72,3 @@ export declare const delay: (timeMs: number) => Promise<void>;

* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
* @internal
*/

@@ -126,3 +126,3 @@ export declare class Heap<T> {

* Interface for a comparer.
* @public
* @internal
*/

@@ -144,3 +144,3 @@ export declare interface IComparer<T> {

* Interface to a node in {@link Heap}.
* @public
* @internal
*/

@@ -155,3 +155,3 @@ export declare interface IHeapNode<T> {

* completes.
* @public
* @internal
*/

@@ -167,3 +167,3 @@ export declare interface IPromiseTimer extends ITimer {

/**
* @public
* @internal
*/

@@ -175,3 +175,3 @@ export declare interface IPromiseTimerResult {

/**
* @public
* @internal
*/

@@ -195,3 +195,3 @@ export declare interface ITimer {

* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
* @internal
*/

@@ -222,3 +222,3 @@ export declare class Lazy<T> {

* All calls are then proxied to the promise returned by the execute method.
* @public
* @internal
*/

@@ -238,3 +238,3 @@ export declare class LazyPromise<T> implements Promise<T> {

* A comparer for numbers.
* @public
* @internal
*/

@@ -246,3 +246,3 @@ export declare const NumberComparer: IComparer<number>;

* without fear of running it multiple times or losing track of errors.
* @public
* @internal
*/

@@ -307,3 +307,3 @@ export declare class PromiseCache<TKey, TResult> {

* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
* @internal
*/

@@ -319,3 +319,3 @@ export declare type PromiseCacheExpiry = {

* Options for configuring the {@link PromiseCache}
* @public
* @internal
*/

@@ -338,3 +338,3 @@ export declare interface PromiseCacheOptions {

* resolves when it times out.
* @public
* @internal
*/

@@ -366,3 +366,3 @@ export declare class PromiseTimer implements IPromiseTimer {

* @returns The initial timeout
* @public
* @internal
*/

@@ -376,3 +376,3 @@ export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;

* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
* @internal
*/

@@ -428,3 +428,3 @@ export declare class Timer implements ITimer {

* ```
* @public
* @internal
*/

@@ -431,0 +431,0 @@ export declare function unreachableCase(_: never, message?: string): never;

@@ -8,5 +8,5 @@ /*!

* @param timeMs - Time in milliseconds to wait.
* @public
* @internal
*/
export declare const delay: (timeMs: number) => Promise<void>;
//# sourceMappingURL=delay.d.ts.map

@@ -8,5 +8,5 @@ /*!

* @param timeMs - Time in milliseconds to wait.
* @public
* @internal
*/
export const delay = async (timeMs) => new Promise((resolve) => setTimeout(() => resolve(), timeMs));
//# sourceMappingURL=delay.js.map

@@ -7,3 +7,3 @@ /*!

* Interface for a comparer.
* @public
* @internal
*/

@@ -24,3 +24,3 @@ export interface IComparer<T> {

* A comparer for numbers.
* @public
* @internal
*/

@@ -30,3 +30,3 @@ export declare const NumberComparer: IComparer<number>;

* Interface to a node in {@link Heap}.
* @public
* @internal
*/

@@ -39,3 +39,3 @@ export interface IHeapNode<T> {

* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
* @internal
*/

@@ -42,0 +42,0 @@ export declare class Heap<T> {

@@ -7,3 +7,3 @@ /*!

* A comparer for numbers.
* @public
* @internal
*/

@@ -23,3 +23,3 @@ export const NumberComparer = {

* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
* @internal
*/

@@ -26,0 +26,0 @@ export class Heap {

@@ -7,3 +7,3 @@ /*!

* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
* @internal
*/

@@ -33,3 +33,3 @@ export declare class Lazy<T> {

* All calls are then proxied to the promise returned by the execute method.
* @public
* @internal
*/

@@ -36,0 +36,0 @@ export declare class LazyPromise<T> implements Promise<T> {

@@ -7,3 +7,3 @@ /*!

* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
* @internal
*/

@@ -42,3 +42,3 @@ export class Lazy {

* All calls are then proxied to the promise returned by the execute method.
* @public
* @internal
*/

@@ -45,0 +45,0 @@ export class LazyPromise {

@@ -10,3 +10,3 @@ /*!

* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
* @internal
*/

@@ -21,3 +21,3 @@ export type PromiseCacheExpiry = {

* Options for configuring the {@link PromiseCache}
* @public
* @internal
*/

@@ -37,3 +37,3 @@ export interface PromiseCacheOptions {

* without fear of running it multiple times or losing track of errors.
* @public
* @internal
*/

@@ -40,0 +40,0 @@ export declare class PromiseCache<TKey, TResult> {

@@ -50,3 +50,3 @@ /*!

* without fear of running it multiple times or losing track of errors.
* @public
* @internal
*/

@@ -53,0 +53,0 @@ export class PromiseCache {

@@ -7,3 +7,3 @@ /*!

* A deferred creates a promise and the ability to resolve or reject it
* @public
* @internal
*/

@@ -10,0 +10,0 @@ export declare class Deferred<T> {

@@ -7,3 +7,3 @@ /*!

* A deferred creates a promise and the ability to resolve or reject it
* @public
* @internal
*/

@@ -10,0 +10,0 @@ export class Deferred {

@@ -6,3 +6,3 @@ /*!

/**
* @public
* @internal
*/

@@ -32,3 +32,3 @@ export interface ITimer {

* @returns The initial timeout
* @public
* @internal
*/

@@ -41,3 +41,3 @@ export declare function setLongTimeout(timeoutFn: () => void, timeoutMs: number, setTimeoutIdFn?: (timeoutId: ReturnType<typeof setTimeout>) => void): ReturnType<typeof setTimeout>;

* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
* @internal
*/

@@ -79,3 +79,3 @@ export declare class Timer implements ITimer {

/**
* @public
* @internal
*/

@@ -88,3 +88,3 @@ export interface IPromiseTimerResult {

* completes.
* @public
* @internal
*/

@@ -103,3 +103,3 @@ export interface IPromiseTimer extends ITimer {

* resolves when it times out.
* @public
* @internal
*/

@@ -106,0 +106,0 @@ export declare class PromiseTimer implements IPromiseTimer {

@@ -17,3 +17,3 @@ /*!

* @returns The initial timeout
* @public
* @internal
*/

@@ -38,3 +38,3 @@ export function setLongTimeout(timeoutFn, timeoutMs, setTimeoutIdFn) {

* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
* @internal
*/

@@ -150,3 +150,3 @@ export class Timer {

* resolves when it times out.
* @public
* @internal
*/

@@ -153,0 +153,0 @@ export class PromiseTimer {

@@ -19,5 +19,5 @@ /*!

* ```
* @public
* @internal
*/
export declare function unreachableCase(_: never, message?: string): never;
//# sourceMappingURL=unreachable.d.ts.map

@@ -19,3 +19,3 @@ /*!

* ```
* @public
* @internal
*/

@@ -22,0 +22,0 @@ export function unreachableCase(_, message = "Unreachable Case") {

{
"name": "@fluidframework/core-utils",
"version": "2.0.0-dev.7.4.0.215930",
"version": "2.0.0-dev.7.4.0.216897",
"description": "Not intended for use outside the Fluid client repo.",

@@ -43,3 +43,3 @@ "homepage": "https://fluidframework.com",

"@fluidframework/eslint-config-fluid": "^3.1.0",
"@fluidframework/mocha-test-setup": "2.0.0-dev.7.4.0.215930",
"@fluidframework/mocha-test-setup": "2.0.0-dev.7.4.0.216897",
"@microsoft/api-extractor": "^7.38.3",

@@ -91,2 +91,3 @@ "@types/mocha": "^9.1.1",

"build:test": "tsc --project ./src/test/tsconfig.json",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
"ci:build:docs": "api-extractor run",

@@ -97,3 +98,3 @@ "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",

"format": "npm run prettier:fix",
"lint": "npm run prettier && npm run eslint",
"lint": "npm run prettier && npm run check:release-tags && npm run eslint",
"lint:fix": "npm run prettier:fix && npm run eslint:fix",

@@ -100,0 +101,0 @@ "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",

@@ -15,3 +15,3 @@ /*!

* use numbered error codes instead.
* @public
* @internal
*/

@@ -18,0 +18,0 @@ export function assert(condition: boolean, message: string | number): asserts condition {

@@ -9,5 +9,5 @@ /*!

* @param timeMs - Time in milliseconds to wait.
* @public
* @internal
*/
export const delay = async (timeMs: number): Promise<void> =>
new Promise((resolve) => setTimeout(() => resolve(), timeMs));

@@ -8,3 +8,3 @@ /*!

* Interface for a comparer.
* @public
* @internal
*/

@@ -27,3 +27,3 @@ export interface IComparer<T> {

* A comparer for numbers.
* @public
* @internal
*/

@@ -45,3 +45,3 @@ export const NumberComparer: IComparer<number> = {

* Interface to a node in {@link Heap}.
* @public
* @internal
*/

@@ -55,3 +55,3 @@ export interface IHeapNode<T> {

* Ordered {@link https://en.wikipedia.org/wiki/Heap_(data_structure) | Heap} data structure implementation.
* @public
* @internal
*/

@@ -58,0 +58,0 @@ export class Heap<T> {

@@ -8,3 +8,3 @@ /*!

* Helper class for lazy initialized values. Ensures the value is only generated once, and remain immutable.
* @public
* @internal
*/

@@ -45,3 +45,3 @@ export class Lazy<T> {

* All calls are then proxied to the promise returned by the execute method.
* @public
* @internal
*/

@@ -48,0 +48,0 @@ export class LazyPromise<T> implements Promise<T> {

@@ -11,3 +11,3 @@ /*!

* - sliding: entries expire after the given duration in MS of inactivity (i.e. get resets the clock)
* @public
* @internal
*/

@@ -25,3 +25,3 @@ export type PromiseCacheExpiry =

* Options for configuring the {@link PromiseCache}
* @public
* @internal
*/

@@ -94,3 +94,3 @@ export interface PromiseCacheOptions {

* without fear of running it multiple times or losing track of errors.
* @public
* @internal
*/

@@ -97,0 +97,0 @@ export class PromiseCache<TKey, TResult> {

@@ -8,3 +8,3 @@ /*!

* A deferred creates a promise and the ability to resolve or reject it
* @public
* @internal
*/

@@ -11,0 +11,0 @@ export class Deferred<T> {

@@ -10,3 +10,3 @@ /*!

/**
* @public
* @internal
*/

@@ -75,3 +75,3 @@ export interface ITimer {

* @returns The initial timeout
* @public
* @internal
*/

@@ -104,3 +104,3 @@ export function setLongTimeout(

* or timeouts exceeding (2^31)-1 ms or approximately 24.8 days.
* @public
* @internal
*/

@@ -227,3 +227,3 @@ export class Timer implements ITimer {

/**
* @public
* @internal
*/

@@ -237,3 +237,3 @@ export interface IPromiseTimerResult {

* completes.
* @public
* @internal
*/

@@ -253,3 +253,3 @@ export interface IPromiseTimer extends ITimer {

* resolves when it times out.
* @public
* @internal
*/

@@ -256,0 +256,0 @@ export class PromiseTimer implements IPromiseTimer {

@@ -20,3 +20,3 @@ /*!

* ```
* @public
* @internal
*/

@@ -23,0 +23,0 @@ export function unreachableCase(_: never, message = "Unreachable Case"): never {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc