UNPKG

@typescript-package/data

Version:

A lightweight TypeScript library for basic data management.

54 lines (53 loc) 1.58 kB
import { DataCore } from './data-core.abstract'; /** * @description The `WeakData` class is a concrete class that stores data in a static `WeakMap`. * @export * @class WeakData * @template Type * @extends {DataCore<Type>} */ export declare class WeakData<Type> extends DataCore<Type> { #private; /** * @description Gets the data value from another instance. * @public * @static * @template Type * @param {DataStore<Type>} instance Another instance from which to get the data. * @returns {Type} The value of the data stored in the given instance. */ static get<Type>(instance: WeakData<Type>): Type; /** * @description Returns the `string` tag representation of the `WeakData` class when used in `Object.prototype.toString.call(instance)`. * @public * @readonly * @type {string} */ get [Symbol.toStringTag](): string; /** * @description * @public * @readonly * @type {Type} */ get value(): Type; /** * Creates an instance of `WeakData` child class. * @constructor * @param {Type} value Initial data value of `Type`. */ constructor(value: Type); /** * @description Destroys the value in a static `WeakMap`. * @public * @returns {this} Returns current instance. */ destroy(): this; /** * @description Sets the data value in a static `WeakMap`. * @public * @param {Type} value The data of `Type` to set. * @returns {this} Returns current instance. */ set(value: Type): this; }