From ea8f993a4a268b76bdde8c668778382cd86bb7d9 Mon Sep 17 00:00:00 2001 From: Revone Date: Fri, 22 Sep 2023 10:43:16 +0800 Subject: [PATCH] [prettier] bracket spacing false --- .prettierrc.js | 2 +- .../binary-tree/abstract-binary-tree.ts | 48 +++++++++---------- src/data-structures/binary-tree/avl-tree.ts | 8 ++-- .../binary-tree/binary-tree.ts | 6 +-- src/data-structures/binary-tree/bst.ts | 16 ++----- src/data-structures/binary-tree/rb-tree.ts | 6 +-- .../binary-tree/segment-tree.ts | 2 +- .../binary-tree/tree-multiset.ts | 16 +++---- src/data-structures/graph/abstract-graph.ts | 32 ++++++------- src/data-structures/graph/directed-graph.ts | 8 ++-- src/data-structures/graph/map-graph.ts | 4 +- src/data-structures/graph/undirected-graph.ts | 8 ++-- src/data-structures/heap/heap.ts | 6 +-- src/data-structures/heap/max-heap.ts | 6 +-- src/data-structures/heap/min-heap.ts | 6 +-- src/data-structures/matrix/matrix.ts | 4 +- src/data-structures/matrix/navigator.ts | 6 +-- .../priority-queue/max-priority-queue.ts | 4 +- .../priority-queue/min-priority-queue.ts | 4 +- .../priority-queue/priority-queue.ts | 6 +-- src/data-structures/queue/deque.ts | 8 ++-- src/data-structures/queue/queue.ts | 2 +- src/data-structures/tree/tree.ts | 2 +- src/interfaces/abstract-binary-tree.ts | 2 +- src/interfaces/abstract-graph.ts | 2 +- src/interfaces/avl-tree.ts | 6 +-- src/interfaces/binary-tree.ts | 4 +- src/interfaces/bst.ts | 6 +-- src/interfaces/directed-graph.ts | 4 +- src/interfaces/rb-tree.ts | 6 +-- src/interfaces/tree-multiset.ts | 6 +-- src/interfaces/undirected-graph.ts | 4 +- src/types/data-structures/navigator.ts | 2 +- src/types/utils/utils.ts | 2 +- src/types/utils/validate-type.ts | 4 +- src/utils/utils.ts | 6 +-- 36 files changed, 129 insertions(+), 135 deletions(-) diff --git a/.prettierrc.js b/.prettierrc.js index dfdbfaa..661979f 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,6 +1,6 @@ module.exports = { arrowParens: 'avoid', - bracketSpacing: true, + bracketSpacing: false, htmlWhitespaceSensitivity: 'css', insertPragma: false, bracketSameLine: false, diff --git a/src/data-structures/binary-tree/abstract-binary-tree.ts b/src/data-structures/binary-tree/abstract-binary-tree.ts index 70ce521..947634f 100644 --- a/src/data-structures/binary-tree/abstract-binary-tree.ts +++ b/src/data-structures/binary-tree/abstract-binary-tree.ts @@ -6,7 +6,7 @@ * @license MIT License */ -import { trampoline } from '../../utils'; +import {trampoline} from '../../utils'; import type { AbstractBinaryTreeNodeNested, AbstractBinaryTreeNodeProperties, @@ -17,8 +17,8 @@ import type { DFSOrderPattern, NodeOrPropertyName } from '../../types'; -import { AbstractBinaryTreeOptions, FamilyPosition, LoopType } from '../../types'; -import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from '../../interfaces'; +import {AbstractBinaryTreeOptions, FamilyPosition, LoopType} from '../../types'; +import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from '../../interfaces'; export abstract class AbstractBinaryTreeNode< T = any, @@ -145,7 +145,7 @@ export abstract class AbstractBinaryTree 0) { - const { node, depth } = stack.pop()!; + const {node, depth} = stack.pop()!; if (node.left) { - stack.push({ node: node.left, depth: depth + 1 }); + stack.push({node: node.left, depth: depth + 1}); } if (node.right) { - stack.push({ node: node.right, depth: depth + 1 }); + stack.push({node: node.right, depth: depth + 1}); } maxHeight = Math.max(maxHeight, depth); @@ -1086,7 +1086,7 @@ export abstract class AbstractBinaryTree 0) { const cur = stack.pop(); @@ -1096,24 +1096,24 @@ export abstract class AbstractBinaryTree * @license MIT License */ -import { BST, BSTNode } from './bst'; -import type { AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeId } from '../../types'; -import { IAVLTree, IAVLTreeNode } from '../../interfaces'; +import {BST, BSTNode} from './bst'; +import type {AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeId} from '../../types'; +import {IAVLTree, IAVLTreeNode} from '../../interfaces'; export class AVLTreeNode = AVLTreeNodeNested> extends BSTNode @@ -67,7 +67,7 @@ export class AVLTree = AVLTreeNode> extends B */ override remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult[] { const deletedResults = super.remove(id, isUpdateAllLeftSum); - for (const { needBalanced } of deletedResults) { + for (const {needBalanced} of deletedResults) { if (needBalanced) { this._balancePath(needBalanced); } diff --git a/src/data-structures/binary-tree/binary-tree.ts b/src/data-structures/binary-tree/binary-tree.ts index 4e7ff81..e56a12e 100644 --- a/src/data-structures/binary-tree/binary-tree.ts +++ b/src/data-structures/binary-tree/binary-tree.ts @@ -6,9 +6,9 @@ * @license MIT License */ -import type { BinaryTreeNodeId, BinaryTreeNodeNested, BinaryTreeOptions } from '../../types'; -import { AbstractBinaryTree, AbstractBinaryTreeNode } from './abstract-binary-tree'; -import { IBinaryTree, IBinaryTreeNode } from '../../interfaces'; +import type {BinaryTreeNodeId, BinaryTreeNodeNested, BinaryTreeOptions} from '../../types'; +import {AbstractBinaryTree, AbstractBinaryTreeNode} from './abstract-binary-tree'; +import {IBinaryTree, IBinaryTreeNode} from '../../interfaces'; export class BinaryTreeNode = BinaryTreeNodeNested> extends AbstractBinaryTreeNode diff --git a/src/data-structures/binary-tree/bst.ts b/src/data-structures/binary-tree/bst.ts index 07f9fe1..c1ea1f4 100644 --- a/src/data-structures/binary-tree/bst.ts +++ b/src/data-structures/binary-tree/bst.ts @@ -5,16 +5,10 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type { - BinaryTreeNodeId, - BinaryTreeNodePropertyName, - BSTComparator, - BSTNodeNested, - BSTOptions -} from '../../types'; -import { CP, LoopType } from '../../types'; -import { BinaryTree, BinaryTreeNode } from './binary-tree'; -import { IBST, IBSTNode } from '../../interfaces'; +import type {BinaryTreeNodeId, BinaryTreeNodePropertyName, BSTComparator, BSTNodeNested, BSTOptions} from '../../types'; +import {CP, LoopType} from '../../types'; +import {BinaryTree, BinaryTreeNode} from './binary-tree'; +import {IBST, IBSTNode} from '../../interfaces'; export class BSTNode = BSTNodeNested> extends BinaryTreeNode @@ -33,7 +27,7 @@ export class BST = BSTNode> extends BinaryTree constructor(options?: BSTOptions) { super(options); if (options !== undefined) { - const { comparator } = options; + const {comparator} = options; if (comparator !== undefined) { this._comparator = comparator; } diff --git a/src/data-structures/binary-tree/rb-tree.ts b/src/data-structures/binary-tree/rb-tree.ts index 226d0e5..6b50061 100644 --- a/src/data-structures/binary-tree/rb-tree.ts +++ b/src/data-structures/binary-tree/rb-tree.ts @@ -1,6 +1,6 @@ -import { BinaryTreeNodeId, RBColor, RBTreeNodeNested, RBTreeOptions } from '../../types'; -import { IRBTree, IRBTreeNode } from '../../interfaces/rb-tree'; -import { BST, BSTNode } from './bst'; +import {BinaryTreeNodeId, RBColor, RBTreeNodeNested, RBTreeOptions} from '../../types'; +import {IRBTree, IRBTreeNode} from '../../interfaces/rb-tree'; +import {BST, BSTNode} from './bst'; export class RBTreeNode = RBTreeNodeNested> extends BSTNode diff --git a/src/data-structures/binary-tree/segment-tree.ts b/src/data-structures/binary-tree/segment-tree.ts index e377866..4dda8dd 100644 --- a/src/data-structures/binary-tree/segment-tree.ts +++ b/src/data-structures/binary-tree/segment-tree.ts @@ -6,7 +6,7 @@ * @license MIT License */ -import type { SegmentTreeNodeVal } from '../../types'; +import type {SegmentTreeNodeVal} from '../../types'; export class SegmentTreeNode { constructor(start: number, end: number, sum: number, val?: SegmentTreeNodeVal | null) { diff --git a/src/data-structures/binary-tree/tree-multiset.ts b/src/data-structures/binary-tree/tree-multiset.ts index bf6a6b9..beec9d8 100644 --- a/src/data-structures/binary-tree/tree-multiset.ts +++ b/src/data-structures/binary-tree/tree-multiset.ts @@ -5,10 +5,10 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type { BinaryTreeNodeId, TreeMultisetNodeNested, TreeMultisetOptions } from '../../types'; -import { BinaryTreeDeletedResult, CP, DFSOrderPattern, FamilyPosition, LoopType } from '../../types'; -import { ITreeMultiset, ITreeMultisetNode } from '../../interfaces'; -import { AVLTree, AVLTreeNode } from './avl-tree'; +import type {BinaryTreeNodeId, TreeMultisetNodeNested, TreeMultisetOptions} from '../../types'; +import {BinaryTreeDeletedResult, CP, DFSOrderPattern, FamilyPosition, LoopType} from '../../types'; +import {ITreeMultiset, ITreeMultisetNode} from '../../interfaces'; +import {AVLTree, AVLTreeNode} from './avl-tree'; export class TreeMultisetNode = TreeMultisetNodeNested> extends AVLTreeNode @@ -54,7 +54,7 @@ export class TreeMultiset = TreeMultiset * TreeMultiset. */ constructor(options?: TreeMultisetOptions) { - super({ ...options }); + super({...options}); } private _count = 0; @@ -84,7 +84,7 @@ export class TreeMultiset = TreeMultiset * @returns the `destNode` after swapping its values with the `srcNode`. */ override swapLocation(srcNode: N, destNode: N): N { - const { id, val, count, height } = destNode; + const {id, val, count, height} = destNode; const tempNode = this.createNode(id, val, count); if (tempNode) { tempNode.height = height; @@ -321,7 +321,7 @@ export class TreeMultiset = TreeMultiset if (!parent) { if (curr.right !== undefined) this._setRoot(curr.right); } else { - const { familyPosition: fp } = curr; + const {familyPosition: fp} = curr; if (fp === FamilyPosition.LEFT || fp === FamilyPosition.ROOT_LEFT) { parent.left = curr.right; } else if (fp === FamilyPosition.RIGHT || fp === FamilyPosition.ROOT_RIGHT) { @@ -349,7 +349,7 @@ export class TreeMultiset = TreeMultiset this._setCount(this.count - orgCurrent.count); } - bstDeletedResult.push({ deleted: orgCurrent, needBalanced }); + bstDeletedResult.push({deleted: orgCurrent, needBalanced}); if (needBalanced) { this._balancePath(needBalanced); diff --git a/src/data-structures/graph/abstract-graph.ts b/src/data-structures/graph/abstract-graph.ts index a1d2299..c020eba 100644 --- a/src/data-structures/graph/abstract-graph.ts +++ b/src/data-structures/graph/abstract-graph.ts @@ -5,10 +5,10 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import { arrayRemove, uuidV4 } from '../../utils'; -import { PriorityQueue } from '../priority-queue'; -import type { DijkstraResult, VertexId } from '../../types'; -import { IAbstractGraph } from '../../interfaces'; +import {arrayRemove, uuidV4} from '../../utils'; +import {PriorityQueue} from '../priority-queue'; +import type {DijkstraResult, VertexId} from '../../types'; +import {IAbstractGraph} from '../../interfaces'; export abstract class AbstractVertex { /** @@ -530,7 +530,7 @@ export abstract class AbstractGraph< if (genPaths) { getPaths(destVertex); } - return { distMap, preMap, seen, paths, minDist, minPath }; + return {distMap, preMap, seen, paths, minDist, minPath}; } const neighbors = this.getNeighbors(cur); for (const neighbor of neighbors) { @@ -564,7 +564,7 @@ export abstract class AbstractGraph< genPaths && getPaths(minDest); - return { distMap, preMap, seen, paths, minDist, minPath }; + return {distMap, preMap, seen, paths, minDist, minPath}; } /** @@ -617,10 +617,10 @@ export abstract class AbstractGraph< if (vertexOrId instanceof AbstractVertex) distMap.set(vertexOrId, Infinity); } - const heap = new PriorityQueue<{ id: number; val: V }>({ + const heap = new PriorityQueue<{id: number; val: V}>({ comparator: (a, b) => a.id - b.id }); - heap.add({ id: 0, val: srcVertex }); + heap.add({id: 0, val: srcVertex}); distMap.set(srcVertex, 0); preMap.set(srcVertex, null); @@ -661,7 +661,7 @@ export abstract class AbstractGraph< if (genPaths) { getPaths(destVertex); } - return { distMap, preMap, seen, paths, minDist, minPath }; + return {distMap, preMap, seen, paths, minDist, minPath}; } const neighbors = this.getNeighbors(cur); for (const neighbor of neighbors) { @@ -671,7 +671,7 @@ export abstract class AbstractGraph< const distSrcToNeighbor = distMap.get(neighbor); if (distSrcToNeighbor) { if (dist + weight < distSrcToNeighbor) { - heap.add({ id: dist + weight, val: neighbor }); + heap.add({id: dist + weight, val: neighbor}); preMap.set(neighbor, cur); distMap.set(neighbor, dist + weight); } @@ -698,7 +698,7 @@ export abstract class AbstractGraph< getPaths(minDest); } - return { distMap, preMap, seen, paths, minDist, minPath }; + return {distMap, preMap, seen, paths, minDist, minPath}; } /** @@ -735,7 +735,7 @@ export abstract class AbstractGraph< // TODO let hasNegativeCycle: boolean | undefined; if (scanNegativeCycle) hasNegativeCycle = false; - if (!srcVertex) return { hasNegativeCycle, distMap, preMap, paths, min, minPath }; + if (!srcVertex) return {hasNegativeCycle, distMap, preMap, paths, min, minPath}; const vertices = this._vertices; const numOfVertices = vertices.size; @@ -807,7 +807,7 @@ export abstract class AbstractGraph< } } - return { hasNegativeCycle, distMap, preMap, paths, min, minPath }; + return {hasNegativeCycle, distMap, preMap, paths, min, minPath}; } /** @@ -848,7 +848,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; @@ -880,7 +880,7 @@ export abstract class AbstractGraph< } } } - return { costs, predecessor }; + return {costs, predecessor}; } /** @@ -1011,7 +1011,7 @@ export abstract class AbstractGraph< }); } - return { dfnMap, lowMap, bridges, articulationPoints, SCCs, cycles }; + return {dfnMap, lowMap, bridges, articulationPoints, SCCs, cycles}; } protected abstract _addEdgeOnly(edge: E): boolean; diff --git a/src/data-structures/graph/directed-graph.ts b/src/data-structures/graph/directed-graph.ts index 5c86df6..f9da13e 100644 --- a/src/data-structures/graph/directed-graph.ts +++ b/src/data-structures/graph/directed-graph.ts @@ -5,10 +5,10 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import { arrayRemove } from '../../utils'; -import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph'; -import type { TopologicalStatus, VertexId } from '../../types'; -import { IDirectedGraph } from '../../interfaces'; +import {arrayRemove} from '../../utils'; +import {AbstractEdge, AbstractGraph, AbstractVertex} from './abstract-graph'; +import type {TopologicalStatus, VertexId} from '../../types'; +import {IDirectedGraph} from '../../interfaces'; export class DirectedVertex extends AbstractVertex { /** diff --git a/src/data-structures/graph/map-graph.ts b/src/data-structures/graph/map-graph.ts index ff02681..9375e65 100644 --- a/src/data-structures/graph/map-graph.ts +++ b/src/data-structures/graph/map-graph.ts @@ -1,5 +1,5 @@ -import { MapGraphCoordinate, VertexId } from '../../types'; -import { DirectedEdge, DirectedGraph, DirectedVertex } from './directed-graph'; +import {MapGraphCoordinate, VertexId} from '../../types'; +import {DirectedEdge, DirectedGraph, DirectedVertex} from './directed-graph'; export class MapVertex extends DirectedVertex { /** diff --git a/src/data-structures/graph/undirected-graph.ts b/src/data-structures/graph/undirected-graph.ts index 29590be..8550b64 100644 --- a/src/data-structures/graph/undirected-graph.ts +++ b/src/data-structures/graph/undirected-graph.ts @@ -5,10 +5,10 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import { arrayRemove } from '../../utils'; -import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph'; -import type { VertexId } from '../../types'; -import { IUNDirectedGraph } from '../../interfaces'; +import {arrayRemove} from '../../utils'; +import {AbstractEdge, AbstractGraph, AbstractVertex} from './abstract-graph'; +import type {VertexId} from '../../types'; +import {IUNDirectedGraph} from '../../interfaces'; export class UndirectedVertex extends AbstractVertex { /** diff --git a/src/data-structures/heap/heap.ts b/src/data-structures/heap/heap.ts index 2fba239..c59a57d 100644 --- a/src/data-structures/heap/heap.ts +++ b/src/data-structures/heap/heap.ts @@ -5,8 +5,8 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import { PriorityQueue } from '../priority-queue'; -import type { HeapOptions } from '../../types'; +import {PriorityQueue} from '../priority-queue'; +import type {HeapOptions} from '../../types'; export class HeapItem { /** @@ -50,7 +50,7 @@ export abstract class Heap { */ protected constructor(options?: HeapOptions) { if (options) { - const { priorityExtractor } = options; + const {priorityExtractor} = options; if (priorityExtractor !== undefined && typeof priorityExtractor !== 'function') { throw new Error('.constructor expects a valid priority function'); } diff --git a/src/data-structures/heap/max-heap.ts b/src/data-structures/heap/max-heap.ts index df6c55b..48a72bd 100644 --- a/src/data-structures/heap/max-heap.ts +++ b/src/data-structures/heap/max-heap.ts @@ -6,9 +6,9 @@ * @license MIT License */ -import { Heap, HeapItem } from './heap'; -import { PriorityQueue } from '../priority-queue'; -import type { HeapOptions } from '../../types'; +import {Heap, HeapItem} from './heap'; +import {PriorityQueue} from '../priority-queue'; +import type {HeapOptions} from '../../types'; /** * @class MaxHeap diff --git a/src/data-structures/heap/min-heap.ts b/src/data-structures/heap/min-heap.ts index bff2995..7c39209 100644 --- a/src/data-structures/heap/min-heap.ts +++ b/src/data-structures/heap/min-heap.ts @@ -6,9 +6,9 @@ * @license MIT License */ -import { Heap, HeapItem } from './heap'; -import { PriorityQueue } from '../priority-queue'; -import type { HeapOptions } from '../../types'; +import {Heap, HeapItem} from './heap'; +import {PriorityQueue} from '../priority-queue'; +import type {HeapOptions} from '../../types'; /** * @class MinHeap diff --git a/src/data-structures/matrix/matrix.ts b/src/data-structures/matrix/matrix.ts index 6f3f08f..26c0ff3 100644 --- a/src/data-structures/matrix/matrix.ts +++ b/src/data-structures/matrix/matrix.ts @@ -14,8 +14,8 @@ 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?: T }) { - const { row, col, initialVal } = options; + constructor(options: {row: number; col: number; initialVal?: T}) { + 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/navigator.ts b/src/data-structures/matrix/navigator.ts index e78205d..dd2f854 100644 --- a/src/data-structures/matrix/navigator.ts +++ b/src/data-structures/matrix/navigator.ts @@ -5,7 +5,7 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type { Direction, NavigatorParams, Turning } from '../../types'; +import type {Direction, NavigatorParams, Turning} from '../../types'; export class Character { direction: Direction; @@ -37,7 +37,7 @@ export class Navigator { * in the matrix. * @param - - `matrix`: a 2D array representing the grid or map */ - constructor({ matrix, turning, onMove, init: { cur, charDir, VISITED } }: NavigatorParams) { + constructor({matrix, turning, onMove, init: {cur, charDir, VISITED}}: NavigatorParams) { this._matrix = matrix; this._cur = cur; this._character = new Character(charDir, turning); @@ -53,7 +53,7 @@ export class Navigator { */ start() { while (this.check(this._character.direction) || this.check(this._character.turn().direction)) { - const { direction } = this._character; + const {direction} = this._character; if (this.check(direction)) { this.move(direction); } else if (this.check(this._character.turn().direction)) { diff --git a/src/data-structures/priority-queue/max-priority-queue.ts b/src/data-structures/priority-queue/max-priority-queue.ts index 0e0c410..c979f98 100644 --- a/src/data-structures/priority-queue/max-priority-queue.ts +++ b/src/data-structures/priority-queue/max-priority-queue.ts @@ -5,8 +5,8 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import { PriorityQueue } from './priority-queue'; -import type { PriorityQueueOptions, SpecifyOptional } from '../../types'; +import {PriorityQueue} from './priority-queue'; +import type {PriorityQueueOptions, SpecifyOptional} from '../../types'; export class MaxPriorityQueue extends PriorityQueue { constructor(options?: Omit, 'comparator'>); diff --git a/src/data-structures/priority-queue/min-priority-queue.ts b/src/data-structures/priority-queue/min-priority-queue.ts index 3a4a0dc..261b901 100644 --- a/src/data-structures/priority-queue/min-priority-queue.ts +++ b/src/data-structures/priority-queue/min-priority-queue.ts @@ -5,8 +5,8 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import { PriorityQueue } from './priority-queue'; -import type { PriorityQueueOptions, SpecifyOptional } from '../../types'; +import {PriorityQueue} from './priority-queue'; +import type {PriorityQueueOptions, SpecifyOptional} from '../../types'; export class MinPriorityQueue extends PriorityQueue { constructor(options?: Omit, 'comparator'>); diff --git a/src/data-structures/priority-queue/priority-queue.ts b/src/data-structures/priority-queue/priority-queue.ts index 69e0f8d..aeba809 100644 --- a/src/data-structures/priority-queue/priority-queue.ts +++ b/src/data-structures/priority-queue/priority-queue.ts @@ -5,7 +5,7 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type { PriorityQueueComparator, PriorityQueueDFSOrderPattern, PriorityQueueOptions } from '../../types'; +import type {PriorityQueueComparator, PriorityQueueDFSOrderPattern, PriorityQueueOptions} from '../../types'; export class PriorityQueue { /** @@ -14,7 +14,7 @@ export class PriorityQueue { * @param options - The `options` parameter is an object that contains the following properties: */ constructor(options: PriorityQueueOptions) { - const { nodes, comparator, isFix = true } = options; + const {nodes, comparator, isFix = true} = options; this._comparator = comparator; if (nodes && Array.isArray(nodes) && nodes.length > 0) { @@ -55,7 +55,7 @@ export class PriorityQueue { * @returns the result of calling the `isValid()` method on a new instance of the `PriorityQueue` class. */ static isPriorityQueueified(options: Omit, 'isFix'>) { - return new PriorityQueue({ ...options, isFix: false }).isValid(); + return new PriorityQueue({...options, isFix: false}).isValid(); } /** diff --git a/src/data-structures/queue/deque.ts b/src/data-structures/queue/deque.ts index da1c97a..7cbea71 100644 --- a/src/data-structures/queue/deque.ts +++ b/src/data-structures/queue/deque.ts @@ -5,7 +5,7 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import { DoublyLinkedList } from '../linked-list'; +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 @@ -19,9 +19,9 @@ export class ObjectDeque { if (capacity !== undefined) this._capacity = capacity; } - private _nodes: { [key: number]: T } = {}; + private _nodes: {[key: number]: T} = {}; - get nodes(): { [p: number]: T } { + get nodes(): {[p: number]: T} { return this._nodes; } @@ -156,7 +156,7 @@ export class ObjectDeque { return this._size <= 0; } - protected _seNodes(value: { [p: number]: T }) { + protected _seNodes(value: {[p: number]: T}) { this._nodes = value; } diff --git a/src/data-structures/queue/queue.ts b/src/data-structures/queue/queue.ts index 6327384..2b4ba38 100644 --- a/src/data-structures/queue/queue.ts +++ b/src/data-structures/queue/queue.ts @@ -3,7 +3,7 @@ * @copyright Tyler Zeng * @class */ -import { SinglyLinkedList } from '../linked-list'; +import {SinglyLinkedList} from '../linked-list'; export class LinkedListQueue extends SinglyLinkedList { /** diff --git a/src/data-structures/tree/tree.ts b/src/data-structures/tree/tree.ts index dc271d2..cfede18 100644 --- a/src/data-structures/tree/tree.ts +++ b/src/data-structures/tree/tree.ts @@ -55,7 +55,7 @@ export class TreeNode { if (level > maxDepth) { maxDepth = level; } - const { children } = node; + const {children} = node; if (children) { for (let i = 0, len = children.length; i < len; i++) { bfs(children[i], level + 1); diff --git a/src/interfaces/abstract-binary-tree.ts b/src/interfaces/abstract-binary-tree.ts index b9c40aa..3b233fd 100644 --- a/src/interfaces/abstract-binary-tree.ts +++ b/src/interfaces/abstract-binary-tree.ts @@ -9,7 +9,7 @@ import { LoopType, NodeOrPropertyName } from '../types'; -import { AbstractBinaryTreeNode } from '../data-structures'; +import {AbstractBinaryTreeNode} from '../data-structures'; export interface IAbstractBinaryTreeNode> { get id(): BinaryTreeNodeId; diff --git a/src/interfaces/abstract-graph.ts b/src/interfaces/abstract-graph.ts index f24c427..07a4a3d 100644 --- a/src/interfaces/abstract-graph.ts +++ b/src/interfaces/abstract-graph.ts @@ -1,4 +1,4 @@ -import { VertexId } from '../types'; +import {VertexId} from '../types'; export interface IAbstractGraph { hasVertex(vertexOrId: V | VertexId): boolean; diff --git a/src/interfaces/avl-tree.ts b/src/interfaces/avl-tree.ts index 6e21f76..e54484f 100644 --- a/src/interfaces/avl-tree.ts +++ b/src/interfaces/avl-tree.ts @@ -1,6 +1,6 @@ -import { AVLTreeNode } from '../data-structures'; -import { IBST, IBSTNode } from './bst'; -import { BinaryTreeDeletedResult, BinaryTreeNodeId } from '../types'; +import {AVLTreeNode} from '../data-structures'; +import {IBST, IBSTNode} from './bst'; +import {BinaryTreeDeletedResult, BinaryTreeNodeId} from '../types'; export type IAVLTreeNode> = IBSTNode; diff --git a/src/interfaces/binary-tree.ts b/src/interfaces/binary-tree.ts index 8e419de..d21cfd3 100644 --- a/src/interfaces/binary-tree.ts +++ b/src/interfaces/binary-tree.ts @@ -1,5 +1,5 @@ -import { BinaryTreeNode } from '../data-structures'; -import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from './abstract-binary-tree'; +import {BinaryTreeNode} from '../data-structures'; +import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from './abstract-binary-tree'; export type IBinaryTreeNode> = IAbstractBinaryTreeNode; diff --git a/src/interfaces/bst.ts b/src/interfaces/bst.ts index c2bb34a..8dcac57 100644 --- a/src/interfaces/bst.ts +++ b/src/interfaces/bst.ts @@ -1,6 +1,6 @@ -import { BSTNode } from '../data-structures'; -import { IBinaryTree, IBinaryTreeNode } from './binary-tree'; -import { BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName } from '../types'; +import {BSTNode} from '../data-structures'; +import {IBinaryTree, IBinaryTreeNode} from './binary-tree'; +import {BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName} from '../types'; export type IBSTNode> = IBinaryTreeNode; diff --git a/src/interfaces/directed-graph.ts b/src/interfaces/directed-graph.ts index 338353b..a4d6166 100644 --- a/src/interfaces/directed-graph.ts +++ b/src/interfaces/directed-graph.ts @@ -1,5 +1,5 @@ -import { VertexId } from '../types'; -import { IAbstractGraph } from './abstract-graph'; +import {VertexId} from '../types'; +import {IAbstractGraph} from './abstract-graph'; export interface IDirectedGraph extends IAbstractGraph { incomingEdgesOf(vertex: V): E[]; diff --git a/src/interfaces/rb-tree.ts b/src/interfaces/rb-tree.ts index 9951433..89db51b 100644 --- a/src/interfaces/rb-tree.ts +++ b/src/interfaces/rb-tree.ts @@ -1,6 +1,6 @@ -import { RBTreeNode } from '../data-structures'; -import { IBST, IBSTNode } from './bst'; -import { BinaryTreeNodeId } from '../types'; +import {RBTreeNode} from '../data-structures'; +import {IBST, IBSTNode} from './bst'; +import {BinaryTreeNodeId} from '../types'; export type IRBTreeNode> = IBSTNode; diff --git a/src/interfaces/tree-multiset.ts b/src/interfaces/tree-multiset.ts index 556857a..a46449f 100644 --- a/src/interfaces/tree-multiset.ts +++ b/src/interfaces/tree-multiset.ts @@ -1,6 +1,6 @@ -import { TreeMultisetNode } from '../data-structures'; -import { IBSTNode } from './bst'; -import { IAVLTree } from './avl-tree'; +import {TreeMultisetNode} from '../data-structures'; +import {IBSTNode} from './bst'; +import {IAVLTree} from './avl-tree'; export type ITreeMultisetNode> = IBSTNode; diff --git a/src/interfaces/undirected-graph.ts b/src/interfaces/undirected-graph.ts index de5d1a3..200801f 100644 --- a/src/interfaces/undirected-graph.ts +++ b/src/interfaces/undirected-graph.ts @@ -1,5 +1,5 @@ -import { VertexId } from '../types'; -import { IAbstractGraph } from './abstract-graph'; +import {VertexId} from '../types'; +import {IAbstractGraph} from './abstract-graph'; export interface IUNDirectedGraph extends IAbstractGraph { removeEdgeBetween(v1: V | VertexId, v2: V | VertexId): E | null; diff --git a/src/types/data-structures/navigator.ts b/src/types/data-structures/navigator.ts index 6a66ad6..5ca21be 100644 --- a/src/types/data-structures/navigator.ts +++ b/src/types/data-structures/navigator.ts @@ -1,5 +1,5 @@ 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/utils/utils.ts b/src/types/utils/utils.ts index 1f3a505..f4d26c4 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 eea98a5..867691f 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 KeyValueObjectWithId = { [key: string]: any; id: string | number | symbol }; +export type KeyValueObjectWithId = {[key: string]: any; id: string | number | symbol}; export type NonNumberNonObjectButDefined = string | boolean | symbol | null; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index f6de3d8..392d7e4 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -5,7 +5,7 @@ * @copyright Copyright (c) 2022 Tyler Zeng * @license MIT License */ -import type { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types'; +import type {Thunk, ToThunkFn, TrlAsyncFn, TrlFn} from '../types'; export const uuidV4 = function () { return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) { @@ -57,7 +57,7 @@ export const trampoline = (fn: TrlFn) => { return result; }, - { cont } + {cont} ); }; @@ -74,6 +74,6 @@ export const trampolineAsync = (fn: TrlAsyncFn) => { return result; }, - { cont } + {cont} ); };