new LocalStorage(fileName: string)
Creates a persistent storage file and handles interacting with the persistent
storage
Parameters:
Name | Type | Description |
---|---|---|
fileName |
|
The name of the persistent storage file. Will be json format |
Properties
.keys: Array<string>
The names of all keys in this storage
Type:
.length: number
The number of keys in this storage
Type:
Methods
.clear()
Delete all items from this storage
.deincr(key: string)
Deincrement a stored integer value
Parameters:
Name | Type | Description |
---|---|---|
key |
|
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 |
|
The key of the item to check for |
.getItem(key: string) → *
Get the value of the given key in this storage
Parameters:
Name | Type | Description |
---|---|---|
key |
|
The key of the item to get |
.incr(key: string)
Increment a stored integer value
Parameters:
Name | Type | Description |
---|---|---|
key |
|
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 |
|
The index of the key to find |
.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 |
|
the storage key you will be accessing |
callback |
|
callback to execute that will be accessing the key |
.removeItem(key: string)
Delete an item in this storage
Parameters:
Name | Type | Description |
---|---|---|
key |
|
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 |
|
The key of the item to set |
value |
|
The value to set |