UNPKG

for-emit-of

Version:

Turn Node.js Events into Async Iterables

33 lines (32 loc) 759 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getQueue = void 0; function getQueue() { let first; let last; return { length: 0, shift() { if (first) { const { value } = first; first = first.next; if (!first) { last = first; } this.length--; return value; } }, push(value) { const node = { value }; if (!last) { first = last = node; } else { last = last.next = node; } this.length++; }, }; } exports.getQueue = getQueue;