- ✅ 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
66 lines
1.4 KiB
JavaScript
Executable file
66 lines
1.4 KiB
JavaScript
Executable file
'use strict'
|
|
var stringWidth = require('string-width')
|
|
|
|
exports.center = alignCenter
|
|
exports.left = alignLeft
|
|
exports.right = alignRight
|
|
|
|
// lodash's way of generating pad characters.
|
|
|
|
function createPadding (width) {
|
|
var result = ''
|
|
var string = ' '
|
|
var n = width
|
|
do {
|
|
if (n % 2) {
|
|
result += string;
|
|
}
|
|
n = Math.floor(n / 2);
|
|
string += string;
|
|
} while (n);
|
|
|
|
return result;
|
|
}
|
|
|
|
function alignLeft (str, width) {
|
|
var trimmed = str.trimRight()
|
|
if (trimmed.length === 0 && str.length >= width) return str
|
|
var padding = ''
|
|
var strWidth = stringWidth(trimmed)
|
|
|
|
if (strWidth < width) {
|
|
padding = createPadding(width - strWidth)
|
|
}
|
|
|
|
return trimmed + padding
|
|
}
|
|
|
|
function alignRight (str, width) {
|
|
var trimmed = str.trimLeft()
|
|
if (trimmed.length === 0 && str.length >= width) return str
|
|
var padding = ''
|
|
var strWidth = stringWidth(trimmed)
|
|
|
|
if (strWidth < width) {
|
|
padding = createPadding(width - strWidth)
|
|
}
|
|
|
|
return padding + trimmed
|
|
}
|
|
|
|
function alignCenter (str, width) {
|
|
var trimmed = str.trim()
|
|
if (trimmed.length === 0 && str.length >= width) return str
|
|
var padLeft = ''
|
|
var padRight = ''
|
|
var strWidth = stringWidth(trimmed)
|
|
|
|
if (strWidth < width) {
|
|
var padLeftBy = parseInt((width - strWidth) / 2, 10)
|
|
padLeft = createPadding(padLeftBy)
|
|
padRight = createPadding(width - (strWidth + padLeftBy))
|
|
}
|
|
|
|
return padLeft + trimmed + padRight
|
|
}
|