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

    browser-config

localStorage wrapper for convenient access.


Version published
Weekly downloads
19
increased by5.56%
Maintainers
1
Install size
10.2 MB
Created
Weekly downloads
 

Readme

Source

Browser config

localStorage wrapper for convenient access.

Installation

yarn add browser-config
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


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

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
}

FAQs

Last updated on 23 Feb 2021

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.

Install

Related posts

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