import { IDiffSchema } from '@src/Utils/DiffGenerator/IDiffSchema' ; export class DiffFormatter { public static diffToMarkdown ( diffs , limit = 2000 ) { const parts = [ ] ; let part = '' ; let text = '' ; for ( const diff of diffs ) { if ( diff . changes . length === 1 ) { text = '**' + ( diff . name === null ? '' : diff . name + '**: ' ) + diff . changes [ 0 ] ; } else { text = '**' + diff . name + '**:\n\t' + diff . changes . join ( '\n\t' ) ; } if ( ( part + text + '\n' ) . length >= limit - 10 ) { parts . push ( part ) ; part = '' ; } part += text + '\n' ; } parts . push ( part ) ; return parts . join ( '\n=====\n' ) ; } }