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

aging-storage

v1.0.22

Published

LocalStorage to be aging

Readme

aging-storage

基于 LocalStorage 的封装,使得键值对支持设置过期时间,同时存储的值支持多种类型(包括string | number | boolean | object | Date | null | undefined),无需转成字符串再存储。并且借用 storage 事件,实现同域下浏览器标签页之间的自定义事件传递。

Installation

npm install aging-storage

Usage

import AgingStorage from "aging-storage";

const agingStorage = new AgingStorage();
// or
const agingStorage = new AgingStorage({
    preKey: 'aging',
    listen: true,
    eventKey: 'storage_event'
});

API

    /** 
     * 从 LocalStorage 获得对应键值的数据。
     * @param key 键的名称
     */
    getItem: (key: string) => string | number | object | undefined;

    /** 
     * 将数据以键值对的形式存到 LocalStorage 中,并且可以指定过期时间。
     * @param key 键的名称
     * @param value 值数据,支持字符串、数字、对象、undefined
     * @param expire 有效时长,单位:s
     */
    setItem: (key: string, value: string | number | object | undefined, expire?: number) => void;

    /** 
     * 删除 LocalStorage 中给定键的数据条目,支持指定只删除过期时间前的数据条目。
     * @param key 键的名称
     * @param deadline 过期时间或13位时间戳
     */
    removeItem: (key: string, deadline?: string | number) => void;

    /** 
     * 批量删除 LocalStorage 中给定键的数据条目,支持指定只删除过期时间前的数据条目。
     * @param keyList 一个包含键的名称和过期时间或13位时间戳的数组对象
     */
    batchRemoveItem: (keyList: Array<{ key: string; deadline?: string | number }>) => void;

    /** 
     * 在当前浏览器标签页触发一个自定义事件。第二个参数将会传递给事件监听器的回调函数。
     * (只有当 new AgingStorage 时选项 listen 设成 true 时有效。)
     * @param event 自定义事件名
     * @param params 回调函数的入参
     */
    emit: (event: string, params?: any) => void;

    /** 
     * 注册监听一个来自其他浏览器标签页的自定义事件。
     * (只有当 new AgingStorage 时选项 listen 设成 true 时有效。)
     * @param event 自定义事件名
     * @param callback 回调函数
     */
    on: (event: string, callback: (params?: any) => void) => void;

    /** 
     * 取消监听一个来自其他浏览器标签页的自定义事件。
     * (只有当 new AgingStorage 时选项 listen 设成 true 时有效。)
     * @param event 自定义事件名
     * @param callback 回调函数
     */
    off: (event?: string, callback?: Function) => void;