Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active February 28, 2023 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/39866fe4cd40138fd9bffb7f86d6fe10 to your computer and use it in GitHub Desktop.
Save parzibyte/39866fe4cd40138fd9bffb7f86d6fe10 to your computer and use it in GitHub Desktop.
const producto = "Nintendo Switch OLED con 2 juegos incluidos (Zelda BOTW y TOTK)";
const cantidad = "1.00";
const subtotal = "$152,986.22";
const longitudProducto = 10;
const longitudCantidad = 5;
const longitudSubtotal = 6;
const separadorColumnas = "|";
const separadorColumnasEnSeparador = "+";
const columnasEncabezado = [{ contenido: "Producto", maximaLongitud: longitudProducto }, { contenido: "Cant.", maximaLongitud: longitudCantidad }, { contenido: "Precio", maximaLongitud: longitudSubtotal },];
const columnasContenido = [{ contenido: producto, maximaLongitud: longitudProducto }, { contenido: cantidad, maximaLongitud: longitudCantidad }, { contenido: subtotal, maximaLongitud: longitudSubtotal },];
const lineasEncabezado = tabularDatos(columnasEncabezado, " ", separadorColumnas);
const lineasSeparador = tabularDatos([{ contenido: "-", maximaLongitud: longitudProducto }, { contenido: "-", maximaLongitud: longitudCantidad }, { contenido: "-", maximaLongitud: longitudSubtotal }], "-", separadorColumnasEnSeparador);
const lineasCuerpo = tabularDatos(columnasContenido, " ", separadorColumnas);
for (const linea of lineasEncabezado) {
console.log(linea);
}
for (const linea of lineasSeparador) {
console.log(linea);
}
for (const linea of lineasCuerpo) {
console.log(linea);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment