OOKNET                             [ /  search the index  ]  
──────────────────────────────────────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════════════════════════
OOKNET   [ /  search  ]  
────────────────────────────────────────────────
════════════════════════════════════════════════
 
 
master @ 25 LINES
 
[ HISTORY ]  [ UP ]
 

// Labeled key/value rows with values word-wrapped under their column -
// the pattern ArticleMeta hand-rolls, as a reusable block.
import { checkGrid, len, pad, wrapHard } from "../../lib/ascii";

export interface Props {
  entries: [string, string][];
  keyW?: number;
}

export function buildKeyValue(entries: [string, string][], width: number, keyW?: n
umber): string {
  if (!entries.length) return "";
  const kw = keyW ?? Math.max(...entries.map(([k]) => len(k))) + 3;
  const valW = Math.max(1, width - kw);

  const lines: string[] = [];
  for (const [key, value] of entries) {
    wrapHard(value, valW)
      .split("\n")
      .forEach((ln, i) => {
        lines.push(pad(i === 0 ? key : "", kw) + ln);
      });
  }
  return checkGrid(lines.join("\n"), width, "key-value");
}

// Labeled key/value rows with values word-w
rapped under their column -
// the pattern ArticleMeta hand-rolls, as a 
reusable block.
import { checkGrid, len, pad, wrapHard } fro
m "../../lib/ascii";

export interface Props {
  entries: [string, string][];
  keyW?: number;
}

export function buildKeyValue(entries: [stri
ng, string][], width: number, keyW?: number)
: string {
  if (!entries.length) return "";
  const kw = keyW ?? Math.max(...entries.map
(([k]) => len(k))) + 3;
  const valW = Math.max(1, width - kw);

  const lines: string[] = [];
  for (const [key, value] of entries) {
    wrapHard(value, valW)
      .split("\n")
      .forEach((ln, i) => {
        lines.push(pad(i === 0 ? key : "", k
w) + ln);
      });
  }
  return checkGrid(lines.join("\n"), width, 
"key-value");
}
 
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET