New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

isomorphic-localstorage

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isomorphic-localstorage - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

0

browser.js

@@ -0,0 +0,0 @@ const getStorage = (_path) => {

46

node.js
"use strict";
const { LocalStorage } = require("node-localstorage");
const fs = require("fs");
class MockLocalStorage {
_store;
constructor() {
this._store = {};
}
getItem(key) {
if (typeof key !== "string") {
throw new Error("Key must be a string!");
}
return this._store?.[key] ?? null;
}
removeItem(key) {
if (typeof key !== "string") {
throw new Error("Key must be a string!");
}
if (typeof this._store?.[key] !== "undefined") {
this._store[key] = undefined;
}
}
setItem(key, value) {
if (typeof key !== "string" || typeof value !== "string") {
throw new Error("Both key and value must be strings!");
}
this._store[key] = value;
}
}
const getStorage = (location) => {

@@ -13,12 +46,15 @@ let storage;

if (typeof error.code !== "undefined" && error.code === "ENOENT") {
fs.chmodSync(location, 0o755)
storage = new LocalStorage(location);
console.log(
"[isomorphic-localstorage] Unable to instantiate localStorage in given location due to lack of permissions; mock will be used instead."
);
storage = new MockLocalStorage();
} else {
throw error
throw error;
}
}
return storage
return storage;
};
module.exports = getStorage;

2

package.json
{
"name": "isomorphic-localstorage",
"version": "0.0.7",
"version": "0.0.8",
"main": "node.js",

@@ -5,0 +5,0 @@ "browser": "browser.js",

# isomorphic-localstorage
Isomorphic implementation of localStorage
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