diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e34f57..182e92e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.38.5](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming) +## [v1.38.6](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming) ### Changes diff --git a/package-lock.json b/package-lock.json index 469cb06..a984c7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "data-structure-typed", - "version": "1.38.5", + "version": "1.38.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "data-structure-typed", - "version": "1.38.5", + "version": "1.38.6", "license": "MIT", "devDependencies": { "@types/benchmark": "^2.1.3", @@ -15,17 +15,17 @@ "@typescript-eslint/eslint-plugin": "^6.7.4", "@typescript-eslint/parser": "^6.7.4", "auto-changelog": "^2.4.0", - "avl-tree-typed": "^1.38.4", + "avl-tree-typed": "^1.38.5", "benchmark": "^2.1.4", - "binary-tree-typed": "^1.38.4", - "bst-typed": "^1.38.4", + "binary-tree-typed": "^1.38.5", + "bst-typed": "^1.38.5", "dependency-cruiser": "^14.1.0", "eslint": "^8.50.0", "eslint-config-prettier": "^9.0.0", "eslint-import-resolver-alias": "^1.1.2", "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.28.1", - "heap-typed": "^1.38.4", + "heap-typed": "^1.38.5", "istanbul-badges-readme": "^1.8.5", "jest": "^29.7.0", "prettier": "^3.0.3", @@ -2728,9 +2728,9 @@ } }, "node_modules/avl-tree-typed": { - "version": "1.38.4", - "resolved": "https://registry.npmjs.org/avl-tree-typed/-/avl-tree-typed-1.38.4.tgz", - "integrity": "sha512-m4+vC3t52CnPqMB5dxZI016OKMCxitk6vDsdqSadPHUeZd92E9LEQSHzgjdZ380FGcIZuz9q0IS7VTHR4F3+gg==", + "version": "1.38.5", + "resolved": "https://registry.npmjs.org/avl-tree-typed/-/avl-tree-typed-1.38.5.tgz", + "integrity": "sha512-rwVkzj8+N57YPCurFn+kmtxEd9xvE8QqYlOAkibRsEScN8E2z7cHkVlT0mxc26Q8HfLUvkqJjvEcwoLaHqYxzw==", "dev": true, "dependencies": { "data-structure-typed": "^1.38.4" @@ -2927,9 +2927,9 @@ } }, "node_modules/binary-tree-typed": { - "version": "1.38.4", - "resolved": "https://registry.npmjs.org/binary-tree-typed/-/binary-tree-typed-1.38.4.tgz", - "integrity": "sha512-InWS3ggQsmEyqgvaO+Veme/uTphUxaFQ1C7/9Bz07zcr8lV0riDsj0En9qwGTI8R4L32CpBL1cxQXJbk9Do45g==", + "version": "1.38.5", + "resolved": "https://registry.npmjs.org/binary-tree-typed/-/binary-tree-typed-1.38.5.tgz", + "integrity": "sha512-ksluya1YOjzQWMJzCNWnkjw/iinYvYMQhZYLwcdhwuiSy7nlDJpSxil3dh3sc3ffZDjCDi+FtTe2TOlOKBNzHQ==", "dev": true, "dependencies": { "data-structure-typed": "^1.38.4" @@ -3011,9 +3011,9 @@ } }, "node_modules/bst-typed": { - "version": "1.38.4", - "resolved": "https://registry.npmjs.org/bst-typed/-/bst-typed-1.38.4.tgz", - "integrity": "sha512-OCY+VQBfj8m8KYZullDuKrwYD8vzRBiIQ92hYDL3GWzuDMlTeEFUyIcDni0SR91JxRuUPbL7CuxN0fQRjDMKRg==", + "version": "1.38.5", + "resolved": "https://registry.npmjs.org/bst-typed/-/bst-typed-1.38.5.tgz", + "integrity": "sha512-JrfBhfqx9VFFQ/EMjG+CHCnEoJdrR3BZ0AGCpT2y6NbBWOdjuLghorVnvy85kiEpU06xSQewhqf3cWNz0pSrPA==", "dev": true, "dependencies": { "data-structure-typed": "^1.38.4" @@ -4771,9 +4771,9 @@ } }, "node_modules/heap-typed": { - "version": "1.38.4", - "resolved": "https://registry.npmjs.org/heap-typed/-/heap-typed-1.38.4.tgz", - "integrity": "sha512-fI+xbxoC3jpkmwqKIFRoJ8BGojd7FitEeYhwrkGpKnNMs9zp5dxA2qmrk+Gof0lDMuRca5CplVyInvGgL7cjzw==", + "version": "1.38.5", + "resolved": "https://registry.npmjs.org/heap-typed/-/heap-typed-1.38.5.tgz", + "integrity": "sha512-C9LQZScfnHGbhxL6wnUJEGwfg2oqdY10a0An3t/1pSVGEN91tmZzQS10BfYf5plQgF2fYNhZJbSkiuanUA0TgQ==", "dev": true, "dependencies": { "data-structure-typed": "^1.38.4" diff --git a/package.json b/package.json index dfce9bd..41e8e4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "data-structure-typed", - "version": "1.38.5", + "version": "1.38.6", "description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.", "main": "dist/cjs/index.js", "module": "dist/mjs/index.js", @@ -61,17 +61,17 @@ "@typescript-eslint/eslint-plugin": "^6.7.4", "@typescript-eslint/parser": "^6.7.4", "auto-changelog": "^2.4.0", - "avl-tree-typed": "^1.38.4", + "avl-tree-typed": "^1.38.5", "benchmark": "^2.1.4", - "binary-tree-typed": "^1.38.4", - "bst-typed": "^1.38.4", + "binary-tree-typed": "^1.38.5", + "bst-typed": "^1.38.5", "dependency-cruiser": "^14.1.0", "eslint": "^8.50.0", "eslint-config-prettier": "^9.0.0", "eslint-import-resolver-alias": "^1.1.2", "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.28.1", - "heap-typed": "^1.38.4", + "heap-typed": "^1.38.5", "istanbul-badges-readme": "^1.8.5", "jest": "^29.7.0", "prettier": "^3.0.3", diff --git a/src/data-structures/binary-tree/avl-tree.ts b/src/data-structures/binary-tree/avl-tree.ts index da4d2e6..e1c7bc7 100644 --- a/src/data-structures/binary-tree/avl-tree.ts +++ b/src/data-structures/binary-tree/avl-tree.ts @@ -6,20 +6,12 @@ * @license MIT License */ import {BST, BSTNode} from './bst'; -import type { - AVLTreeNodeNested, - AVLTreeOptions, - BinaryTreeDeletedResult, - BinaryTreeNodeKey, - DefaultMapCallback -} from '../../types'; +import type {AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeKey} from '../../types'; +import {MapCallback} from '../../types'; import {IBinaryTree} from '../../interfaces'; -import {MapCallback} from "../../types"; -export class AVLTreeNode = AVLTreeNodeNested> extends BSTNode< - V, - FAMILY -> { +export class AVLTreeNode = AVLTreeNodeNested> extends + BSTNode { height: number; constructor(key: BinaryTreeNodeKey, val?: V) { @@ -82,7 +74,8 @@ export class AVLTree = AVLTreeNode> extends B */ override delete>( identifier: ReturnType, - callback: C = this._defaultCallbackByKey as C): BinaryTreeDeletedResult[] { + callback: C = this._defaultCallbackByKey as C + ): BinaryTreeDeletedResult[] { const deletedResults = super.delete(identifier, callback); for (const {needBalanced} of deletedResults) { if (needBalanced) { @@ -166,7 +159,7 @@ export class AVLTree = AVLTreeNode> extends B // Balance Restoration: If a balance issue is discovered after inserting a node, it requires balance restoration operations. Balance restoration includes four basic cases where rotation operations need to be performed to fix the balance: switch ( this._balanceFactor(A) // second O(1) - ) { + ) { case -2: if (A && A.left) { if (this._balanceFactor(A.left) <= 0) { diff --git a/src/data-structures/binary-tree/binary-indexed-tree.ts b/src/data-structures/binary-tree/binary-indexed-tree.ts index da9dae0..467e918 100644 --- a/src/data-structures/binary-tree/binary-indexed-tree.ts +++ b/src/data-structures/binary-tree/binary-indexed-tree.ts @@ -17,7 +17,7 @@ export class BinaryIndexedTree { * @param - - `frequency`: The default frequency value. It is optional and has a default * value of 0. */ - constructor({frequency = 0, max}: {frequency?: number; max: number}) { + constructor({frequency = 0, max}: { frequency?: number; max: number }) { this._freq = frequency; this._max = max; this._freqMap = {0: 0}; diff --git a/src/data-structures/binary-tree/binary-tree.ts b/src/data-structures/binary-tree/binary-tree.ts index 70aa5d5..b18e848 100644 --- a/src/data-structures/binary-tree/binary-tree.ts +++ b/src/data-structures/binary-tree/binary-tree.ts @@ -116,8 +116,6 @@ export class BinaryTreeNode = * @template N - The type of the binary tree's nodes. */ export class BinaryTree = BinaryTreeNode> implements IBinaryTree { - private _loopType: IterationType = IterationType.ITERATIVE; - /** * Creates a new instance of BinaryTree. * @param {BinaryTreeOptions} [options] - The options for the binary tree. @@ -125,10 +123,27 @@ export class BinaryTree = BinaryTreeNode> constructor(options?: BinaryTreeOptions) { if (options !== undefined) { const {iterationType = IterationType.ITERATIVE} = options; - this._loopType = iterationType; + this._iterationType = iterationType; } } + private _iterationType: IterationType = IterationType.ITERATIVE; + + /** + * Get the iteration type used in the binary tree. + */ + get iterationType(): IterationType { + return this._iterationType; + } + + /** + * Set the iteration type for the binary tree. + * @param {IterationType} v - The new iteration type to set. + */ + set iterationType(v: IterationType) { + this._iterationType = v; + } + private _root: N | null = null; /** @@ -147,21 +162,6 @@ export class BinaryTree = BinaryTreeNode> return this._size; } - /** - * Get the iteration type used in the binary tree. - */ - get iterationType(): IterationType { - return this._loopType; - } - - /** - * Set the iteration type for the binary tree. - * @param {IterationType} v - The new iteration type to set. - */ - set iterationType(v: IterationType) { - this._loopType = v; - } - /** * Creates a new instance of BinaryTreeNode with the given key and value. * @param {BinaryTreeNodeKey} key - The key for the new node. @@ -222,7 +222,7 @@ export class BinaryTree = BinaryTreeNode> return; } - const key = typeof keyOrNode === 'number' ? keyOrNode : keyOrNode ? keyOrNode.key: undefined; + const key = typeof keyOrNode === 'number' ? keyOrNode : keyOrNode ? keyOrNode.key : undefined; const existNode = key !== undefined ? this.get(key, this._defaultCallbackByKey) : undefined; if (this.root) { @@ -284,14 +284,9 @@ export class BinaryTree = BinaryTreeNode> return keysOrNodes.length === this.addMany(keysOrNodes, data).length; } - delete>( - identifier: ReturnType | N - ): BinaryTreeDeletedResult[]; + delete>(identifier: ReturnType | N): BinaryTreeDeletedResult[]; - delete>( - identifier: ReturnType | N, - callback: C - ): BinaryTreeDeletedResult[]; + delete>(identifier: ReturnType | N, callback: C): BinaryTreeDeletedResult[]; /** * The `delete` function removes a node from a binary search tree and returns the deleted node along @@ -309,7 +304,8 @@ export class BinaryTree = BinaryTreeNode> */ delete>( identifier: ReturnType | N, - callback: C = this._defaultCallbackByKey as C): BinaryTreeDeletedResult[] { + callback: C = this._defaultCallbackByKey as C + ): BinaryTreeDeletedResult[] { const bstDeletedResult: BinaryTreeDeletedResult[] = []; if (!this.root) return bstDeletedResult; if (identifier instanceof BinaryTreeNode) callback = (node => node) as C; @@ -408,7 +404,7 @@ export class BinaryTree = BinaryTreeNode> return -1; } - const stack: {node: N; depth: number}[] = [{node: beginRoot, depth: 0}]; + const stack: { node: N; depth: number }[] = [{node: beginRoot, depth: 0}]; let maxHeight = 0; while (stack.length > 0) { @@ -492,26 +488,13 @@ export class BinaryTree = BinaryTreeNode> return this.getMinHeight(beginRoot) + 1 >= this.getHeight(beginRoot); } + getNodes>(identifier: ReturnType | N): N[]; - getNodes>( - identifier: ReturnType | N - ): N[]; + getNodes>(identifier: ReturnType | N, callback: C): N[]; - getNodes>( - identifier: ReturnType | N, - callback: C - ): N[]; + getNodes>(identifier: ReturnType | N, onlyOne: boolean): N[]; - getNodes>( - identifier: ReturnType | N, - onlyOne: boolean - ): N[]; - - getNodes>( - identifier: ReturnType | N, - callback: C, - onlyOne: boolean - ): N[]; + getNodes>(identifier: ReturnType | N, callback: C, onlyOne: boolean): N[]; getNodes>( identifier: ReturnType | N, @@ -528,7 +511,6 @@ export class BinaryTree = BinaryTreeNode> iterationType: IterationType ): N[]; - /** * The function `getNodes` returns an array of nodes that match a given node property, using either * recursive or iterative traversal. @@ -635,7 +617,12 @@ export class BinaryTree = BinaryTreeNode> get>(identifier: ReturnType | N, callback: C, beginRoot: N | null): N | null; - get>(identifier: ReturnType | N, callback: C, beginRoot: N | null, iterationType: IterationType): N | null; + get>( + identifier: ReturnType | N, + callback: C, + beginRoot: N | null, + iterationType: IterationType + ): N | null; /** * The function `get` returns the first node in a binary tree that matches the given property or key. @@ -900,7 +887,7 @@ export class BinaryTree = BinaryTreeNode> _traverse(beginRoot); } else { // 0: visit, 1: print - const stack: {opt: 0 | 1; node: N | null | undefined}[] = [{opt: 0, node: beginRoot}]; + const stack: { opt: 0 | 1; node: N | null | undefined }[] = [{opt: 0, node: beginRoot}]; while (stack.length > 0) { const cur = stack.pop(); diff --git a/src/data-structures/binary-tree/tree-multiset.ts b/src/data-structures/binary-tree/tree-multiset.ts index 464956b..9dbf025 100644 --- a/src/data-structures/binary-tree/tree-multiset.ts +++ b/src/data-structures/binary-tree/tree-multiset.ts @@ -5,7 +5,7 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type {BinaryTreeNodeKey, DefaultMapCallback, TreeMultisetNodeNested, TreeMultisetOptions} from '../../types'; +import type {BinaryTreeNodeKey, TreeMultisetNodeNested, TreeMultisetOptions} from '../../types'; import {BinaryTreeDeletedResult, CP, FamilyPosition, IterationType, MapCallback} from '../../types'; import {IBinaryTree} from '../../interfaces'; import {AVLTree, AVLTreeNode} from './avl-tree'; @@ -37,8 +37,7 @@ export class TreeMultisetNode< */ export class TreeMultiset = TreeMultisetNode> extends AVLTree - implements IBinaryTree -{ + implements IBinaryTree { /** * The constructor function for a TreeMultiset class in TypeScript, which extends another class and sets an option to * merge duplicated values. @@ -280,7 +279,9 @@ export class TreeMultiset = TreeMultiset */ override delete>( identifier: ReturnType, - callback: C = this._defaultCallbackByKey as C, ignoreCount = false): BinaryTreeDeletedResult[] { + callback: C = this._defaultCallbackByKey as C, + ignoreCount = false + ): BinaryTreeDeletedResult[] { const bstDeletedResult: BinaryTreeDeletedResult[] = []; if (!this.root) return bstDeletedResult; diff --git a/src/data-structures/graph/abstract-graph.ts b/src/data-structures/graph/abstract-graph.ts index e820f6b..f93a731 100644 --- a/src/data-structures/graph/abstract-graph.ts +++ b/src/data-structures/graph/abstract-graph.ts @@ -105,8 +105,7 @@ export abstract class AbstractEdge { export abstract class AbstractGraph< V extends AbstractVertex = AbstractVertex, E extends AbstractEdge = AbstractEdge -> implements IGraph -{ +> implements IGraph { private _vertices: Map = new Map(); get vertices(): Map { @@ -554,14 +553,14 @@ export abstract class AbstractGraph< } getMinDist && - distMap.forEach((d, v) => { - if (v !== srcVertex) { - if (d < minDist) { - minDist = d; - if (genPaths) minDest = v; - } + distMap.forEach((d, v) => { + if (v !== srcVertex) { + if (d < minDist) { + minDist = d; + if (genPaths) minDest = v; } - }); + } + }); genPaths && getPaths(minDest); @@ -623,7 +622,7 @@ export abstract class AbstractGraph< if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Infinity); } - const heap = new PriorityQueue<{key: number; val: V}>((a, b) => a.key - b.key); + const heap = new PriorityQueue<{ key: number; val: V }>((a, b) => a.key - b.key); heap.add({key: 0, val: srcVertex}); distMap.set(srcVertex, 0); @@ -852,7 +851,7 @@ export abstract class AbstractGraph< * `predecessor` property is a 2D array of vertices (or `null`) representing the predecessor vertices in the shortest * path between vertices in the */ - floyd(): {costs: number[][]; predecessor: (V | null)[][]} { + floyd(): { costs: number[][]; predecessor: (V | null)[][] } { const idAndVertices = [...this._vertices]; const n = idAndVertices.length; diff --git a/src/data-structures/graph/directed-graph.ts b/src/data-structures/graph/directed-graph.ts index 438ea75..f30a841 100644 --- a/src/data-structures/graph/directed-graph.ts +++ b/src/data-structures/graph/directed-graph.ts @@ -64,8 +64,7 @@ export class DirectedEdge extends AbstractEdge { export class DirectedGraph = DirectedVertex, E extends DirectedEdge = DirectedEdge> extends AbstractGraph - implements IGraph -{ + implements IGraph { /** * The constructor function initializes an instance of a class. */ diff --git a/src/data-structures/graph/undirected-graph.ts b/src/data-structures/graph/undirected-graph.ts index b962047..a7a81ff 100644 --- a/src/data-structures/graph/undirected-graph.ts +++ b/src/data-structures/graph/undirected-graph.ts @@ -51,12 +51,11 @@ export class UndirectedEdge extends AbstractEdge { } export class UndirectedGraph< - V extends UndirectedVertex = UndirectedVertex, - E extends UndirectedEdge = UndirectedEdge - > + V extends UndirectedVertex = UndirectedVertex, + E extends UndirectedEdge = UndirectedEdge +> extends AbstractGraph - implements IGraph -{ + implements IGraph { /** * The constructor initializes a new Map object to store edges. */ diff --git a/src/data-structures/hash/hash-map.ts b/src/data-structures/hash/hash-map.ts index f3a5213..5231237 100644 --- a/src/data-structures/hash/hash-map.ts +++ b/src/data-structures/hash/hash-map.ts @@ -157,7 +157,7 @@ export class HashMap { } } - *entries(): IterableIterator<[K, V]> { + * entries(): IterableIterator<[K, V]> { for (const bucket of this.table) { if (bucket) { for (const [key, value] of bucket) { diff --git a/src/data-structures/hash/tree-map.ts b/src/data-structures/hash/tree-map.ts index fe86360..a6d743d 100644 --- a/src/data-structures/hash/tree-map.ts +++ b/src/data-structures/hash/tree-map.ts @@ -1 +1,2 @@ -export class TreeMap {} +export class TreeMap { +} diff --git a/src/data-structures/hash/tree-set.ts b/src/data-structures/hash/tree-set.ts index 591aeda..65f14db 100644 --- a/src/data-structures/hash/tree-set.ts +++ b/src/data-structures/hash/tree-set.ts @@ -1 +1,2 @@ -export class TreeSet {} +export class TreeSet { +} diff --git a/src/data-structures/linked-list/doubly-linked-list.ts b/src/data-structures/linked-list/doubly-linked-list.ts index 972f137..ab9ddc5 100644 --- a/src/data-structures/linked-list/doubly-linked-list.ts +++ b/src/data-structures/linked-list/doubly-linked-list.ts @@ -594,7 +594,6 @@ export class DoublyLinkedList { return false; } - /** * The `insertBefore` function inserts a new value before an existing value or node in a doubly linked list. * @param {E | DoublyLinkedListNode} existingValueOrNode - The existing value or node in the doubly linked list diff --git a/src/data-structures/linked-list/singly-linked-list.ts b/src/data-structures/linked-list/singly-linked-list.ts index c4e1da9..18233d8 100644 --- a/src/data-structures/linked-list/singly-linked-list.ts +++ b/src/data-structures/linked-list/singly-linked-list.ts @@ -485,7 +485,7 @@ export class SinglyLinkedList { return count; } - *[Symbol.iterator]() { + * [Symbol.iterator]() { let current = this.head; while (current) { diff --git a/src/data-structures/matrix/matrix.ts b/src/data-structures/matrix/matrix.ts index 8f27617..7e8ae4b 100644 --- a/src/data-structures/matrix/matrix.ts +++ b/src/data-structures/matrix/matrix.ts @@ -14,7 +14,7 @@ export class MatrixNTI2D { * given initial value or 0 if not provided. * @param options - An object containing the following properties: */ - constructor(options: {row: number; col: number; initialVal?: V}) { + constructor(options: { row: number; col: number; initialVal?: V }) { const {row, col, initialVal} = options; this._matrix = new Array(row).fill(undefined).map(() => new Array(col).fill(initialVal || 0)); } diff --git a/src/data-structures/matrix/vector2d.ts b/src/data-structures/matrix/vector2d.ts index 1b215ca..e8e4074 100644 --- a/src/data-structures/matrix/vector2d.ts +++ b/src/data-structures/matrix/vector2d.ts @@ -10,7 +10,8 @@ export class Vector2D { public x: number = 0, public y: number = 0, public w: number = 1 // needed for matrix multiplication - ) {} + ) { + } /** * The function checks if the x and y values of a point are both zero. diff --git a/src/data-structures/queue/deque.ts b/src/data-structures/queue/deque.ts index 3290ab1..9faabda 100644 --- a/src/data-structures/queue/deque.ts +++ b/src/data-structures/queue/deque.ts @@ -9,7 +9,8 @@ import {DoublyLinkedList} from '../linked-list'; // O(n) time complexity of obtaining the value // O(1) time complexity of adding at the beginning and the end -export class Deque extends DoublyLinkedList {} +export class Deque extends DoublyLinkedList { +} // O(1) time complexity of obtaining the value // O(n) time complexity of adding at the beginning and the end @@ -19,9 +20,9 @@ export class ObjectDeque { if (capacity !== undefined) this._capacity = capacity; } - private _nodes: {[key: number]: E} = {}; + private _nodes: { [key: number]: E } = {}; - get nodes(): {[p: number]: E} { + get nodes(): { [p: number]: E } { return this._nodes; } @@ -156,7 +157,7 @@ export class ObjectDeque { return this._size <= 0; } - protected _seNodes(value: {[p: number]: E}) { + protected _seNodes(value: { [p: number]: E }) { this._nodes = value; } diff --git a/src/data-structures/queue/queue.ts b/src/data-structures/queue/queue.ts index 4549b31..d11dd92 100644 --- a/src/data-structures/queue/queue.ts +++ b/src/data-structures/queue/queue.ts @@ -183,7 +183,7 @@ export class Queue { return new Queue(this.nodes.slice(this.offset)); } - *[Symbol.iterator]() { + * [Symbol.iterator]() { for (const item of this.nodes) { yield item; } diff --git a/src/interfaces/binary-tree.ts b/src/interfaces/binary-tree.ts index ca63969..a499659 100644 --- a/src/interfaces/binary-tree.ts +++ b/src/interfaces/binary-tree.ts @@ -1,10 +1,10 @@ import {BinaryTreeNode} from '../data-structures'; -import {BinaryTreeDeletedResult, BinaryTreeNodeKey} from '../types'; +import {BinaryTreeDeletedResult, BinaryTreeNodeKey, MapCallback} from '../types'; export interface IBinaryTree> { createNode(key: BinaryTreeNodeKey, val?: N['val']): N; add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val']): N | null | undefined; - // delete(keyOrNode: BinaryTreeNodeKey | N): BinaryTreeDeletedResult[]; + delete>(identifier: ReturnType | N, callback: C): BinaryTreeDeletedResult[]; } diff --git a/src/types/data-structures/matrix/navigator.ts b/src/types/data-structures/matrix/navigator.ts index 9d8b9a9..34eddd9 100644 --- a/src/types/data-structures/matrix/navigator.ts +++ b/src/types/data-structures/matrix/navigator.ts @@ -1,6 +1,6 @@ export type Direction = 'up' | 'right' | 'down' | 'left'; -export type Turning = {[key in Direction]: Direction}; +export type Turning = { [key in Direction]: Direction }; export type NavigatorParams = { matrix: T[][]; diff --git a/src/types/helpers.ts b/src/types/helpers.ts index 93a5b64..0d80e9e 100644 --- a/src/types/helpers.ts +++ b/src/types/helpers.ts @@ -1,4 +1,4 @@ -import {BinaryTreeNodeKey} from "./data-structures"; +import {BinaryTreeNodeKey} from './data-structures'; export type Comparator = (a: T, b: T) => number; diff --git a/src/types/utils/utils.ts b/src/types/utils/utils.ts index f4d26c4..1f3a505 100644 --- a/src/types/utils/utils.ts +++ b/src/types/utils/utils.ts @@ -1,5 +1,5 @@ export type ToThunkFn = () => ReturnType; -export type Thunk = () => ReturnType & {__THUNK__: symbol}; +export type Thunk = () => ReturnType & { __THUNK__: symbol }; export type TrlFn = (...args: any[]) => any; export type TrlAsyncFn = (...args: any[]) => any; diff --git a/src/types/utils/validate-type.ts b/src/types/utils/validate-type.ts index ac9ff28..3ebf451 100644 --- a/src/types/utils/validate-type.ts +++ b/src/types/utils/validate-type.ts @@ -1,6 +1,6 @@ -export type KeyValueObject = {[key: string]: any}; +export type KeyValueObject = { [key: string]: any }; -export type KeyValueObjectWithKey = {[key: string]: any; key: string | number | symbol}; +export type KeyValueObjectWithKey = { [key: string]: any; key: string | number | symbol }; export type NonNumberNonObjectButDefined = string | boolean | symbol | null;