Namespace: stbStorage

stbStorage

Global key-value storage.

See:

Members

length

<static, readonly> length :number

Get the total number of keys.

Type:
  • number

Since:
  • 0.2.18

Methods

clear

<static> clear ()

Remove all the keys and data.

Since:
  • 0.2.18

getItem

<static> getItem ( keyName ) → {string}

Get key's value using key name.

See stbStorage.setItem.

Parameters:
Name Type Description

keyName

string

unique key name

Since:
  • 0.2.18
Returns:
Type Argument Description

string

<nullable>

key value or null if the key does not exist

Example

// receive key value
var data = stbStorage.getItem('someName');

key

<static> key ( index ) → {string}

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

Parameters:
Name Type Description

index

number

key position

Since:
  • 0.2.18
Returns:
Type Argument Description

string

<nullable>

key name or null if the key does not exist

Example

// get key name by its position in the storage hash
var keyName = stbStorage.key(3);

removeItem

<static> removeItem ( keyName )

Remove the given key.

Parameters:
Name Type Description

keyName

string

unique key name

Since:
  • 0.2.18

Example

// delete key
stbStorage.removeItem('someName');

setItem

<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.

Parameters:
Name Type Description

keyName

string

unique key name

keyValue

string | number

new key value

Since:
  • 0.2.18

Example

// create or update key
stbStorage.setItem('someName', 128);