npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

localstorageex

v1.3.5

Published

it use for extending the function ability of localStorage it can store json,array,number,boolean,string excepte function and convert them automatically

Downloads

5

Readme

localstorageex

A simple, fast and small lib that extend the ability of localStorage for browser. we can save or get obj directly without JSON.stringify or JSON.parse.

Install

via npm

$ npm install localstorageex --save

via yarn

$ yarn add localstorageex

Use

const localStorageEx = require("localstorageex");

// or

import localStorageEx from "localstorageex";

// Note. undefined or null values can't be saved.
// eg:
localStorageEx.set("foo", null); // will throw an error.

let a = {
  a: 1,
  b: "",
  c: [1, 2],
  d: {
    e: {
      m: [{ k: 2, d: null }],
    },
    f: null,
  },
};

localStorageEx.set("some_obj_key", a);
console.log(localStorageEx.get("some_obj_key"));
/*
print  {
	a:1,
	b:'',
	c:[1,2],
	d:{
		e:{
			m:[{k:2,d: null}]
		},
		f:null
	}
}
*/

localStorageEx.set("key0", 1);
console.log(localStorageEx.get("key0")); // print 1

localStorageEx.set("key1", 2.2);
console.log(localStorageEx.get("key1")); // print 2.2

localStorageEx.set("key2", "some value");
console.log(localStorageEx.get("key2")); // print 'some value'

localStorageEx.set("key3", false);
console.log(localStorageEx.get("key3")); // print false

localStorageEx.set("key4", true);
console.log(localStorageEx.get("key4")); // print true

localStorageEx.set("key5", []);
console.log(localStorageEx.get("key5")); // print []

localStorageEx.set("key5_1", "[]");
console.log(localStorageEx.get("key5_1")); // print []

localStorageEx.set("key6", [1, 2]);
console.log(localStorageEx.get("key6")); // print [1,2]

localStorageEx.set("key6_1", "[1,2]");
console.log(localStorageEx.get("key6_1")); // print [1,2]

localStorageEx.set("key7", {});
console.log(localStorageEx.get("key7")); // print {}

localStorageEx.set("key8", "");
console.log(localStorageEx.get("key8")); // print ''

Remove Key

// remove key.

localStorageEx.remove("some_key"); // the value for the key will be removed.
console.log(localStorageEx.get("some_key")); // print null

Use Prefix

    // by default there is no prefix for key. but you can customize it by yourself.
    // each key store in different prefix won't impact each other. we can take it as namespace.

    // eg:

    // use the default prefix. default prefix is a empty string.
    localStorageEx.set('key0, 'this is first value')


    localStorageEx.setPrefix('_my_prefix_')
    console.log(localStorageEx.get('key0')) // print null

    localStorageEx.set('key0, 1)
    localStorageEx.set('my_key0', [1,2,{c:false}])

    console.log(localStorageEx.get('key0')) // print 1
    console.log(localStorageEx.get('my_key0')) // print [1,2,{c:false}]


    localStorageEx.setPrefix('_next_prefix_')
    console.log(localStorageEx.get('key0')) // print null
    console.log(localStorageEx.get('my_key0')) // print null

    localStorageEx.set('key0', false)
    console.log(localStorageEx.get('key0')) // print false


    localStorageEx.setPrefix('_my_prefix_')
    console.log(localStorageEx.get('key0')) // print 1
    console.log(localStorageEx.get('my_key0')) // print [1,2,{c:false}]


    localStorageEx.setPrefix('')
    console.log(localStorageEx.get('key0')) // print 'this is first value'

Support

If you have any problem to use it or suggestion. please send a email to [email protected]