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

x-localstore

v1.0.2

Published

Custom store, Use IndexedDB first, if the browser do not support it, change to Localstorage

Downloads

17

Readme

xLocalStore

客户端数据存储封装,默认如果不支持 IndexedDB 会使用 LocalStorage,也可以自动移设置存储引擎。

Demo

版本

  • v1.0.0

基于

  • IndexedDB
  • LocalStorage

安装

npm install x-localstore

或者

github下载源码

使用

直接用script引入

<script src="xLocalstore/dist/xlocalstore.umd.js"></script>

Vue示例

import xLocalStore from 'x-localstore';

初始化

const storeConfig = {
  dbName: '', // 可选,库名称
  tableName: '', // 可选,表名称
  useStores: [ 'indexedDB', 'localstorage' ], // 可选,选择存储引擎的顺序。不设置默认为 indexedDB/localstorage
}
const storeIns = new xLocalStore(storeConfig);

创建数据表

storeIns.createTable(keyPath, [
  {
    name: 'id',  // 字段名称
    keyPath: 'id' // 用于查询时候使用的字段名
  },
  {
    name: 'title',  // 字段名称
    keyPath: 'title' // 用于查询时候使用的字段名
  },
  {
    name: 'time',  // 字段名称
    keyPath: 'time' // 用于查询时候使用的字段名
  }
]);

说明:
keyPath: 当前表不重复值的字段名称,用于查询/更新/删除

获取全量数据

storeIns.getAll().then((result) => {
   console.log(result);
})

获取指定数据

storeIns.get(value, keyPath).then((result) => {
    console.log(result);
});

说明: 
value: 必填。查询的值
keyPath: 可选,查询的字段名,不填使用默认的字段

添加数据

如果和 createTable keyPath 重复的数据将不会被加入

storeIns.add([
    {
      id: '',
      title: '',
      time: ''
    }
]).then((result) => {
    console.log(result);
})

说明: 
result: 返回值,格式为 {
    success: [], // 成功的条目
    failed: [], // 失败的条目
}

添加并更新数据

storeIns.set([
    {
      id: '',
      title: '',
      time: ''
    }
]).then((result) => {
    console.log(result);
})

说明: 
result: 返回值,格式为 {
    success: [], // 成功的条目
    failed: [], // 失败的条目
}

删除条目

storeIns.delete([ value1, value2]).then((result) => {
    console.log(result);
})

说明: 
value: createTable keyPath 对应的条目值

清空数据表

storeIns.clear().then((result) => {
    console.log(result);
})