import events from 'events';

class Feeder extends events.EventEmitter {
    queue = [];
    pending = false;

    feed(data) {
        this.queue = this.queue.concat(data);
    }
    clear() {
        this.queue = [];
        this.pending = false;
    }
    next() {
        if (this.queue.length === 0) {
            this.pending = false;
            return false;
        }

        const data = this.queue.shift();
        this.pending = true;
        this.emit('data', data);

        return data;
    }
    isPending() {
        return this.pending;
    }
}

export default Feeder;

@@ -244,24 +244,77 @@
 alse;%0A    %7D%0A
+    size() %7B%0A        return this.queue.length;%0A    %7D%0A
     next() %7B

Return the number of items in the queue