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.8 to 1.0.0

0

browser.js

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

61

node.js

@@ -1,59 +0,8 @@

"use strict";
'use strict'
const { LocalStorage } = require("node-localstorage");
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) => {
const { LocalStorage } = require('node-localstorage')
return new LocalStorage(location)
}
const getStorage = (location) => {
let storage;
try {
storage = new LocalStorage(location);
} catch (error) {
if (typeof error.code !== "undefined" && error.code === "ENOENT") {
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;
}
}
return storage;
};
module.exports = getStorage;
module.exports = getStorage

8

package.json
{
"name": "isomorphic-localstorage",
"version": "0.0.8",
"version": "1.0.0",
"main": "node.js",
"browser": "browser.js",
"typings": "typings.d.ts",
"repository": "https://github.com/nightly-labs/isomorphic-localstorage.git",

@@ -16,3 +17,6 @@ "author": "Adrian Wójciak <adrianwojciak@interia.pl>",

"README.md"
]
],
"devDependencies": {
"typescript": "^5.1.3"
}
}
# 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