Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@electrovir/local-storage-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@electrovir/local-storage-client
An interface for storing values into the LocalStorage API with type safety. Note that only JSON compatible data can be stored.
Note that some browsers aggressively clear LocalStorage so this should only be used for ephemeral data storage. If you need more permanent storage, use local-db-client instead.
Reference docs: https://electrovir.github.io/local-storage-client
Instal
npm i @electrovir/local-storage-clientUsage
import {defineShape} from 'object-shape-tester';
import {LocalStorageClient} from '@electrovir/local-storage-client';
const myClient = new LocalStorageClient({
stringValue: defineShape(''),
numberValue: defineShape(-1),
booleanValue: defineShape(false),
objectValue: defineShape({
name: '',
age: 0,
location: '',
}),
});
/** Set values with type safety. */
myClient.set.objectValue({
age: 10,
location: 'Earth',
name: 'Example User',
});
myClient.set.booleanValue(true);
/** Delete a stored value. */
myClient.delete.booleanValue();
/** Get a stored value. If the stored value is not valid, `undefined` is returned. */
myClient.get.objectValue();