ScriptCraft icon indicating copy to clipboard operation
ScriptCraft copied to clipboard

Document the `persist()` function with examples.

Open walterhiggins opened this issue 6 years ago • 1 comments

walterhiggins avatar Oct 12 '17 17:10 walterhiggins

https://github.com/walterhiggins/ScriptCraft/blob/development/src/main/js/lib/persistence.js#L18

Example usage

// read data
var data = persist('nanocode')
// write data
data.new = 'Some more data'
persist('nanocode', data, true)

The third parameter of persist(): If it is true, it is a write. If it is not there, or is false, it is a read.

Function signature

/* Load data from persistence */
declare function persist(key: string): object

declare function persist(key: string, data: object): object

/* Write data to persistence */
declare function persist(key: string, data: object, write: true): object

jwulf avatar Jan 28 '20 03:01 jwulf