Socket
Socket
Sign inDemoInstall

fast-fifo

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-fifo - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

4

index.js

@@ -8,5 +8,7 @@ const FixedFIFO = require('./fixed-size')

this.tail = this.head
this.length = 0
}
push (val) {
this.length++
if (!this.head.push(val)) {

@@ -20,2 +22,3 @@ const prev = this.head

shift () {
if (this.length !== 0) this.length--
const val = this.tail.shift()

@@ -28,2 +31,3 @@ if (val === undefined && this.tail.next) {

}
return val

@@ -30,0 +34,0 @@ }

2

package.json
{
"name": "fast-fifo",
"version": "1.1.0",
"version": "1.2.0",
"description": "A fast fifo implementation similar to the one powering nextTick in Node.js core",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -48,2 +48,6 @@ # fast-fifo

#### `len = q.length`
Get the number of entries remaining in the FIFO.
## Benchmarks

@@ -50,0 +54,0 @@

@@ -33,4 +33,8 @@ const tape = require('tape')

t.ok(q.isEmpty())
t.equal(q.length, 0)
for (const value of values) q.push(value)
while (!q.isEmpty()) t.same(q.shift(), values.shift())
while (!q.isEmpty()) {
t.same(q.shift(), values.shift())
t.equal(q.length, values.length)
}
t.same(q.shift(), undefined)

@@ -40,1 +44,21 @@ t.ok(q.isEmpty())

})
tape('long length', function (t) {
const q = new FIFO()
const len = 0x8f7
for (let i = 0; i < len; i++) q.push(i)
t.same(q.length, len)
let shifts = 0
while (!q.isEmpty()) {
q.shift()
shifts++
}
t.same(shifts, len)
t.same(q.length, 0)
t.end()
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc