UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions and classes for everyday development needs.

40 lines 1.86 kB
import type { CapitalizeOptions, RandomIdOptions } from './types'; /** * * Utility to convert the first letter of any string to uppercase and the rest lowercase (unless specified). * * Handles surrounding symbols like quotes or parentheses. * * @param string String to be capitalized. * @param options Options to customize the capitalization. * @returns Capitalized string or fully uppercased string depending on `capitalizeAll` option. */ export declare function capitalizeString(string: string, options?: CapitalizeOptions): string; /** * * Utility to truncate a string to a specified length. * * @param string The string to truncate. * @param maxLength The maximum length of the truncated string. * @returns Truncated string with ellipsis (`...`) (only if it has more length than `maxLength`). */ export declare const truncateString: (string: string, maxLength: number) => string; /** * * Generates a random alphanumeric (16 characters long, this length is customizable in the options) ID string composed of an optional `prefix`, `suffix`, a `timestamp`, `caseOption` and a customizable `separator`. * * @param options Configuration options for random ID generation. * @returns The generated ID string composed of the random alphanumeric string of specified length with optional `timeStamp`, `prefix`, and `suffix`, `caseOption` and `separator`. */ export declare const generateRandomID: (options?: RandomIdOptions) => string; /** * * Trims all the words in a string. * * @param input The string to trim. * @returns Trimmed string. */ export declare function trimString(input: string): string; /** * * Trims all the words in an array of strings. * * @param input The array of strings to trim. * @returns Trimmed array of strings. */ export declare function trimString(input: string[]): string[]; //# sourceMappingURL=basics.d.ts.map