Skip to content

Commit

Permalink
fix: Remove export restrictions in package.json to enable ESModules t…
Browse files Browse the repository at this point in the history
…o work properly.
  • Loading branch information
zrwusa committed Nov 30, 2024
1 parent 8b24745 commit dd27393
Show file tree
Hide file tree
Showing 12 changed files with 1,296 additions and 764 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
- [`auto-changelog`](https://github.com/CookPete/auto-changelog)

## [v1.54.0](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)
## [v1.54.1](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)

### Changes

Expand Down
1,609 changes: 859 additions & 750 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
{
"name": "data-structure-typed",
"version": "1.54.1",
"version": "1.54.2",
"description": "Javascript Data Structure. Heap, Binary Tree, Red Black Tree, Linked List, Deque, Trie, HashMap, Directed Graph, Undirected Graph, Binary Search Tree(BST), AVL Tree, Priority Queue, Graph, Queue, Tree Multiset, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue, Stack. Benchmark compared with C++ STL. API aligned with ES6 and Java.util. Usability is comparable to Python",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"browser": "dist/umd/data-structure-typed.min.js",
"types": "dist/esm/index.d.ts",
"umd:main": "dist/umd/data-structure-typed.min.js",
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
}
},
"scripts": {
"build": "npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:docs-class",
"build": "npm run build:ecu && npm run build:docs-class",
"build:esm": "rm -rf dist/esm && tsc -p tsconfig-esm.json",
"build:cjs": "rm -rf dist/cjs && tsc -p tsconfig-cjs.json",
"build:umd": "tsup",
"build:ecu": "npm run build:esm && npm run build:cjs && npm run build:umd",
"build:docs": "npm run gen:examples && typedoc --out docs ./src",
"build:docs-class": "npm run gen:examples && typedoc --out docs ./src/data-structures",
"gen:examples": "ts-node scripts/testToExample.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/types/data-structures/binary-tree/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export * from './bst';
export * from './avl-tree';
export * from './segment-tree';
export * from './avl-tree-multi-map';
export * from './rb-tree';
export * from './red-black-tree';
export * from './tree-multi-map';
export * from './tree-counter';
export * from './avl-tree-counter';
2 changes: 1 addition & 1 deletion src/types/data-structures/binary-tree/tree-counter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import type { RedBlackTreeOptions } from './rb-tree';
import type { RedBlackTreeOptions } from './red-black-tree';

export type TreeCounterOptions<K, V, R> = RedBlackTreeOptions<K, V, R> & {};
2 changes: 1 addition & 1 deletion src/types/data-structures/binary-tree/tree-multi-map.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import type { RedBlackTreeOptions } from './rb-tree';
import type { RedBlackTreeOptions } from './red-black-tree';

export type TreeMultiMapOptions<K, V, R> = Omit<RedBlackTreeOptions<K, V, R>, 'isMapMode'> & {}
135 changes: 135 additions & 0 deletions test/integration/compile.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import { AVLTree, BinaryTree, BST, Deque, DoublyLinkedList, HashMap, Heap, MaxPriorityQueue, MinHeap, MinPriorityQueue, Queue, RedBlackTree, SinglyLinkedList, Stack, TreeMultiMap, Trie } from 'data-structure-typed';
const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8];
const orgStrArr = ['trie', 'trial', 'trick', 'trip', 'tree', 'trend', 'triangle', 'track', 'trace', 'transmit'];
const entries = [
[6, '6'],
[1, '1'],
[2, '2'],
[7, '7'],
[5, '5'],
[3, '3'],
[4, '4'],
[9, '9'],
[8, '8']
];
const queue = new Queue(orgArr);
queue.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
const deque = new Deque(orgArr);
deque.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
const sList = new SinglyLinkedList(orgArr);
sList.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
const dList = new DoublyLinkedList(orgArr);
dList.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
const stack = new Stack(orgArr);
stack.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
const minHeap = new MinHeap(orgArr);
minHeap.print();
// [1, 5, 2, 7, 6, 3, 4, 9, 8]
const maxPQ = new MaxPriorityQueue(orgArr);
maxPQ.print();
// [9, 8, 4, 7, 5, 2, 3, 1, 6]
const biTree = new BinaryTree(entries);
biTree.print();
// ___6___
// / \
// ___1_ _2_
// / \ / \
// _7_ 5 3 4
// / \
// 9 8
const bst = new BST(entries);
bst.print();
// _____5___
// / \
// _2_ _7_
// / \ / \
// 1 3_ 6 8_
// \ \
// 4 9
const rbTree = new RedBlackTree(entries);
rbTree.print();
// ___4___
// / \
// _2_ _6___
// / \ / \
// 1 3 5 _8_
// / \
// 7 9
const avl = new AVLTree(entries);
avl.print();
// ___4___
// / \
// _2_ _6___
// / \ / \
// 1 3 5 _8_
// / \
// 7 9
const treeMulti = new TreeMultiMap(entries);
treeMulti.print();
// ___4___
// / \
// _2_ _6___
// / \ / \
// 1 3 5 _8_
// / \
// 7 9
const hm = new HashMap(entries);
hm.print();
// [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]
const rbTreeH = new RedBlackTree(hm);
rbTreeH.print();
// ___4___
// / \
// _2_ _6___
// / \ / \
// 1 3 5 _8_
// / \
// 7 9
const pq = new MinPriorityQueue(orgArr);
pq.print();
// [1, 5, 2, 7, 6, 3, 4, 9, 8]
const bst1 = new BST(pq);
bst1.print();
// _____5___
// / \
// _2_ _7_
// / \ / \
// 1 3_ 6 8_
// \ \
// 4 9
const dq1 = new Deque(orgArr);
dq1.print();
// [6, 1, 2, 7, 5, 3, 4, 9, 8]
const rbTree1 = new RedBlackTree(dq1);
rbTree1.print();
// _____5___
// / \
// _2___ _7___
// / \ / \
// 1 _4 6 _9
// / /
// 3 8
const trie2 = new Trie(orgStrArr);
trie2.print();
// ['trie', 'trial', 'triangle', 'trick', 'trip', 'tree', 'trend', 'track', 'trace', 'transmit']
const heap2 = new Heap(trie2, { comparator: (a, b) => Number(a) - Number(b) });
heap2.print();
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
const dq2 = new Deque(heap2);
dq2.print();
// ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle']
const entries2 = dq2.map((el, i) => [i, el]);
const avl2 = new AVLTree(entries2);
avl2.print();
// ___3_______
// / \
// _1_ ___7_
// / \ / \
// 0 2 _5_ 8_
// / \ \
// 4 6 9
45 changes: 45 additions & 0 deletions test/performance/data-structures/binary-tree/avl-tree.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { AVLTree } from '../../../../';

Check warning on line 1 in test/performance/data-structures/binary-tree/avl-tree.test.js

View workflow job for this annotation

GitHub Actions / build (19.9.0)

'AVLTree' is defined but never used

Check warning on line 1 in test/performance/data-structures/binary-tree/avl-tree.test.js

View workflow job for this annotation

GitHub Actions / build (19.9.0)

'AVLTree' is defined but never used
import * as Benchmark from 'benchmark';

Check warning on line 2 in test/performance/data-structures/binary-tree/avl-tree.test.js

View workflow job for this annotation

GitHub Actions / build (19.9.0)

'Benchmark' is defined but never used

Check warning on line 2 in test/performance/data-structures/binary-tree/avl-tree.test.js

View workflow job for this annotation

GitHub Actions / build (19.9.0)

'Benchmark' is defined but never used
// import { getRandomIntArray, magnitude } from '../../../utils';
// const suite = new Benchmark.Suite();
// const avlTree = new AVLTree();
// const { HUNDRED_THOUSAND } = magnitude;
// const randomArray = getRandomIntArray(HUNDRED_THOUSAND, 0, HUNDRED_THOUSAND - 1, true);
// suite
// .add(`${HUNDRED_THOUSAND.toLocaleString()} add randomly`, () => {
// avlTree.clear();
// for (let i = 0; i < randomArray.length; i++)
// avlTree.add(randomArray[i]);
// })
// .add(`${HUNDRED_THOUSAND.toLocaleString()} add`, () => {
// avlTree.clear();
// for (let i = 0; i < randomArray.length; i++)
// avlTree.add(i);
// })
// .add(`${HUNDRED_THOUSAND.toLocaleString()} get`, () => {
// for (let i = 0; i < randomArray.length; i++)
// avlTree.get(randomArray[i]);
// })
// .add(`${HUNDRED_THOUSAND.toLocaleString()} getNode`, () => {
// for (let i = 0; i < randomArray.length; i++)
// avlTree.getNode(randomArray[i]);
// })
// .add(`${HUNDRED_THOUSAND.toLocaleString()} iterator`, () => {
// const entries = [...avlTree];
// return entries.length === HUNDRED_THOUSAND;
// })
// .add(`${HUNDRED_THOUSAND.toLocaleString()} add & delete orderly`, () => {
// avlTree.clear();
// for (let i = 0; i < randomArray.length; i++)
// avlTree.add(i);
// for (let i = 0; i < randomArray.length; i++)
// avlTree.delete(i);
// })
// .add(`${HUNDRED_THOUSAND.toLocaleString()} add & delete randomly`, () => {
// avlTree.clear();
// for (let i = 0; i < randomArray.length; i++)
// avlTree.add(randomArray[i]);
// for (let i = 0; i < randomArray.length; i++)
// avlTree.delete(randomArray[i]);
// });
// export { suite };
Loading

0 comments on commit dd27393

Please sign in to comment.