ScriptCraft

ScriptCraft

14.6k Downloads

Document the `persist()` function with examples.

walterhiggins opened this issue ยท 1 comments

commented
commented

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