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

vue2-localstorage

v1.2.1

Published

simplify the localstorage operation

Downloads

4

Readme

vue-storage

Describe

This plugin simplify the localStorage operation.

data type

All JS type

How to use

$ npm install vue2-localstorage
$ yarn add vue2-localstorage

Create Instance

import Vue from 'vue';
import VueStorage from 'vue2-localstorage';

Vue.use(VueStorage);

const storage = new VueStorage({
  DB_NAME : 'test-example',
  DE_KEY  : 'id', // array item's default key
  VERSION : 'v1',
  storage : [
    {
      store   : 'account-list', 
      autoKey : true, // auto provided primary key for every item
      type    : Array, // store target's type
      key     : 'id', // like every item's primary key (set as DE_KEY if not provided)
      default : [], // default value (set as [] if not provided)
    },
    {
      store   : 'remember-password',
      type    : Boolean,
      default : true,
    },
    {
      store   : 'join-info',
      type    : Object,
      default : { account: '13123371892', password: '123456' },
    },
  ],
});

if (process.env.NODE_ENV === 'development') {
  window.storage = storage;
}
export default storage;

Params

DB_NAME : database's name

DE_KAY : default key (For Array type)

VERSION : database version

storage : store items

Operation

Normal

| Method | Example | Description | | :---: | :--- | --- | | get | this.$storage.get('account-list') | Like localStorage.getItem | | set | this.$storage.set('join-info', {"account":"admin","password":"123456"}) | Like localStorage.setItem | | remove | storage.remove('remember-password') | Like localStorage.removeItem |

Tip: you can operate object directly.

Advance

The plugin add some methods to handler Array

insertItem

Definition: insertItem(key, valueList)

Example:

this.$storage.insertItem('account-list', [
  {name:'userA', pass: '1234'}, 
  {name:'userB', pass: '1234'}
]);

insertOrUpdate

Definition: insertOrUpdate(key, valueList)

Example:

this.$storage.insertItem('account-list', [
  {name:'userA', pass: '1234', id: "k45olgia0.jszelqpefiq1"}, // may be updated 
  {name:'userB', pass: '1234'}
]);

if item provide the same key (such as id), item will be updated if not provide key or unique key , item will be inserted

removeItem

Definition: removeItem(key, removedKeys)

Example:

storage.removeItem('account-list', [
        'k45olgia0.jszelqpefiq1',
        'k45olgia0.412q1m7meov2'
    ])

updateItem

Definition: updateItem(key, valueList)

Example:

storage.updateItem('account-list', [
  { 
    name: "userC", 
    pass: "1234", 
    id: "k45p0gw40.a194800akpr3" 
  }
])

updateItem

Definition: getItem(key, value)

Example:

storage.getItem('account-list', 'k45p9t7r0.8n3hntpabfm5')

get value by primary key

clear

Definition: clear(key)

Example:

storage.clear('account-list')

the account-list's value will be set as []