import type { ListLike, Prettify, Stringifiable } from "./types.ts"; /** * Automatically pluralizes the given string an `-s` or `-ies` to the passed {@linkcode term}, if {@linkcode num} is not equal to 1. * By default, words ending in `-y` will have it replaced with `-ies`, and all other words will simply have `-s` appended. * If {@linkcode num} resolves to NaN or the {@linkcode pluralType} is wrong, it defaults to the {@linkcode pluralType} `auto` and sets {@linkcode num} to 2. * @param term The term, written in singular form, to auto-convert to plural form * @param num A number, or list-like value that has either a `length`, `count` or `size` property, like an array, Map or discord.js Collection - does not support iterables, they need to be converted to an array first * @param pluralType Which plural form to use when auto-pluralizing. Defaults to `"auto"`, which removes the last char and uses `-ies` for words ending in `y` and simply appends `-s` for all other words */ export declare function autoPlural(term: Stringifiable, num: number | ListLike, pluralType?: "auto" | "-s" | "-ies"): string; /** Capitalizes the first letter of a string */ export declare function capitalize(text: string): string; /** The default progress bar characters used by {@linkcode createProgressBar()} */ export declare const defaultPbChars: { readonly 100: "█"; readonly 75: "▓"; readonly 50: "▒"; readonly 25: "░"; readonly 0: "─"; }; /** Progress bar characters used by {@linkcode createProgressBar()} */ export type ProgressBarChars = Prettify>; /** * Generates a progress bar with the given percentage and max length. * Uses opaque, dithered unicode block characters by default for extra detail. * Use {@linkcode chars} to override the default characters (for example, use emojis via `<:emoji:ID>` or `😃`) */ export declare function createProgressBar(percentage: number, barLength: number, chars?: ProgressBarChars): string; /** * Inserts the passed values into a string at the respective placeholders. * The placeholder format is `%n`, where `n` is the 1-indexed argument number. * @param input The string to insert the values into * @param values The values to insert, in order, starting at `%1` */ export declare function insertValues(input: string, ...values: Stringifiable[]): string; /** Joins an array of strings with a separator and a last separator - defaults to `,` & `and` */ export declare function joinArrayReadable(array: unknown[], separators?: string, lastSeparator?: string): string; /** Converts seconds into the timestamp format `(hh:)mm:ss`, with intelligent zero-padding */ export declare function secsToTimeStr(seconds: number): string; /** Truncates a string if it exceeds `length` and inserts `endStr` at the end (empty string to disable), so that the final string doesn't exceed the given length */ export declare function truncStr(input: Stringifiable, length: number, endStr?: string): string; /** * Border styles for the `lineStyle` option of the {@linkcode createTable} function. * * | Style | Example | * | :-- | :-- | * | `single` | `┌──────┬──────┐` | * | `double` | `╔══════╦══════╗` | * | `none` | | */ export type TableLineStyle = "single" | "double" | "none"; /** * How to align cell content in a column for the `columnAlign` option of the {@linkcode createTable} function. * * | Alignment | Example | Description | * | :-- | :-- | :-- | * | `left` | `│.Text....│` | Hugs the left border, with padding determined by `minPadding`. | * | `centerLeft` | `│..Text...│` | In the center, but if the padding is uneven, favors the left side. | * | `centerRight` | `│...Text..│` | In the center, but if the padding is uneven, favors the right side. | * | `right` | `│....Text.│` | Hugs the right border, with padding determined by `minPadding`. | */ export type TableColumnAlign = "left" | "centerLeft" | "centerRight" | "right"; /** Options for the {@linkcode createTable} function. */ export type TableOptions = { /** Alignment for each column, either a single value to apply to all columns or an array of values for each column. Defaults to `left`. */ columnAlign?: TableColumnAlign | TableColumnAlign[]; /** If set, cell content that exceeds this width will be truncated with the value of `truncEndStr` (defaults to `…`) so that the final cell content doesn't exceed this width. */ truncateAbove?: number; /** The string to append to truncated cell content if `truncateAbove` is set. Defaults to `…`. */ truncEndStr?: string; /** Minimum padding to add to the left and right of cell content, regardless of alignment settings. Defaults to 1, set to 0 to disable. */ minPadding?: number; /** Which kind of line characters to use for the border of the table. Defaults to `single` (`┌──────┬──────┐`). */ lineStyle?: TableLineStyle; /** Can be used to change the characters used for the lines dividing cells in the table. If not set, {@linkcode defaultTableLineCharset} will be used. */ lineCharset?: TableLineCharset; /** * Can be used to add custom values like ANSI color codes to the lines dividing cells. * Function gets passed the row index (i) and column index (j) of the character being rendered. * Note that each row renders three rows of characters, so the row index (i) is not the same as the index of the row in the input array, but can be used to determine it with `Math.floor(i / 3)`. * The first value of the returned tuple will be added before the line character and the second value will be added after. * Return an empty array to not apply any custom styling. */ applyLineStyle?: (i: number, j: number) => [before?: string, after?: string] | void; /** * Can be used to add custom values like ANSI color codes to the cell content. * Function gets passed the row index (i) and column index (j) of the cell being rendered. * Note: cell width is calculated before applying this style, so characters with non-zero width will mess up the alignment and border placement. * The first value of the returned tuple will be added before the cell content and the second value will be added after. * Return an empty array to not apply any custom styling. */ applyCellStyle?: (i: number, j: number) => [before?: string, after?: string] | void; }; /** Characters to use for the lines dividing cells in the table generated by {@linkcode createTable}, based on the `lineStyle` option. */ export type TableLineStyleChars = Record<"horizontal" | "vertical" | `${"top" | "bottom"}${"Left" | "Right"}` | `${"left" | "right" | "top" | "bottom"}T` | "cross", string>; /** The characters to use for the lines dividing cells in the table generated by {@linkcode createTable}, based on the `lineStyle` option. */ export type TableLineCharset = Record; /** The default characters to use for the lines dividing cells in the table generated by {@linkcode createTable}, based on the `lineStyle` option. */ export declare const defaultTableLineCharset: TableLineCharset; /** * Creates an ASCII table string from the given rows and options. * Supports ANSI color codes in cell content: they are ignored for width calculation, included in the final output, and handled correctly during truncation (escape sequences are never split; any open color code is closed with a reset). * @param rows Array of tuples, where each tuple represents a row and its values. The first tuple is used to determine the column count. * @param options Object with options for customizing the table output, such as column alignment, truncation, padding and line styles. */ export declare function createTable(rows: TRow[], options?: TableOptions): string;