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 to be read and modified.
fn(data: string) => stringa callback function which returns the new content of the note synchronously.
options?DataWriteOptions | undefinedwrite options.

Returns: Promise<string>string - the text value of the note that was written.

Since: 1.1.0

Example:

app.vault.process(file, (data) => {
return data.replace('Hello', 'World');
});