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

@jmondi/browser-storage

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

@jmondi/browser-storage

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@jmondi/browser-storage

Supports null and serializable objects.

Install

npm install @jmondi/browser-storage

Usage

Local Storage

Local storage is persistent after close.

import { LocalStorage } from "@jmondi/browser-storage";

const localStorage = new LocalStorage();

localStorage.set("user1", null);
localStorage.set("user2", { email: "hermoine@hogwarts.com", name: "Hermoine" });

console.log(localStorage.get("user1"));
// null
console.log(localStorage.get("user2"));
// { email: "hermoine@hogwarts.com", name: "Hermoine" }

Session Storage

Session storage is reset when the browser is closed.

import { SessionStorage } from "@jmondi/browser-storage";

const sessionStorage = new SessionStorage();

sessionStorage.set("user1", null);
sessionStorage.set("user2", { email: "hermoine@hogwarts.com", name: "Hermoine" });

console.log(sessionStorage.get("user1"));
// null
console.log(sessionStorage.get("user2"));
// { email: "hermoine@hogwarts.com", name: "Hermoine" }

Cookie storage is more configurable, see https://github.com/js-cookie/js-cookie#cookie-attributes for full options

import type { CookieAttributes } from "js-cookie";
import { CookieStorage } from "@jmondi/browser-storage";

const cookieStorage = new CookieStorage();

const cookieOptions: CookieAttributes = {};

cookieStorage.set("user1", null, cookieOptions);
cookieStorage.set("user2", { email: "hermoine@hogwarts.com", name: "Hermoine" });

console.log(cookieStorage.get("user1"));
// null
console.log(cookieStorage.get("user2"));
// { email: "hermoine@hogwarts.com", name: "Hermoine" }

FAQs

Package last updated on 27 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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