mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 09:28:26 +08:00
feat: Test running overhaul, switch to Prettier & reformat everything (#1407)
* chore: Switch to Node 20 + Vitest * chore: migrate to vitest mock functions * chore: code style (switch to prettier) * test: re-enable long-running test Seems the switch to Node 20 and Vitest has vastly improved the code's and / or the test's runtime! see #1193 * chore: code style * chore: fix failing tests * Updated Documentation in README.md * Update contribution guidelines to state usage of Prettier * fix: set prettier printWidth back to 80 * chore: apply updated code style automatically * fix: set prettier line endings to lf again * chore: apply updated code style automatically --------- Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
This commit is contained in:
@ -1,19 +1,19 @@
|
||||
/* Binary Search Tree!!
|
||||
*
|
||||
* Nodes that will go on the Binary Tree.
|
||||
* They consist of the data in them, the node to the left, the node
|
||||
* to the right, and the parent from which they came from.
|
||||
*
|
||||
* A binary tree is a data structure in which an element
|
||||
* has two successors(children). The left child is usually
|
||||
* smaller than the parent, and the right child is usually
|
||||
* bigger.
|
||||
*/
|
||||
*
|
||||
* Nodes that will go on the Binary Tree.
|
||||
* They consist of the data in them, the node to the left, the node
|
||||
* to the right, and the parent from which they came from.
|
||||
*
|
||||
* A binary tree is a data structure in which an element
|
||||
* has two successors(children). The left child is usually
|
||||
* smaller than the parent, and the right child is usually
|
||||
* bigger.
|
||||
*/
|
||||
|
||||
// class Node
|
||||
const Node = (function Node () {
|
||||
const Node = (function Node() {
|
||||
// Node in the tree
|
||||
function Node (val) {
|
||||
function Node(val) {
|
||||
this.value = val
|
||||
this.left = null
|
||||
this.right = null
|
||||
@ -32,7 +32,7 @@ const Node = (function Node () {
|
||||
}
|
||||
|
||||
// Visit a node
|
||||
Node.prototype.visit = function (output = value => console.log(value)) {
|
||||
Node.prototype.visit = function (output = (value) => console.log(value)) {
|
||||
// Recursively go left
|
||||
if (this.left !== null) {
|
||||
this.left.visit()
|
||||
@ -103,14 +103,14 @@ const Node = (function Node () {
|
||||
}
|
||||
// returns the constructor
|
||||
return Node
|
||||
}())
|
||||
})()
|
||||
|
||||
// class Tree
|
||||
const Tree = (function () {
|
||||
function Tree () {
|
||||
function Tree() {
|
||||
// Just store the root
|
||||
this.root = null
|
||||
};
|
||||
}
|
||||
|
||||
// Inorder traversal
|
||||
Tree.prototype.traverse = function () {
|
||||
@ -149,6 +149,6 @@ const Tree = (function () {
|
||||
|
||||
// returns the constructor
|
||||
return Tree
|
||||
}())
|
||||
})()
|
||||
|
||||
export { Tree }
|
||||
|
Reference in New Issue
Block a user