UNPKG

@typescript-package/data

Version:

A lightweight TypeScript library for basic data management.

61 lines (60 loc) 1.89 kB
import { Immutability } from './immutability.abstract'; /** * @description The base abstraction with immutability for handling data-related classes. * @export * @abstract * @class DataCore * @template Type Represents the type of data value. * @extends {Immutability} */ export declare abstract class DataCore<Type> extends Immutability { /** * @description Returns the `string` tag representation of the `DataCore` class when used in `Object.prototype.toString.call(instance)`. * @public * @readonly * @type {string} */ get [Symbol.toStringTag](): string; /** * @description Returns the string tag of the current instance defined by the `Symbol.toStringTag`. * @public * @returns {string | undefined} The extracted class name, such as `'DataCore'`, or `undefined` if extraction fails. */ get tag(): string | undefined; /** * @description Returns the value of generic type variable `Type`. * @public * @abstract * @readonly * @type {Type} */ abstract get value(): Type; /** * @description Clears the value by setting to `undefined` or `null`. * @public * @abstract * @returns {this} Returns `this` current instance. */ abstract clear(): this; /** * @description Abstract method to clear or remove the stored data value. * @public * @abstract * @returns {this} Returns `this` current instance. */ abstract destroy(): this; /** * @inheritdoc * @public * @returns {this} */ lock(): this; /** * @description Sets the data value. Ensure `super.validate()` is called before invoking this method. * @public * @abstract * @param {Type} value The data value of `Type` to set. * @returns {this} Returns `this` current instance. */ abstract set(value: Type): this; }