Class TJSWebStorage
Implements
Hierarchy
Index
Constructors
Methods
Constructors
constructor
- new TJSWeb
Storage (storageStores): TJSWebStorage 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
- entries<T>(regex?): IterableIterator<[string, Writable<T>], any, any>
Type Parameters
Parameters
Optional
regex: RegExpOptional regular expression to filter by storage keys.
Returns IterableIterator<[string, Writable<T>], any, any>
Iterable iterator of keys and stores.
getItem
getStore
- get
Store <T>(key, defaultValue?, storageStores?): Writable<T> Returns the backing Svelte store for the given key; potentially sets a default value if the key is not already set.
Type Parameters
Parameters
- key: string
Key to lookup in storage API.
Optional
defaultValue: TA default value to return if key not present in session storage.
Optional
storageStores: StorageStoresAdditional store creation options.
Returns Writable<T>
The Svelte store for this key.
- key: string
hasStore
keys
- keys(regex?): IterableIterator<string, any, any>
Returns an iterable for the session storage keys from existing stores.
Parameters
Optional
regex: RegExpOptional regular expression to filter by storage keys.
Returns IterableIterator<string, any, any>
Iterable iterator of session storage keys.
setItem
stores
- stores<T>(regex?): IterableIterator<Writable<T>, any, any>
Type Parameters
Parameters
Optional
regex: RegExpOptional regular expression to filter by storage keys.
Returns IterableIterator<Writable<T>, any, any>
Iterable iterator of stores.
swapItemBoolean
- swap
Item (key, defaultValue?): booleanBoolean 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.
Optional
defaultValue: 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.