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

mini-stash

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini-stash - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "mini-stash",
"version": "0.0.2",
"version": "0.0.3",
"description": "ES browser storage helper",

@@ -5,0 +5,0 @@ "author": "Dean Verleger",

@@ -40,25 +40,35 @@ # mini-stash

const data = {
latitude: 33.441792,
longitude: -94.037689
};
// it's a good idea to prefix storage keys
const storageKey = 'myapp-coords';
// save to local storage
stash(storageKey, data);
// save to session storage
stash(data, false);
stash(storageKey, data, false);
// retrieve from local storage (discard if data is older than a day)
// retrieve from local storage (discard if older than a day)
let coords = retrieve(storageKey, 60 * 24);
if (!coords) {
// ... get the coords
coords = {
latitude: 33.441792,
longitude: -94.037689
};
// save to local storage
stash(storageKey, coords);
}
// retrieve from session storage (disable cache)
let sessionCoords = retrieve(storageKey, 0, true);
// retrieve from session storage (disable expiration)
const loginStorageKey = 'myapp-login';
let loginData = retrieve(loginStorageKey, 0, true);
if (!loginData) {
// ... get login data
loginData = {
uid: 021947
};
// save to session storage
stash(loginStorageKey, loginData, true);
}
// clear from local storage

@@ -68,3 +78,3 @@ clear(storageKey);

// clear from session storage
clear(storageKey, true);
clear(loginStorageKey, true);
```

@@ -71,0 +81,0 @@

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