code: function streamToPromise(stream) {
      return new Promise((resolve, reject) => {
          stream.on('error', reject);
          stream.on('end', resolve);
      });
  }
docs: Utility function to chain stream success/fail state as promises