Manage items in localStorage
- Source:
Methods
-
<static> clearLastError() → {Promise.<void>}
-
Set the LastError to an empty message in chrome.storage.local
- Source:
Returns:
void
- Type
- Promise.<void>
-
<static> get(key [, def]) → {Object}
-
Get a JSON parsed value from localStorage
Parameters:
Name Type Argument Default Description key
string key to get value for
def
Object <optional>
<nullable>
null return value if key not found
- Source:
Returns:
JSON object, null if key does not exist
- Type
- Object
-
<static> getBool(key [, def]) → {boolean}
-
Get boolean value from localStorage
Parameters:
Name Type Argument Default Description key
string key to get value for
def
boolean <optional>
<nullable>
null return value if key not found
- Source:
Returns:
value as boolean, null if key does not exist
- Type
- boolean
-
<static> getInt(key [, def]) → {int}
-
Get integer value from localStorage
Parameters:
Name Type Argument Default Description key
string key to get value for
def
int <optional>
<nullable>
null optional value to return, if NaN
- Source:
Returns:
value as integer, NaN on error
- Type
- int
-
<static> getLastError() → {Promise.<Chrome.Msg.LastError>}
-
Get the LastError from chrome.storage.local
- Source:
Returns:
last error
- Type
- Promise.<Chrome.Msg.LastError>
-
<static> LastError( [message] [, title])
-
An error that can be persisted Usage: const err = new LastError(message, title)
Parameters:
Name Type Argument Default Description message
string <optional>
<nullable>
'' the message
title
string <optional>
<nullable>
'An error occurred' the title
- Source:
Properties:
Name Type Description name
string Error name
stack
string stack trace
-
<static> safeSet(key, value [, keyBool]) → {boolean}
-
Save a value to localStorage only if there is enough room
Parameters:
Name Type Argument Description key
string localStorage Key
value
Object value to save
keyBool
string <optional>
key to a boolean value that is true if the primary key has non-empty value
- Source:
Returns:
true if value was set successfully
- Type
- boolean
-
<static> set(key [, value])
-
JSON stringify and save a value to localStorage
Parameters:
Name Type Argument Default Description key
string key to set value for
value
Object <optional>
<nullable>
null new value, if null remove item
- Source:
-
<static> setLastError(error) → {Promise.<void>}
-
Save the LastError to chrome.storage.local
Parameters:
Name Type Description error
Chrome.Storage.LastError the LastError
Returns:
void
- Type
- Promise.<void>