Socket
Socket
Sign inDemoInstall

browser-config

Package Overview
Dependencies
55
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

2

package.json
{
"name": "browser-config",
"version": "0.1.0",
"version": "0.1.1",
"main": "build/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -0,10 +1,75 @@

# Browser config
localStorage wrapper for convenient access.
## Installation
yarn add browser-config
```js
import BrowserConfig from "browser-config";
const config = new BrowserConfig();
// setting value
config.name = "Hello"
// getting value
config.name // "hello"
// deleting
delete config.name //
// using getters and settings
config.set('name', 'Hello');
config.get('name') // Hello
config.delete('name')
config.get('name') // undefined
config.name // undefined
// can support any serializable data
config.users = [{ name: 'Hello' }]
config.users // [{ name: 'Hello' }]
// mutation is not supported
config.users.push({name: 'New User'}); // x will not work
// adding new value to array
config.users = [ ...config.users, {name: 'New User'} ]
```
Multiple instances
```js
const config1 = new BrowserConfig('abcd'); // id
const config2 = new BrowserConfig('dcba'); // id
config1.name = 'Something'
config2.name = 'Something else'
config1.name // Something
config2.name // Something else
```
## Allow iterate
```js
const config = new BrowserConfig('default', true) // iterable
config.name = 'Something'
config.email = 'johndoe@example.com'
for (const [ key, value ] of config) {
console.log({ key, value }) // { key: 'email', value: 'Something' } and on
}
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc