squarier
Version:
This package can help you format text in a square like manner.
23 lines • 883 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function pad(str, len, options) {
var _a = getDefault(options || {}), symbol = _a.symbol, mode = _a.mode, include = _a.include;
if (mode !== 'after') {
throw new Error("'".concat(mode, "' mode is not implemented yet"));
}
if (include === false) {
throw new Error("'false' include is not implemented yet");
}
var paddingLength = Math.max(len - str.length, 0);
return str + symbol.repeat(paddingLength);
}
function getDefault(options) {
var _a, _b, _c;
return {
include: (_a = options.include) !== null && _a !== void 0 ? _a : true,
mode: (_b = options.mode) !== null && _b !== void 0 ? _b : 'after',
symbol: (_c = options.symbol) !== null && _c !== void 0 ? _c : ' ',
};
}
exports.default = pad;
//# sourceMappingURL=pad.js.map