@gabrielrufino/cube 1.0.20 → 1.0.21

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.
@@ -3,5 +3,5 @@ export default class BinarySearchTreeNode<T> {
3
3
  left: BinarySearchTreeNode<T> | null;
4
4
  right: BinarySearchTreeNode<T> | null;
5
5
  constructor(value: T);
6
- [Symbol.toPrimitive](type: string): string | number | null;
6
+ private [Symbol.toPrimitive];
7
7
  }
@@ -9,13 +9,12 @@ var BinarySearchTreeNode = /** @class */ (function () {
9
9
  this.right = null;
10
10
  }
11
11
  BinarySearchTreeNode.prototype[Symbol.toPrimitive] = function (type) {
12
- if (type === 'string') {
13
- return "[".concat(this.left, "] <= (").concat(this.value, ") => [").concat(this.right, "]");
14
- }
15
- if (type === 'number') {
16
- return 1 + (this.left ? 1 : 0) + (this.right ? 1 : 0);
17
- }
18
- return null;
12
+ var primitives = {
13
+ default: true,
14
+ number: 1 + (this.left ? 1 : 0) + (this.right ? 1 : 0),
15
+ string: "[".concat(this.left, "] <= (").concat(this.value, ") => [").concat(this.right, "]"),
16
+ };
17
+ return primitives[type];
19
18
  };
20
19
  return BinarySearchTreeNode;
21
20
  }());
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  var BinarySearchTreeNode_1 = __importDefault(require("./BinarySearchTreeNode"));
18
18
  var BinarySearchTree = /** @class */ (function () {
19
19
  function BinarySearchTree(_a) {
20
- var _b = _a === void 0 ? { inputs: [] } : _a, _c = _b.inputs, inputs = _c === void 0 ? [] : _c, lessThanOrEqualTo = _b.lessThanOrEqualTo;
20
+ var _b = _a === void 0 ? {} : _a, _c = _b.inputs, inputs = _c === void 0 ? [] : _c, lessThanOrEqualTo = _b.lessThanOrEqualTo;
21
21
  this._root = null;
22
22
  this._size = 0;
23
23
  if (lessThanOrEqualTo) {
@@ -183,13 +183,12 @@ var BinarySearchTree = /** @class */ (function () {
183
183
  }
184
184
  };
185
185
  BinarySearchTree.prototype[Symbol.toPrimitive] = function (type) {
186
- if (type === 'string') {
187
- return "".concat(this._root);
188
- }
189
- if (type === 'number') {
190
- return this.size;
191
- }
192
- return null;
186
+ var primitives = {
187
+ default: true,
188
+ number: this.size,
189
+ string: "".concat(this._root),
190
+ };
191
+ return primitives[type];
193
192
  };
194
193
  return BinarySearchTree;
195
194
  }());
@@ -13,14 +13,12 @@ var LinkedList = /** @class */ (function () {
13
13
  this._FIRST_POSITION = 0;
14
14
  this._head = 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 - 1; i++) {
19
- nodes[i].next = nodes[i + 1];
20
- }
21
- this._head = nodes[0];
22
- this._size = nodes.length;
16
+ var nodes = inputs.map(function (input) { return new Node_1.default(input); });
17
+ for (var i = 0; i < inputs.length - 1; i++) {
18
+ nodes[i].next = nodes[i + 1];
23
19
  }
20
+ this._head = nodes[0];
21
+ this._size = nodes.length;
24
22
  }
25
23
  Object.defineProperty(LinkedList.prototype, "data", {
26
24
  get: function () {
@@ -153,16 +151,15 @@ var LinkedList = /** @class */ (function () {
153
151
  return node || undefined;
154
152
  };
155
153
  LinkedList.prototype[Symbol.toPrimitive] = function (type) {
156
- if (type === 'string') {
157
- return "[Head] ".concat(this.data.map(function (_a) {
154
+ var primitives = {
155
+ default: true,
156
+ number: this.size,
157
+ string: "[Head] ".concat(this.data.map(function (_a) {
158
158
  var value = _a.value;
159
159
  return value;
160
- }).join(' => '));
161
- }
162
- if (type === 'number') {
163
- return this.size;
164
- }
165
- return null;
160
+ }).join(' => ')),
161
+ };
162
+ return primitives[type];
166
163
  };
167
164
  return LinkedList;
168
165
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gabrielrufino/cube",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Data Structures and Algorithms made in Typescript",
5
5
  "main": "build/index.js",
6
6
  "scripts": {