export enum Align { Left = ':---' , Center = ':---:' , Right = '---:' , None = '---' } export const Icon = { skip : '✖️' , success : '✔️' , fail : '❌' } ; export function link ( title , address ) { return `[${ title }](${ address })` ; } type ToString = string | number | boolean | Date ; export function table ( headers , align , ... rows ) { const headerRow = `|${ headers . map ( tableEscape ) . join ( '|' ) }|` ; const alignRow = `|${ align . join ( '|' ) }|` ; const contentRows = rows . map ( row => `|${ row . map ( tableEscape ) . join ( '|' ) }|` ) . join ( '\n' ) ; return [ headerRow , alignRow , contentRows ] . join ( '\n' ) ; } export function tableEscape ( content ) { return content . toString ( ) . replace ( '|' , '\\|' ) ; } export function fixEol ( text ? ) { return text ?. replace ( /\r/g , '' ) ?? '' ; } export function ellipsis ( text , maxLength ) { if ( text . length <= maxLength ) { return text ; } return text . substr ( 0 , maxLength - 3 ) + '...' ; } export function formatTime ( ms ) { if ( ms > 1000 ) { return `${ Math . round ( ms / 1000 ) }s` ; } return `${ Math . round ( ms ) }ms` ; }