@typescript-package/affix
Version:
A lightweight TypeScript library for different kind of affixes.
1 lines • 35.4 kB
Source Map (JSON)
{"version":3,"file":"typescript-package-affix.mjs","sources":["../../../package/affix/src/lib/affix-core.abstract.ts","../../../package/affix/src/lib/affix.class.ts","../../../package/affix/src/lib/circumfix.class.ts","../../../package/affix/src/lib/infix.class.ts","../../../package/affix/src/lib/prefix.class.ts","../../../package/affix/src/lib/suffix.class.ts","../../../package/affix/src/lib/index.ts","../../../package/affix/src/public-api.ts","../../../package/affix/src/typescript-package-affix.ts"],"sourcesContent":["// Interface.\nimport { BasicAffixKind } from \"@typedly/affix\";\n/**\n * @description A core abstract class to manage affixes with the value and kind that can be applied to strings.\n * @export\n * @abstract\n * @class AffixCore\n * @template {string | [string, string]} [Value=string | [string, string]] The type of affix constrained by the `string` and tuple of strings. Defaults to `string`.\n * @template {BasicAffixKind | undefined} [Kind=BasicAffixKind | undefined] The kind of affix.\n */\nexport abstract class AffixCore<\n Value extends string | [string, string] = string | [string, string],\n Kind extends BasicAffixKind | undefined = BasicAffixKind | undefined,\n> {\n /**\n * @description Checks if the given instance is an instance of `AffixCore`.\n * @public\n * @static\n * @param {any} instance The instance to check.\n * @returns {boolean} The boolean value indicating whether the instance is of type `AffixCore`.\n */\n public static is(instance: any): boolean {\n return Object.prototype.toString.call(instance).match(/\\[object (\\w+)]/)?.[1] === this.tagName;\n }\n\n /**\n * @description Tag name for the `toStringTag`.\n * @public\n * @static\n * @type {string}\n */\n public static tagName: string = 'AffixCore';\n\n /**\n * @description Returns the `string` tag representation of the `Affix` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public get [Symbol.toStringTag]() {\n return AffixCore.tagName;\n }\n\n /**\n * @description Returns the kind of affix.\n * @public\n * @readonly\n * @type {(Kind)}\n */\n public get kind(): Kind {\n return this.#kind as Kind;\n }\n\n /**\n * @description Returns the privately stored affix of generic type variable `Value` constrained by `string` type.\n * @public\n * @readonly\n * @type {Value}\n */\n public get value(): Value {\n return this.#value;\n }\n\n /**\n * @description Privately stored kind of `Kind` to define the type of affix.\n * @type {Kind | undefined}\n */\n #kind?: Kind;\n\n /**\n * @description Privately stored affix of generic type variable `Value` constrained by `string` type.\n * @type {Value}\n */\n #value: Value;\n\n /**\n * Creates an instance of `AffixCore`.\n * @constructor\n * @param {Value} value An optional initial affix of generic type variable `Value` constrained by `string` type. Defaults to `Affix.pattern`.\n * @param {?Kind} [kind] The kind of generic type variable `Kind` constrained by `BasicAffixKind` type. Defaults to `undefined`.\n */\n constructor(\n value: Value,\n kind?: Kind,\n ) {\n this.#kind = kind;\n this.#value = value as Value;\n }\n\n /**\n * @description Sets the kind of affix.\n * @public\n * @param {Kind} kind The kind of generic type variable `Kind` constrained by `BasicAffixKind` type.\n * @returns {this} The returned value is current instance for method chaining.\n */\n public setKind(kind: Kind): this {\n this.#kind = kind;\n return this;\n }\n\n /**\n * @description Sets the value of the affix, sanitizing it according to the defined pattern.\n * @public\n * @param {Value} value \n * @returns {this} \n */\n public setValue(value: Value): this {\n this.#value = value as Value;\n return this;\n }\n}\n","// Abstract.\nimport { AffixCore } from \"./affix-core.abstract\";\n// Interface.\nimport { BasicAffixKind } from \"@typedly/affix\";\n/**\n * @description A concrete class to manage affixes that can be applied to strings with additional sanitization.\n * @export\n * @class Affix\n * @template {string | [string, string]} [Value=string | [string, string]] The type of affix constrained by the `string`. Defaults to `string`.\n * @template {BasicAffixKind | undefined} [Kind=BasicAffixKind | undefined] \n * @template {RegExp | string | undefined} [Pattern=RegExp | string | undefined] \n */\nexport class Affix<\n Value extends string | [string, string] = string | [string, string],\n Kind extends BasicAffixKind | undefined = BasicAffixKind | undefined,\n Pattern extends RegExp | string | undefined = RegExp | string | undefined,\n> extends AffixCore<Value, Kind> {\n /**\n * @description Defines the affix sanitized by specified pattern.\n * @public\n * @static\n * @template {string | [string, string]} [Value=string | [string, string]] The type of affix constrained by the `string` type. Defaults to `string`.\n * @param {Value} value A value of generic type variable `Value` constrained by the `string` type to be sanitized with the `pattern`.\n * @param {RegExp | string} [pattern=Affix.pattern] The pattern of `RegExp` to sanitize the `affix`. Defaults to static `Affix.pattern`.\n * @returns {Value} The returned value is an affix of a generic type variable `Value`, optionally sanitized by the `pattern`.\n */\n public static sanitize<\n Start extends string = string,\n End extends string = Start,\n Value extends string | [Start, End] = string | [Start, End]\n >(\n value: Value,\n pattern: RegExp | string = this.pattern,\n ): Value {\n return (typeof value === 'string'\n ? value.replace(pattern, '')\n : value.map(v => v.replace(pattern, ''))\n ) as any;\n }\n\n /**\n * @description The default pattern used to sanitize the affix, which removes characters that are not part of the valid characters for the affix.\n * @public\n * @static\n * @type {RegExp | string}\n */\n public static pattern: RegExp | string = /[^a-zA-Z0-9$_]/g;\n\n /**\n * @description Tag name for the `toStringTag`.\n * @public\n * @static\n * @type {string}\n */\n public static override tagName: string = Affix.name;\n\n /**\n * @description Returns the `string` tag representation of the `Affix` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag]() {\n return Affix.tagName;\n }\n\n /**\n * @description Returns the privately stored pattern of `PatternValue` type to sanitize the affix.\n * @public\n * @readonly\n * @type {(Pattern)}\n */\n public get pattern(): Pattern {\n return this.#pattern as Pattern;\n }\n\n /**\n * @description Privately stored pattern of `Pattern` to sanitize the affix.\n * @type {Pattern | undefined}\n */\n #pattern?: Pattern;\n\n /**\n * Creates an instance of `Affix`.\n * @constructor\n * @param {Value} value An optional initial affix of generic type variable `Value` constrained by `string` type. Defaults to `Affix.pattern`.\n * @param {{ kind?: Kind, pattern?: Pattern }} [param0={}] The options object to set the kind and pattern of the affix.\n * @param {Kind} param0.kind The kind of affix constrained by `BasicAffixKind` type.\n * @param {Pattern} param0.pattern The pattern of `PatternValue` to sanitize the affix.\n */\n constructor(\n value: Value,\n { kind, pattern }: { kind?: Kind, pattern?: Pattern } = {},\n ) {\n super(Affix.sanitize(value, pattern), kind);\n this.#pattern = pattern ?? Affix.pattern as Pattern;\n }\n\n /**\n * @description Returns the affix, optionally sanitized by the `pattern`.\n * @public\n * @param {(Pattern)} [pattern=this.#pattern] The pattern of `RegExp` to sanitize privately stored affix.\n * @returns {Value} Returns privately stored `#affix` of `Value` type optionally sanitized by the `pattern`.\n */\n public get(pattern: Pattern = this.#pattern as Pattern): Value {\n return Affix.sanitize(super.value, pattern) as Value;\n }\n\n /**\n * @description Sets and stores privately sanitized affix of generic type variable `Value` constrained by `string` type.\n * @public\n * @param {({ kind?: Kind, pattern?: Pattern, value?: Value})} [param0={}] \n * @param {Kind} param0.kind The kind of affix constrained by `BasicAffixKind` type.\n * @param {Pattern} param0.pattern The pattern of `Pattern` to sanitize the affix.\n * @param {Value} param0.value The value of the affix constrained by `string` type.\n * @returns {this} The returned value is current instance for method chaining.\n */\n public set({ kind, pattern, value }: { kind?: Kind, pattern?: Pattern, value?: Value } = {}): this {\n typeof value === 'string' && this.setValue(Affix.sanitize(value, pattern) as Value);\n 'kind' in arguments[0] && this.setKind(kind as Kind);\n 'pattern' in arguments[0] && this.setPattern(pattern as Pattern);\n return this;\n }\n\n /**\n * @description Sets the pattern to sanitize the affix.\n * @public\n * @param {Pattern} pattern The pattern of `Pattern` to sanitize the affix.\n * @returns {this} The returned value is current instance for method chaining.\n */\n public setPattern(pattern: Pattern): this {\n this.#pattern = pattern;\n return this;\n }\n}\n","// Class.\nimport { Affix } from \"./affix.class\";\n// Type.\nimport { CircumfixTemplate } from \"@typedly/affix\";\n/**\n * @description A class to manage circumfixes that can be applied to strings.\n * @export\n * @class Circumfix\n * @template {string} [Start=string] The type of circumfix constrained by the `string`. Defaults to `string`.\n * @template {string} [End=Start] The type of circumfix end constrained by the `string`, defaults to the same type as `Start`.\n * @template {RegExp | string | undefined} [Pattern=RegExp | string | undefined] The type of pattern constrained by the `RegExp` or `string`.\n * @extends {Affix<[Start, End], 'circumfix', Pattern>}\n */\nexport class Circumfix<\n Start extends string = string,\n End extends string = Start,\n Pattern extends RegExp | string | undefined = RegExp | string | undefined,\n> extends Affix<[Start, End], 'circumfix', Pattern> {\n /**\n * @description Inserts a circumfix to a given stem with an optional delimiter.\n * @public\n * @static\n * @template {string} [Start=string] The type of circumfix start constrained by the `string`. Defaults to `string`.\n * @template {string} [Stem=string] The type of stem constrained by the `string`. Defaults to `string`.\n * @template {string} [End=Start] The type of circumfix end constrained by the `string`, defaults to the same type as `Start`.\n * @template {string} [Delimiter=''] The type of delimiter constrained by the `string`, defaults to an empty string.\n * @param {Stem} stem The stem to which the circumfix will be inserted.\n * @param {(Start | [Start, End])} [circumfix=Circumfix.default as Start] The circumfix to be applied.\n * @param {Delimiter} [delimiter='' as Delimiter] The delimiter to be used.\n * @returns {CircumfixTemplate<Start, Stem, End, Delimiter>} The resulting circumfixed string.\n */\n public static insert<\n Start extends string = string,\n Stem extends string = string,\n End extends string = Start,\n Delimiter extends string = '',\n >(\n stem: Stem,\n circumfix: Start | [Start, End] = Circumfix.default as Start,\n delimiter: Delimiter = '' as Delimiter\n ): CircumfixTemplate<Start, Stem, End, Delimiter> {\n return `${typeof circumfix === 'string' ? circumfix : circumfix[0] }${delimiter}${stem}${delimiter}${typeof circumfix === 'string' ? circumfix as unknown as End : circumfix[1] as End}`;\n }\n\n /**\n * @inheritdoc\n * @public\n * @static\n * @type {string}\n */\n public static override tagName: string = 'Circumfix';\n\n /**\n * @description The default circumfix value, which is an empty string. This is used when no circumfix is provided.\n * @public\n * @static\n * @type {string | [string, string]}\n */\n public static default: string | [string, string] = '';\n\n /**\n * @description Returns the `string` tag representation of the `Circumfix` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag]() {\n return Circumfix.tagName;\n }\n\n /**\n * @description The circumfix value, which is a tuple containing the start and end of the circumfix.\n * @public\n * @readonly\n * @type {[Start, End]}\n */\n public get circumfix(): [Start, End] {\n return this.value;\n }\n\n /**\n * @description The end of the circumfix, which is the second element of the tuple.\n * @public\n * @readonly\n * @type {End}\n */\n public get end(): End { \n return this.value[1];\n }\n\n /**\n * @description The start of the circumfix, which is the first element of the tuple.\n * @public\n * @readonly\n * @type {Start}\n */\n public get start(): Start {\n return this.value[0];\n }\n\n /**\n * Creates an instance of `Circumfix`.\n * @constructor\n * @param {Start} [start='' as Value] The value of the prefix, constrained by the `string` type. Defaults to an empty string.\n * @param {End} [end=start as End] The value of the suffix, constrained by the `string` type, defaults to the same type as `start`.\n * @param {Pattern} [pattern=Circumfix.pattern] The pattern to sanitize the prefix. Defaults to the static `Circumfix.pattern`.\n */\n constructor(\n start: Start = '' as Start,\n end: End = start as unknown as End,\n pattern: Pattern = Circumfix.pattern as Pattern\n ) {\n super([start, end], { kind: 'circumfix', pattern });\n }\n\n /**\n * @description Inserts the circumfix to a given stem with an optional delimiter.\n * @param {string} stem The stem to which the circumfix will be inserted.\n * @returns {string} The resulting string with the circumfix inserted.\n */\n public insertTo<\n Stem extends string = string,\n Delimiter extends string = '',\n >(stem: Stem, delimiter: Delimiter = '' as Delimiter): CircumfixTemplate<Start, Stem, End, Delimiter> {\n return Circumfix.insert<Start, Stem, End, Delimiter>(\n stem,\n [this.start, this.end],\n delimiter\n ) as CircumfixTemplate<Start, Stem, End, Delimiter>;\n }\n} \n","// Class.\nimport { Affix } from \"./affix.class\";\n// Type.\nimport { InfixTemplate } from \"@typedly/affix\";\nimport { SplitAt } from \"../type\";\n/**\n * @description A class to manage infixes that can be applied to strings.\n * @export\n * @class Infix\n * @template {string} [Value=string] The type of infix constrained by the `string`.\n * @template {RegExp | string | undefined} [Pattern=RegExp | string | undefined] The type of pattern constrained by the `RegExp` or `string`.\n * @extends {Affix<Value, 'infix', Pattern>}\n */\nexport class Infix<\n Value extends string = string,\n Pattern extends RegExp | string | undefined = RegExp | string | undefined,\n> extends Affix<Value, 'infix', Pattern> {\n /**\n * @description Inserts the infix into a given stem at a specified position with an optional delimiter.\n * @public\n * @static\n * @template {string} Infix Type of the infix constrained by the `string`.\n * @template {string} [Stem=string] The type of the stem string.\n * @template {number} [Position=number] The type of the position number, defaults to `Math.floor(stem.length / 2)`.\n * @template {string} [Delimiter=''] The type of delimiter string, defaults to an empty string.\n * @param {Infix} infix The infix to insert into the stem at specified position.\n * @param {Stem} stem The stem to insert the infix into its specified position.\n * @param {Position} [position=Math.floor(stem.length / 2) as Position] The position of stem to insert the infix.\n * @param {Delimiter} [delimiter='' as Delimiter] The delimiter to use between the two halves of stem and infix.\n * @returns {InfixTemplate<SplitAt<Stem, Position>[0], Infix, SplitAt<Stem, Position>[1], Delimiter>} \n */\n public static insert<\n Stem extends string = string,\n Infix extends string = string,\n Position extends number = number,\n Delimiter extends string = ''\n >(\n stem: Stem,\n infix: Infix,\n position: Position = Math.floor(stem.length / 2) as Position,\n delimiter: Delimiter = '' as Delimiter\n ): InfixTemplate<SplitAt<Stem, Position>[0], Infix, SplitAt<Stem, Position>[1], Delimiter> {\n return `${stem.slice(0, position)}${delimiter}${infix}${delimiter}${stem.slice(position)}` as any;\n }\n\n /**\n * @description Tag name for the `toStringTag`.\n * @public\n * @static\n * @type {string}\n */\n public static override tagName: string = 'Infix';\n\n /**\n * @description The default infix to use.\n * @public\n * @static\n * @type {string}\n */\n public static default: string = '';\n\n /**\n * @description Returns the `string` tag representation of the `Infix` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag]() {\n return Infix.tagName;\n }\n\n /**\n * @description The infix value, which is a generic type variable `Value` constrained by the `string` type.\n * @public\n * @readonly\n * @type {Value}\n */\n public get infix(): Value {\n return this.value;\n }\n\n /**\n * Creates an instance of `Infix`.\n * @constructor\n * @param {Value} [value='' as Value] The value of the infix, constrained by the `string` type. Defaults to an empty string.\n * @param {Pattern} [pattern=Infix.pattern] The pattern to sanitize the infix. Defaults to the static `Infix.pattern`.\n */\n constructor(\n value: Value = '' as Value,\n pattern: Pattern = Infix.pattern as Pattern\n ) {\n super(value, { kind: 'infix', pattern });\n }\n\n /**\n * @description Inserts the infix into a given stem at a specified position with an optional delimiter.\n * @public\n * @template {string} [Stem=string] The type of the stem string.\n * @template {number} [Position=number] The type of the position number, defaults to `Math.floor(stem.length / 2)`.\n * @template {string} [Delimiter=''] The type of delimiter string, defaults to an empty string.\n * @param {Stem} stem The stem to insert the infix into specified position of stem.\n * @param {Position} [position=Math.floor(stem.length / 2) as Position] The position of stem to insert the infix.\n * @param {Delimiter} [delimiter='' as Delimiter] The delimiter to use between the two halves of stem and infix.\n * @returns {InfixTemplate<SplitAt<Stem, Position>[0], Value, SplitAt<Stem, Position>[1], Delimiter>}\n */\n public insertTo<\n Stem extends string = string,\n Position extends number = number,\n Delimiter extends string = '',\n >(\n stem: Stem,\n position: Position = Math.floor(stem.length / 2) as Position,\n delimiter: Delimiter = '' as Delimiter\n ): InfixTemplate<SplitAt<Stem, Position>[0], Value, SplitAt<Stem, Position>[1], Delimiter> {\n return Infix.insert(stem, this.value, position, delimiter);\n }\n}\n","// Class.\nimport { Affix } from \"./affix.class\";\n// Type.\nimport { PrefixTemplate } from '@typedly/affix';\n/**\n * @description A class to manage prefixes that can be applied to strings.\n * @export\n * @class Prefix\n * @template {string} [Value=string] The type of prefix constrained by the `string`.\n * @template {RegExp | string | undefined} [Pattern=RegExp | string | undefined] The type of pattern constrained by the `RegExp` or `string`.\n * @extends {Affix<Value, 'prefix', Pattern>}\n */\nexport class Prefix<\n Value extends string = string,\n Pattern extends RegExp | string | undefined = RegExp | string | undefined,\n> extends Affix<Value, 'prefix', Pattern> {\n /**\n * @description Prepends the prefix to stem string.\n * @public\n * @static\n * @template {string} [Stem=string] The type of stem string constrained by the `string`.\n * @template {string} [Prefix=string] The type of prefix constrained by the `string`.\n * @param {Stem} stem The stem string to append the prefix.\n * @param {Prefix} [prefix=Prefix.default as Prefix] Prefix to append to stem.\n * @param {Delimiter} [delimiter='' as Delimiter] The delimiter to use between the prefix and the stem.\n * @param {boolean} [sanitize=true] Whether to sanitize the prefix using the static `Prefix.pattern`.\n * @returns {PrefixTemplate<Prefix, Stem, Delimiter>} \n */\n public static prepend<\n Stem extends string = string,\n Prefix extends string = string,\n Delimiter extends string = '',\n >(\n stem: Stem,\n prefix: Prefix = Prefix.default as Prefix,\n delimiter: Delimiter = '' as Delimiter,\n sanitize: boolean = true\n ): PrefixTemplate<Prefix, Stem, Delimiter> {\n return `${sanitize ? super.sanitize(prefix, this.pattern) : prefix}${delimiter}${stem}`;\n }\n\n /**\n * @description Tag name for the `toStringTag`.\n * @public\n * @static\n * @type {string}\n */\n public static override tagName: string = 'Prefix';\n\n /**\n * @description The default prefix to use.\n * @public\n * @static\n * @type {string}\n */\n public static default: string = '';\n\n /**\n * @description Returns the `string` tag representation of the `Prefix` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag]() {\n return Prefix.tagName;\n }\n\n /**\n * @description The prefix value of the generic type variable `Value` constrained by the `string` type.\n * @public\n * @readonly\n * @type {Value}\n */\n public get prefix(): Value {\n return this.value as Value;\n }\n\n /**\n * Creates an instance of `Prefix`.\n * @constructor\n * @param {Value} [value='' as Value] The value of the prefix, constrained by the `string` type. Defaults to an empty string.\n * @param {Pattern} [pattern=Prefix.pattern] The pattern to sanitize the prefix. Defaults to the static `Prefix.pattern`.\n */\n constructor(\n value: Value = '' as Value,\n pattern: Pattern = Prefix.pattern as Pattern\n ) {\n super(value, { kind: 'prefix', pattern });\n }\n\n /**\n * @description Prepends the prefix to stem string.\n * @public\n * @template {string} [Stem=string] The type of the stem string.\n * @template {string} [Delimiter=''] The type of delimiter string.\n * @param {Stem} stem The stem to prepend the prefix.\n * @param {Delimiter} [delimiter='' as Delimiter] The delimiter to use between the prefix and the stem.\n * @returns {PrefixTemplate<Value, Stem, Delimiter>} The resulting string with the prefix prepended.\n */\n public prependTo<Stem extends string = string, Delimiter extends string = ''>(\n stem: Stem,\n delimiter: Delimiter = '' as Delimiter\n ): PrefixTemplate<Value, Stem, Delimiter> {\n return Prefix.prepend(\n stem,\n Prefix.sanitize(this.prefix, this.pattern),\n delimiter\n ) as PrefixTemplate<Value, Stem, Delimiter>;\n }\n\n /**\n * Sets the pattern and value for the prefix affix.\n * @inheritdoc\n * @public\n * @param {{ pattern?: Pattern, value?: Value }} [param0={}] \n * @param {Pattern} param0.pattern The pattern to sanitize the prefix.\n * @param {Value} param0.value The value of the prefix, constrained by the `string` type.\n * @returns {this} The current instance of `Prefix`.\n */\n public override set({ pattern, value }: { pattern?: Pattern, value?: Value } = {}): this {\n super.set({ pattern, value });\n return this;\n }\n}\n","// Class.\nimport { Affix } from \"./affix.class\";\n// Type.\nimport { SuffixTemplate } from \"@typedly/affix\";\n/**\n * @description A class to manage suffixes that can be applied to strings.\n * @export\n * @class Suffix\n * @template {string} [Value=string] The type of suffix constrained by the `string`.\n * @template {RegExp | string | undefined} [Pattern=RegExp | string | undefined] The type of pattern constrained by the `RegExp` or `string`.\n * @extends {Affix<Value, 'suffix', Pattern>}\n */\nexport class Suffix<\n Value extends string = string,\n Pattern extends RegExp | string | undefined = RegExp | string | undefined,\n> extends Affix<Value, 'suffix', Pattern> {\n /**\n * @description Appends the suffix to the stem string.\n * @public\n * @static\n * @template {string} [Stem=string] The type of stem string constrained by the `string`.\n * @template {string} [Suffix=string] The type of suffix constrained by the `string`.\n * @param {Stem} stem The stem string to append the suffix.\n * @param {Suffix} [suffix=Suffix.default as Suffix] Suffix to append to stem.\n * @param {Delimiter} [delimiter='' as Delimiter] The delimiter to use between the stem and the suffix.\n * @param {boolean} [sanitize=true] Whether to sanitize the suffix using the static `Suffix.pattern`.\n * @returns {SuffixTemplate<Stem, Suffix>} \n */\n public static append<\n Stem extends string = string,\n Suffix extends string = string,\n Delimiter extends string = ''\n >(\n stem: Stem,\n suffix: Suffix = Suffix.default as Suffix,\n delimiter: Delimiter = '' as Delimiter,\n sanitize: boolean = true\n ): SuffixTemplate<Stem, Suffix, Delimiter> {\n return `${stem}${delimiter}${sanitize ? super.sanitize(suffix, this.pattern) : suffix}`;\n }\n\n /**\n * @description Tag name for the `toStringTag`.\n * @public\n * @static\n * @type {string}\n */\n public static override tagName: string = 'Suffix';\n\n /**\n * @description The default suffix to use.\n * @public\n * @static\n * @type {string}\n */\n public static default: string = '';\n\n /**\n * @description Returns the `string` tag representation of the `Suffix` class when used in `Object.prototype.toString.call(instance)`.\n * @public\n * @readonly\n * @type {string}\n */\n public override get [Symbol.toStringTag]() {\n return Suffix.tagName;\n }\n\n /**\n * @description The suffix value of generic type variable `Value` constrained by the `string` type.\n * @public\n * @readonly\n * @type {Value}\n */\n public get suffix(): Value {\n return this.value as Value;\n }\n\n /**\n * Creates an instance of `Suffix`.\n * @constructor\n * @param {Value} [value='' as Value] The value of the suffix, constrained by the `string` type. Defaults to an empty string.\n * @param {(Pattern)} [pattern=Suffix.pattern] The pattern to sanitize the suffix. Defaults to the static `Suffix.pattern`.\n */\n constructor(\n value: Value = '' as Value,\n pattern: Pattern = Suffix.pattern as Pattern\n ) {\n super(value, { kind: 'suffix', pattern });\n }\n\n /**\n * @description Appends the internal suffix to the stem string.\n * @public\n * @template {string} Stem The type of stem string.\n * @param {Stem} stem The stem string to append the suffix.\n * @param {Delimiter} delimiter The delimiter between stem and suffix.\n * @returns {SuffixTemplate<Stem, Value, Delimiter>} The returned value is a template of stem and suffix.\n */\n public appendTo<\n Stem extends string,\n Delimiter extends string = ''\n >(\n stem: Stem,\n delimiter: Delimiter = '' as Delimiter\n ): SuffixTemplate<Stem, Value, Delimiter> {\n return Suffix.append(\n stem,\n Suffix.sanitize(this.suffix, this.pattern),\n delimiter,\n false\n );\n }\n \n /**\n * Sets the pattern and value for the suffix affix.\n * @inheritdoc\n * @public\n * @param {{ pattern?: Pattern, value?: Value }} [param0={}] \n * @param {Pattern} param0.pattern The pattern to sanitize the suffix.\n * @param {Value} param0.value The value of the suffix, constrained by the `string` type.\n * @returns {this} The current instance of `Suffix`.\n */\n public override set({ pattern, value }: { pattern?: Pattern, value?: Value } = {}): this {\n super.set({ pattern, value });\n return this;\n }\n}\n","// Abstract.\nexport { AffixCore } from './affix-core.abstract';\n// Class.\nexport { Affix } from './affix.class';\nexport { Circumfix } from './circumfix.class';\nexport { Infix } from './infix.class';\nexport { Prefix } from './prefix.class';\nexport { Suffix } from './suffix.class';","/*\n * Public API Surface of affix\n */\n\nexport {\n // Abstract.\n AffixCore,\n // Class.\n Affix,\n Circumfix,\n Infix,\n Prefix,\n Suffix,\n} from './lib';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAEA;;;;;;;AAOG;MACmB,SAAS,CAAA;AAI7B;;;;;;AAMG;IACI,OAAO,EAAE,CAAC,QAAa,EAAA;QAC5B,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,OAAO;;AAGhG;;;;;AAKG;AACI,IAAA,OAAO,OAAO,GAAW,WAAW;AAE3C;;;;;AAKG;AACH,IAAA,KAAY,MAAM,CAAC,WAAW,CAAC,GAAA;QAC7B,OAAO,SAAS,CAAC,OAAO;;AAG1B;;;;;AAKG;AACH,IAAA,IAAW,IAAI,GAAA;QACb,OAAO,IAAI,CAAC,KAAa;;AAG3B;;;;;AAKG;AACH,IAAA,IAAW,KAAK,GAAA;QACd,OAAO,IAAI,CAAC,MAAM;;AAGpB;;;AAGG;AACH,IAAA,KAAK;AAEL;;;AAGG;AACH,IAAA,MAAM;AAEN;;;;;AAKG;IACH,WACE,CAAA,KAAY,EACZ,IAAW,EAAA;AAEX,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI;AACjB,QAAA,IAAI,CAAC,MAAM,GAAG,KAAc;;AAG9B;;;;;AAKG;AACI,IAAA,OAAO,CAAC,IAAU,EAAA;AACvB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI;AACjB,QAAA,OAAO,IAAI;;AAGb;;;;;AAKG;AACI,IAAA,QA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