"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1280.1/src/lib/error-format.ts" (20 Feb 2024, 314 Bytes) of package /linux/misc/snyk-cli-1.1280.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 export function abridgeErrorMessage(
    2   msg: string,
    3   maxLen: number,
    4   ellipsis = ' ... ',
    5 ): string {
    6   if (msg.length <= maxLen) {
    7     return msg;
    8   }
    9   const toKeep = Math.floor((maxLen - ellipsis.length) / 2);
   10   return (
   11     msg.slice(0, toKeep) + ellipsis + msg.slice(msg.length - toKeep, msg.length)
   12   );
   13 }