
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fixβa new CLI tool that turns CVE alerts into safe, automated upgrades.
local-sync
Advanced tools
A friendly, tiny, synchronous, namespaced, and dependency free local storage solution.
A friendly, tiny, synchronous, namespaced, and dependency free local storage solution.
npm i local-sync -S
Set or get the current bucket. Subsequent methods operate only in the current bucket namespace.
ls = new LocalSync() // default settings
ls = new LocalSync({ // custom settings
prefix: 'ocean',
bucket: 'fish',
separator: '~'
})
ls.setBucket('BikiniBottom') // => 'BikiniBottom'
ls.getBucket() // => 'BikiniBottom'
List all buckets in storage.
ls.allBuckets() // => [...buckets]
Use any JSON serializable data type.
ls.set('bob', {name: 'SpongeBob'})
ls.get('bob')
// => {name: 'SpongeBob'}
ls.set('quotes', ['Squidward!'])
ls.get('quotes')
// => ['Squidward!]
Update stored objects and arrays.
ls.put('bob', {address: '124 Conch Street'})
// => {name: 'SpongeBob', address: '124 Conch Street'}
ls.put('quotes', ['Why so crabby, Patty?'])
// => ['Squidward!', 'Why so crabby, Patty?']
List all keys in storage.
ls.keys()
// => ['bob', 'quotes']
List all values in storage.
ls.values()
// [
// {address: '124 Conch Street', name: 'SpongeBob'},
// ['Squidward!', 'Why so crabby, Patty?']
// ]
List all keys and values in storage.
ls.getAll()
// [
// {address: '124 Conch Street', name: 'SpongeBob'},
// {quotes: ['Squidward!', 'Why so crabby, Patty?']}
// ]
Remove a single value by key or clear all values.
ls.remove('bob')
ls.keys()
// => ['quotes']
Clear all keys and values.
ls.clear()
ls.keys()
// => []
String
String
Array.<String>
*
*
*
*
Array.<String>
Array.<*>
Array.<Object>
Create a new Local Sync instance. Each instance can have its own prefix, buckets, and separator.
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | {} | Instance options. |
[options.bucket] | String | default | The bucket namespace to use. |
[options.prefix] | String | ls | The key prefix namespace to use. |
[options.separator] | String | . | Separates prefix, bucket, and keys. |
String
Set the current bucket
. Methods will only operate on keys in this namespace.
Kind: instance method of LocalSync
Returns: String
- The bucket name just set.
Param | Type | Description |
---|---|---|
bucket | String | The bucket name. |
String
Get the current bucket
.
Kind: instance method of LocalSync
Returns: String
- The current bucket name.
Array.<String>
Get all buckets currently in storage.
Kind: instance method of LocalSync
Returns: Array.<String>
- An array of bucket strings.
*
Get a value from the current bucket.
Kind: instance method of LocalSync
Returns: *
- The stored value at the specified key
.
Param | Type | Description |
---|---|---|
key | String | The name of the key you want to retrieve the value of. |
*
Set a value in the current bucket.
Kind: instance method of LocalSync
Returns: *
- The value that was just set.
Param | Type | Description |
---|---|---|
key | String | The name of the key you want to create/overwrite. |
value | * | The value for this key. |
*
Update a value in the current bucket.
Kind: instance method of LocalSync
Returns: *
- The updated value.
Param | Type | Description |
---|---|---|
key | String | The key under which the value to be updated is stored. |
value | * | Value to assign to the stored object. |
*
Remove a value from the current bucket.
Kind: instance method of LocalSync
Returns: *
- The object just removed.
Param | Type | Description |
---|---|---|
key | String | The key under which the value to be deleted is stored. |
Clears all values from the current bucket.
Kind: instance method of LocalSync
Array.<String>
Get all key
s in the current bucket.
Kind: instance method of LocalSync
Returns: Array.<String>
- An array of key
strings.
Array.<*>
Get all value
s in the current bucket.
Kind: instance method of LocalSync
Returns: Array.<*>
- An array of values.
Array.<Object>
Get all key/value pairs in the current bucket.
Kind: instance method of LocalSync
Returns: Array.<Object>
- An array of objects {<key>: <value>}
.
Β© 2015 TechnologyAdvice. API Docs by jsdoc-to-markdown.
FAQs
A friendly, tiny, synchronous, namespaced, and dependency free local storage solution.
The npm package local-sync receives a total of 37 weekly downloads. As such, local-sync popularity was classified as not popular.
We found that local-sync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Β It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fixβa new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
Weβre excited to announce a powerful new capability in Socket: historical data and enhanced analytics.