/** * @module util/vfile */ /// import vfile, { VFileContents } from 'vfile'; /** * The virtual file type */ export type VFile = vfile.VFile; /** * Create a virtual file * * @param contents Raw string contents of `VFile`, or file path * @param options Options to `vfile` see https://github.com/vfile/vfile#vfileoptions */ export declare function create(contents?: string, options?: vfile.VFileOptions): VFile; /** * Load a string into a virtual file * * @param contents Contents to load */ export declare function load(contents: VFileContents, options?: vfile.VFileOptions): VFile; /** * Dump a string from the contents of a virtual files * * If the file has no `contents` but does have a file * `path`, then `read` the virtual file. * * @param file The virtual file to dump */ export declare function dump(vfile: VFile, mode?: 'string'): Promise; export declare function dump(vfile: VFile, mode?: 'buffer'): Promise; /** * Read a file path into a virtual file * * @param path The content, or file system path to read from. If `-`, read from stdin. */ export declare function read(content: string): Promise; /** * Write a virtual file to the file system or standard output. * * Will never write an empty file i.e. will only write if the * `vfile` has `contents`. * * @param vfile Virtual file to write * @param filePath The file system path to write to, or `-` to write to stdout. */ export declare function write(vfile: VFile, filePath: string): Promise; /** * Is a string a file system path? * * Several functions in this module allow for content to be passed as a * string of raw content (e.g. `This is some Markdown`) or as a file system * path. This function, assesses whether a file is a file system path or not. * * If the string starts with `/`, `./`, `../` (or Windows compatible backslash * equivalents as well as drive letter prefixed strings e.g. `C:\`), * or has a 1-5 character extension, * then it is assumed to be a path but the presence of the path is not checked. * The reason for not checking presence * here is because "if the content looks like a path then the user probably meant * it to be a path". That is, if a user tries to convert the string "./file.md" then, * if that file doesn't exist, they probably want the Markdown converter to give me an error * message. They probably don't want the `match` function to try and find some other converter * that acts on a plain strings. * * For all other strings, this function does check for presence, returning `true` * if the file exists. * * @param content The string to assess. */ export declare function isPath(content: string): boolean;