UNPKG

@typescript-package/data

Version:

A lightweight TypeScript library for basic data management.

100 lines (99 loc) 2.75 kB
/** * @description Manages the immutability states of `this` current instance. * @export * @abstract * @class Immutability */ export declare abstract class Immutability { #private; /** * @description * @template Type * @param {Type} object * @returns {Readonly<Type>} */ static deepFreeze<Type>(object: Type): Readonly<Type>; /** * @description * @public * @readonly * @type {boolean} */ get frozen(): boolean; /** * @description * @public * @readonly * @type {boolean} */ get locked(): boolean; /** * @description * @public * @readonly * @type {boolean} */ get mutable(): boolean; /** * @description * @public * @readonly * @type {boolean} */ get sealed(): boolean; /** * @description Deeply freezes current `this` instance. * @public * @returns {this} Returns current instance. */ deepFreeze(): this; /** * @description "Prevents the modification of existing property attributes and values, and prevents the addition of new properties." * @public * @returns {this} Returns current instance. */ freeze(): this; /** * @description Checks whether `this` current instance is frozen. * @public * @returns {boolean} */ isFrozen(): boolean; /** * @description Checks whether the current instance is locked. * @public * @returns {boolean} Returns a `boolean` indicating whether current instance is locked. */ isLocked(): boolean; /** * @description Checks whether the object is mutable. * @public * @returns {boolean} True if the object is mutable, otherwise `false`. */ isMutable(): boolean; /** * @description Checks whether `this` current instance is sealed. * @public * @returns {boolean} Returns a `boolean` indicating whether current instance is sealed. */ isSealed(): boolean; /** * @description Locks the object, means deeply freezes and blocks the `set()`, ensuring deep immutability. * It combines the features of `Object.freeze`, but extends immutability to nested structures (deep immutability). * @public * @returns {this} Returns current instance. */ lock(): this; /** * @description "Prevents the modification of attributes of existing properties, and prevents the addition of new properties." * @public * @returns {this} Returns current instance. */ seal(): this; /** * @description Validates the ability to set the value. * @protected * @returns {this} Returns current instance. */ protected validate(): this; }