LocalStorage

new LocalStorage(fileName: string)

Creates a persistent storage file and handles interacting with the persistent storage
Parameters:
Name Type Description
fileName
string
The name of the persistent storage file. Will be json format

Properties

.keys: Array<string>

The names of all keys in this storage
Type:
Array<string>

.length: number

The number of keys in this storage
Type:
number

Methods

.clear()

Delete all items from this storage

.deincr(key: string)

Deincrement a stored integer value
Parameters:
Name Type Description
key
string
The key of the item to increment

.exists(key: string) → boolean

Check if key/value pair exists in this storage
Parameters:
Name Type Description
key
string
The key of the item to check for
Returns:
boolean

.getItem(key: string) → *

Get the value of the given key in this storage
Parameters:
Name Type Description
key
string
The key of the item to get
Returns:
*

.incr(key: string)

Increment a stored integer value
Parameters:
Name Type Description
key
string
The key of the item to increment

.key(index: number) → string

Get the name of the key at the given index in this storage
Parameters:
Name Type Description
index
number
The index of the key to find
Returns:
string

.queue(key: string, callback: function) → Promise

Allow access to a storage item only when it is not currently being accessed. Waits for other queued operations to finish before proceeding with the provided callback
Parameters:
Name Type Description
key
string
the storage key you will be accessing
callback
function
callback to execute that will be accessing the key
Returns:
Promise

.removeItem(key: string)

Delete an item in this storage
Parameters:
Name Type Description
key
string
The key of the item to delete

.setItem(key: string, value: *)

Set the value of a given key in this storage
Parameters:
Name Type Description
key
string
The key of the item to set
value
*
The value to set