data-structure-typed 2.1.1 → 2.2.0
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 +4 -0
- package/README.md +19 -7
- package/dist/cjs/index.cjs +1175 -585
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/{index.cjs → cjs-legacy/index.cjs} +1145 -613
- package/dist/cjs-legacy/index.cjs.map +1 -0
- package/dist/esm/index.mjs +1175 -585
- package/dist/esm/index.mjs.map +1 -1
- package/dist/{index.js → esm-legacy/index.mjs} +1147 -615
- package/dist/esm-legacy/index.mjs.map +1 -0
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +58 -4
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +66 -4
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +59 -5
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/bst.d.ts +58 -4
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +60 -6
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +58 -4
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +66 -4
- package/dist/types/data-structures/heap/heap.d.ts +4 -4
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +1 -1
- package/dist/types/interfaces/binary-tree.d.ts +1 -1
- package/dist/umd/data-structure-typed.js +711 -228
- package/dist/umd/data-structure-typed.js.map +1 -1
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/jest.integration.config.js +7 -3
- package/package.json +29 -7
- package/src/data-structures/binary-tree/avl-tree-counter.ts +106 -15
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +116 -12
- package/src/data-structures/binary-tree/avl-tree.ts +107 -16
- package/src/data-structures/binary-tree/binary-tree.ts +4 -4
- package/src/data-structures/binary-tree/bst.ts +103 -12
- package/src/data-structures/binary-tree/red-black-tree.ts +110 -20
- package/src/data-structures/binary-tree/tree-counter.ts +105 -14
- package/src/data-structures/binary-tree/tree-multi-map.ts +123 -12
- package/src/data-structures/graph/abstract-graph.ts +5 -5
- package/src/data-structures/graph/directed-graph.ts +5 -5
- package/src/data-structures/graph/undirected-graph.ts +5 -5
- package/src/data-structures/heap/heap.ts +5 -5
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
- package/src/interfaces/binary-tree.ts +1 -1
- package/test/integration/compile.test.mjs +159 -0
- package/test/integration/compile.test.ts +176 -0
- package/test/integration/heap.test.js +1 -1
- package/test/integration/index.html +1 -1
- package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +5 -4
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +3 -3
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +3 -3
- package/test/unit/data-structures/binary-tree/bst.test.ts +2 -2
- package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +3 -3
- package/test/unit/data-structures/binary-tree/tree-counter.test.ts +5 -4
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +4 -4
- package/{tsconfig-base.json → tsconfig.base.json} +0 -1
- package/tsconfig.test.json +1 -0
- package/{tsconfig-types.json → tsconfig.types.json} +1 -3
- package/tsup.config.js +2 -3
- package/tsup.node.config.js +71 -0
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/test/integration/compile.js +0 -144
- package/test/integration/compile.mjs +0 -135
- package/test/integration/compile.ts +0 -171
- package/tsup.node.config.ts +0 -37
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.
|
|
11
|
+
## [v2.2.0](https://github.com/zrwusa/data-structure-typed/compare/v2.0.4...main) (upcoming)
|
|
12
12
|
|
|
13
13
|
### Changes
|
|
14
14
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -82,6 +82,10 @@
|
|
|
82
82
|
- `git push`
|
|
83
83
|
- click the `New pull request` on Github https://github.com/zrwusa/data-structure-typed/branches
|
|
84
84
|
|
|
85
|
+
**performance inspection**
|
|
86
|
+
- `node --inspect-brk benchmark/all.js`
|
|
87
|
+
- chrome://inspect/#devices -> Open dedicated DevTools for Node
|
|
88
|
+
|
|
85
89
|
**Contributing New Data Structures**
|
|
86
90
|
|
|
87
91
|
- Make your pull requests to be **specific** and **focused**. Instead of
|
package/README.md
CHANGED
|
@@ -32,7 +32,6 @@ yarn add data-structure-typed
|
|
|
32
32
|
|
|
33
33
|
[Playground](https://stackblitz.com/edit/data-structure-typed-playground?file=src%2Fmain.ts)
|
|
34
34
|
|
|
35
|
-
|
|
36
35
|
```js
|
|
37
36
|
import {
|
|
38
37
|
Heap, Graph, Queue, Deque, PriorityQueue, BST, Trie, DoublyLinkedList,
|
|
@@ -50,7 +49,7 @@ npm i heap-typed --save
|
|
|
50
49
|
## Why
|
|
51
50
|
|
|
52
51
|
Do you envy C++ with [STL]() (std::), Python with [collections](), and Java with [java.util]() ? Well, no need to envy
|
|
53
|
-
anymore! JavaScript and TypeScript now have [data-structure-typed]().**`Benchmark`** compared with C++ STL.
|
|
52
|
+
anymore! JavaScript and TypeScript now have [data-structure-typed]().**`Benchmark`** compared with C++ STL.
|
|
54
53
|
**`API standards`** aligned with ES6 and Java. **`Usability`** is comparable to Python
|
|
55
54
|
|
|
56
55
|
|
|
@@ -214,8 +213,6 @@ Performance surpasses that of native JS/TS
|
|
|
214
213
|
</tr>
|
|
215
214
|
</table>
|
|
216
215
|
|
|
217
|
-
|
|
218
|
-
|
|
219
216
|
### Conciseness and uniformity
|
|
220
217
|
|
|
221
218
|
In [java.utils](), you need to memorize a table for all sequential data structures(Queue, Deque, LinkedList),
|
|
@@ -801,7 +798,6 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.key) // ['A', 'B', '
|
|
|
801
798
|
|
|
802
799
|
```
|
|
803
800
|
|
|
804
|
-
|
|
805
801
|
[//]: # (No deletion!!! Start of Example Replace Section)
|
|
806
802
|
|
|
807
803
|
|
|
@@ -832,9 +828,10 @@ macOS Big Sur
|
|
|
832
828
|
Version 11.7.9
|
|
833
829
|
|
|
834
830
|
***Our performance testing is conducted directly on the TypeScript source code. The actual performance of the compiled JavaScript code is generally 3 times higher. We have compared it with C++, and it is only 30% slower than C++.***
|
|
835
|
-
Try it
|
|
831
|
+
Try it
|
|
836
832
|
|
|
837
833
|
Just run
|
|
834
|
+
|
|
838
835
|
```shell
|
|
839
836
|
pnpm perf:rbtree
|
|
840
837
|
```
|
|
@@ -847,7 +844,8 @@ pnpm perf:rbtree
|
|
|
847
844
|
```
|
|
848
845
|
|
|
849
846
|
[//]: # (No deletion!!! Start of Replace Section)
|
|
850
|
-
<h2>comparison</h2><table><thead><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr></thead><tbody><tr><td>SRC PQ 1,000,000 add</td><td>36.30</td><td>0.04</td><td>0.01</td></tr><tr><td>CJS PQ 100,000 add</td><td>2.76</td><td>0.00</td><td>1.11e-4</td></tr><tr><td>MJS PQ 100,000 add</td><td>14.33</td><td>0.01</td><td>2.60e-4</td></tr><tr><td>CPT PQ 100,000 add</td><td>4.81</td><td>0.00</td><td>1.36e-4</td></tr><tr><td>SRC PQ 100,000 add & poll</td><td>22.57</td><td>0.02</td><td>4.66e-4</td></tr><tr><td>CJS PQ 100,000 add & poll</td><td>22.84</td><td>0.02</td><td>6.65e-4</td></tr><tr><td>MJS PQ 100,000 add & poll</td><td>23.43</td><td>0.02</td><td>0.00</td></tr><tr><td>CPT PQ 1,000,000 add & pop</td><td>181.14</td><td>0.18</td><td>0.03</td></tr><tr><td>CPT OM 100,000 add</td><td>26.64</td><td>0.03</td><td>0.00</td></tr><tr><td>CPT HM 100,000 set</td><td>5.90</td><td>0.01</td><td>8.46e-4</td></tr><tr><td>CPT HM 100,000 set & get</td><td>
|
|
847
|
+
<h2>comparison</h2><table><thead><tr><th>test name</th><th>time taken (ms)</th><th>sample mean (secs)</th><th>sample deviation</th></tr></thead><tbody><tr><td>SRC PQ 1,000,000 add</td><td>36.30</td><td>0.04</td><td>0.01</td></tr><tr><td>CJS PQ 100,000 add</td><td>2.76</td><td>0.00</td><td>1.11e-4</td></tr><tr><td>MJS PQ 100,000 add</td><td>14.33</td><td>0.01</td><td>2.60e-4</td></tr><tr><td>CPT PQ 100,000 add</td><td>4.81</td><td>0.00</td><td>1.36e-4</td></tr><tr><td>SRC PQ 100,000 add & poll</td><td>22.57</td><td>0.02</td><td>4.66e-4</td></tr><tr><td>CJS PQ 100,000 add & poll</td><td>22.84</td><td>0.02</td><td>6.65e-4</td></tr><tr><td>MJS PQ 100,000 add & poll</td><td>23.43</td><td>0.02</td><td>0.00</td></tr><tr><td>CPT PQ 1,000,000 add & pop</td><td>181.14</td><td>0.18</td><td>0.03</td></tr><tr><td>CPT OM 100,000 add</td><td>26.64</td><td>0.03</td><td>0.00</td></tr><tr><td>CPT HM 100,000 set</td><td>5.90</td><td>0.01</td><td>8.46e-4</td></tr><tr><td>CPT HM 100,000 set & get</td><td>
|
|
848
|
+
6.69</td><td>0.01</td><td>7.52e-4</td></tr><tr><td>CPT LL 1,000,000 unshift</td><td>19.78</td><td>0.02</td><td>0.01</td></tr><tr><td>CPT PQ 100,000 add & pop</td><td>14.36</td><td>0.01</td><td>0.00</td></tr><tr><td>CPT DQ 1,000,000 push</td><td>8.11</td><td>0.01</td><td>5.23e-4</td></tr><tr><td>CPT Q 1,000,000 push</td><td>30.25</td><td>0.03</td><td>0.01</td></tr><tr><td>CPT ST 1,000,000 push</td><td>27.10</td><td>0.03</td><td>0.00</td></tr><tr><td>CPT ST 1,000,000 push & pop</td><td>30.19</td><td>0.03</td><td>0.00</td></tr></tbody></table>[//]: # (No deletion!!! End of Replace Section)
|
|
851
849
|
|
|
852
850
|
## The corresponding relationships between data structures in different language standard libraries.
|
|
853
851
|
|
|
@@ -1182,6 +1180,20 @@ Copy the line below into the head tag in an HTML document.
|
|
|
1182
1180
|
|
|
1183
1181
|
#### development
|
|
1184
1182
|
|
|
1183
|
+
##### ES Module
|
|
1184
|
+
|
|
1185
|
+
```html
|
|
1186
|
+
|
|
1187
|
+
<script type="module">
|
|
1188
|
+
import { BST } from "https://cdn.jsdelivr.net/npm/data-structure-typed/dist/esm/index.mjs";
|
|
1189
|
+
|
|
1190
|
+
const bst = new BST([2, 1, 6, 7, 5, 3, 4, 8, 9]);
|
|
1191
|
+
bst.print();
|
|
1192
|
+
</script>
|
|
1193
|
+
```
|
|
1194
|
+
|
|
1195
|
+
##### UMD
|
|
1196
|
+
|
|
1185
1197
|
```html
|
|
1186
1198
|
|
|
1187
1199
|
<script src='https://cdn.jsdelivr.net/npm/data-structure-typed/dist/umd/data-structure-typed.js'></script>
|