Expand all

abstract ve.init.SafeStorage

ve.init.SafeStorage

Constructor

new ve.init.SafeStorage(store)abstract #

A wrapper for an HTML5 Storage interface (localStorage or sessionStorage) that is safe to call on all browsers.

Parameters:

Name Type Description
store Storage | undefined

The Storage instance to wrap around

Source:

Methods

clearExpired() → {jQuery.Promise}abstractprotected #

Clear any expired items from the store

Source:

Returns:

Resolves when items have been expired

Type
jQuery.Promise
Clear any expired items from the store

get(key) → {string|null|boolean}abstract #

Retrieve value from device storage.

Parameters:

Name Type Description
key string

Key of item to retrieve

Source:

Returns:

String value, null if no value exists, or false if storage is not available.

Type
string | null | boolean
Retrieve value from device storage.

getExpiryKeys() → {jQuery.Promise}abstractprotected #

Get all keys with expiry values

Source:

Returns:

Promise resolving with all the keys which have expiry values (unprefixed), or as many could be retrieved in the allocated time.

Type
jQuery.Promise
Get all keys with expiry values

getObject(key) → {Object|null|boolean}abstract #

Retrieve JSON object from device storage.

Parameters:

Name Type Description
key string

Key of item to retrieve

Source:

Returns:

Object, null if no value exists or value is not JSON-parseable, or false if storage is not available.

Type
Object | null | boolean
Retrieve JSON object from device storage.

isExpired(key) → {boolean}abstractprotected #

Check if a given key has expired

Parameters:

Name Type Description
key string

Key name

Source:

Returns:

Whether key is expired

Type
boolean
Check if a given key has expired

remove(key) → {boolean}abstract #

Remove a value from device storage.

Parameters:

Name Type Description
key string

Key of item to remove

Source:

Returns:

Whether the save succeeded or not

Type
boolean
Remove a value from device storage.

set(key, value, [expiry]) → {boolean}abstract #

Set a value in device storage.

Parameters:

Name Type Attributes Description
key string

Key name to store under

value string

Value to be stored

expiry number optional

Number of seconds after which this item can be deleted

Source:

Returns:

The value was set

Type
boolean
Set a value in device storage.

setExpires(key, [expiry])abstract #

Set the expiry time for an item in the store

Parameters:

Name Type Attributes Description
key string

Key name

expiry number optional

Number of seconds after which this item can be deleted, omit to clear the expiry (either making the item never expire, or to clean up when deleting a key).

Source:
Set the expiry time for an item in the store

setObject(key, value, [expiry]) → {boolean}abstract #

Set an object value in device storage by JSON encoding

Parameters:

Name Type Attributes Description
key string

Key name to store under

value Object

Object value to be stored

expiry number optional

Number of seconds after which this item can be deleted

Source:

Returns:

The value was set

Type
boolean
Set an object value in device storage by JSON encoding