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

local-data-manage

v0.1.0

Published

本地数据持久化,序列化,格式化的综合实现

Readme

介绍

LDM ( local-data-manage ) 将本地数据的持久化,序列化,格式化融合到一起,能方便的处理以上数据操作的组合。更多使用方式, 请查询 API

注:LDM 是异步的, 本地持久化优先使用 indexedDB。

开始使用

下载

npm install @in2iot/local-data-manage --save

使用

  1. 简单的格式化一个数据
import ldm from '@in2iot/local-data-manage'

var sf = ldm.init{ type:'single' } // 如果您想把数据持久化到本地,你只需要 init({ type:'single', persistence: { isOpen:true } }); 如果您在同一项目中初始化了多个ldm对象,你需要定义 persistence.flag 来区分它们。

sf.add('test', { a:'aaaa', b:[1,2], d:234 }) // 这里你也可以添加format进行格式化

const res = sf.get('test', 'a') // 获取对象中的‘a’属性值,即 res.value = 'aaaa'。

const format = {
    a:'String',
    c:'String',
    d:'String'
}

const res = sf.get('test', undefined, format) // 格式化获取值,即 res.value = { a:'aaaa', c:'', d:'234' }。
  1. 序列化多个数据
import ldm from '@in2iot/local-data-manage'

var mf = ldm.init{ type:'multi' } //同样,如果您想把数据持久化到本地,你只需要更改 persistence 对象。

const saveFormat = {
    a:'String',
    c:'String',
    d:'String'
}

mf.add('test', undefined, saveFormat) // 这样你就添加了一条定义了固定格式的队列。这条队列的每一项都由该格式限制。

mf.up('test', value, false) // 向队列末尾添加一项。注意: 操作是异步的。

const getFormat = {
    prop: 'a', // 筛选出包含这个属性的项
    timeInterval: 2000, // 间隔时间为 2s
    format: { a: 'String', c: 'Object' }, // 格式化输出项
}

mf.get('keyName', undefined,getFormat)

测试

npm install

npm run test