mirror of
https://github.com/sbrl/terrain50-cli.git
synced 2024-11-26 07:33:00 +00:00
StreamHelpers: await for finish event
This commit is contained in:
parent
03fc6b55ea
commit
aca3fb0278
1 changed files with 4 additions and 2 deletions
|
@ -42,9 +42,11 @@ function write_safe(stream_out, data) {
|
|||
*/
|
||||
function end_safe(stream, chunk = undefined) {
|
||||
return new Promise((resolve, _reject) => {
|
||||
if(typeof chunk == "undefined") stream.end(resolve);
|
||||
else stream.end(chunk, resolve);
|
||||
stream.once("finish", resolve);
|
||||
if(typeof chunk == "undefined") stream.end();
|
||||
else stream.end(chunk);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export { write_safe, end_safe };
|
||||
|
|
Loading…
Reference in a new issue