Comparing version 1.3.0 to 1.3.1
@@ -40,8 +40,10 @@ const FixedFIFO = require('./fixed-size') | ||
peek () { | ||
return this.tail.peek() | ||
const val = this.tail.peek() | ||
if (val === undefined && this.tail.next) return this.tail.next.peek() | ||
return val | ||
} | ||
isEmpty () { | ||
return this.head.isEmpty() | ||
return this.length === 0 | ||
} | ||
} |
{ | ||
"name": "fast-fifo", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "A fast fifo implementation similar to the one powering nextTick in Node.js core", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
17
test.js
@@ -120,4 +120,21 @@ const test = require('brittle') | ||
test('peek edgecase', function (t) { | ||
const q = new FIFO(4) | ||
q.push('a') | ||
q.push('b') | ||
q.push('c') | ||
q.push('d') | ||
q.push('e') | ||
t.is(q.peek(), q.shift()) | ||
t.is(q.peek(), q.shift()) | ||
t.is(q.peek(), q.shift()) | ||
t.is(q.peek(), q.shift()) | ||
t.is(q.peek(), q.shift()) | ||
t.is(q.peek(), q.shift()) | ||
}) | ||
test('invalid hwm', function (t) { | ||
t.exception(() => new FIFO(3)) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8305
215