Skip to content

Commit

Permalink
add tests for List
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Oct 17, 2016
1 parent 5f63b94 commit ae1f83f
Show file tree
Hide file tree
Showing 2 changed files with 528 additions and 16 deletions.
29 changes: 13 additions & 16 deletions lib/utils/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,20 @@ var List = function() {
this.tail = null;
};

Object.defineProperty(List.prototype, 'size', {
get: function() {
var size = 0;
var cursor = this.head;

while (cursor) {
size++;
cursor = cursor.next;
}
List.createItem = createItem;
List.prototype.createItem = createItem;

return size;
List.prototype.getSize = function() {
var size = 0;
var cursor = this.head;

while (cursor) {
size++;
cursor = cursor.next;
}
});

List.createItem = createItem;
List.prototype.createItem = createItem;
return size;
};

List.prototype.fromArray = function(array) {
var cursor = null;
Expand Down Expand Up @@ -78,9 +76,8 @@ List.prototype.toArray = function() {

return result;
};
List.prototype.toJSON = function() {
return this.toArray();
};

List.prototype.toJSON = List.prototype.toArray;

List.prototype.isEmpty = function() {
return this.head === null;
Expand Down
Loading

0 comments on commit ae1f83f

Please sign in to comment.