- ✅ 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
26 lines
828 B
JavaScript
26 lines
828 B
JavaScript
'use strict'
|
|
var stringWidth = require('string-width')
|
|
var stripAnsi = require('strip-ansi')
|
|
|
|
module.exports = wideTruncate
|
|
|
|
function wideTruncate (str, target) {
|
|
if (stringWidth(str) === 0) return str
|
|
if (target <= 0) return ''
|
|
if (stringWidth(str) <= target) return str
|
|
|
|
// We compute the number of bytes of ansi sequences here and add
|
|
// that to our initial truncation to ensure that we don't slice one
|
|
// that we want to keep in half.
|
|
var noAnsi = stripAnsi(str)
|
|
var ansiSize = str.length + noAnsi.length
|
|
var truncated = str.slice(0, target + ansiSize)
|
|
|
|
// we have to shrink the result to account for our ansi sequence buffer
|
|
// (if an ansi sequence was truncated) and double width characters.
|
|
while (stringWidth(truncated) > target) {
|
|
truncated = truncated.slice(0, -1)
|
|
}
|
|
return truncated
|
|
}
|