UNPKG

@fivem-ts/shared

Version:

FiveM Typescript wrapper shared part

26 lines (25 loc) 783 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.padString = padString; /** * Pads a string to a specified length with a given character. * * @example * ```ts * const result = padString("Hello", 10, "*"); * console.log(result); // "Hello*****" * ``` * * @param {string} input - The input string to be padded. * @param {number} targetLength - The target length of the resulting string. * @param [padChar=' '] - The character to pad the string with. Defaults to a space character. * * @return The padded string. */ function padString(input, targetLength, padChar = ' ') { if (input.length >= targetLength) { return input; } const padding = padChar.repeat(targetLength - input.length); return input + padding; }