[core] remove all the unnecessary files and directories when publishing the npm package

This commit is contained in:
Revone 2023-09-09 23:49:53 +08:00
parent da68f2f97c
commit b0774bee5b
11 changed files with 1226 additions and 298 deletions

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

View file

@ -1,6 +1,14 @@
/.idea
/src
/tests
/notes
/docs
/backup
/backup
.dependency-cruiser.js
jest.config.js
package-lock.json
rename-clear-files.sh
tsconfig.json
webpack.config.js

174
README.md
View file

@ -3,25 +3,52 @@
## Brief
Javascript & TypeScript Data Structure collections.
## Algorithms
## Algorithms
DFS, DFSIterative, BFS, morris, Bellman-Ford Algorithm, Dijkstra's Algorithm, Floyd-Warshall Algorithm, Tarjan's Algorithm. Listed only a few out, you can discover more in API docs
## Code design
By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree -> TreeMultiset), you can seamlessly inherit the existing data structures to implement the customized ones you need. Object-oriented design stands as the optimal approach to data structure design.
# How
## install
### npm
```bash
npm install data-structure-typed
npm install data-structure-typed --save
```
## install
### yarn
```bash
yarn add data-structure-typed
yarn add data-structure-typed -D
```
### CDN
```html
<script src="https://cdn.jsdelivr.net/npm/data-structure-typed/dist/bundle.js"></script>
```
```javascript
const {AVLTree} = dataStructureTyped;
const {Heap, MinHeap, SinglyLinkedList, Stack, AVLTreeNode, BST, Trie, DirectedGraph, DirectedVertex, TreeMultiset} = dataStructureTyped;
```
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/dfs-pre-order.webp?raw=true)
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/test-avl-tree.webp?raw=true)
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/map-graph.webp?raw=true)
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/test-graphs.webp?raw=true)
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/cut-off-trees-for-golf.webp?raw=true)
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/parenthesis-check.webp?raw=true)
## API docs & Examples
[API Docs](https://data-structure-typed-docs.vercel.app)
[Live Examples](https://data-structure-typed-examples.vercel.app)
[//]: # (<a href="https://data-structure-typed-examples.vercel.app" target="_blank">Live Examples</a>)
<a href="https://github.com/zrwusa/data-structure-typed-examples" target="_blank">Examples Repository</a>
### Binary Search Tree (BST) snippet
@ -46,7 +73,7 @@ yarn add data-structure-typed
bst.get(6); // null
bst.isAVLBalanced(); // true or false
const bfsIDs = bst.BFS();
bfsIDs[0] === 11; // true
bfsIDs[0] === 11; // true
expect(bfsIDs[0]).toBe(11);
const objBST = new BST<BSTNode<{ id: number, keyA: number }>>();
@ -90,7 +117,7 @@ yarn add data-structure-typed
bst.get(6); // null
bst.isAVLBalanced(); // true or false
const bfsIDs = bst.BFS();
bfsIDs[0] === 11; // true
bfsIDs[0] === 11; // true
expect(bfsIDs[0]).toBe(11);
const objBST = new BST();
@ -130,8 +157,8 @@ import {DirectedGraph} from 'data-structure-typed';
graph.hasVertex('C'); // false
graph.addEdge('A', 'B');
graph.hasEdge('A', 'B'); // true
graph.hasEdge('B', 'A'); // false
graph.hasEdge('A', 'B'); // true
graph.hasEdge('B', 'A'); // false
graph.removeEdgeSrcToDest('A', 'B');
graph.hasEdge('A', 'B'); // false
@ -163,7 +190,6 @@ import {UndirectedGraph} from 'data-structure-typed';
Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D']
```
## Data Structures
<table>
<thead>
<tr>
@ -177,10 +203,8 @@ import {UndirectedGraph} from 'data-structure-typed';
<tbody>
<tr>
<td>Binary Tree</td>
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt="">
</img></td>
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt="">
</img></td>
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
<td><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary Tree</span></a></td>
<td><img src="https://raw.githubusercontent.com/zrwusa/assets/master/images/data-structure-typed/assets/tick.svg" alt=""></td>
</tr>
@ -355,30 +379,52 @@ import {UndirectedGraph} from 'data-structure-typed';
</tbody>
</table>
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/dfs-pre-order.webp?raw=true)
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/map-graph.webp?raw=true)
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/test-graphs.webp?raw=true)
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/cut-off-trees-for-golf.webp?raw=true)
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/examples/parenthesis-check.webp?raw=true)
## API docs & Examples
[API Docs](https://data-structure-typed-docs.vercel.app)
[Live Examples](https://data-structure-typed-examples.vercel.app)
<a href="https://data-structure-typed-examples.vercel.app" target="_blank">Live Examples</a>
[//]: # ([Examples Repository]&#40;https://github.com/zrwusa/data-structure-typed-examples&#41;)
<a href="https://github.com/zrwusa/data-structure-typed-examples" target="_blank">Examples Repository</a>
## API docs
<ul>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html" rel="nofollow"><span>AVLTree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTreeNode.html" rel="nofollow"><span>AVLTreeNode</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractEdge.html" rel="nofollow"><span>AbstractEdge</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html" rel="nofollow"><span>AbstractGraph</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractVertex.html" rel="nofollow"><span>AbstractVertex</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/ArrayDeque.html" rel="nofollow"><span>ArrayDeque</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html" rel="nofollow"><span>BST</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BSTNode.html" rel="nofollow"><span>BSTNode</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html" rel="nofollow"><span>BinaryIndexedTree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html" rel="nofollow"><span>BinaryTree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTreeNode.html" rel="nofollow"><span>BinaryTreeNode</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Character.html" rel="nofollow"><span>Character</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateMap.html" rel="nofollow"><span>CoordinateMap</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateSet.html" rel="nofollow"><span>CoordinateSet</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html" rel="nofollow"><span>Deque</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedEdge.html" rel="nofollow"><span>DirectedEdge</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html" rel="nofollow"><span>DirectedGraph</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedVertex.html" rel="nofollow"><span>DirectedVertex</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html" rel="nofollow"><span>DoublyLinkedList</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedListNode.html" rel="nofollow"><span>DoublyLinkedListNode</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html" rel="nofollow"><span>Heap</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Matrix2D.html" rel="nofollow"><span>Matrix2D</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MatrixNTI2D.html" rel="nofollow"><span>MatrixNTI2D</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxHeap.html" rel="nofollow"><span>MaxHeap</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html" rel="nofollow"><span>MaxPriorityQueue</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MinHeap.html" rel="nofollow"><span>MinHeap</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html" rel="nofollow"><span>MinPriorityQueue</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Navigator.html" rel="nofollow"><span>Navigator</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/ObjectDeque.html" rel="nofollow"><span>ObjectDeque</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html" rel="nofollow"><span>PriorityQueue</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html" rel="nofollow"><span>Queue</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html" rel="nofollow"><span>SegmentTree</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTreeNode.html" rel="nofollow"><span>SegmentTreeNode</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html" rel="nofollow"><span>SinglyLinkedList</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedListNode.html" rel="nofollow"><span>SinglyLinkedListNode</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html" rel="nofollow"><span>Stack</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultiSet.html" rel="nofollow"><span>TreeMultiSet</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html" rel="nofollow"><span>Trie</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/TrieNode.html" rel="nofollow"><span>TrieNode</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedEdge.html" rel="nofollow"><span>UndirectedEdge</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html" rel="nofollow"><span>UndirectedGraph</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedVertex.html" rel="nofollow"><span>UndirectedVertex</span></a></li>
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Vector2D.html" rel="nofollow"><span>Vector2D</span></a></li>
</ul>
# Why
@ -645,54 +691,8 @@ import {UndirectedGraph} from 'data-structure-typed';
</tbody>
</table>
![overview diagram](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/assets/overview-diagram-of-data-structures.png)
![complexities](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/assets/complexities-diff.jpg)
![complexities of data structures](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/assets/data-structure-complexities.jpg)
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/binary-tree/bst-rotation.gif&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/binary-tree/avl-tree-inserting.gif&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/tarjan.webp&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/adjacency-list.jpg&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/adjacency-list-pros-cons.jpg&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/adjacency-matrix.jpg&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/adjacency-matrix-pros-cons.jpg&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/dfs-can-do.jpg&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/edge-list.jpg&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/edge-list-pros-cons.jpg&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/max-flow.jpg&#41;)
[//]: # ()
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/mst.jpg&#41;)
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/tarjan-articulation-point-bridge.png&#41;)
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/tarjan-complicate-simple.png&#41;)
[//]: # (![]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/graph/tarjan-strongly-connected-component.png&#41;)
[//]: # (![overview diagram]&#40;https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/assets/overview-diagram-of-data-structures.png?raw=true&#41;)
![complexities](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/assets/complexities-diff.jpg?raw=true)
![complexities of data structures](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/assets/data-structure-complexities.jpg?raw=true)

1209
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,16 @@
{
"name": "data-structure-typed",
"version": "1.21.0",
"version": "1.21.2",
"description": "Javascript & TypeScript Data Structure Library, meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures, such as Binary Tree, AVL Tree, Binary Search Tree (BST), Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Singly Linked List, Hash, CoordinateSet, CoordinateMap, Heap, Doubly Linked List, Priority Queue, Max Priority Queue, Min Priority Queue, Queue, ObjectDeque, ArrayDeque, Stack, and Trie. Each data structure is thoughtfully designed and implemented using TypeScript to provide efficient, reliable, and easy-to-use solutions for your programming needs. Whether you're optimizing algorithms, managing data, or enhancing performance, our TypeScript Data Structure Library is your go-to resource. Elevate your coding experience with these fundamental building blocks for software development.",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf dist && npx tsc",
"build": "rm -rf dist && npx tsc && npm run build:browser",
"build:browser": "webpack",
"build:docs": "typedoc --out docs ./src",
"test": "jest",
"update:test-deps": "npm i avl-tree-typed binary-tree-typed bst-typed deque-typed directed-graph-typed doubly-linked-list-typed graph-typed heap-typed linked-list-typed max-heap-typed max-priority-queue-typed min-heap-typed min-priority-queue-typed priority-queue-typed singly-linked-list-typed stack-typed tree-multiset-typed trie-typed undirected-graph-typed --save-dev",
"build:docs": "typedoc --out docs ./src",
"deps:check": "dependency-cruiser src",
"build:publish": "npm run test && npm run build && npm run build:docs && npm publish"
},
@ -55,34 +58,36 @@
"url": "https://github.com/zrwusa/data-structure-typed/issues"
},
"homepage": "https://github.com/zrwusa/data-structure-typed#readme",
"types": "dist/index.d.ts",
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/node": "^20.4.9",
"avl-tree-typed": "^1.19.7",
"binary-tree-typed": "^1.19.7",
"bst-typed": "^1.19.7",
"avl-tree-typed": "^1.21.2",
"binary-tree-typed": "^1.21.2",
"bst-typed": "^1.21.2",
"dependency-cruiser": "^13.1.2",
"deque-typed": "^1.19.7",
"directed-graph-typed": "^1.19.7",
"doubly-linked-list-typed": "^1.19.7",
"graph-typed": "^1.19.7",
"heap-typed": "^1.19.7",
"deque-typed": "^1.21.2",
"directed-graph-typed": "^1.21.2",
"doubly-linked-list-typed": "^1.21.2",
"graph-typed": "^1.21.2",
"heap-typed": "^1.21.2",
"jest": "^29.6.2",
"linked-list-typed": "^1.19.7",
"max-heap-typed": "^1.19.7",
"max-priority-queue-typed": "^1.19.7",
"min-heap-typed": "^1.19.7",
"min-priority-queue-typed": "^1.19.7",
"priority-queue-typed": "^1.19.7",
"singly-linked-list-typed": "^1.19.7",
"stack-typed": "^1.19.7",
"tree-multiset-typed": "^1.19.7",
"trie-typed": "^1.19.7",
"linked-list-typed": "^1.21.2",
"max-heap-typed": "^1.21.2",
"max-priority-queue-typed": "^1.21.2",
"min-heap-typed": "^1.21.2",
"min-priority-queue-typed": "^1.21.2",
"priority-queue-typed": "^1.21.2",
"singly-linked-list-typed": "^1.21.2",
"stack-typed": "^1.21.2",
"tree-multiset-typed": "^1.21.2",
"trie-typed": "^1.21.2",
"ts-jest": "^29.1.1",
"ts-loader": "^9.4.4",
"typedoc": "^0.24.8",
"typescript": "^4.9.5",
"undirected-graph-typed": "^1.19.7"
"undirected-graph-typed": "^1.21.2",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"zod": "^3.22.2"

View file

@ -1,5 +1,5 @@
export type VertexId = string | number;
export type EdgeId = string;
export type DijkstraResult<V> =
{ distMap: Map<V, number>, distPaths?: Map<V, V[]> ,preMap: Map<V, V | null>, seen: Set<V>, paths: V[][], minDist: number, minPath: V[] }
{ distMap: Map<V, number>, distPaths?: Map<V, V[]>, preMap: Map<V, V | null>, seen: Set<V>, paths: V[][], minDist: number, minPath: V[] }
| null;

View file

@ -1,4 +1,4 @@
const {MaxHeap, MinHeap} = require('heap-typed');
const {MinHeap} = require('heap-typed');
describe('JS Heap Operation Test', () => {
it('should numeric heap work well', function () {

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CDN Test</title>
<script src="https://cdn.jsdelivr.net/npm/data-structure-typed/dist/bundle.js"></script>
</head>
<body>
<div id="app">
<ul class="modules">
</ul>
</div>
<script defer>
const $modules = document.querySelector('.modules');
const $avlTree = document.createElement('li');
const $avlTreeSpan = document.createElement('span');
$avlTreeSpan.innerText = 'AVLTree';
$avlTree.append($avlTreeSpan);
const {AVLTree} = dataStructureTyped;
const avlTree = new AVLTree();
avlTree.add(1, 1);
console.log(avlTree.BFS());
$modules.append($avlTree);
</script>
</body>
</html>

View file

@ -2,10 +2,12 @@
"compilerOptions": {
"declaration": true,
"outDir": "./dist",
"module": "commonjs",
"target": "es6",
"module": "CommonJS",
// "target": "CommonJS",
"target": "ES6",
"lib": [
"esnext"
"esnext",
"dom"
],
"strict": true,
"esModuleInterop": true,
@ -26,9 +28,7 @@
]
},
"include": [
"src",
],
"include": ["src/**/*.ts", "src/**/*.js"],
"exclude": [
// "node_modules/data-structure-typed",
"node_modules",

27
webpack.config.js Normal file
View file

@ -0,0 +1,27 @@
const path = require('path');
module.exports = [
{
mode:'production',
entry: './src/index.ts',
target: 'web',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
library: 'dataStructureTyped',
libraryTarget: 'window',
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/,
}
],
},
},
];