@technobuddha/library
Version:
A large library of useful functions
24 lines (23 loc) • 885 B
TypeScript
export declare type Options = {
/** the file name will be truncated to this length */
maxLength?: number;
/** character to use to replace "bad" characters */
replacement?: string;
/** number of characters to presere 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 __namedParameters see {@link Options}
* @default maxLength 64
* @default replacement - (dash)
* @default disambiguate 10
* @default separator … (ellipsis)
* @returns the file name
*/
export declare function toFilename(input: string, { maxLength, replacement, disambiguate, separator }?: Options): string;
export default toFilename;