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

extend-storage

v1.0.1

Published

A extend tool of Web Storage

Downloads

4

Readme

简介

基于Web Storage (sessionStorage 和localStorage)做的方法扩展,旨在减少浏览器存储过程的数据序列化和反序列化操作,使得Web Storage的使用更加简单,开发者不用关心存入的数据类型是什么,原生数据存取。 并且在原生基础上增加了Function类型, Date类型的存储。

数据格式

  • 支持七种数据存储格式
  • String,Number,Boolean,Function,Date,Object,Array
  • 存入什么数据类型,取出什么数据类型
  • 与原生方法共存
  • 易扩展

安装使用

<!DOCTYPE html>
<html>

<head>
<title>extend-storage使用</title>
</head>

<body>
<script src="./dist/extend-storage.min.js"></script>
<script>
  EStorage.session.set('sessionKey', {key:'value'})
  console.log(EStorage.session.get('sessionKey'))


  EStorage.local.set('localKey', {key:'value'})
  console.log(EStorage.local.get('localKey'))
</script>
</body>

</html>

npm:

npm install extend-storage
// commonjs 引入
const EStorage = require('extend-storage')
EStorage.session.set('newObj', {key: 'value'})
console.log(EStorage.session.get('newObj')) // 

// es6 引入
import EStorage from 'extend-storage'
EStorage.local.set('number', 123)
console.log(EStorage.local.get('number'))

API

  • 两个操作对象EStorage.session和EStorage.local
  • 支持以下方法:
  • set(key,value,expireIn):创建新数据项和更新已存在的值。接受三个参数——要创建/修改的数据项的键、值、过期时间(非必填、毫秒)。
  • update(key,value,expireIn):更新已存在的值。接受三个参数——要创建/修改的数据项的键、值、过期时间(非必填、毫秒)。
  • remove(key):接受一个参数——你想要移除的数据项的键,然后会将对应的数据项从域名对应的存储对象中移除。
  • clear():不接受参数,清空域名对应的整个存储对象。
  • get(key):接受数据项的键作为参数,并返回从存储中的数据项
  • keyType(key): 返回对应key值的数据类型
  • isExist(key): 接受数据项的键作为参数,并返回布尔值
  • getAll(): 不接受具体参数,获取所有的键值对,返回Object

事件

addEvent支持对某个键值对进行监听,如果监听的值发生变化(set, update,remove,clear),则触发注册的回调函数

EStorage.session.addEvent("key", function(newVal, oldVal, type){
  console.log( newVal, oldVal, type) // 
})