Commit 9893e85 1 parent d86b80e commit 9893e85 Copy full SHA for 9893e85
File tree 1 file changed +6
-5
lines changed
electron/renderer/components/game
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -42,18 +42,19 @@ export const excludeDuplicateEmptyLines: rxjs.MonoTypeOperatorFunction<
42
42
GameLogLine
43
43
> = ( observable : rxjs . Observable < GameLogLine > ) => {
44
44
return observable . pipe (
45
- // Compare the current and next log lines to decide whether to emit or not.
45
+ // Compare the previous and next log lines to decide whether to emit or not.
46
46
// https://www.learnrxjs.io/learn-rxjs/operators/transformation/buffercount
47
47
rxjs . bufferCount ( 2 , 1 ) ,
48
48
// Inspect buffer to identify if there are duplicate empty lines.
49
- // If yes, emit only one and standardize on the prompt format.
50
- rxjs . map ( ( [ curr , next ] ) => {
51
- if ( isEmptyLogLine ( curr ) && isEmptyLogLine ( next ) ) {
49
+ // If yes, standardize on the prompt format, else emit the line as-is .
50
+ rxjs . map ( ( [ prev , curr ] ) => {
51
+ if ( isEmptyLogLine ( prev ) && isEmptyLogLine ( curr ) ) {
52
52
return { ...curr , text : '>\n' } ;
53
53
}
54
54
return curr ;
55
55
} ) ,
56
- // Emit only unique log lines.
56
+ // Exclude duplicate empty lines.
57
+ // But if the game repeats anything else, let it through.
57
58
rxjs . distinctUntilChanged ( ( prev , curr ) => {
58
59
return isEmptyLogLine ( prev ) && isEmptyLogLine ( curr ) ;
59
60
} )
You can’t perform that action at this time.
0 commit comments