Vault.process() method
Atomically read, modify, and save the contents of a note.
Signature:
process(file: TFile, fn: (data: string) => string, options?: DataWriteOptions): Promise<string>;
Parameters
Parameter | Type | Description |
---|---|---|
file | TFile | the file to be read and modified. |
fn | (data: string) โ string | a callback function which returns the new content of the note synchronously. |
options | DataWriteOptions | (Optional) write options. |
Returns:
Promise<string>
string - the text value of the note that was written.
Example
app.vault.process(file, (data) => {
return data.replace('Hello', 'World');
});