binary-tree-typed 1.19.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/.dependency-cruiser.js +449 -0
- package/README.md +700 -0
- package/dist/binary-tree.d.ts +30 -0
- package/dist/binary-tree.js +59 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/jest.config.js +5 -0
- package/package.json +63 -0
- package/tsconfig.json +37 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Tyler Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
8
|
+
import type { BinaryTreeNodeId, BinaryTreeNodeNested, BinaryTreeOptions } from 'data-structure-typed';
|
|
9
|
+
import { AbstractBinaryTree, AbstractBinaryTreeNode } from 'data-structure-typed';
|
|
10
|
+
import { IBinaryTree, IBinaryTreeNode } from 'data-structure-typed';
|
|
11
|
+
export declare class BinaryTreeNode<T = any, NEIGHBOR extends BinaryTreeNode<T, NEIGHBOR> = BinaryTreeNodeNested<T>> extends AbstractBinaryTreeNode<T, NEIGHBOR> implements IBinaryTreeNode<T, NEIGHBOR> {
|
|
12
|
+
}
|
|
13
|
+
export declare class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode> extends AbstractBinaryTree<N> implements IBinaryTree<N> {
|
|
14
|
+
/**
|
|
15
|
+
* This is a constructor function for a binary tree class that takes an optional options parameter.
|
|
16
|
+
* @param {BinaryTreeOptions} [options] - The `options` parameter is an optional object that can be passed to the
|
|
17
|
+
* constructor of the `BinaryTree` class. It allows you to customize the behavior of the binary tree by providing
|
|
18
|
+
* different configuration options.
|
|
19
|
+
*/
|
|
20
|
+
constructor(options?: BinaryTreeOptions);
|
|
21
|
+
/**
|
|
22
|
+
* The function creates a new binary tree node with an optional value.
|
|
23
|
+
* @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is of type
|
|
24
|
+
* `BinaryTreeNodeId`, which represents the unique identifier for each node in the binary tree.
|
|
25
|
+
* @param [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the value
|
|
26
|
+
* stored in the node.
|
|
27
|
+
* @returns a new instance of a BinaryTreeNode with the specified id and value.
|
|
28
|
+
*/
|
|
29
|
+
createNode(id: BinaryTreeNodeId, val?: N['val']): N;
|
|
30
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* data-structure-typed
|
|
4
|
+
*
|
|
5
|
+
* @author Tyler Zeng
|
|
6
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
7
|
+
* @license MIT License
|
|
8
|
+
*/
|
|
9
|
+
var __extends = (this && this.__extends) || (function () {
|
|
10
|
+
var extendStatics = function (d, b) {
|
|
11
|
+
extendStatics = Object.setPrototypeOf ||
|
|
12
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
13
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
14
|
+
return extendStatics(d, b);
|
|
15
|
+
};
|
|
16
|
+
return function (d, b) {
|
|
17
|
+
if (typeof b !== "function" && b !== null)
|
|
18
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
19
|
+
extendStatics(d, b);
|
|
20
|
+
function __() { this.constructor = d; }
|
|
21
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.BinaryTree = exports.BinaryTreeNode = void 0;
|
|
26
|
+
var data_structure_typed_1 = require("data-structure-typed");
|
|
27
|
+
var BinaryTreeNode = /** @class */ (function (_super) {
|
|
28
|
+
__extends(BinaryTreeNode, _super);
|
|
29
|
+
function BinaryTreeNode() {
|
|
30
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
31
|
+
}
|
|
32
|
+
return BinaryTreeNode;
|
|
33
|
+
}(data_structure_typed_1.AbstractBinaryTreeNode));
|
|
34
|
+
exports.BinaryTreeNode = BinaryTreeNode;
|
|
35
|
+
var BinaryTree = /** @class */ (function (_super) {
|
|
36
|
+
__extends(BinaryTree, _super);
|
|
37
|
+
/**
|
|
38
|
+
* This is a constructor function for a binary tree class that takes an optional options parameter.
|
|
39
|
+
* @param {BinaryTreeOptions} [options] - The `options` parameter is an optional object that can be passed to the
|
|
40
|
+
* constructor of the `BinaryTree` class. It allows you to customize the behavior of the binary tree by providing
|
|
41
|
+
* different configuration options.
|
|
42
|
+
*/
|
|
43
|
+
function BinaryTree(options) {
|
|
44
|
+
return _super.call(this, options) || this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The function creates a new binary tree node with an optional value.
|
|
48
|
+
* @param {BinaryTreeNodeId} id - The `id` parameter is the identifier for the binary tree node. It is of type
|
|
49
|
+
* `BinaryTreeNodeId`, which represents the unique identifier for each node in the binary tree.
|
|
50
|
+
* @param [val] - The `val` parameter is an optional value that can be assigned to the node. It represents the value
|
|
51
|
+
* stored in the node.
|
|
52
|
+
* @returns a new instance of a BinaryTreeNode with the specified id and value.
|
|
53
|
+
*/
|
|
54
|
+
BinaryTree.prototype.createNode = function (id, val) {
|
|
55
|
+
return new BinaryTreeNode(id, val);
|
|
56
|
+
};
|
|
57
|
+
return BinaryTree;
|
|
58
|
+
}(data_structure_typed_1.AbstractBinaryTree));
|
|
59
|
+
exports.BinaryTree = BinaryTree;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './binary-tree';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./binary-tree"), exports);
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "binary-tree-typed",
|
|
3
|
+
"version": "1.19.0",
|
|
4
|
+
"description": "Binary Tree. Javascript & Typescript Data Structure.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "rm -rf dist && npx tsc",
|
|
8
|
+
"test": "jest",
|
|
9
|
+
"build:docs": "typedoc --out docs ./src",
|
|
10
|
+
"deps:check": "dependency-cruiser src",
|
|
11
|
+
"build:publish": "npm run build && npm run build:docs && npm publish"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/zrwusa/data-structure-typed"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"Binary Tree",
|
|
19
|
+
"DFS",
|
|
20
|
+
"DFSIterative",
|
|
21
|
+
"BFS",
|
|
22
|
+
"Node",
|
|
23
|
+
"Parent",
|
|
24
|
+
"Child",
|
|
25
|
+
"Root",
|
|
26
|
+
"Leaf",
|
|
27
|
+
"Depth",
|
|
28
|
+
"Height",
|
|
29
|
+
"Traversal",
|
|
30
|
+
"Pre-order",
|
|
31
|
+
"In-order",
|
|
32
|
+
"Post-order",
|
|
33
|
+
"Level-order",
|
|
34
|
+
"Balanced",
|
|
35
|
+
"Unbalanced",
|
|
36
|
+
"Full Binary Tree",
|
|
37
|
+
"Complete Binary Tree",
|
|
38
|
+
"Perfect Binary Tree",
|
|
39
|
+
"Binary Search Tree",
|
|
40
|
+
"Binary Expression Tree",
|
|
41
|
+
"Binary Heap"
|
|
42
|
+
],
|
|
43
|
+
"author": "Tyler Zeng zrwusa@gmail.com",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/zrwusa/data-structure-typed/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/zrwusa/data-structure-typed#readme",
|
|
49
|
+
"types": "dist/index.d.ts",
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/jest": "^29.5.3",
|
|
52
|
+
"@types/node": "^20.4.9",
|
|
53
|
+
"dependency-cruiser": "^13.1.2",
|
|
54
|
+
"jest": "^29.6.2",
|
|
55
|
+
"ts-jest": "^29.1.1",
|
|
56
|
+
"typedoc": "^0.24.8",
|
|
57
|
+
"typescript": "^4.9.5"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"data-structure-typed": "^1.19.3",
|
|
61
|
+
"zod": "^3.22.2"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"declaration": true,
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"target": "es5",
|
|
7
|
+
"lib": [
|
|
8
|
+
"esnext",
|
|
9
|
+
],
|
|
10
|
+
"strict": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"moduleResolution": "node",
|
|
13
|
+
"declarationDir": "./dist",
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"downlevelIteration": true,
|
|
16
|
+
"experimentalDecorators": true,
|
|
17
|
+
// "allowJs": true,
|
|
18
|
+
// "allowSyntheticDefaultImports": true,
|
|
19
|
+
// "forceConsistentCasingInFileNames": true,
|
|
20
|
+
// "noFallthroughCasesInSwitch": true,
|
|
21
|
+
// "resolveJsonModule": true,
|
|
22
|
+
// "isolatedModules": true,
|
|
23
|
+
// "noEmit": true,
|
|
24
|
+
"typeRoots": [
|
|
25
|
+
"node_modules/@types"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
"include": [
|
|
30
|
+
"src",
|
|
31
|
+
],
|
|
32
|
+
"exclude": [
|
|
33
|
+
// "node_modules/data-structure-typed",
|
|
34
|
+
"node_modules",
|
|
35
|
+
"dist"
|
|
36
|
+
]
|
|
37
|
+
}
|