@dstoolkit/data-structures

中文文档
1.6.0发布于 2026/10/05MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2802

A comprehensive collection of generic data structure implementations for TypeScript/JavaScript, published on npm.

原始使用文档
文档目录8 节
  1. 📚 Full Documentation
  2. Quick Start
  3. Installation
  4. Example
  5. Data Structures
  6. Features
  7. Links
  8. License

data-structures

A comprehensive collection of type-safe, zero-dependency data structure implementations for TypeScript/JavaScript.

JSR JSR Score npm version codecov CI

📚 Full Documentation

Visit our comprehensive documentation site for detailed guides, API references, and examples.

Quick Start

Installation

npm:

npm install @dstoolkit/data-structures

Deno (JSR):

import { Queue, LRUCache } from 'jsr:@dstoolkit/data-structures';

Example

import { Queue, LRUCache } from '@dstoolkit/data-structures';

// FIFO Queue
const queue = new Queue<number>();
queue.enqueue(1);
queue.enqueue(2);
console.log(queue.dequeue()); // 1

// LRU Cache
const cache = new LRUCache<string, number>({ capacity: 100 });
cache.put('key', 42);
console.log(cache.get('key')); // 42

Data Structures

  • Queues: Queue, Deque, PriorityQueue
  • Lists: LinkedList, DoublyLinkedList
  • Heaps: BinaryHeap (MinHeap, MaxHeap)
  • Trees: Tree, Trie, RedBlackTree
  • Maps & Caches: SortedMap, BiDirectionalMap, LRUCache

Features

  • 🎯 Type Safety - Full TypeScript support with generics
  • 📦 Zero Dependencies - Lightweight and secure
  • ⚡ Performance - Optimized implementations with documented time complexities
  • 🧪 Well Tested - Comprehensive test coverage (~100%)
  • 🌲 Tree Shakeable - Import only what you need
  • 🔄 Dual Published - Available on both JSR and npm

License

MIT License - feel free to use this in your own projects!

版本与发布记录

@dstoolkit/data-structures 共发布 4 个版本,首次发布于 2026/09/15;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.6.0latest2026/10/051 个月前
1.5.12026/09/151 个月前
1.5.02026/09/151 个月前
1.4.22026/09/151 个月前

关于 @dstoolkit/data-structures 的常见问题

@dstoolkit/data-structures 是什么?

A comprehensive collection of generic data structure implementations for TypeScript/JavaScript, published on npm.

如何安装 @dstoolkit/data-structures?

在项目目录运行 npm install @dstoolkit/data-structures,或使用 pnpm add / yarn add / bun add。

@dstoolkit/data-structures 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dstoolkit/data-structures 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dstoolkit/data-structures 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dstoolkit/data-structures 可以商用吗?

@dstoolkit/data-structures 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dstoolkit/data-structures 的下载量有多少?

根据 npm 官方下载统计,@dstoolkit/data-structures 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,802 次,日均约 93 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dstoolkit/data-structures 还在维护吗?

最新版本 1.6.0 发布于 2026/10/05(1 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/09/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。