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 - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0-alpha.0

esm/index.d.ts

42

package.json
{
"module": "./esm/mod.js",
"main": "./script/mod.js",
"name": "@jmondi/browser-storage",
"version": "1.2.0",
"version": "1.3.0-alpha.0",
"description": "Utilities for local and session browser storage.",
"keywords": [
"browser-storage",
"local-storage",
"session-storage"
],
"author": "Jason Raimondi <jason@raimondi.us>",
"main": "dist/browser_storage.js",
"files": [
"dist",
"src"
],
"keywords": [],
"license": "MIT",
"description": "Util functions for local and session storage that handles namespacing as well as json serializing and parsing values.",
"dependencies": {
"js-cookie": "^3.0.1",
"superjson": "^1.11.0"
"engines": {
"node": ">=18.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jasonraimondi/browser-storage.git"
},
"bugs": {
"url": "https://github.com/jasonraimondi/browser-storage/issues"
},
"exports": {
".": {
"import": "./esm/mod.js",
"require": "./script/mod.js"
}
},
"devDependencies": {
"@types/js-cookie": "^3.0.2"
},
"scripts": {
"test": "vitest run",
"build": "tsc",
"prepublish": "rm -rf ./dist && pnpm test && pnpm build"
"@types/node": "^18.11.9"
}
}

@@ -1,68 +0,13 @@

# @jmondi/browser-storage
# DateDuration
Supports null and serializable objects.
## Install (npm)
## Install
```bash
npm install @jmondi/browser-storage
pnpm add @jmondi/browser-storage
```
## Usage
### Deno
### Local Storage
Local storage is persistent after close.
```typescript
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" }
```ts
import { DateDuration } from "https://deno.land/x/browser_storage";
```
### Session Storage
Session storage is reset when the browser is closed.
```typescript
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
Cookie storage is more configurable, see https://github.com/js-cookie/js-cookie#cookie-attributes for full options
```typescript
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" }
```
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