UNPKG

@visulima/fs

Version:

Human friendly file system utilities for Node.js

32 lines (31 loc) 1.17 kB
/** * Supported filesystem types */ export type FileSystemType = "win32" | "unix" | "darwin" | "fat32" | "auto"; /** * Options for the sanitize function */ export interface SanitizeOptions { /** * Target filesystem type for sanitization rules * - "win32": Windows filesystem rules (reserved names, Windows forbidden chars, no trailing periods/spaces) * - "unix": Unix/Linux filesystem rules (only / and null forbidden) * - "darwin": macOS filesystem rules (same as unix) * - "fat32": FAT32 filesystem rules (Windows rules + no leading/trailing spaces/periods in name part) * - "auto": Automatically detect from process.platform * @default "auto" */ filesystem?: FileSystemType; /** * Maximum length of the sanitized name * @default 128 */ maxLength?: number; } /** * Sanitizes a filename by removing or replacing forbidden characters. * @param name The filename to sanitize. * @param options Optional configuration. * @returns The sanitized filename, or "unnamed" if the result would be empty. */ export declare const sanitize: (name: string, options?: Partial<SanitizeOptions>) => string;