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

idb-uni

v1.0.0

Published

IndexedDB and WXStorage are available

Downloads

2

Readme

统一接口:storage

  • storageImpl:指向现有环境创造类:WeChatStorage/IndexedDBStorage/LocalStorage
  • 如果同时支持IndexedDBStorage/LocalStorage,自动选择前者
  • 可以强制选择文件系统,LocalStorage/ FileStorage ,后者用于微信环境
  • 在文件中实现统一api,示例:
async setItem(key,value) {
    if (!this.storageImpl) 
    throw new Error('No storage implementation available');
    return this.storageImpl.setItem(key, value);
  }
  • 注意:WeChatStorage和IndexedDBStorage有一个重要区别,WeChatStorage没有表(对象存储)的概念。微信小程序的本地存储是一个简单的键值存储系统,每个键只对应一个值。而IndexedDBStorage是一个数据库下存储很多表,每个表相当于一个简单的键值存储系统。
  • 现有功能(IndexedDBStorage,所有数据存取在this.storeName表内):
  1. setItem(key, value):将key对应存储value,
  2. getItem(key):获得key对应数据
  3. removeItem(key):清空key对应数据
  4. clear():清空this.storeName对应表
  5. getAllItems():获取this.storeName对应表内所有数据
  • 现有功能(WeChatStorage):
  1. setItem(key, value):将key对应存储value,
  2. getItem(key):获得key对应数据
  3. removeItem(key):清空key对应数据
  4. clear():清空本地所有缓存
  5. getItemById(key, id):key对应数据如果是一个数组,获取数组里对应id的数据
  6. addItem(key, newItem):key对应数据如果是一个数组,向数组里添加newItem

使用思路:

使用方法:

  • 在scrip里:import Storage from 'path/to/Storage.js';
  • 对于统一接口,直接调用Storage.XXX,比如Storage.setItem(key, value);
  • 对于单独接口,调用Storage.storageImpl.XXX
  • 对于强制使用文件系统,调用Storage.localStorage或者Storage.FileStorage