The first key that is not a key
Consecutive duplicate events slip through only at the start.
What’s going wrong
An event filter emits the value of the first item and then emits only when the current selected key differs from the last emitted key using strict equality. Stdin is an array of {"key":scalar,"value":scalar} objects; scalars are strings, finite numbers, booleans or null. Print the emitted values in order. Key types are significant: 1 and "1" differ. Only consecutive equal keys collapse, and emitted payload values do not participate in comparison. An empty stream prints [].
Read one JSON value from stdin and print the specified JSON result to stdout. No actual network or external package is used.
Expected behavior
Normalize stored comparison state from the first item onward instead of mixing a value with its selected key.
Reproduction
[{"key":"a","value":1},{"key":"a","value":2}][1]
[{"key":"a","value":1},{"key":"b","value":2}][1,2]
[]
[]
Before you begin
- Build on missing tuple positions: initialize state explicitly and preserve falsey values as valid data.
- TypeScript unions, arrays, objects and functions
- Trace runtime behavior even when the program type-checks
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.