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
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AVLTree,
|
|
3
|
+
BinaryTree,
|
|
4
|
+
BST,
|
|
5
|
+
Deque,
|
|
6
|
+
DoublyLinkedList,
|
|
7
|
+
HashMap,
|
|
8
|
+
Heap,
|
|
9
|
+
MaxPriorityQueue,
|
|
10
|
+
MinHeap,
|
|
11
|
+
MinPriorityQueue,
|
|
12
|
+
Queue,
|
|
13
|
+
RedBlackTree,
|
|
14
|
+
SinglyLinkedList,
|
|
15
|
+
Stack,
|
|
16
|
+
TreeMultiMap,
|
|
17
|
+
Trie
|
|
18
|
+
} from 'data-structure-typed';
|
|
19
|
+
|
|
20
|
+
describe('compile', () => {
|
|
21
|
+
it('compiles an empty array', () => {
|
|
22
|
+
const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8];
|
|
23
|
+
const orgStrArr = ['trie', 'trial', 'trick', 'trip', 'tree', 'trend', 'triangle', 'track', 'trace', 'transmit'];
|
|
24
|
+
const entries: [number, string][] = [
|
|
25
|
+
[6, '6'],
|
|
26
|
+
[1, '1'],
|
|
27
|
+
[2, '2'],
|
|
28
|
+
[7, '7'],
|
|
29
|
+
[5, '5'],
|
|
30
|
+
[3, '3'],
|
|
31
|
+
[4, '4'],
|
|
32
|
+
[9, '9'],
|
|
33
|
+
[8, '8']
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const queue = new Queue(orgArr);
|
|
37
|
+
queue.print();
|
|
38
|
+
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
39
|
+
|
|
40
|
+
const deque = new Deque(orgArr);
|
|
41
|
+
deque.print();
|
|
42
|
+
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
43
|
+
|
|
44
|
+
const sList = new SinglyLinkedList(orgArr);
|
|
45
|
+
sList.print();
|
|
46
|
+
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
47
|
+
|
|
48
|
+
const dList = new DoublyLinkedList(orgArr);
|
|
49
|
+
dList.print();
|
|
50
|
+
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
51
|
+
|
|
52
|
+
const stack = new Stack(orgArr);
|
|
53
|
+
stack.print();
|
|
54
|
+
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
55
|
+
|
|
56
|
+
const minHeap = new MinHeap(orgArr);
|
|
57
|
+
minHeap.print();
|
|
58
|
+
// [1, 5, 2, 7, 6, 3, 4, 9, 8]
|
|
59
|
+
|
|
60
|
+
const maxPQ = new MaxPriorityQueue(orgArr);
|
|
61
|
+
maxPQ.print();
|
|
62
|
+
// [9, 8, 4, 7, 5, 2, 3, 1, 6]
|
|
63
|
+
|
|
64
|
+
const biTree = new BinaryTree(entries);
|
|
65
|
+
biTree.print();
|
|
66
|
+
// ___6___
|
|
67
|
+
// / \
|
|
68
|
+
// ___1_ _2_
|
|
69
|
+
// / \ / \
|
|
70
|
+
// _7_ 5 3 4
|
|
71
|
+
// / \
|
|
72
|
+
// 9 8
|
|
73
|
+
|
|
74
|
+
const bst = new BST(entries);
|
|
75
|
+
bst.print();
|
|
76
|
+
// _____5___
|
|
77
|
+
// / \
|
|
78
|
+
// _2_ _7_
|
|
79
|
+
// / \ / \
|
|
80
|
+
// 1 3_ 6 8_
|
|
81
|
+
// \ \
|
|
82
|
+
// 4 9
|
|
83
|
+
|
|
84
|
+
const rbTree = new RedBlackTree(entries);
|
|
85
|
+
rbTree.print();
|
|
86
|
+
// ___4___
|
|
87
|
+
// / \
|
|
88
|
+
// _2_ _6___
|
|
89
|
+
// / \ / \
|
|
90
|
+
// 1 3 5 _8_
|
|
91
|
+
// / \
|
|
92
|
+
// 7 9
|
|
93
|
+
|
|
94
|
+
const avl = new AVLTree(entries);
|
|
95
|
+
avl.print();
|
|
96
|
+
// ___4___
|
|
97
|
+
// / \
|
|
98
|
+
// _2_ _6___
|
|
99
|
+
// / \ / \
|
|
100
|
+
// 1 3 5 _8_
|
|
101
|
+
// / \
|
|
102
|
+
// 7 9
|
|
103
|
+
|
|
104
|
+
const treeMulti = new TreeMultiMap(entries);
|
|
105
|
+
treeMulti.print();
|
|
106
|
+
// ___4___
|
|
107
|
+
// / \
|
|
108
|
+
// _2_ _6___
|
|
109
|
+
// / \ / \
|
|
110
|
+
// 1 3 5 _8_
|
|
111
|
+
// / \
|
|
112
|
+
// 7 9
|
|
113
|
+
|
|
114
|
+
const hm = new HashMap(entries);
|
|
115
|
+
hm.print();
|
|
116
|
+
// [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]
|
|
117
|
+
|
|
118
|
+
const rbTreeH = new RedBlackTree(hm);
|
|
119
|
+
rbTreeH.print();
|
|
120
|
+
// ___4___
|
|
121
|
+
// / \
|
|
122
|
+
// _2_ _6___
|
|
123
|
+
// / \ / \
|
|
124
|
+
// 1 3 5 _8_
|
|
125
|
+
// / \
|
|
126
|
+
// 7 9
|
|
127
|
+
|
|
128
|
+
const pq = new MinPriorityQueue(orgArr);
|
|
129
|
+
pq.print();
|
|
130
|
+
// [1, 5, 2, 7, 6, 3, 4, 9, 8]
|
|
131
|
+
|
|
132
|
+
const bst1 = new BST(pq);
|
|
133
|
+
bst1.print();
|
|
134
|
+
// _____5___
|
|
135
|
+
// / \
|
|
136
|
+
// _2_ _7_
|
|
137
|
+
// / \ / \
|
|
138
|
+
// 1 3_ 6 8_
|
|
139
|
+
// \ \
|
|
140
|
+
// 4 9
|
|
141
|
+
|
|
142
|
+
const dq1 = new Deque(orgArr);
|
|
143
|
+
dq1.print();
|
|
144
|
+
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
|
|
145
|
+
const rbTree1 = new RedBlackTree(dq1);
|
|
146
|
+
rbTree1.print();
|
|
147
|
+
// _____5___
|
|
148
|
+
// / \
|
|
149
|
+
// _2___ _7___
|
|
150
|
+
// / \ / \
|
|
151
|
+
// 1 _4 6 _9
|
|
152
|
+
// / /
|
|
153
|
+
// 3 8
|
|
154
|
+
|
|
155
|
+
const trie2 = new Trie(orgStrArr);
|
|
156
|
+
trie2.print();
|
|
157
|
+
// ['trie', 'trial', 'triangle', 'trick', 'trip', 'tree', 'trend', 'track', 'trace', 'transmit']
|
|
158
|
+
const heap2 = new Heap(trie2, { comparator: (a, b) => Number(a) - Number(b) });
|
|
159
|
+
heap2.print();
|
|
160
|
+
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
|
|
161
|
+
const dq2 = new Deque(heap2);
|
|
162
|
+
dq2.print();
|
|
163
|
+
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
|
|
164
|
+
const entries2 = dq2.map((el, i) => [i, el]);
|
|
165
|
+
const avl2 = new AVLTree(entries2);
|
|
166
|
+
avl2.print();
|
|
167
|
+
// ___3_______
|
|
168
|
+
// / \
|
|
169
|
+
// _1_ ___7_
|
|
170
|
+
// / \ / \
|
|
171
|
+
// 0 2 _5_ 8_
|
|
172
|
+
// / \ \
|
|
173
|
+
// 4 6 9
|
|
174
|
+
expect(avl2.size).toBe(10);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
tree.print(undefined, { isShowUndefined: true });
|
|
87
87
|
|
|
88
88
|
const node3 = tree.getNode(3);
|
|
89
|
-
if (node3) node3.right = tree.
|
|
89
|
+
if (node3) node3.right = tree.createNode(1);
|
|
90
90
|
console.log(tree.isPerfectlyBalanced(), `tree.isPerfectlyBalanced()`);
|
|
91
91
|
tree.print();
|
|
92
92
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AVLTreeCounter, AVLTreeCounterNode,
|
|
1
|
+
import { AVLTreeCounter, AVLTreeCounterNode, IBinaryTree } from '../../../../src';
|
|
2
2
|
import { isDebugTest } from '../../../config';
|
|
3
3
|
|
|
4
4
|
const isDebug = isDebugTest;
|
|
@@ -619,9 +619,10 @@ describe('AVLTreeCounter iterative methods test', () => {
|
|
|
619
619
|
|
|
620
620
|
it('The node obtained by get Node should match the node type', () => {
|
|
621
621
|
const node3 = avlCounter.getNode(3);
|
|
622
|
-
expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
623
|
-
expect(node3).toBeInstanceOf(BSTNode);
|
|
624
|
-
expect(node3).toBeInstanceOf(AVLTreeNode);
|
|
622
|
+
// expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
623
|
+
// expect(node3).toBeInstanceOf(BSTNode);
|
|
624
|
+
// expect(node3).toBeInstanceOf(AVLTreeNode);
|
|
625
|
+
expect(node3).toBeInstanceOf(AVLTreeCounterNode);
|
|
625
626
|
});
|
|
626
627
|
|
|
627
628
|
it('forEach should iterate over all elements', () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AVLTree, AVLTreeNode,
|
|
1
|
+
import { AVLTree, AVLTreeNode, IBinaryTree } from '../../../../src';
|
|
2
2
|
|
|
3
3
|
describe('AVL Tree Test', () => {
|
|
4
4
|
it('should perform various operations on a AVL Tree', () => {
|
|
@@ -379,8 +379,8 @@ describe('AVLTree iterative methods test', () => {
|
|
|
379
379
|
|
|
380
380
|
it('The node obtained by get Node should match the node type', () => {
|
|
381
381
|
const node3 = avlTree.getNode(3);
|
|
382
|
-
expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
383
|
-
expect(node3).toBeInstanceOf(BSTNode);
|
|
382
|
+
// expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
383
|
+
// expect(node3).toBeInstanceOf(BSTNode);
|
|
384
384
|
expect(node3).toBeInstanceOf(AVLTreeNode);
|
|
385
385
|
});
|
|
386
386
|
|
|
@@ -152,7 +152,7 @@ describe('BinaryTree', () => {
|
|
|
152
152
|
it('delete(): leaf/one-child/two-children/missing; updates size and minHeight', () => {
|
|
153
153
|
expect(binTree.getHeight(binTree.root, 'ITERATIVE')).toBe(-1);
|
|
154
154
|
expect(binTree.getMinHeight()).toBe(-1);
|
|
155
|
-
const node1 = binTree.
|
|
155
|
+
const node1 = binTree.createNode(1);
|
|
156
156
|
binTree.add(node1);
|
|
157
157
|
expect(binTree.size).toBe(1);
|
|
158
158
|
|
|
@@ -261,7 +261,7 @@ describe('BinaryTree', () => {
|
|
|
261
261
|
expect(binTree.isPerfectlyBalanced()).toBe(true);
|
|
262
262
|
const node3 = binTree.getNode(3);
|
|
263
263
|
|
|
264
|
-
if (node3) node3.right = binTree.
|
|
264
|
+
if (node3) node3.right = binTree.createNode(1);
|
|
265
265
|
expect(binTree.isPerfectlyBalanced()).toBe(false);
|
|
266
266
|
|
|
267
267
|
binTree.clear();
|
|
@@ -1587,7 +1587,7 @@ describe('Coverage boosters - close remaining uncovered branches', () => {
|
|
|
1587
1587
|
|
|
1588
1588
|
it('add(): build tree with no undefined child slot -> return false path', () => {
|
|
1589
1589
|
const t = new BinaryTree<number>();
|
|
1590
|
-
const r = t.
|
|
1590
|
+
const r = t.createNode(1)!;
|
|
1591
1591
|
// explicitly set left/right child pointers to null (not undefined) so BFS finds no insertion slot
|
|
1592
1592
|
(r as any).left = null;
|
|
1593
1593
|
(r as any).right = null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BST, BSTNode, IBinaryTree, Range } from '../../../../src';
|
|
2
2
|
import { isDebugTest, isTestStackOverflow, SYSTEM_MAX_CALL_STACK } from '../../../config';
|
|
3
3
|
|
|
4
4
|
const isDebug = isDebugTest;
|
|
@@ -1103,7 +1103,7 @@ describe('BST iterative methods test', () => {
|
|
|
1103
1103
|
|
|
1104
1104
|
it('The node obtained by get Node should match the node type', () => {
|
|
1105
1105
|
const node3 = bst.getNode(3);
|
|
1106
|
-
expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
1106
|
+
// expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
1107
1107
|
expect(node3).toBeInstanceOf(BSTNode);
|
|
1108
1108
|
});
|
|
1109
1109
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBinaryTree, RedBlackTree, RedBlackTreeNode } from '../../../../src';
|
|
2
2
|
import { getRandomInt, getRandomIntArray, magnitude } from '../../../utils';
|
|
3
3
|
import { OrderedMap } from 'js-sdsl';
|
|
4
4
|
|
|
@@ -641,8 +641,8 @@ describe('RedBlackTree 2', () => {
|
|
|
641
641
|
|
|
642
642
|
it('The node obtained by get Node should match the node type', () => {
|
|
643
643
|
const node3 = rbTree.getNode(3);
|
|
644
|
-
expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
645
|
-
expect(node3).toBeInstanceOf(BSTNode);
|
|
644
|
+
// expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
645
|
+
// expect(node3).toBeInstanceOf(BSTNode);
|
|
646
646
|
expect(node3).toBeInstanceOf(RedBlackTreeNode);
|
|
647
647
|
});
|
|
648
648
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBinaryTree, TreeCounter, TreeCounterNode } from '../../../../src';
|
|
2
2
|
import { isDebugTest } from '../../../config';
|
|
3
3
|
import { getRandomInt } from '../../../utils';
|
|
4
4
|
|
|
@@ -757,9 +757,10 @@ describe('TreeCounter iterative methods test', () => {
|
|
|
757
757
|
|
|
758
758
|
it('The node obtained by get Node should match the node type', () => {
|
|
759
759
|
const node3 = treeCounter.getNode(3);
|
|
760
|
-
expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
761
|
-
expect(node3).toBeInstanceOf(BSTNode);
|
|
762
|
-
expect(node3).toBeInstanceOf(RedBlackTreeNode);
|
|
760
|
+
// expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
761
|
+
// expect(node3).toBeInstanceOf(BSTNode);
|
|
762
|
+
// expect(node3).toBeInstanceOf(RedBlackTreeNode);
|
|
763
|
+
expect(node3).toBeInstanceOf(TreeCounterNode);
|
|
763
764
|
});
|
|
764
765
|
|
|
765
766
|
it('forEach should iterate over all elements', () => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBinaryTree, Range, TreeMultiMap, TreeMultiMapNode } from '../../../../src';
|
|
2
2
|
import { getRandomInt } from '../../../utils';
|
|
3
|
-
import { Range } from '../../../../src';
|
|
4
3
|
import { isDebugTest } from '../../../config';
|
|
5
4
|
import { costOfLiving } from './data/cost-of-living-by-country';
|
|
6
5
|
|
|
@@ -637,8 +636,8 @@ describe('TreeMultiMap 2', () => {
|
|
|
637
636
|
|
|
638
637
|
it('The node obtained by get Node should match the node type', () => {
|
|
639
638
|
const node3 = tmm.getNode(3);
|
|
640
|
-
expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
641
|
-
expect(node3).toBeInstanceOf(BSTNode);
|
|
639
|
+
// expect(node3).toBeInstanceOf(BinaryTreeNode);
|
|
640
|
+
// expect(node3).toBeInstanceOf(BSTNode);
|
|
642
641
|
expect(node3).toBeInstanceOf(TreeMultiMapNode);
|
|
643
642
|
});
|
|
644
643
|
|
|
@@ -1023,6 +1022,7 @@ function leftKey(tmm: TreeMultiMap<number, Product, Product>): number | undefine
|
|
|
1023
1022
|
const v = tmm.getLeftMost();
|
|
1024
1023
|
return v == null ? undefined : typeof v === 'object' ? v.key : v;
|
|
1025
1024
|
}
|
|
1025
|
+
|
|
1026
1026
|
function rightKey(tmm: TreeMultiMap<number, Product, Product>): number | undefined {
|
|
1027
1027
|
const v = tmm.getRightMost();
|
|
1028
1028
|
return v == null ? undefined : typeof v === 'object' ? v.key : v;
|
package/tsconfig.test.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "./tsconfig
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"target": "ES2018",
|
|
5
5
|
"lib": ["ES2018", "DOM"],
|
|
6
|
-
|
|
7
6
|
"module": "NodeNext",
|
|
8
7
|
"moduleResolution": "NodeNext",
|
|
9
|
-
|
|
10
8
|
"declaration": true,
|
|
11
9
|
"emitDeclarationOnly": true,
|
|
12
10
|
"declarationMap": false,
|
package/tsup.config.js
CHANGED
|
@@ -3,7 +3,7 @@ import { defineConfig } from 'tsup';
|
|
|
3
3
|
export default defineConfig([
|
|
4
4
|
{
|
|
5
5
|
entry: { "data-structure-typed": "src/index.ts" },
|
|
6
|
-
target: '
|
|
6
|
+
target: 'es2018',
|
|
7
7
|
format: ["iife"],
|
|
8
8
|
clean: true,
|
|
9
9
|
sourcemap: true,
|
|
@@ -13,10 +13,9 @@ export default defineConfig([
|
|
|
13
13
|
platform: "browser",
|
|
14
14
|
outExtension: () => ({ js: '.min.js' }),
|
|
15
15
|
},
|
|
16
|
-
// 配置 2: Unminified (开发调试用)
|
|
17
16
|
{
|
|
18
17
|
entry: { "data-structure-typed": "src/index.ts" },
|
|
19
|
-
target: '
|
|
18
|
+
target: 'es2018',
|
|
20
19
|
format: ["iife"],
|
|
21
20
|
clean: false,
|
|
22
21
|
sourcemap: true,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { defineConfig } from "tsup";
|
|
2
|
+
|
|
3
|
+
export default defineConfig([
|
|
4
|
+
// ESM (modern) - ES2022
|
|
5
|
+
{
|
|
6
|
+
entry: { index: "src/index.ts" },
|
|
7
|
+
format: ["esm"],
|
|
8
|
+
outDir: "dist/esm",
|
|
9
|
+
splitting: false,
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
minify: false,
|
|
12
|
+
keepNames: true,
|
|
13
|
+
treeshake: true,
|
|
14
|
+
clean: true,
|
|
15
|
+
target: "es2022",
|
|
16
|
+
outExtension() {
|
|
17
|
+
return { js: ".mjs" };
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
// ESM (legacy) - ES2018
|
|
22
|
+
{
|
|
23
|
+
entry: { index: "src/index.ts" },
|
|
24
|
+
format: ["esm"],
|
|
25
|
+
outDir: "dist/esm-legacy",
|
|
26
|
+
splitting: false,
|
|
27
|
+
sourcemap: true,
|
|
28
|
+
minify: false,
|
|
29
|
+
keepNames: true,
|
|
30
|
+
treeshake: true,
|
|
31
|
+
clean: false,
|
|
32
|
+
target: "es2018",
|
|
33
|
+
outExtension() {
|
|
34
|
+
return { js: ".mjs" };
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
// CJS (modern) - ES2022
|
|
39
|
+
{
|
|
40
|
+
entry: { index: "src/index.ts" },
|
|
41
|
+
format: ["cjs"],
|
|
42
|
+
outDir: "dist/cjs",
|
|
43
|
+
splitting: false,
|
|
44
|
+
sourcemap: true,
|
|
45
|
+
minify: false,
|
|
46
|
+
keepNames: true,
|
|
47
|
+
treeshake: true,
|
|
48
|
+
clean: false,
|
|
49
|
+
target: "es2022",
|
|
50
|
+
outExtension() {
|
|
51
|
+
return { js: ".cjs" };
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
// CJS (legacy) - ES2018
|
|
56
|
+
{
|
|
57
|
+
entry: { index: "src/index.ts" },
|
|
58
|
+
format: ["cjs"],
|
|
59
|
+
outDir: "dist/cjs-legacy",
|
|
60
|
+
splitting: false,
|
|
61
|
+
sourcemap: true,
|
|
62
|
+
minify: false,
|
|
63
|
+
keepNames: true,
|
|
64
|
+
treeshake: true,
|
|
65
|
+
clean: false,
|
|
66
|
+
target: "es2018",
|
|
67
|
+
outExtension() {
|
|
68
|
+
return { js: ".cjs" };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
]);
|