import { Change } from "./change" ; import { Summary } from "./summary" ; export class ChangeStorage { private readonly changes : String [ ] = [ ] ; private readonly personalChanges : String [ ] = [ ] ; public contains ( change ) { return this . getCorrespondingArray ( change ) . indexOf ( change . toString ( ) ) !== - 1 ; } public storeNewChanges ( newChanges ) { if ( newChanges ) { newChanges . forEach ( ( change ) => { this . getCorrespondingArray ( change ) . push ( change . toString ( ) ) ; } ) ; } } private getCorrespondingArray ( change ) { return change . isPersonal ? this . personalChanges : this . changes ; } public reset ( ) { this . changes . length = 0 ; this . personalChanges . length = 0 ; } public extractNewChangesFromSummary ( summary ) { const newChanges = [ ] ; const changeSet = [ summary . changes , summary . personalChanges ] ; changeSet . forEach ( ( changes ) => { changes . forEach ( ( change ) => { if ( ! this . contains ( change ) ) { newChanges . push ( change ) ; } } ) ; } ) ; return newChanges ; } }