Question: is there a way to convert stream to buffer in sync mode?
I need to get it like:

```
let newBuffer = outputStream.getDataSync();

```

rather than `outputStream.on('data'...` like below

```
let newBuffer = convertStream(outputStream);

function convertStream(strm) {
  return new Promise((resolve, reject) => {
    const chunks = [];
    strm.on('data', (chunk) => {
      chunks.push(chunk);
    }).on('end', () => {
      resolve(Buffer.concat(chunks));
    }).on('error', (err) => {
      reject(err);
    });
  });
}

```

I cannot use await for convertStream because the function I call it from is not async

Answer: 
You could potentially use `await` by wrapping the the call to `convertStream()` in an [Immediately Invoked Async Function Expression](http://2ality.com/2016/10/async-function-tips.html#immediately-invoked-async-function-expressions).

```js
function foo() {
  return Promise.resolve('bar');
}

(async function() { console.log(await foo()); })();
```
It is said that asynchrony is contagious: as soon as you have one asynchronous bit in your flow, all the dependent flow needs to be asynchronous. Streams are asynchronous by nature, so you can only simplify your code via synchronous-looking async-await.

BTW, the [asynchronous iterator interface for streams](https://nodejs.org/api/stream.html#stream_readable_symbol_asynciterator) may be the most concise way to do this.