33 points | by b_llc 2 days ago
2 comments
Ugly code though.
// env QUEUES = [EVEN_QUEUE, ODD_QUEUE] // producers env.QUEUES[hour % 2].send … // consumer env.QUEUES[1 + hour % 2]
// results in index 1 or 2 as js has precedence for */% over +-
So something like the following, for your desired visual succinctness? ...
env.QUEUES[hour % 2 ^ 1]
// results in desired js index 0 or 1
I wonder if any of you using AI code assistance regularly might tell an old hack like me if your code review tools would have caught such a bug?
Ugly code though.
// results in index 1 or 2 as js has precedence for */% over +-
So something like the following, for your desired visual succinctness? ...
env.QUEUES[hour % 2 ^ 1]
// results in desired js index 0 or 1
I wonder if any of you using AI code assistance regularly might tell an old hack like me if your code review tools would have caught such a bug?