@gabrielrufino/cube 1.0.21 → 1.0.22

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.
@@ -13,16 +13,14 @@ var DoublyLinkedList = /** @class */ (function () {
13
13
  this._head = null;
14
14
  this._tail = null;
15
15
  this._size = 0;
16
- if (inputs.length) {
17
- var nodes = inputs.map(function (input) { return new Node_1.default(input); });
18
- for (var i = 0; i < inputs.length; i++) {
19
- nodes[i].previous = nodes[i - 1] || null;
20
- nodes[i].next = nodes[i + 1] || null;
21
- }
22
- this._head = nodes[0];
23
- this._tail = nodes[nodes.length - 1];
24
- this._size = inputs.length;
25
- }
16
+ var nodes = inputs.map(function (input) { return new Node_1.default(input); });
17
+ for (var i = 0; i < inputs.length; i++) {
18
+ nodes[i].previous = nodes[i - 1] || null;
19
+ nodes[i].next = nodes[i + 1] || null;
20
+ }
21
+ this._head = nodes[0];
22
+ this._tail = nodes[nodes.length - 1];
23
+ this._size = inputs.length;
26
24
  }
27
25
  Object.defineProperty(DoublyLinkedList.prototype, "data", {
28
26
  get: function () {
@@ -70,7 +68,7 @@ var DoublyLinkedList = /** @class */ (function () {
70
68
  */
71
69
  DoublyLinkedList.prototype.getFromPosition = function (position) {
72
70
  var _a, _b;
73
- if (position < 0 || position >= this._size) {
71
+ if (position < 0 || position >= this.size) {
74
72
  return undefined;
75
73
  }
76
74
  var distanceToTheHead = position;
@@ -90,9 +88,9 @@ var DoublyLinkedList = /** @class */ (function () {
90
88
  }
91
89
  if (current === null || current === void 0 ? void 0 : current.value) {
92
90
  return {
93
- previous: ((_a = current === null || current === void 0 ? void 0 : current.previous) === null || _a === void 0 ? void 0 : _a.value) || null,
94
- value: current === null || current === void 0 ? void 0 : current.value,
95
- next: ((_b = current === null || current === void 0 ? void 0 : current.next) === null || _b === void 0 ? void 0 : _b.value) || null,
91
+ previous: ((_a = current.previous) === null || _a === void 0 ? void 0 : _a.value) || null,
92
+ value: current.value,
93
+ next: ((_b = current.next) === null || _b === void 0 ? void 0 : _b.value) || null,
96
94
  };
97
95
  }
98
96
  };
@@ -205,16 +203,15 @@ var DoublyLinkedList = /** @class */ (function () {
205
203
  return 'DESC';
206
204
  };
207
205
  DoublyLinkedList.prototype[Symbol.toPrimitive] = function (type) {
208
- if (type === 'string') {
209
- return "[Head] ".concat(this.data.map(function (_a) {
206
+ var primitives = {
207
+ default: true,
208
+ number: this.size,
209
+ string: "[Head] ".concat(this.data.map(function (_a) {
210
210
  var value = _a.value;
211
211
  return value;
212
- }).join(' <=> '), " [Tail]");
213
- }
214
- if (type === 'number') {
215
- return this.size;
216
- }
217
- return null;
212
+ }).join(' <=> '), " [Tail]"),
213
+ };
214
+ return primitives[type];
218
215
  };
219
216
  return DoublyLinkedList;
220
217
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gabrielrufino/cube",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "Data Structures and Algorithms made in Typescript",
5
5
  "main": "build/index.js",
6
6
  "scripts": {