Class TJSWebStorage
Implements
Hierarchy
Index
Constructors
Methods
Constructors
constructor
Parameters
- storageStores: StorageStores
Provides a complete set of storage API store helper functions and the associated storage API instance and serializations strategy.
Returns TJSWebStorage
- storageStores: StorageStores
Methods
entries
Type Parameters
- T
Returns an iterable for the session storage keys and stores.
Parameters
Optionalregex: RegExpOptional regular expression to filter by storage keys.
Returns IterableIterator<[string, Writable<T>]>
Iterable iterator of keys and stores.
- T
getItem
Get value from the storage API.
Parameters
- key: string
Key to lookup in storage API.
OptionaldefaultValue: anyA default value to return if key not present in session storage.
Returns any
Value from session storage or if not defined any default value provided.
- key: string
getStore
Returns the backing Svelte store for the given key; potentially sets a default value if the key is not already set.
Type Parameters
- T
Parameters
- key: string
Key to lookup in storage API.
OptionaldefaultValue: TA default value to return if key not present in session storage.
OptionalstorageStores: StorageStoresAdditional store creation options.
Returns Writable<T>
The Svelte store for this key.
hasStore
Returns whether a store has already been created for the given key.
Parameters
- key: string
Key to lookup in storage API.
Returns boolean
- key: string
keys
Returns an iterable for the session storage keys from existing stores.
Parameters
Optionalregex: RegExpOptional regular expression to filter by storage keys.
Returns IterableIterator<string>
Iterable iterator of session storage keys.
setItem
Sets the value for the given key in storage API.
Parameters
- key: string
Key to lookup in storage API.
- value: any
A value to set for this key.
Returns void
- key: string
stores
Type Parameters
- T
Returns an iterable for the session storage stores.
Parameters
Optionalregex: RegExpOptional regular expression to filter by storage keys.
Returns IterableIterator<Writable<T>>
Iterable iterator of stores.
- T
swapItemBoolean
Convenience method to swap a boolean value stored in storage API updating the associated store value.
Parameters
- key: string
Key to lookup in storage API.
OptionaldefaultValue: booleanA default value to return if key not present in session storage.
Returns boolean
The boolean swap for the given key.
- key: string
Provides the base Storage API store manager. It is recommended to use TJSLocalStorage & TJSSessionStorage for standard browser local and session storage use cases. TJSWebStorage exists to provide additional customization options for custom Storage API compatible storage instances and custom serialization configuration.