@gabrielrufino/cube 2.0.8 → 2.0.10

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.
Files changed (45) hide show
  1. package/README.md +0 -4
  2. package/dist/Array/IArray.d.ts +6 -6
  3. package/dist/Array/index.d.ts +1 -1
  4. package/dist/BinarySearchTree/IBinarySearchTree.d.ts +7 -7
  5. package/dist/BinarySearchTree/IBinarySearchTreeData.d.ts +1 -1
  6. package/dist/BinarySearchTree/index.d.ts +3 -3
  7. package/dist/BinarySearchTree/index.js +3 -2
  8. package/dist/Deck/IDeck.d.ts +6 -6
  9. package/dist/Deck/index.d.ts +1 -1
  10. package/dist/Dictionary/IDictionary.d.ts +7 -7
  11. package/dist/Dictionary/index.d.ts +2 -2
  12. package/dist/DoublyLinkedList/IDoublyLinkedList.d.ts +6 -6
  13. package/dist/DoublyLinkedList/index.d.ts +2 -1
  14. package/dist/Graph/GraphSearchNodeStates.js +0 -1
  15. package/dist/Graph/IGraph.d.ts +4 -4
  16. package/dist/Graph/index.d.ts +3 -3
  17. package/dist/Graph/index.js +2 -2
  18. package/dist/HashTable/IHashTable.d.ts +4 -4
  19. package/dist/HashTable/index.d.ts +5 -5
  20. package/dist/HashTable/index.js +2 -8
  21. package/dist/HashTableLinearProbing/HashTableLinearProbingElement.js +0 -2
  22. package/dist/HashTableLinearProbing/IHashTableLinearProbing.d.ts +4 -4
  23. package/dist/HashTableLinearProbing/IHashTableLinearProbingData.d.ts +1 -1
  24. package/dist/HashTableLinearProbing/index.d.ts +3 -3
  25. package/dist/HashTableSeparateChaining/HashTableSeparateChainingElement.js +0 -2
  26. package/dist/HashTableSeparateChaining/IHashTableSeparateChaining.d.ts +5 -5
  27. package/dist/HashTableSeparateChaining/IHashTableSeparateChainingData.d.ts +1 -1
  28. package/dist/HashTableSeparateChaining/index.d.ts +4 -4
  29. package/dist/HashTableSeparateChaining/index.js +3 -9
  30. package/dist/LinkedList/ILinkedList.d.ts +7 -7
  31. package/dist/LinkedList/index.d.ts +2 -2
  32. package/dist/LinkedList/index.js +1 -1
  33. package/dist/MaxHeap/IMaxHeap.d.ts +2 -2
  34. package/dist/MaxHeap/index.d.ts +2 -2
  35. package/dist/MinHeap/IMinHeap.d.ts +2 -2
  36. package/dist/MinHeap/index.d.ts +2 -2
  37. package/dist/Queue/IQueue.d.ts +4 -4
  38. package/dist/Queue/index.d.ts +1 -1
  39. package/dist/Set/ISet.d.ts +10 -10
  40. package/dist/Set/index.d.ts +1 -1
  41. package/dist/Stack/IStack.d.ts +4 -4
  42. package/dist/Stack/index.d.ts +1 -1
  43. package/eslint.config.mjs +3 -0
  44. package/package.json +25 -26
  45. package/stryker.config.json +1 -1
package/README.md CHANGED
@@ -44,7 +44,3 @@ const cube = require('@gabrielrufino/cube')
44
44
  * [Min Heap](./docs/MinHeap.md)
45
45
  * [Max Heap](./docs/MaxHeap.md)
46
46
  * [Graph](./docs/Graph.md)
47
-
48
- ---
49
-
50
- <small>Black Tech By [Gabriel Rufino](https://github.com/gabrielrufino) 🖤</small>
@@ -1,9 +1,9 @@
1
1
  interface IArray<T> {
2
- insertInLastPosition(_element: T): T;
3
- insertInFirstPosition(_element: T): T;
4
- insertInPosition(_position: number, _element: T): T;
5
- removeFromLastPosition(): T | undefined;
6
- removeFromFirstPosition(): T | undefined;
7
- removeFromPosition(_position: number): T | undefined;
2
+ insertInLastPosition: (_element: T) => T;
3
+ insertInFirstPosition: (_element: T) => T;
4
+ insertInPosition: (_position: number, _element: T) => T;
5
+ removeFromLastPosition: () => T | undefined;
6
+ removeFromFirstPosition: () => T | undefined;
7
+ removeFromPosition: (_position: number) => T | undefined;
8
8
  }
9
9
  export default IArray;
@@ -1,5 +1,5 @@
1
+ import type IArray from './IArray';
1
2
  import DataStructure from '../DataStructure';
2
- import IArray from './IArray';
3
3
  export default class Array<T = number> extends DataStructure<T> implements IArray<T> {
4
4
  constructor(...inputs: Readonly<T[]>);
5
5
  insertInLastPosition(element: T): T;
@@ -1,14 +1,14 @@
1
- import IBinarySearchTreeData from './IBinarySearchTreeData';
1
+ import type IBinarySearchTreeData from './IBinarySearchTreeData';
2
2
  interface IBinarySearchTree<T> {
3
3
  get data(): IBinarySearchTreeData<T>;
4
4
  get size(): number;
5
5
  get min(): T | null;
6
6
  get max(): T | null;
7
- insert(_value: T): T;
8
- walkInOrder(_callback: (_value: T) => any): void;
9
- walkPreOrder(_callback: (_value: T) => any): void;
10
- walkPostOrder(_callback: (_value: T) => any): void;
11
- search(_value: T): boolean;
12
- remove(_value: T): T | null;
7
+ insert: (_value: T) => T;
8
+ walkInOrder: (_callback: (_value: T) => any) => void;
9
+ walkPreOrder: (_callback: (_value: T) => any) => void;
10
+ walkPostOrder: (_callback: (_value: T) => any) => void;
11
+ search: (_value: T) => boolean;
12
+ remove: (_value: T) => T | null;
13
13
  }
14
14
  export default IBinarySearchTree;
@@ -1,4 +1,4 @@
1
- import BinarySearchTreeNode from './BinarySearchTreeNode';
1
+ import type BinarySearchTreeNode from './BinarySearchTreeNode';
2
2
  interface IBinarySearchTreeData<T> {
3
3
  left: BinarySearchTreeNode<T> | null;
4
4
  value: T | null;
@@ -1,6 +1,6 @@
1
- import IBinarySearchNodeOptions from './IBinarySearchNodeOptions';
2
- import IBinarySearchTree from './IBinarySearchTree';
3
- import IBinarySearchTreeData from './IBinarySearchTreeData';
1
+ import type IBinarySearchNodeOptions from './IBinarySearchNodeOptions';
2
+ import type IBinarySearchTree from './IBinarySearchTree';
3
+ import type IBinarySearchTreeData from './IBinarySearchTreeData';
4
4
  export default class BinarySearchTree<T = number> implements IBinarySearchTree<T> {
5
5
  private _root;
6
6
  private _size;
@@ -99,6 +99,7 @@ var BinarySearchTree = /** @class */ (function () {
99
99
  return Boolean(current);
100
100
  };
101
101
  BinarySearchTree.prototype.remove = function (value) {
102
+ var _a;
102
103
  var current = this._root;
103
104
  var path = [];
104
105
  while (current && current.value !== value) {
@@ -114,7 +115,7 @@ var BinarySearchTree = /** @class */ (function () {
114
115
  var found = __assign({}, current);
115
116
  var parent = path
116
117
  .slice(0, path.length - 1)
117
- .reduce(function (accumulator, current) { return accumulator && accumulator[current]; }, this._root);
118
+ .reduce(function (accumulator, current) { return accumulator[current]; }, this._root);
118
119
  var child = path[path.length - 1];
119
120
  if ((current === null || current === void 0 ? void 0 : current.left) && current.right && parent) {
120
121
  var head = current.right;
@@ -136,7 +137,7 @@ var BinarySearchTree = /** @class */ (function () {
136
137
  parent[child] = null;
137
138
  this._size -= 1;
138
139
  }
139
- return found.value || null;
140
+ return (_a = found.value) !== null && _a !== void 0 ? _a : null;
140
141
  };
141
142
  BinarySearchTree.prototype._lessThanOrEqualTo = function (value1, value2) {
142
143
  if (value1 <= value2) {
@@ -1,9 +1,9 @@
1
1
  interface IDeck<T> {
2
- addFront(_element: T): T;
3
- addBack(_element: T): T;
4
- removeFront(): T | undefined;
5
- removeBack(): T | undefined;
6
- peekFront(): T | undefined;
7
- peekBack(): T | undefined;
2
+ addFront: (_element: T) => T;
3
+ addBack: (_element: T) => T;
4
+ removeFront: () => T | undefined;
5
+ removeBack: () => T | undefined;
6
+ peekFront: () => T | undefined;
7
+ peekBack: () => T | undefined;
8
8
  }
9
9
  export default IDeck;
@@ -1,5 +1,5 @@
1
+ import type IDeck from './IDeck';
1
2
  import DataStructure from '../DataStructure';
2
- import IDeck from './IDeck';
3
3
  export default class Deck<T = number> extends DataStructure<T> implements IDeck<T> {
4
4
  constructor(...inputs: Readonly<T[]>);
5
5
  addFront(element: T): T;
@@ -1,4 +1,4 @@
1
- import IDictionaryData from './IDictionaryData';
1
+ import type IDictionaryData from './IDictionaryData';
2
2
  interface IDictionary<T> {
3
3
  get data(): IDictionaryData<T>;
4
4
  get size(): number;
@@ -6,11 +6,11 @@ interface IDictionary<T> {
6
6
  get keys(): string[];
7
7
  get values(): T[];
8
8
  get pairs(): [string, T][];
9
- set(_key: string, _value: T): [string, T];
10
- remove(_key: string): [string, T] | null;
11
- hasKey(_key: string): boolean;
12
- get(_key: string): T | null;
13
- clear(): IDictionaryData<T>;
14
- forEach(_func: (_key: string, _value: T) => any): void;
9
+ set: (_key: string, _value: T) => [string, T];
10
+ remove: (_key: string) => [string, T] | null;
11
+ hasKey: (_key: string) => boolean;
12
+ get: (_key: string) => T | null;
13
+ clear: () => IDictionaryData<T>;
14
+ forEach: (_func: (_key: string, _value: T) => any) => void;
15
15
  }
16
16
  export default IDictionary;
@@ -1,5 +1,5 @@
1
- import IDictionary from './IDictionary';
2
- import IDictionaryData from './IDictionaryData';
1
+ import type IDictionary from './IDictionary';
2
+ import type IDictionaryData from './IDictionaryData';
3
3
  export default class Dictionary<T = number> implements IDictionary<T> {
4
4
  private _data;
5
5
  constructor(inputs?: Readonly<{
@@ -6,11 +6,11 @@ export interface IDoublyLinkedListItem<T> {
6
6
  interface IDoublyLinkedList<T> {
7
7
  get data(): IDoublyLinkedListItem<T>[];
8
8
  get size(): number;
9
- push(_element: T): T;
10
- getFromPosition(_position: number): IDoublyLinkedListItem<T> | undefined;
11
- positionOf(_element: T): number | undefined;
12
- insertInPosition(_element: T, _position: number): T | undefined;
13
- remove(_element: T): T | undefined;
14
- removeFromPosition(_position: number): T | undefined;
9
+ push: (_element: T) => T;
10
+ getFromPosition: (_position: number) => IDoublyLinkedListItem<T> | undefined;
11
+ positionOf: (_element: T) => number | undefined;
12
+ insertInPosition: (_element: T, _position: number) => T | undefined;
13
+ remove: (_element: T) => T | undefined;
14
+ removeFromPosition: (_position: number) => T | undefined;
15
15
  }
16
16
  export default IDoublyLinkedList;
@@ -1,4 +1,5 @@
1
- import IDoublyLinkedList, { IDoublyLinkedListItem } from './IDoublyLinkedList';
1
+ import type { IDoublyLinkedListItem } from './IDoublyLinkedList';
2
+ import type IDoublyLinkedList from './IDoublyLinkedList';
2
3
  export default class DoublyLinkedList<T = number> implements IDoublyLinkedList<T> {
3
4
  private _head;
4
5
  private _tail;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable no-unused-vars */
4
3
  var GraphSearchNodeStates;
5
4
  (function (GraphSearchNodeStates) {
6
5
  GraphSearchNodeStates[GraphSearchNodeStates["UNEXPLORED"] = 0] = "UNEXPLORED";
@@ -6,10 +6,10 @@ interface IGraph {
6
6
  get size(): number;
7
7
  get nodes(): string[];
8
8
  get edges(): [string, string][];
9
- insert(_node: string): string | null;
10
- connect(_node1: string, _node2: string): [string, string];
11
- breadthFirstSearch(_startNode: string, _callback: (_node: string) => void): void;
12
- getDistancesFrom(_node: string): {
9
+ insert: (_node: string) => string | null;
10
+ connect: (_node1: string, _node2: string) => [string, string];
11
+ breadthFirstSearch: (_startNode: string, _callback: (_node: string) => void) => void;
12
+ getDistancesFrom: (_node: string) => {
13
13
  [key: string]: number;
14
14
  };
15
15
  }
@@ -1,6 +1,6 @@
1
- import IGraph from './IGraph';
2
- import IGraphOptions from './IGraphOptions';
3
- import { Edge } from './Edge';
1
+ import type { Edge } from './Edge';
2
+ import type IGraph from './IGraph';
3
+ import type IGraphOptions from './IGraphOptions';
4
4
  export default class Graph implements IGraph {
5
5
  private readonly _isDirected;
6
6
  private readonly _data;
@@ -23,11 +23,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- var GraphNodeNotFoundError_1 = __importDefault(require("./GraphNodeNotFoundError"));
27
- var GraphSearchNodeStates_1 = __importDefault(require("./GraphSearchNodeStates"));
28
26
  var Dictionary_1 = __importDefault(require("../Dictionary"));
29
27
  var Queue_1 = __importDefault(require("../Queue"));
30
28
  var Set_1 = __importDefault(require("../Set"));
29
+ var GraphNodeNotFoundError_1 = __importDefault(require("./GraphNodeNotFoundError"));
30
+ var GraphSearchNodeStates_1 = __importDefault(require("./GraphSearchNodeStates"));
31
31
  var Graph = /** @class */ (function () {
32
32
  function Graph(_a) {
33
33
  var _b = _a === void 0 ? {} : _a, _c = _b.inputs, inputs = _c === void 0 ? {} : _c, _d = _b.isDirected, isDirected = _d === void 0 ? false : _d;
@@ -1,10 +1,10 @@
1
- import IHashTableData from './IHashTableData';
1
+ import type IHashTableData from './IHashTableData';
2
2
  interface IHashTable<T> {
3
3
  get data(): IHashTableData<T>;
4
4
  get size(): number;
5
5
  get maxSize(): number;
6
- put(_key: string, _value: T): T;
7
- get(_key: string): T | null;
8
- remove(_key: string): T | null;
6
+ put: (_key: string, _value: T) => T;
7
+ get: (_key: string) => T | null;
8
+ remove: (_key: string) => T | null;
9
9
  }
10
10
  export default IHashTable;
@@ -1,13 +1,13 @@
1
- import IHashTable from './IHashTable';
2
- import IHashTableData from './IHashTableData';
3
- import IHashTableInputs from './IHashTableInputs';
4
- import IHashTableOptions from './IHashTableOptions';
1
+ import type IHashTable from './IHashTable';
2
+ import type IHashTableData from './IHashTableData';
3
+ import type IHashTableInputs from './IHashTableInputs';
4
+ import type IHashTableOptions from './IHashTableOptions';
5
5
  export default class HashTable<T = number> implements IHashTable<T> {
6
+ readonly maxSize: number;
6
7
  private _data;
7
8
  constructor(inputs?: Readonly<IHashTableInputs<T>>, { maxSize }?: IHashTableOptions);
8
9
  get data(): IHashTableData<T>;
9
10
  get size(): number;
10
- get maxSize(): number;
11
11
  put(key: string, value: T): T;
12
12
  get(key: string): T | null;
13
13
  remove(key: string): T | null;
@@ -15,7 +15,8 @@ var HashTable = /** @class */ (function () {
15
15
  function HashTable(inputs, _a) {
16
16
  if (inputs === void 0) { inputs = {}; }
17
17
  var _b = _a === void 0 ? {} : _a, _c = _b.maxSize, maxSize = _c === void 0 ? 100 : _c;
18
- this._data = new Array(maxSize);
18
+ this._data = [];
19
+ this.maxSize = maxSize;
19
20
  for (var _i = 0, _d = Object.entries(inputs); _i < _d.length; _i++) {
20
21
  var _e = _d[_i], key = _e[0], value = _e[1];
21
22
  this.put(key, value);
@@ -40,13 +41,6 @@ var HashTable = /** @class */ (function () {
40
41
  enumerable: false,
41
42
  configurable: true
42
43
  });
43
- Object.defineProperty(HashTable.prototype, "maxSize", {
44
- get: function () {
45
- return this._data.length;
46
- },
47
- enumerable: false,
48
- configurable: true
49
- });
50
44
  HashTable.prototype.put = function (key, value) {
51
45
  var position = this._hashCode(key);
52
46
  this._data[position] = value;
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable no-unused-vars */
3
- /* eslint-disable no-useless-constructor */
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
5
3
  var HashTableLinearProbingElement = /** @class */ (function () {
6
4
  function HashTableLinearProbingElement(key, value) {
@@ -1,9 +1,9 @@
1
- import IHashTableLinearProbingData from './IHashTableLinearProbingData';
1
+ import type IHashTableLinearProbingData from './IHashTableLinearProbingData';
2
2
  interface IHashTableLinearProbing<T> {
3
3
  get data(): IHashTableLinearProbingData<T>;
4
4
  get size(): number;
5
- put(_key: string, _value: T): T | null;
6
- get(_key: string): T | null;
7
- remove(_key: string): T | null;
5
+ put: (_key: string, _value: T) => T | null;
6
+ get: (_key: string) => T | null;
7
+ remove: (_key: string) => T | null;
8
8
  }
9
9
  export default IHashTableLinearProbing;
@@ -1,4 +1,4 @@
1
- import HashTableLinearProbingElement from './HashTableLinearProbingElement';
1
+ import type HashTableLinearProbingElement from './HashTableLinearProbingElement';
2
2
  interface IHashTableLinearProbingData<T> {
3
3
  [index: number]: HashTableLinearProbingElement<T>;
4
4
  }
@@ -1,7 +1,7 @@
1
+ import type IHashTableLinearProbing from './IHashTableLinearProbing';
2
+ import type IHashTableLinearProbingInputs from './IHashTableLinearProbingInputs';
3
+ import type IHashTableLinearProbingOptions from './IHashTableLinearProbingOptions';
1
4
  import HashTableLinearProbingElement from './HashTableLinearProbingElement';
2
- import IHashTableLinearProbing from './IHashTableLinearProbing';
3
- import IHashTableLinearProbingInputs from './IHashTableLinearProbingInputs';
4
- import IHashTableLinearProbingOptions from './IHashTableLinearProbingOptions';
5
5
  export default class HashTableLinearProbing<T = number> implements IHashTableLinearProbing<T> {
6
6
  private _maxSize;
7
7
  private _data;
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable no-useless-constructor */
3
- /* eslint-disable no-unused-vars */
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
5
3
  var HashTableSeparateChainingElement = /** @class */ (function () {
6
4
  function HashTableSeparateChainingElement(key, value) {
@@ -1,11 +1,11 @@
1
- import HashTableSeparateChainingElement from './HashTableSeparateChainingElement';
2
- import IHashTableSeparateChainingData from './IHashTableSeparateChainingData';
1
+ import type HashTableSeparateChainingElement from './HashTableSeparateChainingElement';
2
+ import type IHashTableSeparateChainingData from './IHashTableSeparateChainingData';
3
3
  interface IHashTableSeparateChaining<T> {
4
4
  get data(): IHashTableSeparateChainingData<T>;
5
5
  get size(): number;
6
6
  get maxSize(): number;
7
- put(_key: string, _value: T): T;
8
- get(_key: string): HashTableSeparateChainingElement<T> | null;
9
- remove(_key: string): HashTableSeparateChainingElement<T> | null;
7
+ put: (_key: string, _value: T) => T;
8
+ get: (_key: string) => HashTableSeparateChainingElement<T> | null;
9
+ remove: (_key: string) => HashTableSeparateChainingElement<T> | null;
10
10
  }
11
11
  export default IHashTableSeparateChaining;
@@ -1,4 +1,4 @@
1
- import LinkedList from '../LinkedList';
1
+ import type LinkedList from '../LinkedList';
2
2
  interface IHashTableSeparateChainingData<T> {
3
3
  [key: number]: LinkedList<T>;
4
4
  }
@@ -1,15 +1,15 @@
1
+ import type IHashTableSeparateChaining from './IHashTableSeparateChaining';
2
+ import type IHashTableSeparateChainingData from './IHashTableSeparateChainingData';
3
+ import type IHashTableSeparateChainingInputs from './IHashTableSeparateChainingInputs';
1
4
  import HashTableSeparateChainingElement from './HashTableSeparateChainingElement';
2
- import IHashTableSeparateChaining from './IHashTableSeparateChaining';
3
- import IHashTableSeparateChainingData from './IHashTableSeparateChainingData';
4
- import IHashTableSeparateChainingInputs from './IHashTableSeparateChainingInputs';
5
5
  export default class HashTableSeparateChaining<T = number> implements IHashTableSeparateChaining<T> {
6
6
  private _data;
7
+ readonly maxSize: number;
7
8
  constructor(inputs?: Readonly<IHashTableSeparateChainingInputs<T>>, { maxSize }?: {
8
9
  maxSize: number;
9
10
  });
10
11
  get data(): IHashTableSeparateChainingData<T>;
11
12
  get size(): number;
12
- get maxSize(): number;
13
13
  put(key: string, value: T): T;
14
14
  get(key: string): HashTableSeparateChainingElement<T> | null;
15
15
  remove(key: string): HashTableSeparateChainingElement<T> | null;
@@ -14,13 +14,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- var HashTableSeparateChainingElement_1 = __importDefault(require("./HashTableSeparateChainingElement"));
18
17
  var LinkedList_1 = __importDefault(require("../LinkedList"));
18
+ var HashTableSeparateChainingElement_1 = __importDefault(require("./HashTableSeparateChainingElement"));
19
19
  var HashTableSeparateChaining = /** @class */ (function () {
20
20
  function HashTableSeparateChaining(inputs, _a) {
21
21
  if (inputs === void 0) { inputs = {}; }
22
22
  var _b = _a === void 0 ? { maxSize: 100 } : _a, maxSize = _b.maxSize;
23
- this._data = new Array(maxSize);
23
+ this._data = [];
24
+ this.maxSize = maxSize;
24
25
  for (var _i = 0, _c = Object.entries(inputs); _i < _c.length; _i++) {
25
26
  var _d = _c[_i], key = _d[0], value = _d[1];
26
27
  this.put(key, value);
@@ -45,13 +46,6 @@ var HashTableSeparateChaining = /** @class */ (function () {
45
46
  enumerable: false,
46
47
  configurable: true
47
48
  });
48
- Object.defineProperty(HashTableSeparateChaining.prototype, "maxSize", {
49
- get: function () {
50
- return this._data.length;
51
- },
52
- enumerable: false,
53
- configurable: true
54
- });
55
49
  HashTableSeparateChaining.prototype.put = function (key, value) {
56
50
  var linkedList = this._getLinkedListByKey(key);
57
51
  var element = new HashTableSeparateChainingElement_1.default(key, value);
@@ -1,13 +1,13 @@
1
- import ILinkedListItem from './ILinkedListItem';
1
+ import type ILinkedListItem from './ILinkedListItem';
2
2
  interface ILinkedList<T> {
3
3
  get data(): ILinkedListItem<T>[];
4
4
  get size(): number;
5
5
  get isEmpty(): boolean;
6
- push(_element: T): T;
7
- getFromPosition(_position: number): ILinkedListItem<T> | null;
8
- positionOf(_element: T): number | undefined;
9
- insertInPosition(_element: T, _position: number): T | undefined;
10
- remove(_element: T): T | null;
11
- removeFromPosition(_position: number): T | null;
6
+ push: (_element: T) => T;
7
+ getFromPosition: (_position: number) => ILinkedListItem<T> | null;
8
+ positionOf: (_element: T) => number | undefined;
9
+ insertInPosition: (_element: T, _position: number) => T | undefined;
10
+ remove: (_element: T) => T | null;
11
+ removeFromPosition: (_position: number) => T | null;
12
12
  }
13
13
  export default ILinkedList;
@@ -1,5 +1,5 @@
1
- import ILinkedList from './ILinkedList';
2
- import ILinkedListItem from './ILinkedListItem';
1
+ import type ILinkedList from './ILinkedList';
2
+ import type ILinkedListItem from './ILinkedListItem';
3
3
  export default class LinkedList<T = number> implements ILinkedList<T> {
4
4
  private readonly _FIRST_POSITION;
5
5
  private _head;
@@ -94,7 +94,7 @@ var LinkedList = /** @class */ (function () {
94
94
  }
95
95
  else {
96
96
  var before = this._getNodeFromPosition(position - 1);
97
- var after = (before && before.next) || null;
97
+ var after = (before === null || before === void 0 ? void 0 : before.next) || null;
98
98
  if (before) {
99
99
  before.next = node;
100
100
  }
@@ -3,7 +3,7 @@ interface IMaxHeap<T> {
3
3
  get size(): number;
4
4
  get isEmpty(): boolean;
5
5
  get max(): T | null;
6
- insert(_value: T): T;
7
- extract(): T | null;
6
+ insert: (_value: T) => T;
7
+ extract: () => T | null;
8
8
  }
9
9
  export default IMaxHeap;
@@ -1,5 +1,5 @@
1
- import IMaxHeap from './IMaxHeap';
2
- import IMaxHeapOptions from './IMaxHeapOptions';
1
+ import type IMaxHeap from './IMaxHeap';
2
+ import type IMaxHeapOptions from './IMaxHeapOptions';
3
3
  export default class MaxHeap<T = number> implements IMaxHeap<T> {
4
4
  private _data;
5
5
  constructor({ greaterThanOrEqualTo, inputs }?: IMaxHeapOptions<T>);
@@ -3,7 +3,7 @@ interface IMinHeap<T> {
3
3
  get size(): number;
4
4
  get isEmpty(): boolean;
5
5
  get min(): T | null;
6
- insert(_value: T): T;
7
- extract(): T | null;
6
+ insert: (_value: T) => T;
7
+ extract: () => T | null;
8
8
  }
9
9
  export default IMinHeap;
@@ -1,5 +1,5 @@
1
- import IMinHeap from './IMinHeap';
2
- import IMinHeapOptions from './IMinHeapOptions';
1
+ import type IMinHeap from './IMinHeap';
2
+ import type IMinHeapOptions from './IMinHeapOptions';
3
3
  export default class MinHeap<T = number> implements IMinHeap<T> {
4
4
  private _data;
5
5
  constructor({ lessThanOrEqualTo, inputs }?: IMinHeapOptions<T>);
@@ -1,8 +1,8 @@
1
1
  interface IQueue<T> {
2
- enqueue(_element: T): T;
3
- dequeue(): T | undefined;
4
- peek(): T | undefined;
5
- clear(): void;
2
+ enqueue: (_element: T) => T;
3
+ dequeue: () => T | undefined;
4
+ peek: () => T | undefined;
5
+ clear: () => void;
6
6
  get isEmpty(): boolean;
7
7
  }
8
8
  export default IQueue;
@@ -1,5 +1,5 @@
1
+ import type IQueue from './IQueue';
1
2
  import DataStructure from '../DataStructure';
2
- import IQueue from './IQueue';
3
3
  export default class Queue<T = number> extends DataStructure<T> implements IQueue<T> {
4
4
  constructor(...inputs: Readonly<T[]>);
5
5
  get isEmpty(): boolean;
@@ -1,15 +1,15 @@
1
- import Set from './';
1
+ import type Set from './';
2
2
  interface ISet<T> {
3
3
  get data(): T[];
4
4
  get size(): number;
5
- has(_elemet: T): boolean;
6
- add(_element: T): T | null;
7
- delete(_element: T): T | null;
8
- clear(_element: T): T[];
9
- union(_set: Set<T>): Set<T>;
10
- intersection(_set: Set<T>): Set<T>;
11
- difference(_set: Set<T>): Set<T>;
12
- isSubsetOf(_set: Set<T>): boolean;
13
- contains(_set: Set<T>): boolean;
5
+ has: (_elemet: T) => boolean;
6
+ add: (_element: T) => T | null;
7
+ delete: (_element: T) => T | null;
8
+ clear: (_element: T) => T[];
9
+ union: (_set: Set<T>) => Set<T>;
10
+ intersection: (_set: Set<T>) => Set<T>;
11
+ difference: (_set: Set<T>) => Set<T>;
12
+ isSubsetOf: (_set: Set<T>) => boolean;
13
+ contains: (_set: Set<T>) => boolean;
14
14
  }
15
15
  export default ISet;
@@ -1,4 +1,4 @@
1
- import ISet from './ISet';
1
+ import type ISet from './ISet';
2
2
  export default class Set<T = number> implements ISet<T> {
3
3
  private _data;
4
4
  constructor(...inputs: Readonly<T[]>);
@@ -1,8 +1,8 @@
1
1
  interface IStack<T> {
2
- push(_element: T): T;
3
- pop(): T | undefined;
4
- peek(): T | undefined;
5
- clear(): void;
2
+ push: (_element: T) => T;
3
+ pop: () => T | undefined;
4
+ peek: () => T | undefined;
5
+ clear: () => void;
6
6
  get isEmpty(): boolean;
7
7
  }
8
8
  export default IStack;
@@ -1,5 +1,5 @@
1
+ import type IStack from './IStack';
1
2
  import DataStructure from '../DataStructure';
2
- import IStack from './IStack';
3
3
  export default class Stack<T = number> extends DataStructure<T> implements IStack<T> {
4
4
  constructor(...inputs: Readonly<T[]>);
5
5
  push(element: T): T;
@@ -0,0 +1,3 @@
1
+ import antfu from '@antfu/eslint-config'
2
+
3
+ export default antfu()
package/package.json CHANGED
@@ -1,44 +1,43 @@
1
1
  {
2
2
  "name": "@gabrielrufino/cube",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "description": "Data structures made in Typescript",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "build": "tsc",
8
- "build:watch": "npm run build -- --watch",
9
- "lint": "eslint src/**/*.ts",
10
- "test": "vitest run",
11
- "test:cov": "npm t -- --coverage",
12
- "test:mutation": "npx stryker run",
13
- "test:watch": "vitest"
14
- },
5
+ "author": "Gabriel Rufino <contato@gabrielrufino.com>",
6
+ "license": "UNLICENSED",
7
+ "funding": "https://github.com/sponsors/gabrielrufino",
8
+ "homepage": "https://github.com/gabrielrufino/cube#readme",
15
9
  "repository": {
16
10
  "type": "git",
17
11
  "url": "git+https://github.com/gabrielrufino/cube.git"
18
12
  },
13
+ "bugs": {
14
+ "url": "https://github.com/gabrielrufino/cube/issues"
15
+ },
19
16
  "keywords": [
20
17
  "Data",
21
18
  "Structures"
22
19
  ],
23
- "author": "Gabriel Rufino <contato@gabrielrufino.com>",
24
- "funding": "https://github.com/sponsors/gabrielrufino",
25
- "license": "UNLICENSED",
26
- "bugs": {
27
- "url": "https://github.com/gabrielrufino/cube/issues"
20
+ "main": "dist/index.js",
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "build:watch": "npm run build -- --watch",
24
+ "lint": "eslint",
25
+ "lint:fix": "npm run lint -- --fix",
26
+ "test": "vitest run",
27
+ "test:cov": "npm t -- --coverage",
28
+ "test:mutation": "npx stryker run",
29
+ "test:watch": "vitest"
28
30
  },
29
- "homepage": "https://github.com/gabrielrufino/cube#readme",
30
31
  "devDependencies": {
31
- "@commitlint/cli": "^19.8.0",
32
- "@commitlint/config-conventional": "^19.8.0",
33
- "@faker-js/faker": "^8.4.1",
32
+ "@antfu/eslint-config": "^4.13.0",
33
+ "@commitlint/cli": "^19.8.1",
34
+ "@commitlint/config-conventional": "^19.8.1",
35
+ "@faker-js/faker": "^9.7.0",
34
36
  "@stryker-mutator/vitest-runner": "^8.7.1",
35
- "@typescript-eslint/eslint-plugin": "^5.62.0",
36
- "@typescript-eslint/parser": "^5.62.0",
37
- "@vitest/coverage-v8": "^3.0.8",
38
- "eslint": "^8.57.1",
39
- "eslint-config-xo": "^0.43.1",
37
+ "@vitest/coverage-v8": "^3.1.3",
38
+ "eslint": "^9.26.0",
40
39
  "husky": "^9.1.7",
41
- "typescript": "^5.8.2",
40
+ "typescript": "^5.8.3",
42
41
  "vitest": "^3.0.4"
43
42
  }
44
43
  }
@@ -14,4 +14,4 @@
14
14
  "htmlReporter": {
15
15
  "baseDir": ".stryker-reports"
16
16
  }
17
- }
17
+ }