Skip to content

DataAdapter.process method

DataAdapter › process

Official

Atomically read, modify, and save the contents of a plaintext file.

Signature:

process(normalizedPath: string, fn: (data: string) => string, options?: DataWriteOptions | undefined): Promise<string>

Parameters:

ParameterTypeDescription
normalizedPathstringpath to file/folder, use {@link normalizePath} to normalize beforehand.
fn(data: string) => stringa callback function which returns the new content of the file synchronously.
options?DataWriteOptions | undefinedwrite options.

Returns: Promise<string> — The new content of the file.

Example:

await adapter.process('foo/bar.md', (data) => {
return data.replace('foo', 'bar');
});