This file contains hidden or 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 Queue = require('then-queue'); // async queue that doesn't care what order you call push and pop. | |
const queue = new Queue(); | |
// push sends to the first waiting `pop` if available, otherwise it acts as a buffer | |
listenToNewMessages(message => queue.push(message)); | |
async function* MessagesGenerator() { | |
try { | |
while (true) { |