UNPKG

@accounter/shaam-uniform-format-generator

Version:

Fully typed application that generates, parses, and validates SHAAM uniform format tax reports (INI.TXT and BKMVDATA.TXT).

40 lines (39 loc) 1.14 kB
"use strict"; /** * String padding utilities for fixed-width formatting */ Object.defineProperty(exports, "__esModule", { value: true }); exports.padLeft = padLeft; exports.padRight = padRight; /** * Pads a string on the left (right-aligns the content) * * @param value - The string to pad * @param width - Target width * @param fill - Character to use for padding (default: space) * @returns Left-padded string */ function padLeft(value, width, fill = ' ') { if (value.length >= width) { return value.substring(0, width); } const padLength = width - value.length; const padding = fill.repeat(padLength); return padding + value; } /** * Pads a string on the right (left-aligns the content) * * @param value - The string to pad * @param width - Target width * @param fill - Character to use for padding (default: space) * @returns Right-padded string */ function padRight(value, width, fill = ' ') { if (value.length >= width) { return value.substring(0, width); } const padLength = width - value.length; const padding = fill.repeat(padLength); return value + padding; }