diff options
Diffstat (limited to 'util/waitForData.js')
-rw-r--r-- | util/waitForData.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/util/waitForData.js b/util/waitForData.js new file mode 100644 index 0000000..bf40c52 --- /dev/null +++ b/util/waitForData.js @@ -0,0 +1,9 @@ +module.exports = function waitForData(stream, cond = null) { + return new Promise(resolve => { + stream.on('data', data => { + if (cond ? cond(data) : true) { + resolve(data) + } + }) + }) +} |