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

tlssa

v0.2.1

Published

A strictly typed Local and Storage Adapter for Typescript that uses JSON format when storing to actual storage.

Readme

Typed Local and Session Storage Adapter (tlssa).

Typed Local and Session Storage Adapter (TLSSA) - A Strictly typed Local and Session Storage Adapter for Typescript that uses JSON format when saving to actual storage.

Current Release Licence

Quick start

npm i tlssa

Define the schema of entities you want to store to local or session storage. Create an instance of TypedStorageAdapter with the schema as type parameter, and storage instance (localStorage or sessionStorage) and prefix of key name as constructor parameters. Then, you can load and store entities using typed getItem and setItem methods. Namespace-like behavior with key prefix and getOrCreateItem, removeItem, keys, length, clear methods are also available.

// TypedStorageAdapter needs a type parameter as the schmema of the stored items,
// and storage instance and key prefix as constructor parameters.
// Actual key to access the storage is "myapp.key". If key prefix is not provided,
// the actual key is just "key".
const storage = new TypedStorageAdapter<{id: string; name: string}>(localStorage, "myapp");

// getOrCreateItem returns the stored value or "000" with storing it
// if "myapp.id" is not stored.
storage.getOrCreateItem("id", "000");
// returns the stored value or execution result of supplied function with storing
// it to the storage if "myapp.id" is not stored.
storage.getOrCreateItem("id", (_key)=>"000");

// getItem() returns the stored value or "000" if not stored.
storage.getItem("id", "000");
// returns the stored value or execution result of supplied function if not stored.
storage.getItem("id", (_key)=>"000");
// returns the stored value or null if not stored.
storage.getItem("id");

// setItem() stores the value to the storage with key generated by concatenating
// prefix and the given key.
storage.setItem("name", "000");

// removeItem() removes the stored value.
storage.removeItem("name");

// keys() returns all keys. If key prefix is valid, this method only returns
// the key string after prefix string (i.e. returns "name" when the actual
// key is "myapp.name").
const allKeys = storage.keys();

// clear() clears all entries that has the key `${prefix}.*`.
// If the prefix is not supplied or empty, this method clears all entries.
storage.clear();

Type checking

const storage = new TypedStorageAdapter<{id: string; name: string}>(localStorage, "myapp");

storage.getOrCreateItem("id", "000");  // OK
storage.getOrCreateItem("id", 0);  // NG
storage.getOrCreateItem("id", true);  // NG
storage.getOrCreateItem("name", (_key)=>"000");  // OK
storage.getOrCreateItem("name", ()=>"000");  // OK
storage.getOrCreateItem("name", ()=>true);  // NG
storage.getOrCreateItem("name");  // NG
storage.getOrCreateItem("age", 20);  // NG

storage.getItem("id", "000");  // OK
storage.getItem("id", (_key)=>"000");  // OK
storage.getItem("name");  // OK
storage.getItem("name", 20);  // NG
storage.getItem("age"); // NG

storage.setItem("id", "000");
storage.setItem("name", 20);  // NG

storage.removeItem("id");  // OK
storage.removeItem("age");  // NG