npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ozntel/local-storage-handler

v1.0.3

Published

This package will help you to set local storage items with a time stamp and retrieve them by checking how many hours ago it was set.

Downloads

16

Readme

Local Storage Handler

Cookies are good options for keeping data for limited time on client side. But what if you have data, which is much bigger than cookies accept? You might still want to have expire date for the data. This small library will help you to achieve this. It will basically set local storage items with a time stamp and retrieve them by checking how many hours ago it was set. You decide by specifying the number of hours. It is useful for applications where you have data, which needs to be refreshed once in a while but you don't need to refresh after each page load and you want to unload your server a little bit.

  • The library is written in Typescript, hence, you have built-in type support.

  • No additional dependencies.

  • The handler basically sets a timestamp for each key. Every time you try to retrieve the key, it will check the timestamp if it key value is set earlier than the cacheHours hours. If not, it will return the string value. If older, it will return null

Install the Library

npm i @ozntel/local-storage-handler

Import

import { LocalStorageHandler } from '@ozntel/local-storage-handler';

Usage

// You can create Handler by passing specified cacheHours
let lsh = new LocalStorageHandler({ cacheHours: 0.5 });

// or use 24 Hours by default and pass only an empy object
let lsh = new LocalStorageHandler({});

// You can change the cacheHours later on
lsh.cacheHours = 12;

// Set a new Local Storage Value
// It'll return 'success' but you don't need to assign to variable
let setResp = lsh.setLocalStorage({ key: 'key1', value: 'value1' });

// Get Local Storage Item.
// It'll return value if the data in local storage isn't older than specified cachedHours
// or null if key not found or is older than cachedHours
let val1 = lsh.getFromLocalStorage({ key: 'key1' });

// You can ask for local storage item by ignoring the cacheTime.
// It'll return value no matter when the local storage key was set
let val1 = lsh.getFromLocalStorage({ key: 'key1', checkCacheHours: false });

// If you want to check the value by certain cacheTime, you can also pass additionally
let val1 = lsh.getFromLocalStorage({ key: 'key1', checkCacheHours: false, cacheHours: 5 });

// Finally you can remove the local storage key
// It'll return 'success' if deleted
// or 'not-found' if it couldn't find the key.
// It will also delete the timestamp related to the key from local storage.
let clearResp = lsh.removeFromLocalStorage({ key: 'key1' });