UNPKG

@typescript-package/value

Version:

A lightweight TypeScript library for encapsulating and managing a single, strongly-typed value.

44 lines (43 loc) 1.47 kB
/** * @description The class to manage the value of generic type variable `Type`. * @export * @class Value * @template Type The type of the privately stored `#value`. */ export declare class Value<Type> { #private; /** * @description Returns the `string` tag representation of the `Value` class when used in `Object.prototype.toString.call(instance)`. * The `tag` getter returns the actual class name defined with the `Symbol.toStringTag()` of the child class. * @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 `'Value'`, or `undefined` if extraction fails. */ get tag(): string | undefined; /** * @description Returns the privately stored value of generic type variable `Type`. * @public * @readonly * @type {Type} */ get value(): Type; /** * Creates an instance of child class. * @constructor * @param {Type} value The value of generic type variable `Type`. */ constructor(value: Type); /** * @description Sets the value of generic type variable `Type`. * @public * @param {Type} value The value of `Type` to set. * @returns {this} The `this` current instance. */ set(value: Type): this; }