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

@jzjy/storage

v1.0.3

Published

A simple wrapper of browser localStorage

Readme

浏览器Stroage封装

安装

可以使用Npm或Yarn

npm i --save @jzjy/storage

或者

yarn add @jzjy/storage

如何引入

import storage from '@jzjy/storage'

API

这里的API规则主要是localStroage的交互方式,也可以传入sessionStorage

使用方式

直接使用json,添加过期时间

let stroage = new Stroage()
let session = new Storage('sessionStorage')

可以增加key的前缀

let storage = new Storage('localStorage', 'prefix--')

set(key, value, options)

添加/修改数据

|参数|类型|默认值|描述| |:----- |:------|:------|:------| |key |any |'' |缓存的key | |value |any | |缓存的value | |options |object | |可选,过期时间 |

可选时间参数,可以传 number(秒) 或者 Date类型,其余参数要为Number

|参数|类型|默认值|描述| |:----- |:------|:------|:------| |exp |number | |秒 | |hour |number | |时 | |day |number | |天 | |weak |number | |周 | |month |number | |月 | |year |number | |年 |

storage.set('token', 123)
storage.set('token', 123, { day: 1 })
storage.set('token', 123, { exp: 24 * 3600 })
storage.set('token', 123, { exp: new Date(2021, 3, 22) })

get(key)

获取数据

|参数|类型|默认值|描述| |:----- |:------|:------|:------| |key |any |'' |缓存的key |

stroage.get('token')

remove(key)

删除缓存的数据,返回key

storage.remove('token')

clearExpires()

清空所有过期的缓存数据

clear()

清空所有缓存数据,包括原始的 stroage API 添加的数据

reset(key, options)

重置过期时间

stroage.reset('token', { hour: 2})

replace(key)

重置value,过期时间不变

storage.replace('token', 2222)

add(key, value, options)

当key不存在或者过期了才添加数据

storage.add('token', 123456)
storage.add('token', 1234455, { day: 1 })