UNPKG

buroventures-harald-code

Version:

Harald Code - AI-powered coding assistant CLI

36 lines 1.22 kB
/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ /** * Calculates the maximum width of a multi-line ASCII art string. * @param asciiArt The ASCII art string. * @returns The length of the longest line in the ASCII art. */ export const getAsciiArtWidth = (asciiArt) => { if (!asciiArt) { return 0; } const lines = asciiArt.split('\n'); return Math.max(...lines.map((line) => line.length)); }; /* * ------------------------------------------------------------------------- * Unicode‑aware helpers (work at the code‑point level rather than UTF‑16 * code units so that surrogate‑pair emoji count as one "column".) * ---------------------------------------------------------------------- */ export function toCodePoints(str) { // [...str] or Array.from both iterate by UTF‑32 code point, handling // surrogate pairs correctly. return Array.from(str); } export function cpLen(str) { return toCodePoints(str).length; } export function cpSlice(str, start, end) { // Slice by code‑point indices and re‑join. const arr = toCodePoints(str).slice(start, end); return arr.join(''); } //# sourceMappingURL=textUtils.js.map