Local Sync
A friendly, tiny, and cross-browser local storage solution:
✓ No dependencies
✓ Synchronous
✓ Namespaced storage support
✓ In-memory fallback
Install
yarn add local-sync
CDN
Common JS
https://unpkg.com/local-sync@x.x.x/dist/cjs/local-sync.js
https://unpkg.com/local-sync@x.x.x/dist/cjs/local-sync.min.js
ES Module
https://unpkg.com/local-sync@x.x.x/dist/esm/local-sync.js
https://unpkg.com/local-sync@x.x.x/dist/esm/local-sync.min.js
UMD
https://unpkg.com/local-sync@x.x.x/dist/umd/local-sync.js
https://unpkg.com/local-sync@x.x.x/dist/umd/local-sync.min.js
API
See API Documentation.
Usage
Buckets
Set or get the current bucket. Subsequent methods operate only in the current bucket namespace.
ls = // default settingsls = // custom settings prefix: 'ocean' bucket: 'fish' separator: '~' ls // => 'BikiniBottom'ls // => 'BikiniBottom'
List all buckets in storage.
ls // => [...buckets]
set, get, put
Use any JSON serializable data type.
lsls// => {name: 'SpongeBob'} lsls// => ['Squidward!]
Update stored objects and arrays.
ls// => {name: 'SpongeBob', address: '124 Conch Street'} ls// => ['Squidward!', 'Why so crabby, Patty?']
keys, values, getAll
List all keys in storage.
ls// => ['bob', 'quotes']
List all values in storage.
ls// [// {address: '124 Conch Street', name: 'SpongeBob'},// ['Squidward!', 'Why so crabby, Patty?']// ]
List all keys and values in storage.
ls// [// {address: '124 Conch Street', name: 'SpongeBob'},// {quotes: ['Squidward!', 'Why so crabby, Patty?']}// ]
remove, clear
Remove a single value by key or clear all values.
lsls// => ['quotes']
Clear all keys and values.
lsclearls// => []