Created
December 11, 2020 17:36
-
-
Save r3b/88fabc090abd2178a88570c6ef78e364 to your computer and use it in GitHub Desktop.
easter egg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const expected = [ | |
'ArrowUp', | |
'ArrowDown', | |
'ArrowUp', | |
'ArrowDown', | |
'ArrowLeft', | |
'ArrowRight', | |
'ArrowLeft', | |
'ArrowRight', | |
'a', | |
'b', | |
'a', | |
'b', | |
'Enter', | |
] | |
fromEvent(document, 'keyup') | |
.pipe( | |
map((e: KeyboardEvent) => e.key), | |
bufferCount(expected.length), | |
mergeMap(keys => | |
from(keys).pipe( | |
sequenceEqual(from(expected)) | |
) | |
) | |
) | |
.subscribe(e => console.log(`You win!`)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment