Socket
Socket
Sign inDemoInstall

local-json-storage

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    local-json-storage

localJSONStorage is extended localStorage for support JSON.


Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Install size
2.22 kB
Created
Weekly downloads
 

Readme

Source

Local JSON Storage

Extended LocalStorage for support JSON data into LocalStorage.

Without this,

You should stringify/parse JavaScript object everytime:

var people = { name: '.modernator', age: 25 };
localStorage.set('people', JSON.stringify(people));

console.log(JSON.parse(localStorage.get('people')));

With this,

Only you need is use extended two new methods: getJSON and setJSON

import localStorage from './local-json-storage';

var people = { name: '.modernator', age: 25 };
localStorage.setJSON('people', people);

console.log(localStorage.getJSON('people'));

Usage

This module requires Web bundler like Browserify or Webpack. After you import this module, you can use it directly.

###void localJSONStorage.setJSON(string key, object obj) Insert obj to localStorage.

###Object localJSONStorage.getJSON(string key) Get object from localStorage.

Cautions

  • You can use native local storage method with this module too, because the module is just adding additional methods when it is imported. Also after you include it, even if it does not have reference variable, you can use with original localStorage with these new methods, But I don't recommend it.
  • Of course, this module is client side only.
  • It uses ES6 syntax, so you must transpile this module with transpiler like Babel.

Keywords

FAQs

Last updated on 10 Sep 2016

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