mirror of https://github.com/portainer/portainer
16 lines
371 B
TypeScript
16 lines
371 B
TypeScript
|
import { NEW_LINE_BREAKER } from '@/constants';
|
||
|
|
||
|
import { FormattedLine } from './types';
|
||
|
|
||
|
type FormatFunc = (line: FormattedLine) => string;
|
||
|
|
||
|
export function concatLogsToString(
|
||
|
logs: FormattedLine[],
|
||
|
formatFunc: FormatFunc = (line) => line.line
|
||
|
) {
|
||
|
return logs.reduce(
|
||
|
(acc, formattedLine) => acc + formatFunc(formattedLine) + NEW_LINE_BREAKER,
|
||
|
''
|
||
|
);
|
||
|
}
|