Comparing version 2.0.0 to 2.1.0
11
index.js
@@ -68,2 +68,13 @@ var Node = function(list, val) { | ||
FIFO.prototype.isEmpty = function() { | ||
return this.length === 0 || this.node === null | ||
} | ||
FIFO.prototype.removeAll = function() { | ||
if (this.length !== 0 && this.node !== null) { | ||
this.length = 0 | ||
this.node = null | ||
} | ||
} | ||
FIFO.prototype.toArray = function() { | ||
@@ -70,0 +81,0 @@ var list = [] |
{ | ||
"name": "fifo", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"repository": "git://github.com/mafintosh/fifo", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -29,2 +29,9 @@ # FIFO | ||
fifo.unshift('hello'); // insert at the beginning | ||
fifo.removeAll(); // Clear stack | ||
if (!fifo.isEmpty()) { // Check if stack is empty | ||
fifo.shift(); | ||
} | ||
``` | ||
@@ -31,0 +38,0 @@ |
11
test.js
@@ -6,2 +6,4 @@ var test = require('tape') | ||
var fifo = new FIFO() | ||
t.equal(fifo.isEmpty(), true); | ||
fifo.push('foo') | ||
@@ -30,2 +32,11 @@ t.equal(fifo.length, 1) | ||
fifo.push('foo') | ||
fifo.push('bar') | ||
fifo.push('foo1') | ||
t.equal(fifo.isEmpty(), false) | ||
fifo.removeAll() | ||
t.equal(fifo.length, 0) | ||
t.equal(fifo.first(), null) | ||
t.equal(fifo.last(), null) | ||
t.end() | ||
@@ -32,0 +43,0 @@ }) |
4305
120
43