UNPKG

@typescript-package/history

Version:

A TypeScript package for tracking the history of values.

59 lines (58 loc) 1.95 kB
import { HistoryCore } from './history-core.abstract'; /** * @description Class extends the `HistoryCore` class to maintain a history of values in a append manner. * This means that new entries are added to the end of the history, and as the history exceeds its size limit, entries from the beginning are removed. * - LIFO(Last in, First out). * @export * @abstract * @class HistoryAppend * @template Type * @template {number} [Size=number] */ export declare abstract class HistoryAppend<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 `HistoryAppend` class when used in `Object.prototype.toString.call(instance)`. * @public * @readonly * @type {string} */ get [Symbol.toStringTag](): string; /** * Creates an instance of `HistoryAppend` child class. * @constructor * @param {Size} [size=HistoryAppend.size as Size] */ constructor(size?: Size); /** * @description Adds the value to the history. * @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 use to redo or undo without modifying history. * @public * @returns {Type | undefined} The next redo value. */ peekLast(): Type | undefined; /** * @description Returns the next value that would be use to redo or undo without modifying history. * @public * @returns {Type | undefined} The next redo value. */ peekNext(): Type | undefined; /** * @description Takes the last value. * @public * @returns {(Type | undefined)} */ take(): Type | undefined; }