Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.
/ note-unstorage Public archive
forked from unjs/unstorage

💾 Unstorage provides an async Key-Value storage API with conventional features like multi driver mounting, watching and working with metadata, dozens of built-in drivers and a tiny core.

License

Notifications You must be signed in to change notification settings

mefengl/note-unstorage

 
 

Repository files navigation

代码阅读推荐顺序

建议按以下顺序阅读代码,以理解项目结构和核心功能:

  1. 核心类型与接口:
    • src/types.ts - 定义项目中使用到的主要类型和接口。
  2. 核心存储逻辑:
    • src/storage.ts - 实现核心的 Storage 类,包含挂载驱动、基本 K/V 操作等。
  3. 通用工具函数:
  4. 入口与导出:
    • src/index.ts - 项目的主入口文件,导出公共 API。
  5. 驱动实现:
  6. HTTP 服务器:
  7. 命令行工具:
  8. 构建与配置:
  9. 测试:

💾 Unstorage

npm version npm downloads Codecov bundle License

Unstorage provides an async Key-Value storage API with conventional features like multi driver mounting, watching and working with metadata, dozens of built-in drivers and a tiny core.

👉 Documentation

Features

  • Designed for all environments: Browser, NodeJS, and Workers
  • Lots of Built-in drivers
  • Asynchronous API
  • Unix-style driver mounting to combine storages
  • Default in-memory storage
  • Tree-shakable utils and tiny core
  • Auto JSON value serialization and deserialization
  • Binary and raw value support
  • State snapshots and hydration
  • Storage watcher
  • HTTP Storage with built-in server

Usage

Install unstorage npm package:

# yarn
yarn add unstorage

# npm
npm install unstorage

# pnpm
pnpm add unstorage
import { createStorage } from "unstorage";

const storage = createStorage(/* opts */);

await storage.getItem("foo:bar"); // or storage.getItem('/foo/bar')

👉 Check out the the documentation for usage information.

Nightly release channel

You can use the nightly release channel to try the latest changes in the main branch via unstorage-nightly.

If directly using unstorage in your project:

{
  "devDependencies": {
    "unstorage": "npm:unstorage-nightly"
  }
}

If using unstorage via another tool in your project:

{
  "resolutions": {
    "unstorage": "npm:unstorage-nightly"
  }
}

Contribution

  • Clone repository
  • Install dependencies with pnpm install
  • Use pnpm dev to start jest watcher verifying changes
  • Use pnpm test before pushing to ensure all tests and lint checks passing

License

MIT

About

💾 Unstorage provides an async Key-Value storage API with conventional features like multi driver mounting, watching and working with metadata, dozens of built-in drivers and a tiny core.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.5%
  • JavaScript 1.5%