data-structure-typed 2.2.6 → 2.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/CONTRIBUTING.md +47 -1
- package/README.md +19 -8
- package/README_CN.md +119 -275
- package/benchmark/report.html +1 -1
- package/benchmark/report.json +20 -324
- package/dist/cjs/index.cjs +109 -107
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +109 -107
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +109 -107
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +109 -107
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/leetcode/avl-tree-counter.mjs +2957 -0
- package/dist/leetcode/avl-tree-multi-map.mjs +2889 -0
- package/dist/leetcode/avl-tree.mjs +2720 -0
- package/dist/leetcode/binary-tree.mjs +1594 -0
- package/dist/leetcode/bst.mjs +2398 -0
- package/dist/leetcode/deque.mjs +683 -0
- package/dist/leetcode/directed-graph.mjs +1733 -0
- package/dist/leetcode/doubly-linked-list.mjs +709 -0
- package/dist/leetcode/hash-map.mjs +493 -0
- package/dist/leetcode/heap.mjs +542 -0
- package/dist/leetcode/max-heap.mjs +375 -0
- package/dist/leetcode/max-priority-queue.mjs +383 -0
- package/dist/leetcode/min-heap.mjs +363 -0
- package/dist/leetcode/min-priority-queue.mjs +371 -0
- package/dist/leetcode/priority-queue.mjs +363 -0
- package/dist/leetcode/queue.mjs +943 -0
- package/dist/leetcode/red-black-tree.mjs +2765 -0
- package/dist/leetcode/singly-linked-list.mjs +754 -0
- package/dist/leetcode/stack.mjs +217 -0
- package/dist/leetcode/tree-counter.mjs +3039 -0
- package/dist/leetcode/tree-multi-map.mjs +2913 -0
- package/dist/leetcode/trie.mjs +413 -0
- package/dist/leetcode/undirected-graph.mjs +1650 -0
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -2
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +10 -10
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +22 -23
- package/dist/types/data-structures/binary-tree/bst.d.ts +11 -11
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -2
- package/dist/umd/data-structure-typed.js +105 -103
- package/dist/umd/data-structure-typed.js.map +1 -1
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +48 -171
- package/src/data-structures/binary-tree/avl-tree-counter.ts +6 -6
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +13 -13
- package/src/data-structures/binary-tree/avl-tree.ts +15 -15
- package/src/data-structures/binary-tree/binary-tree.ts +53 -55
- package/src/data-structures/binary-tree/bst.ts +21 -22
- package/src/data-structures/binary-tree/red-black-tree.ts +3 -3
- package/src/data-structures/binary-tree/tree-counter.ts +4 -4
- package/src/data-structures/binary-tree/tree-multi-map.ts +13 -13
- package/test/performance/data-structures/binary-tree/red-black-tree.test.ts +1 -2
- package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +30 -30
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +46 -46
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +43 -43
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +151 -151
- package/test/unit/data-structures/binary-tree/bst.test.ts +99 -99
- package/test/unit/data-structures/binary-tree/overall.test.ts +20 -20
- package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +141 -141
- package/test/unit/data-structures/binary-tree/tree-counter.test.ts +37 -37
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +145 -145
- package/tsup.config.js +50 -21
- package/tsup.leetcode.config.js +1 -1
- package/tsup.umd.config.js +29 -0
- package/tsup.node.config.js +0 -83
package/CHANGELOG.md
CHANGED
|
@@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
|
|
9
9
|
- [`auto-changelog`](https://github.com/CookPete/auto-changelog)
|
|
10
10
|
|
|
11
|
-
## [v2.2.
|
|
11
|
+
## [v2.2.8](https://github.com/zrwusa/data-structure-typed/compare/v2.2.3...main) (upcoming)
|
|
12
12
|
|
|
13
13
|
## [v2.2.3](https://github.com/zrwusa/data-structure-typed/compare/v2.2.2...v2.2.3) (6 January 2026)
|
|
14
14
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -83,9 +83,55 @@
|
|
|
83
83
|
- click the `New pull request` on Github https://github.com/zrwusa/data-structure-typed/branches
|
|
84
84
|
|
|
85
85
|
**performance inspection**
|
|
86
|
-
- `node --inspect-brk
|
|
86
|
+
- `node --inspect-brk perf/hello-world.js`
|
|
87
87
|
- chrome://inspect/#devices -> Open dedicated DevTools for Node
|
|
88
88
|
|
|
89
|
+
|
|
90
|
+
**node:perf_hooks**
|
|
91
|
+
```javascript
|
|
92
|
+
const { performance } = require('node:perf_hooks');
|
|
93
|
+
|
|
94
|
+
// Force garbage collection (run with --expose-gc flag)
|
|
95
|
+
const forceGC = () => {
|
|
96
|
+
if (global.gc) {
|
|
97
|
+
global.gc();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Test Queue
|
|
102
|
+
function testQueue(QUANTITY) {
|
|
103
|
+
forceGC();
|
|
104
|
+
const initialMemory = process.memoryUsage().heapUsed;
|
|
105
|
+
|
|
106
|
+
const queue = new Queue();
|
|
107
|
+
const start = performance.now();
|
|
108
|
+
|
|
109
|
+
for (let i = 0; i < QUANTITY; i++) {
|
|
110
|
+
queue.push(i);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const end = performance.now();
|
|
114
|
+
const finalMemory = process.memoryUsage().heapUsed;
|
|
115
|
+
const memoryDelta = formatMemory(finalMemory - initialMemory);
|
|
116
|
+
|
|
117
|
+
console.log(`Queue push ${QUANTITY} elements: ${(end - start).toFixed(2)}ms`);
|
|
118
|
+
console.log(`Memory usage: ${memoryDelta}${CURRENT_UNIT} (growth)`);
|
|
119
|
+
|
|
120
|
+
return queue;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
testDeque(1000000);
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```shell
|
|
128
|
+
node --expose-gc benchmark/deque.js
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**performance info output**
|
|
132
|
+
-`node --prof perf/hello-world.js`
|
|
133
|
+
-`node --prof-process isolate-*.log > prof.txt`
|
|
134
|
+
|
|
89
135
|
**Contributing New Data Structures**
|
|
90
136
|
|
|
91
137
|
- Make your pull requests to be **specific** and **focused**. Instead of
|
package/README.md
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# data-structure-typed
|
|
2
|
+
|
|
3
|
+
English | [简体中文](./README_CN.md)
|
|
2
4
|
|
|
3
5
|
A comprehensive TypeScript data structures library with production-ready implementations.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
**📚 [Installation](#-installation) • [Quick Start](#-quick-start-30-seconds) • [Full Docs](#-documentation) • [API Reference](./docs/REFERENCE.md) • [Playground](#playground) • [Examples](./docs/GUIDES.md)**
|
|
6
17
|
|
|
7
18
|
---
|
|
8
19
|
|
|
@@ -484,14 +495,14 @@ const tree = new RedBlackTree([5, 2, 8]);
|
|
|
484
495
|
console.log([...tree]); // [2, 5, 8] - Automatically sorted!
|
|
485
496
|
```
|
|
486
497
|
|
|
487
|
-
##
|
|
498
|
+
## Playground
|
|
488
499
|
|
|
489
|
-
Try it instantly:
|
|
500
|
+
🏃🏻♀️ Try it instantly:
|
|
490
501
|
|
|
491
502
|
- [Node.js TypeScript](https://stackblitz.com/edit/stackblitz-starters-e1vdy3zw?file=src%2Findex.ts)
|
|
492
|
-
- [Node.js JavaScript](https://stackblitz.com/edit/stackblitz-starters-
|
|
493
|
-
- [React TypeScript](https://stackblitz.com/edit/vitejs-vite-
|
|
494
|
-
- [NestJS](https://stackblitz.com/edit/nestjs-typescript-starter-
|
|
503
|
+
- [Node.js JavaScript](https://stackblitz.com/edit/stackblitz-starters-oczhrfzn?file=src%2Findex.js)
|
|
504
|
+
- [React TypeScript](https://stackblitz.com/edit/vitejs-vite-7bva1zhd?file=src%2FApp.tsx)
|
|
505
|
+
- [NestJS](https://stackblitz.com/edit/nestjs-typescript-starter-q9n7okgc?file=src%2Fproduct%2Fservices%2Fproduct-price-index.service.ts)
|
|
495
506
|
|
|
496
507
|
|
|
497
508
|
### Step 4: Learn More
|
|
@@ -541,8 +552,8 @@ MIT
|
|
|
541
552
|
## 📚 Full Documentation Structure
|
|
542
553
|
|
|
543
554
|
```
|
|
555
|
+
README.md (this file)
|
|
544
556
|
docs/
|
|
545
|
-
├── README.md (this file)
|
|
546
557
|
├── CONCEPTS.md (theory & fundamentals)
|
|
547
558
|
├── REFERENCE.md (API documentation)
|
|
548
559
|
├── ARCHITECTURE.md (design principles)
|