stbStorage

stbStorage

Tutorials:
See:

stbStorage provides API to access global key-value storage.

Members

(static, readonly) length :number

Get the total number of keys.

Type:
  • number

Methods

(static) clear()

Remove all the keys and data.

(static) key(index) → (nullable) {string}

Get the key name by its index.
If there is no key associated with the index then return null.

Example
// get key name by its position in the storage hash
var keyName = stbStorage.key(3);
Parameters:
Name Type Description
index number

key position

Returns:

key name or null if the key does not exist

Type
string

(static) getItem(keyName) → (nullable) {string}

Get key's value using key name.

See stbStorage.setItem.

Example
// receive key value
var data = stbStorage.getItem('someName');
Parameters:
Name Type Description
keyName string

unique key name

Returns:

key value or null if the key does not exist

Type
string

(static) setItem(keyName, keyValue)

Set key value for key keyName.
Old key value will be replaced with the new one.
If there was no value associated with the key then new one will be stored.

See stbStorage.getItem.

Example
// create or update key
stbStorage.setItem('someName', 128);
Parameters:
Name Type Description
keyName string

unique key name

keyValue string | number

new key value

(static) removeItem(keyName)

Remove the given key.

Example
// delete key
stbStorage.removeItem('someName');
Parameters:
Name Type Description
keyName string

unique key name