I usually do not create Streams, but it seems that JavaScript doesn't have a built-in one and I figured I would do it for a personal project I am working on. This code seems to work as intended and does what I want just fine, but I have concerns mainly about how often I am checking my buffer. I am mainly looking for a recommendation about how often I should check to see if any data has been written to my buffer. If there are any other improvements/suggestions, I am open to hearing them!

    const StreamPrototype = {
         _data: [],
    
        readAsync: async function* () {
            while(await sleep(25)) {
                let data;
                while((data = this._data.pop()))
                    yield data;
            }
        },
    
        push: function(data) {
            if (data) {
                this._data.push(data);
            }
        }
    };

    // This was just copied from the internet
    const sleep = time => new Promise(res => setTimeout(res, time, "done sleeping"));