![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/node_modules/fast-fifo/ |
const FixedFIFO = require('./fixed-size')
module.exports = class FastFIFO {
constructor (hwm) {
this.hwm = hwm || 16
this.head = new FixedFIFO(this.hwm)
this.tail = this.head
this.length = 0
}
clear () {
this.head = this.tail
this.head.clear()
this.length = 0
}
push (val) {
this.length++
if (!this.head.push(val)) {
const prev = this.head
this.head = prev.next = new FixedFIFO(2 * this.head.buffer.length)
this.head.push(val)
}
}
shift () {
if (this.length !== 0) this.length--
const val = this.tail.shift()
if (val === undefined && this.tail.next) {
const next = this.tail.next
this.tail.next = null
this.tail = next
return this.tail.shift()
}
return val
}
peek () {
const val = this.tail.peek()
if (val === undefined && this.tail.next) return this.tail.next.peek()
return val
}
isEmpty () {
return this.length === 0
}
}