Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-ls

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-ls - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

2

package.json
{
"name": "vue-ls",
"version": "2.1.2",
"version": "2.1.3",
"description": "Vue plugin for work with LocalStorage from Vue context",

@@ -5,0 +5,0 @@ "main": "dist/vue-ls.js",

@@ -5,5 +5,5 @@ # vue-ls

This plugin has been developed thanks to the inspiration of the [local-storage](https://www.npmjs.com/package/local-storage) package
[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg)](https://github.com/Flet/semistandard)
[![VueJS 1.x](https://img.shields.io/badge/vuejs-1.x-brightgreen.svg)](https://github.com/RobinCK/vue-ls)
[![VueJS 2.x](https://img.shields.io/badge/vuejs-2.x-brightgreen.svg)](https://github.com/RobinCK/vue-ls)
[![Build Status](https://img.shields.io/travis/RobinCK/vue-ls.svg)](https://travis-ci.org/RobinCK/vue-ls)

@@ -10,0 +10,0 @@ [![Coverage Status](https://coveralls.io/repos/github/RobinCK/vue-ls/badge.svg?branch=master)](https://coveralls.io/github/RobinCK/vue-ls?branch=master)

import ls from './localStorage';
let VueLocalStorage = {
/**
* Install plugin
*
* @param {Object} Vue
* @param {Object} options
* @returns {Storage}
*/
install (Vue, options) {

@@ -5,0 +12,0 @@ ls.options = Object.assign(ls.options, {

let ls = {};
const memoryStorage = {
/**
* Get item
*
* @param {string} name
* @returns {*}
*/
getItem (name) {

@@ -8,2 +14,9 @@ return name in ls ? ls[name] : null;

/**
* Set item
*
* @param {string} name
* @param {*} value
* @returns {boolean}
*/
setItem (name, value) {

@@ -15,2 +28,8 @@ ls[name] = value;

/**
* Remove item
*
* @param {string} name
* @returns {boolean}
*/
removeItem (name) {

@@ -26,2 +45,7 @@ var found = name in ls;

/**
* Clear storage
*
* @returns {boolean}
*/
clear () {

@@ -33,2 +57,8 @@ ls = {};

/**
* Get item by key
*
* @param {number} index
* @returns {*}
*/
key (index) {

@@ -35,0 +65,0 @@ let keys = Object.keys(ls);

const eventListeners = {};
/**
* Event callback
*
* @param {Object} e
*/
function change (e) {

@@ -23,3 +28,10 @@ if (!e) {

/**
* Storage Bridge
*/
class Storage {
/**
* @param {Object} storage
* @param {Object} options
*/
constructor (storage, options) {

@@ -51,2 +63,9 @@ this.storage = storage;

/**
* Set item
*
* @param {string} name
* @param {*} value
* @param {number} expire - seconds
*/
set (name, value, expire = null) {

@@ -59,2 +78,9 @@ this.storage.setItem(

/**
* Get item
*
* @param {string} name
* @param {*} def - default value
* @returns {*}
*/
get (name, def = null) {

@@ -80,2 +106,8 @@ let item = this.storage.getItem(this.options.namespace + name);

/**
* Get item by key
*
* @param {number} index
* @return {*}
*/
key (index) {

@@ -85,2 +117,8 @@ return this.storage.key(index);

/**
* Remove item
*
* @param {string} name
* @return {boolean}
*/
remove (name) {

@@ -90,2 +128,5 @@ return this.storage.removeItem(this.options.namespace + name);

/**
* Clear storage
*/
clear () {

@@ -114,2 +155,8 @@ if (this.length === 0) {

/**
* Add storage change event
*
* @param {string} name
* @param {Function} callback
*/
on (name, callback) {

@@ -123,2 +170,8 @@ if (eventListeners[this.options.namespace + name]) {

/**
* Remove storage change event
*
* @param {string} name
* @param {Function} callback
*/
off (name, callback) {

@@ -125,0 +178,0 @@ let ns = eventListeners[this.options.namespace + name];

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc