UNPKG

@technobuddha/library

Version:
25 lines (24 loc) 880 B
/** * Options for the {@link toFilename} function * @group String * @category Operations */ export type FilenameOptions = { /** the file name will be truncated to this length */ maxLength?: number; /** character to use to replace "bad" characters */ replacement?: string; /** number of characters to preserve at the end of the filename when truncated (for disambiguation) */ disambiguate?: number; /** string to separate the main section from the disambiguated section */ separator?: string; }; /** * Convert a string so that it can be used as a filename * @param input - The string to escape * @param options - see {@link FilenameOptions} * @returns the file name * @group String * @category Operations */ export declare function toFilename(input: string, { maxLength, replacement, disambiguate, separator }?: FilenameOptions): string;