Skip to content

Vault.process method

Vault › process

Official

Atomically read, modify, and save the contents of a note.

Signature:

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

Parameters:

ParameterTypeDescription
fileTFileThe file.
fn(data: string) => stringA callback function which returns the new content of the note synchronously.
options?DataWriteOptions | undefinedWrite options.

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

Since: 1.1.0

Example:

await vault.process(file, (data) => {
return data.replace('foo', 'bar');
});