custom module: add optional errorCallback argument toloadJSON and saveJSON

This commit is contained in:
jean-emmanuel 2023-04-05 22:57:42 +02:00
parent 3d36f3e4d7
commit b480889b70
3 changed files with 27 additions and 8 deletions

View file

@ -96,16 +96,24 @@ Returns the server's http addresses.
----
#### `loadJSON(path)`
#### `loadJSON(path, errorCallback)`
Loads a json file (path is relative to the custom module location)
- `path`: `string`, path to file (any extension allowed, but the content must be valid JSON)
- `errorCallback` (optional): `function`, called with the error as argument if the file can't be loaded
----
#### `saveJSON(path, object)`
#### `saveJSON(path, data, errorCallback)`
Saves an object/array to a json file (path is relative to the custom module location)
- `path`: `string`, path to file (any extension allowed)
- `data`: `object`, `array` or any value that can be encoded to JSON
- `errorCallback` (optional): `function`, called with the error as argument if the file can't be loaded
----
#### `require(path)`