« get me outta code hell
1 2 3 4 5 6 7 8 9
export default function waitForData(stream, cond = null) { return new Promise(resolve => { stream.on('data', data => { if (cond ? cond(data) : true) { resolve(data) } }) }) }