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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dz-storage

v1.0.6

Published

Better Storage (localStorage, sessionStorage)

Downloads

97

Readme

dz-storage

更好用的 localStorage 封装,支持几乎所有 Javascript 数据类型的存取,当然 sessionStorage 也是支持的。

😁 即取即用:存值、取值均不需要任何转换

😁 100% 基于 localStorage 纯原生封装

😁 1:1 实现 localStorage api,极致纯粹

😁 100% 同步写法,无需 asyncawait

😁 支持 stringnumberbooleannullundefinedNaNobjectSetMapbigintsymbol

😁 稳定可靠,测试用例完善,100% 测试覆盖率

😁 超小代码体积,gzip 后不足 1kb

😁 支持 TypeScript

安装

# npm
npm i dz-storage

# pnpm
pnpm add dz-storage

# yarn
yarn add dz-storage

使用

import {localStore, sessionStore} from 'dz-storage'

localStore.set('s', 'hello')
localStore.get('s') // 'hello'

localStore.set('n', 123)
localStore.get('n') // 123

localStore.set('b', true)
localStore.get('b') // true

localStore.set('n2', NaN)
localStore.get('n2') // NaN

localStore.set('o', {name: 'zhangsan'})
localStore.get('o') // {name: 'zhangsan'}

localStore.set('a', [{name: 'zhangsan'}])
localStore.get('a') // [{name: 'zhangsan'}]

localStore.set('s', Symbol.for('Hello world'))
localStore.get('s') // Symbol(Hello world)

注意:为保证 symbol 的唯一性,请使用 Symbol.for 来创建。

更多代码示例请查阅 https://blog.csdn.net/dizuncainiao/article/details/134958324

api

| 属性名 | 说明 | 别名 | | :----- | ------------------------------------------------------------ | ---------- | | set | 同 localStorage.setItem | setItem | | get | 同 localStorage.getItem | getItem | | remove | 同 localStorage.removeItem | removeItem | | clear | 同 localStorage.clear | | | length | 同 localStorage.length | | | key | 同 localStorage.key | |