@gabrielrufino/cube 1.0.23 → 1.0.26

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.
@@ -116,7 +116,7 @@ var BinarySearchTree = /** @class */ (function () {
116
116
  .slice(0, path.length - 1)
117
117
  .reduce(function (accumulator, current) { return accumulator && accumulator[current]; }, this._root);
118
118
  var child = path[path.length - 1];
119
- if ((current === null || current === void 0 ? void 0 : current.left) && (current === null || current === void 0 ? void 0 : current.right) && parent) {
119
+ if ((current === null || current === void 0 ? void 0 : current.left) && current.right && parent) {
120
120
  var head = current.right;
121
121
  while (head.left) {
122
122
  head = head.left;
@@ -30,7 +30,7 @@ var Queue_1 = __importDefault(require("../Queue"));
30
30
  var Set_1 = __importDefault(require("../Set"));
31
31
  var Graph = /** @class */ (function () {
32
32
  function Graph(_a) {
33
- var _b = _a === void 0 ? { inputs: {}, isDirected: false } : _a, _c = _b.inputs, inputs = _c === void 0 ? {} : _c, _d = _b.isDirected, isDirected = _d === void 0 ? false : _d;
33
+ var _b = _a === void 0 ? {} : _a, _c = _b.inputs, inputs = _c === void 0 ? {} : _c, _d = _b.isDirected, isDirected = _d === void 0 ? false : _d;
34
34
  this._isDirected = isDirected;
35
35
  this._data = new Dictionary_1.default();
36
36
  var nodes = Object.keys(inputs);
@@ -135,15 +135,13 @@ var Graph = /** @class */ (function () {
135
135
  queue.enqueue(startNode);
136
136
  while (!queue.isEmpty) {
137
137
  var current = queue.dequeue() || '';
138
- if (current) {
139
- states[current] = GraphSearchNodeStates_1.default.DISCOVERED;
140
- var neighbors = ((_a = this._data.get(current)) === null || _a === void 0 ? void 0 : _a.data) || [];
141
- var unexploredNeighbors = neighbors.filter(function (neighbor) { return states[neighbor] === GraphSearchNodeStates_1.default.UNEXPLORED; });
142
- for (var _i = 0, unexploredNeighbors_1 = unexploredNeighbors; _i < unexploredNeighbors_1.length; _i++) {
143
- var neighbor = unexploredNeighbors_1[_i];
144
- states[neighbor] = GraphSearchNodeStates_1.default.DISCOVERED;
145
- queue.enqueue(neighbor);
146
- }
138
+ states[current] = GraphSearchNodeStates_1.default.DISCOVERED;
139
+ var neighbors = ((_a = this._data.get(current)) === null || _a === void 0 ? void 0 : _a.data) || [];
140
+ var unexploredNeighbors = neighbors.filter(function (neighbor) { return states[neighbor] === GraphSearchNodeStates_1.default.UNEXPLORED; });
141
+ for (var _i = 0, unexploredNeighbors_1 = unexploredNeighbors; _i < unexploredNeighbors_1.length; _i++) {
142
+ var neighbor = unexploredNeighbors_1[_i];
143
+ states[neighbor] = GraphSearchNodeStates_1.default.DISCOVERED;
144
+ queue.enqueue(neighbor);
147
145
  }
148
146
  states[current] = GraphSearchNodeStates_1.default.EXPLORED;
149
147
  callback(current);
@@ -167,16 +165,14 @@ var Graph = /** @class */ (function () {
167
165
  queue.enqueue(node);
168
166
  while (!queue.isEmpty) {
169
167
  var current = queue.dequeue() || '';
170
- if (current) {
171
- states[current] = GraphSearchNodeStates_1.default.DISCOVERED;
172
- var neighbors = ((_a = this._data.get(current)) === null || _a === void 0 ? void 0 : _a.data) || [];
173
- var unexploredNeighbors = neighbors.filter(function (neighbor) { return states[neighbor] === GraphSearchNodeStates_1.default.UNEXPLORED; });
174
- for (var _i = 0, unexploredNeighbors_2 = unexploredNeighbors; _i < unexploredNeighbors_2.length; _i++) {
175
- var neighbor = unexploredNeighbors_2[_i];
176
- states[neighbor] = GraphSearchNodeStates_1.default.DISCOVERED;
177
- distances[neighbor] = distances[current] + 1;
178
- queue.enqueue(neighbor);
179
- }
168
+ states[current] = GraphSearchNodeStates_1.default.DISCOVERED;
169
+ var neighbors = ((_a = this._data.get(current)) === null || _a === void 0 ? void 0 : _a.data) || [];
170
+ var unexploredNeighbors = neighbors.filter(function (neighbor) { return states[neighbor] === GraphSearchNodeStates_1.default.UNEXPLORED; });
171
+ for (var _i = 0, unexploredNeighbors_2 = unexploredNeighbors; _i < unexploredNeighbors_2.length; _i++) {
172
+ var neighbor = unexploredNeighbors_2[_i];
173
+ states[neighbor] = GraphSearchNodeStates_1.default.DISCOVERED;
174
+ distances[neighbor] = distances[current] + 1;
175
+ queue.enqueue(neighbor);
180
176
  }
181
177
  states[current] = GraphSearchNodeStates_1.default.EXPLORED;
182
178
  }
@@ -86,9 +86,7 @@ var HashTableLinearProbing = /** @class */ (function () {
86
86
  && this._nextPositionOf(i) !== position; i = this._nextPositionOf(i)) {
87
87
  this._data[i] = this._data[this._nextPositionOf(i)];
88
88
  }
89
- if (i !== position) {
90
- Reflect.deleteProperty(this._data, i);
91
- }
89
+ Reflect.deleteProperty(this._data, i);
92
90
  return value;
93
91
  }
94
92
  return null;
@@ -107,13 +105,12 @@ var HashTableLinearProbing = /** @class */ (function () {
107
105
  return (position + this.size - 1) % this._maxSize;
108
106
  };
109
107
  HashTableLinearProbing.prototype[Symbol.toPrimitive] = function (type) {
110
- if (type === 'string') {
111
- return "[ ".concat(Object.values(this.data).join(', '), " ]");
112
- }
113
- if (type === 'number') {
114
- return this.size;
115
- }
116
- return null;
108
+ var primitives = {
109
+ default: true,
110
+ number: this.size,
111
+ string: "[ ".concat(Object.values(this.data).join(', '), " ]"),
112
+ };
113
+ return primitives[type];
117
114
  };
118
115
  return HashTableLinearProbing;
119
116
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gabrielrufino/cube",
3
- "version": "1.0.23",
3
+ "version": "1.0.26",
4
4
  "description": "Data Structures and Algorithms made in Typescript",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -28,20 +28,20 @@
28
28
  },
29
29
  "homepage": "https://github.com/gabrielrufino/cube#readme",
30
30
  "devDependencies": {
31
- "@faker-js/faker": "^6.1.2",
31
+ "@faker-js/faker": "^6.3.1",
32
32
  "@stryker-mutator/core": "^6.0.2",
33
33
  "@stryker-mutator/jest-runner": "^6.0.2",
34
34
  "@stryker-mutator/typescript-checker": "^6.0.2",
35
- "@types/jest": "^27.4.1",
36
- "@typescript-eslint/eslint-plugin": "^5.13.0",
37
- "@typescript-eslint/parser": "^5.13.0",
38
- "eslint": "^8.10.0",
35
+ "@types/jest": "^27.5.1",
36
+ "@typescript-eslint/eslint-plugin": "^5.26.0",
37
+ "@typescript-eslint/parser": "^5.26.0",
38
+ "eslint": "^8.16.0",
39
39
  "eslint-config-xo": "^0.39.0",
40
40
  "jest": "^27.5.1",
41
41
  "rimraf": "^3.0.2",
42
42
  "stryker-cli": "^1.0.2",
43
- "ts-jest": "^27.1.3",
44
- "ts-node": "^10.5.0",
45
- "typescript": "^4.6.2"
43
+ "ts-jest": "^27.1.5",
44
+ "ts-node": "^10.8.0",
45
+ "typescript": "^4.7.2"
46
46
  }
47
47
  }