Methods
(async, inner) readCachedFile(path, getFileContent, forceUpdateopt) → {Promise}
Reads the content of a file if it exists, else gets the content using the getFileContent function and creates the file.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
path |
string | Path to the file. | ||
getFileContent |
FileContentCallback | Retrieves/generates the content for the file, which is generally slower and/or more resource consuming than reading the local file (e.g. response from a server request, heavy computation). | ||
forceUpdate |
boolean |
<optional> |
false | Forces the use of getFileContent to get the content, and creates/overwrittes the file. |
Returns:
Promise object resolving to the data.
- Type
- Promise
Type Definitions
FileContentCallback() → {string|Promise.<string>}
Gets the content for the file.
Returns:
Returns the file content. Can also return a Promise resolving to the content.
- Type
- string | Promise.<string>