workspaces/mytosis-leveldb/src/index.js
async function* streamToGenerator(stream) {
  let promise;

  stream.on('data', data => promise.resolve(data));
  stream.once('end', () => promise.resolve(null));

  stream.on('error', error => {
    stream.removeAllListeners();
    promise.reject(error);
  });

  while (true) {
    promise = defer();

    yield promise;
  }
}
async function* streamToGenerator(stream) {
  let promise;

  stream.on('data', data => promise.resolve(data));
  stream.once('end', () => promise.resolve(null));

  stream.on('error', error => {
    stream.removeAllListeners();
    promise.reject(error);
  });

  while (true) {
    promise = defer();

    yield promise;
  }
}
async function * streamToGenerator ( stream ) { let promise ; stream . on ( 'data' , data => promise . resolve ( data ) ) ; stream . once ( 'end' , ( ) => promise . resolve ( null ) ) ; stream . on ( 'error' , error => { stream . removeAllListeners ( ) ; promise . reject ( error ) ; } ) ; while ( true ) { promise = defer ( ) ; yield promise ; } }
Reads values from a object mode readable stream as an async iterator.
@param  {Stream.Readable} stream - A value stream from levelup.
@return {Promise<Object>} - Resolves with each node.
Reads values from a object mode readable stream as an async iterator .