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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sels

v2.5.1

Published

Safe & expirable localStorage

Readme

sels 🍪➡️🗄

sels - safe expirable localStorage

npm Tests LICENSE Package size

Using cookies for client-only purposes is irrational and unsafe. There is no point in using cookies if the data is not intended to be sent to the server. In this case, you need to use localStorage. However, localStorage may not be available (then an error will be generated), and there is no expiry mechanism in localStorage.

This library solves both problems

Installing and usage

npm i sels
import sels from 'sels';

sels.set('key', 'value');

или

<script src="https://cdn.jsdelivr.net/npm/sels@latest/index.min.js"></script>
Sels.set('key', 'value');

Breaking changes ⚠️

  • The method get version 1.x.x has been renamed to asyncGet (see description below)

Types & interfaces

interface RecordOptions {
  maxAge?: number
  expires?: string | Date
}

type RecordValue = string | boolean | number;

Methods

set(key: string, value: RecordValue, options?: RecordOptions): boolean - adds or modifies a record in localStorage. value will be cast to string. Before write, the ability to write will be checked, if the recording failed, it will return false, else true.

asyncGet(key: string): Promise - reads a record from localStorage. Checks readability before reading. If it fails, the Promise will be rejected with an error value, otherwise the Promise will be resolved with the read value. Promise will resolve with value null, if the specified key is not found.

get(key: string): string | null - reads a record from localStorage. Checks readability before reading. If the read failed, it will return null, otherwise the key value will be returned. If the key is not found, it will also return null.

remove(key: string) - removes record from localStorage. Before deleting, it checks if deletion is possible. It will return true, if deletion is successful, else false. If the key is not found, but there is no error, it will return true anyway.

clear() - completely cleans localStorage, it will return true, if successful, else false.

Fields

Sels also exports value isAvailable: boolean - availability of localStorage.

Options

The set method takes a third (optional) parameter - options. If nothing is passed, the record will be eternal.

  • maxAge is needed to indicate the number of seconds - the lifetime of the record. After this time expires, the record will no longer be available.
  • expires is needed to specify a date string or object Date, after which the record should become inaccessible. The date can be passed as a string (e.g. ISO string or 12-31-2021). Date.parse() will be used for parsing. You can also specify a Jira-like period, for example, 1w 2d 3h, so the record will stop being read after 1 week (7 days) + 2 days + 3 hours. Supported units: y, m, w, d, h (year, month, week, day, hour).

Translations