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

ng2-webstorage

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng2-webstorage - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

README.md

2

lib/app.ts

@@ -7,5 +7,5 @@ import {LocalStorageService, SessionStorageService} from './services';

export const NG2_WEBSTORAGES = [
export const NG2_WEBSTORAGE = [
SessionStorageService,
LocalStorageService
];

@@ -15,3 +15,3 @@ import {STORAGE} from '../enums/storage';

static emit(sType:STORAGE, sKey:string, value:string):void {
static emit(sType:STORAGE, sKey:string, value:any):void {
let oKey = this.genObserverKey(sType, sKey);

@@ -18,0 +18,0 @@ if(oKey in this.observers) this.observers[oKey].emit(value);

@@ -19,3 +19,3 @@ import {beforeEachProviders, describe, inject, injectAsync, it} from '@angular/core/testing';

WebStorageHelper.store(STORAGE.session, 'webStorage:session:key', value);
expect(sessionStorage.getItem('webStorage:session:key')).toEqual(value)
expect(sessionStorage.getItem('webStorage:session:key')).toEqual(JSON.stringify(value))

@@ -29,3 +29,3 @@ });

WebStorageHelper.store(STORAGE.local, 'webStorage:local:key', value);
expect(localStorage.getItem('webStorage:local:key')).toEqual(value)
expect(localStorage.getItem('webStorage:local:key')).toEqual(JSON.stringify(value))

@@ -61,3 +61,3 @@ });

let value = 'value', key = 'webStorage:local:key2';
localStorage.setItem(key, value);
localStorage.setItem(key, JSON.stringify(value));
expect(WebStorageHelper.retrieve(STORAGE.local, key)).toEqual(value);

@@ -70,3 +70,3 @@

let value = 'value', key = 'webStorage:session:key2';
sessionStorage.setItem(key, value);
sessionStorage.setItem(key, JSON.stringify(value));
expect(WebStorageHelper.retrieve(STORAGE.session, key)).toEqual(value);

@@ -79,3 +79,3 @@

let value = 'value', key = 'webStorage:session:key2';
sessionStorage.setItem(key, 'other value');
sessionStorage.setItem(key, JSON.stringify('other value'));
expect(WebStorageHelper.retrieve(STORAGE.session, key)).toEqual(value);

@@ -82,0 +82,0 @@

@@ -10,4 +10,4 @@ import {IWebStorage} from '../interfaces/webStorage';

static store(sType:STORAGE, sKey:string, value:string):void {
this.getWStorage(sType).setItem(sKey, value);
static store(sType:STORAGE, sKey:string, value:any):void {
this.getWStorage(sType).setItem(sKey, JSON.stringify(value));
this.cached[sType][sKey] = value;

@@ -20,3 +20,11 @@ StorageObserverHelper.emit(sType, sKey, value);

return this.cached[sType][sKey];
return this.cached[sType][sKey] = this.getWStorage(sType).getItem(sKey);
let data = null;
try {
data = JSON.parse(this.getWStorage(sType).getItem(sKey));
} catch(err) {
console.error(`invalid value for ${sKey}`);
}
return this.cached[sType][sKey] = data;
}

@@ -23,0 +31,0 @@

@@ -5,6 +5,6 @@ import {EventEmitter} from '@angular/core';

export interface IStorage {
store(key:string, value:string):void;
retrieve(key:string):string;
store(key:string, value:any):void;
retrieve(key:string):any;
clear(key?:string):void;
observe(key:string): EventEmitter;
}

@@ -14,3 +14,3 @@ import {EventEmitter} from '@angular/core';

public store(raw:string, value:string):void {
public store(raw:string, value:any):void {
let sKey = KeyStorageHelper.genKey(raw);

@@ -20,3 +20,3 @@ WebStorageHelper.store(this.sType, sKey, value);

public retrieve(raw:string):string {
public retrieve(raw:string):any {
let sKey = KeyStorageHelper.genKey(raw);

@@ -23,0 +23,0 @@ return WebStorageHelper.retrieve(this.sType, sKey);

{
"name": "ng2-webstorage",
"version": "1.0.0",
"version": "1.0.1",
"description": "angular2 webstorage manager",

@@ -5,0 +5,0 @@ "main": "index.js",

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