UNPKG

@typescript-package/value

Version:

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

1 lines 2.89 kB
{"version":3,"file":"typescript-package-value.mjs","sources":["../../../package/value/src/lib/value.class.ts","../../../package/value/src/public-api.ts","../../../package/value/src/typescript-package-value.ts"],"sourcesContent":["/**\n * @description The class to manage the value of generic type variable `Type`.\n * @export\n * @class Value\n * @template Type The type of the privately stored `#value`.\n */\nexport class Value<Type> {\n /**\n * @description Returns the `string` tag representation of the `Value` class when used in `Object.prototype.toString.call(instance)`.\n * The `tag` getter returns the actual class name defined with the `Symbol.toStringTag()` of the child class.\n * @public\n * @readonly\n * @type {string}\n */\n public get [Symbol.toStringTag]() {\n return Value.name;\n }\n\n /**\n * @description Returns the string tag of the current instance defined by the `Symbol.toStringTag`.\n * @public\n * @returns {string | undefined} The extracted class name, such as `'Value'`, or `undefined` if extraction fails.\n */\n public get tag(): string | undefined {\n const tag = Object.prototype.toString.call(this).slice(8, -1);\n return tag !== 'Object' ? tag : undefined;\n }\n\n /**\n * @description Returns the privately stored value of generic type variable `Type`.\n * @public\n * @readonly\n * @type {Type} \n */\n public get value(): Type {\n return this.#value;\n }\n\n /**\n * @description Privately stored value of generic type variable `Type`.\n * @type {Type}\n */\n #value: Type;\n\n /**\n * Creates an instance of child class.\n * @constructor\n * @param {Type} value The value of generic type variable `Type`.\n */\n constructor(value: Type) {\n this.#value = value;\n }\n \n /**\n * @description Sets the value of generic type variable `Type`.\n * @public\n * @param {Type} value The value of `Type` to set.\n * @returns {this} The `this` current instance.\n */\n public set(value: Type): this {\n this.#value = value;\n return this;\n }\n}\n","/*\n * Public API Surface of value\n */\n\nexport {\n Value\n} from './lib';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;;;AAKG;MACU,KAAK,CAAA;AAChB;;;;;;AAMG;AACH,IAAA,KAAY,MAAM,CAAC,WAAW,CAAC,GAAA;QAC7B,OAAO,KAAK,CAAC,IAAI;;AAGnB;;;;AAIG;AACH,IAAA,IAAW,GAAG,GAAA;QACZ,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7D,OAAO,GAAG,KAAK,QAAQ,GAAG,GAAG,GAAG,SAAS;;AAG3C;;;;;AAKG;AACH,IAAA,IAAW,KAAK,GAAA;QACd,OAAO,IAAI,CAAC,MAAM;;AAGpB;;;AAGG;AACH,IAAA,MAAM;AAEN;;;;AAIG;AACH,IAAA,WAAA,CAAY,KAAW,EAAA;AACrB,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;;AAGrB;;;;;AAKG;AACI,IAAA,GAAG,CAAC,KAAW,EAAA;AACpB,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;AACnB,QAAA,OAAO,IAAI;;AAEd;;AC/DD;;AAEG;;ACFH;;AAEG;;;;"}