Created
June 18, 2020 21:58
-
-
Save craigphicks/a5349d1267d501e6f008189446f8a59e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function readStreamToEnd(rstream){ | |
rstream.resume(); | |
let prom=new Promise((resolve,reject)=>{ | |
var buf = Buffer(''); | |
rstream.on('data', function(newbuf) { buf=Buffer.concat([buf,newbuf]); }); | |
rstream.on('end', function() { resolve(buf.toString()); }); | |
rstream.on('error', function(e) { reject(e); }); | |
}); | |
return await prom; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment