import { CutoffFormat, CutoffFormatOptions, PostpendedCutoffParts, PrependedCutoffParts, ResolvedCutoffFormatOptions } from './types'; export declare class CutoffFormatConstructor implements CutoffFormat { private locale; private options; private additionLength; /** * Constructor * @param {Intl.LocalesArgument} locales - The locales to use for formatting. * @param {CutoffFormatOptions} options - The options for formatting. * @param {number} [options.maxChars] - The maximum number of characters to display. * - Undefined values are treated as no cutoff. * - Negative values follow .slice() behavior and terminator will be added before the value. * - 0 will result in an empty string. * - If cutoff results in an empty string, no terminator is added. * @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator. * @param {string} [options.terminator] - Optional override the terminator to use. * @param {string} [options.separator] - Optional override the separator to use between the terminator and the value. * - If no terminator is provided, then separator is ignored. * * @example * const format = new CutoffFormat('en', { maxChars: 5 }); * format.format('Hello, world!'); // 'Hello...' * * const format = new CutoffFormat('en', { maxChars: -3 }); * format.format('Hello, world!'); // '...ld!' */ constructor(locales: Intl.LocalesArgument, options?: CutoffFormatOptions); /** * Format a value according to the cutoff options, returning a formatted string. * * @param {string} value - The string value to format with cutoff behavior. * @returns {string} The formatted string with terminator applied if cutoff occurs. * * @example * const formatter = new CutoffFormatConstructor('en', { maxChars: 8, style: 'ellipsis' }); * formatter.format('Hello, world!'); // Returns 'Hello, w...' */ format(value: string): string; /** * Format a value to parts according to the cutoff options, returning an array of string parts. * This method breaks down the formatted result into individual components for more granular control. * * @param {string} value - The string value to format with cutoff behavior. * @returns {PrependedCutoffParts | PostpendedCutoffParts} An array of string parts representing the formatted result. * - For positive maxChars: [cutoffValue, separator?, terminator?] * - For negative maxChars: [terminator?, separator?, cutoffValue] * - For no cutoff: [originalValue] * * @example * const formatter = new CutoffFormatConstructor('en', { maxChars: 5, style: 'ellipsis' }); * formatter.formatToParts('Hello, world!'); // Returns ['Hello', '...'] */ formatToParts(value: string): PrependedCutoffParts | PostpendedCutoffParts; /** * Get the resolved options * @returns {ResolvedCutoffFormatOptions} The resolved options. */ resolvedOptions(): ResolvedCutoffFormatOptions; }