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

local-store-h5

v1.2.0

Published

H5本地存储增强

Downloads

5

Readme

local-store-h5

  • H5 本地存储增强
  • 支持对本地存储设置过期时间
  • 当浏览器无法使用本地存储是(无痕模式),会自动降级,将数据存入内存中

安装

npm i local-store-h5 --save
TC 改造后,使用 CommonJS 输出,无法直接在 html 中引用,请使用 webpack 加载

使用

import store from "local-store-h5"

// 获取设置的本地数据
store.getItem("the-key")

// 设置本地存储 默认进程
store.getItem("the-key", "value")

// 设置本地存储 无过期
store.getItem("the-key", "value", -1)

// 设置本地存储 一天后过期
store.getItem("the-key", "value", 1)

// 设置本地存储 2200-10-1日过期
store.getItem("the-key", "value", "2200-10-1")

// 移除
store.removeItem("the-key")

// 更改默认的前置字符串 默认为 :
store.prepreposition = "$"

// 创建新的存储分组,并且使用 v4#作为前缀
// store4 包含上面那些方法
let store4 = new store.LSStore("v4#")

API

前缀

store.prepreposition

  • 为了和原生的本地存储区分,特地在所有通过此设置的数据,都加上前缀
  • 此前缀可以修改

存储

store.setItem(key:string, value: any [,expiration:string;data;number = 0])

  • key 本地存储的唯一 key
  • value 存入的基础数据
  • expiration 什么时候过期 默认为 0
    • -1 永久不过期 相当于 localStorage
    • 0 相当于 sessionStorage
    • 大于 0 几天后过期
    • 时间字符串 过期时间
    • 日期 过期时间

获取

store.getItem(key:string)

  • key 本地存储的唯一 key

移除

store.removeItem(key:string)

  • key 本地存储的唯一 key

创建新的本地存储分组

new store.LSStore(prev:string)

  • prev 为本分组存入的本地存储的前缀