@typescript-package/affix
Version:
A lightweight TypeScript library for different kind of affixes.
70 lines (69 loc) • 2.64 kB
TypeScript
import { BasicAffixKind } from "@typedly/affix";
/**
* @description A core abstract class to manage affixes with the value and kind that can be applied to strings.
* @export
* @abstract
* @class AffixCore
* @template {string | [string, string]} [Value=string | [string, string]] The type of affix constrained by the `string` and tuple of strings. Defaults to `string`.
* @template {BasicAffixKind | undefined} [Kind=BasicAffixKind | undefined] The kind of affix.
*/
export declare abstract class AffixCore<Value extends string | [string, string] = string | [string, string], Kind extends BasicAffixKind | undefined = BasicAffixKind | undefined> {
#private;
/**
* @description Checks if the given instance is an instance of `AffixCore`.
* @public
* @static
* @param {any} instance The instance to check.
* @returns {boolean} The boolean value indicating whether the instance is of type `AffixCore`.
*/
static is(instance: any): boolean;
/**
* @description Tag name for the `toStringTag`.
* @public
* @static
* @type {string}
*/
static tagName: string;
/**
* @description Returns the `string` tag representation of the `Affix` class when used in `Object.prototype.toString.call(instance)`.
* @public
* @readonly
* @type {string}
*/
get [Symbol.toStringTag](): string;
/**
* @description Returns the kind of affix.
* @public
* @readonly
* @type {(Kind)}
*/
get kind(): Kind;
/**
* @description Returns the privately stored affix of generic type variable `Value` constrained by `string` type.
* @public
* @readonly
* @type {Value}
*/
get value(): Value;
/**
* Creates an instance of `AffixCore`.
* @constructor
* @param {Value} value An optional initial affix of generic type variable `Value` constrained by `string` type. Defaults to `Affix.pattern`.
* @param {?Kind} [kind] The kind of generic type variable `Kind` constrained by `BasicAffixKind` type. Defaults to `undefined`.
*/
constructor(value: Value, kind?: Kind);
/**
* @description Sets the kind of affix.
* @public
* @param {Kind} kind The kind of generic type variable `Kind` constrained by `BasicAffixKind` type.
* @returns {this} The returned value is current instance for method chaining.
*/
setKind(kind: Kind): this;
/**
* @description Sets the value of the affix, sanitizing it according to the defined pattern.
* @public
* @param {Value} value
* @returns {this}
*/
setValue(value: Value): this;
}