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:
| 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 | undefined | write 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');});