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

dmb

v0.9.5

Published

storage

Downloads

4

Readme

结构化存储工具

下一个版本 dmb2

第一次使用初始化

import {upgrade} from 'dmb'

upgrade()

运行会进入命令行:

1、输入存储名:名称

2、询问是否更新:选择

3、接下来提示是否更新开发文件:暂且选择

文件结构为:假设存储名为:test

root ┯ test ┳ backup ┳
            ┃        ┇ // 备份文件存储目录
            ┃        ┗
            ┣ buffer ┳
            ┃        ┇ // buffer格式或者文本格式的存储目录
            ┃        ┗
            ┣ data          // 数据存储文件
            ┣ index         // 数据索引文件
            ┣ index.mjs     // 数据开发指导文件(更新开发文件选:是)
            ┗ struct.json   // 数据结构文件

定义存储结构

struct.json

{
  "version": 1,
  "head": {
    "admin": {
      "uid": {
        "type": "id",
        "index": true,
        "value": 1,
        "step": 1,
        "": "这个备注信息"
      },
      "pwd": {
        "type": "string",
        "length": 12,
        "value": "123456",
        "index": true,
        "": "index是给加上索引可以使用.indexByPwd('123456')"
      },
      "remark": 64,
      "": "这个集合的备注信息" 
    },
    "log": {
      "uid": "id",
      "time": "time",
      "content": "text"
    }
  }
}

升级需要增加version重新执行upgrade()

类型:id、uint、int、bool、time、float、string、buffer、text

1、简写: 名称: 类型

解释为:名称: { type: 类型}

特殊情况类型id

名称: id

解释为:名称: { type: id, step: 1, value: 1, index: true }

2、简写: 名称: 数字

解释为:名称: { type: string, length: 数字 }

3、简写: 名称: //内容

解释为:名称: { type: string, length: 12, "": "内容" }

4、简写: 名称: 对象

解释为:名称: { 补充默认配置 }

type缺省值为string

type: id缺省值为:step、value、index

type: string缺省值为:length

注意: string的length为大于1的整数,text、buffer不支持默认值,time可使用now、update默认值。

例如

"admin": {
    "uid": "id",
    "pwd": {
        "value": "123456"
    },
    "loginTime": {
        "type": "time",
        "value": "update"
    },
    "remark": "//备注",
    "": "管理员"
},
"log": {
    "uid": {
        "type": "uint",
        "index": true
    },
    "ip": 32,
    "time": {
        "type": "time",
        "value": "now"
    },
    "content": "text"
}

解释为:

"admin": {
    "uid": {
        "type": "id",
        "index": true,
        "value": 1,
        "step": 1
    },
    "pwd": {
        "type": "string",
        "length": 12,
        "value": "123456"
    },
    "loginTime": {
        "type": "time",
        "value": "update"
    },
    "remark": {
        "type": "string",
        "length": 12,
        "": "备注"
    },
    "": "管理员"
},
"log": {
    "uid": {
        "type": "uint",
        "index": true
    },
    "ip": {
        "type": "string",
        "length": 32
    },
    "time": {
        "type": "time",
        "value": "now"
    },
    "content": {
        "type": "text"
    }
}

升级

新增:

"admin": {...}, "log": {...}

"admin": {...}, "role": {...}, "log": {...}

更新:

"admin": {...}, "log": {旧配置}

"admin": {...}, "log": {新配置}

改名:

"admin": {...}, "log": "log2"

删除:

"admin": {...}, "log2": null

打开使用已有存储文件

开发模式

import connect, {close} from "./test/index.mjs";

生产模式

import connect, {close} from "dmb";

连接

const storage = connect({name: 'test'})

使用

查:

storage.admin.find(admin => admin.usn.includes('test')).role

if (storage.admin.indexByUid('admin')[0].pwd === '123456');

增:

storage.admin.push(
    {
        usn: 'admin',
        pwd: '123456'
    },
    {
        usn: 'test',
        pwd: '123456'
    }
)

改:

storage.admin.find(admin => admin.usn === 'admin').role = 'root'

删:

storage.admin.remove(...storage.admin.filter(admin => admin.usn.startsWith('test')))

保存:

storage[close]()

默认是每5分钟保存一次