diff options
author | liam4 <towerofnix@gmail.com> | 2017-07-03 18:59:57 -0300 |
---|---|---|
committer | liam4 <towerofnix@gmail.com> | 2017-07-03 19:00:01 -0300 |
commit | 769413468e88acba1a180baa0113139d929a3b9f (patch) | |
tree | f29af36826077178259b7bcc8bf9927cebfe71e3 /util/waitForData.js | |
parent | 489e4d0c78d5f393729cda0e1f6ac9a0a1237b4a (diff) |
A long-due cleanup + examples + things
..Obviously this breaks old things (particularly, see changes in FocusElement).
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) + } + }) + }) +} |