import { OutputStream } from '@serenity-js/core/lib/io' ; desc public export class Printer { private indentation = new Indentation ( 2 ) ; param { serenity-js constructor ( private readonly stdout = process . stdout ) { } desc param { ... any [ ] } args returns { void } println ( ... args ) { return this . print ( ... args , '\n' ) ; } desc param { ... any [ ] } args returns { void } print ( ... args ) { this . stdout . write ( this . indentation . indented ( `${ args . map ( String ) . join ( '' ) }` ) ) ; } desc returns { void } indent ( ) { this . indentation . increase ( ) ; } desc returns { void } outdent ( ) { this . indentation . decrease ( ) ; } } package class Indentation { private current = 0 ; constructor ( private readonly step ) { } increase ( ) { this . current += this . step ; } decrease ( ) { if ( this . current - this . step >= 0 ) { this . current -= this . step ; } } indented ( ... fragments ) { return fragments . join ( '' ) . split ( '\n' ) . map ( line => line ? ' ' . repeat ( this . current ) + line : '' ) . join ( '\n' ) ; } }