Documentation and formatting

This commit is contained in:
Kim Ravn Hansen
2025-10-13 15:57:03 +02:00
parent 1631143647
commit 2fe8f7149c

View File

@@ -88,7 +88,7 @@ export class FramingOptions {
// Dark block: ▓ (U+2593)
// Solid block: █ (U+2588)
/** @type {string} Single character to use as filler inside the frame. */
paddingChar = " "; // character used for padding inside the frame.
paddingChar = " ";
/** @type {string} Single character to use as filler outside the frame. */
marginChar = " ";
@@ -114,10 +114,7 @@ export class FramingOptions {
//
// Do we have custom and valid frame chars?
if (
typeof o.frameChars === "string" &&
o.frameChars.length === FrameType.values.Double.length
) {
if (typeof o.frameChars === "string" && o.frameChars.length === FrameType.values.Double.length) {
result.frameChars = o.frameChars;
//
@@ -156,9 +153,7 @@ export function frameText(text, options) {
if (typeof text !== "string") {
console.debug(text);
throw new Error(
`text argument was neither an array or a string, it was a ${typeof text}`,
);
throw new Error(`text argument was neither an array or a string, it was a ${typeof text}`);
}
/** @type {string[]} */
@@ -176,12 +171,7 @@ export function frameText(text, options) {
const frameThickness = 1; // always 1 for now.
const outerLineLength =
0 +
innerLineLength +
frameThickness * 2 +
options.hPadding * 2 +
options.hMargin * 2;
const outerLineLength = 0 + innerLineLength + frameThickness * 2 + options.hPadding * 2 + options.hMargin * 2;
// get the frame characters from the frameType.
let [
@@ -230,9 +220,7 @@ export function frameText(text, options) {
// ( space, and what if we want to nest many )
// ( frames inside each other? )
//
output += (options.marginChar.repeat(outerLineLength) + "\n").repeat(
options.vMargin,
);
output += (options.marginChar.repeat(outerLineLength) + "\n").repeat(options.vMargin);
//
// GENERATE THE TOP PART OF THE FRAME
@@ -326,9 +314,7 @@ export function frameText(text, options) {
// ( space, and what if we want to nest many )
// ( frames inside each other? )
//
output += (options.marginChar.repeat(outerLineLength) + "\n").repeat(
options.vMargin,
);
output += (options.marginChar.repeat(outerLineLength) + "\n").repeat(options.vMargin);
return output;
}