New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.2.2 to 1.2.3

dist/helpers/mockStorage.d.ts

1

dist/constants/lib.d.ts
export declare const LIB_KEY: string;
export declare const STORAGE_NAMES: {};
"use strict";
var storage_1 = require('../enums/storage');
exports.LIB_KEY = 'ng2-webstorage';
exports.STORAGE_NAMES = (_a = {},
_a[storage_1.STORAGE.local] = 'local',
_a[storage_1.STORAGE.session] = 'session',
_a
);
var _a;
//# sourceMappingURL=lib.js.map

@@ -5,2 +5,3 @@ import { IWebStorage } from '../interfaces/webStorage';

static cached: {};
static storageAvailability: {};
static store(sType: STORAGE, sKey: string, value: any): void;

@@ -10,3 +11,5 @@ static retrieve(sType: STORAGE, sKey: string): string;

static clear(sType: STORAGE, sKey: string): void;
static getStorage(sType: STORAGE): IWebStorage;
static getWStorage(sType: STORAGE): IWebStorage;
static isStorageAvailable(sType: STORAGE): any;
}

@@ -5,2 +5,4 @@ "use strict";

var keyStorage_1 = require('./keyStorage');
var mockStorage_1 = require('./mockStorage');
var lib_1 = require('../constants/lib');
var WebStorageHelper = (function () {

@@ -10,3 +12,3 @@ function WebStorageHelper() {

WebStorageHelper.store = function (sType, sKey, value) {
this.getWStorage(sType).setItem(sKey, JSON.stringify(value));
this.getStorage(sType).setItem(sKey, JSON.stringify(value));
this.cached[sType][sKey] = value;

@@ -16,10 +18,10 @@ storageObserver_1.StorageObserverHelper.emit(sType, sKey, value);

WebStorageHelper.retrieve = function (sType, sKey) {
if (sKey in this.cached[sType])
if (this.cached[sType][sKey])
return this.cached[sType][sKey];
var data = null;
try {
data = JSON.parse(this.getWStorage(sType).getItem(sKey));
data = JSON.parse(this.getStorage(sType).getItem(sKey));
}
catch (err) {
console.error("invalid value for " + sKey);
console.warn("invalid value for " + sKey);
}

@@ -30,3 +32,3 @@ return this.cached[sType][sKey] = data;

var _this = this;
var storage = this.getWStorage(sType);
var storage = this.getStorage(sType);
keyStorage_1.KeyStorageHelper.retrieveKeysFromStorage(storage)

@@ -40,6 +42,9 @@ .forEach(function (sKey) {

WebStorageHelper.clear = function (sType, sKey) {
this.getWStorage(sType).removeItem(sKey);
this.getStorage(sType).removeItem(sKey);
delete this.cached[sType][sKey];
storageObserver_1.StorageObserverHelper.emit(sType, sKey, null);
};
WebStorageHelper.getStorage = function (sType) {
return this.isStorageAvailable(sType) ? this.getWStorage(sType) : mockStorage_1.MockStorageHelper.getStorage(sType);
};
WebStorageHelper.getWStorage = function (sType) {

@@ -59,7 +64,27 @@ var storage;

};
WebStorageHelper.isStorageAvailable = function (sType) {
if (typeof this.storageAvailability[sType] === 'boolean')
return this.storageAvailability[sType];
var isAvailable = true, storage = this.getWStorage(sType);
if (typeof storage === 'object') {
try {
storage.setItem('test-storage', 'foobar');
storage.removeItem('test-storage');
}
catch (e) {
isAvailable = false;
}
}
else
isAvailable = false;
if (!isAvailable)
console.warn(lib_1.STORAGE_NAMES[sType] + " storage unavailable, Ng2Webstorage will use a fallback strategy instead");
return this.storageAvailability[sType] = isAvailable;
};
WebStorageHelper.cached = (_a = {}, _a[storage_1.STORAGE.local] = {}, _a[storage_1.STORAGE.session] = {}, _a);
WebStorageHelper.storageAvailability = (_b = {}, _b[storage_1.STORAGE.local] = null, _b[storage_1.STORAGE.session] = null, _b);
return WebStorageHelper;
var _a;
var _a, _b;
}());
exports.WebStorageHelper = WebStorageHelper;
//# sourceMappingURL=webStorage.js.map

2

package.json
{
"name": "ng2-webstorage",
"version": "1.2.2",
"version": "1.2.3",
"description": "angular2 webstorage manager",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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