diff options
-rw-r--r-- | lib/internal/DoublyLinkedList.js | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/internal/DoublyLinkedList.js b/lib/internal/DoublyLinkedList.js index ae46957..79c3bb5 100644 --- a/lib/internal/DoublyLinkedList.js +++ b/lib/internal/DoublyLinkedList.js @@ -13,7 +13,6 @@ function setInitial(dll, node) { } DLL.prototype.removeLink = function(node) { - if (!node) return node; if (node.prev) node.prev.next = node.next; else this.head = node.next if (node.next) node.next.prev = node.prev; @@ -54,11 +53,10 @@ DLL.prototype.push = function(node) { else setInitial(this, node); }; - DLL.prototype.shift = function() { - return this.removeLink(this.head); + return this.head && this.removeLink(this.head); }; DLL.prototype.pop = function() { - return this.removeLink(this.tail); + return this.tail && this.removeLink(this.tail); }; |