- ✅ Ticket 1.1: Estructura Clean Architecture en backend - ✅ Ticket 1.2: Schemas Zod compartidos - ✅ Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares) - ✅ Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares) - ✅ Ticket 1.5: Eliminación de duplicidades (~50 líneas) Cambios principales: - Creada estructura Clean Architecture en backend/src/ - Schemas Zod compartidos en backend/src/shared/schemas/ - Refactorización modular de drugs y procedures - Utilidades genéricas en src/utils/ (filter, validation) - Eliminados scripts obsoletos y documentación antigua - Corregidos errores: QueryClient, import test-error-handling - Build verificado y funcionando correctamente
49 lines
972 B
JavaScript
49 lines
972 B
JavaScript
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
|
|
}
|
|
}
|