/** * Too many naming conventions? */ export declare enum Format { KEBAB = "kebab", PASCAL = "pascal", SNAKE = "snake", CAMEL = "camel" } export interface NamerProps { /** * Characters to strip from name parts * * @default '-_' */ readonly deleteCharacters?: string; /** * Characters which will cause an error if included in a name part tested AFTER deleteCharacters * @todo implement me * @default '!@#$%^&*()~`"' maybe more??? needs thought. Should be DNS compliant, I think. */ readonly illegalCharacters?: string; /** * How long can the name be? * @default - no limit */ readonly maxLength?: number; /** * If the name exceeds maxLength, should I snip the head or the tail? * @default false */ readonly maxLengthTruncateHead?: boolean; /** * How long can a part of the name be? * @default - no limit */ readonly maxPartLength?: number; /** * If the part exceeds maxPartLength, should I snip the head or the tail? * @default false */ readonly maxPartLengthTruncateHead?: boolean; /** * When using toString(), which format should be provided? * @default - raise an error if no default specified and toString invoked */ readonly defaultFormat?: Format; /** * Include a uniquifying suffix? If so, this is the seed for that suffix. * @default - do not include a uniquifier */ readonly uniqueSeed?: any; } export declare class Namer { readonly parts: string[]; private _parts; private _camel?; private _kebab?; private _pascal?; private _snake?; private _unique?; readonly props?: NamerProps; /** * Create a namer * @param parts an array of strings to be composed into a name. * @param props modify the behavior of namer. */ constructor(parts: string[], props?: NamerProps); private splitParts; get partsWithUnique(): string[]; enforceMaxLength(raw: string): string; /** camelCase */ get camel(): string; /** kebab-case */ get kebab(): string; /** PascalCase */ get pascal(): string; /** snake_case */ get snake(): string; /** * Create a new Namer with the added prefix * @param prefix the prefix to add * @param props properties to over-ride the parent props */ addPrefix(prefix: Namer | string[], props?: NamerProps): Namer; /** * Create a new Namer with the added suffix * @param suffix the suffix to add * @param props properties to over-ride the parent props */ addSuffix(suffix: Namer | string[], props?: NamerProps): Namer; /** * Create a new Namer with a unique suffix * @param uniqueItem: any value to use as the seed for generating a unique hash */ unique(uniqueItem: any): Namer; toString(): string; }