@typescript-package/history
Version:
A TypeScript package for tracking the history of values.
58 lines (57 loc) • 1.92 kB
TypeScript
import { HistoryCore } from './history-core.abstract';
/**
* @description Class extends the `HistoryCore` class to maintain a history of values in a prepend manner.
* This means that new entries are added to the beginning of the history, and older entries are shifted out as the history size exceeds its limit.
* @export
* @abstract
* @class HistoryPrepend
* @template Type
* @template {number} [Size=number]
*/
export declare abstract class HistoryPrepend<Type, Size extends number = number> extends HistoryCore<Type, Size> {
/**
* @description The default value of maximum history size.
* @public
* @static
* @type {number}
*/
static size: number;
/**
* @description Returns the `string` tag representation of the `HistoryPrepend` class when used in `Object.prototype.toString.call(instance)`.
* @public
* @readonly
* @type {string}
*/
get [Symbol.toStringTag](): string;
/**
* Creates an instance of `HistoryPrepend` child class.
* @constructor
* @param {Size} [size=HistoryPrepend.size as Size]
*/
constructor(size?: Size);
/**
* @description Adds the value to the history in a backward manner.
* @public
* @param {Type} value The value to store.
* @returns {this} The current instance.
*/
add(value: Type): this;
/**
* @description Returns the last value that would be redone without modifying history.
* @public
* @returns {Type | undefined} The next redo value.
*/
peekLast(): Type | undefined;
/**
* @description Returns the next value that would be redone without modifying history.
* @public
* @returns {Type | undefined} The next redo value.
*/
peekNext(): Type | undefined;
/**
* @description Takes the first value.
* @public
* @returns {(Type | undefined)}
*/
take(): Type | undefined;
}