vox-common/level-index.js
function scanIndex(leveldb, options) {
  return new P(function(resolve, reject) {
    var datas = [];
    var resolved = false;
    function fin() {
      if (resolved) {
        return;
      }
      resolve(P.all(datas));
      resolved = true;
    }
    leveldb.createKeyStream(options)
      .on('data', function(key) {
        var i = key.lastIndexOf('\x00');
        var key = key.substr(i + 1);
        datas.push(leveldb.getAsync(key));
      })
      .on('close', fin)
      .on('end', fin)
      .on('error', function(err) {
        reject(err);
      })
  });
}
function scanIndex(leveldb, options) {
  return new P(function(resolve, reject) {
    var datas = [];
    var resolved = false;
    function fin() {
      if (resolved) {
        return;
      }
      resolve(P.all(datas));
      resolved = true;
    }
    leveldb.createKeyStream(options)
      .on('data', function(key) {
        var i = key.lastIndexOf('\x00');
        var key = key.substr(i + 1);
        datas.push(leveldb.getAsync(key));
      })
      .on('close', fin)
      .on('end', fin)
      .on('error', function(err) {
        reject(err);
      })
  });
}
function scanIndex ( leveldb , options ) { return new P ( function ( resolve , reject ) { var datas = [ ] ; var resolved = false ; function fin ( ) { if ( resolved ) { return ; } resolve ( P . all ( datas ) ) ; resolved = true ; } leveldb . createKeyStream ( options ) . on ( 'data' , function ( key ) { var i = key . lastIndexOf ( '\x00' ) ; var key = key . substr ( i + 1 ) ; datas . push ( leveldb . getAsync ( key ) ) ; } ) . on ( 'close' , fin ) . on ( 'end' , fin ) . on ( 'error' , function ( err ) { reject ( err ) ; } ) } ) ; }
Starts a LevelDB index scan and returns a Promise for the list of results.

@param {LevelDB} leveldb The DB to scan.
@param {Object} options An options object passed verbatim to
leveldb.createKeyStream().
@return {Promise<Object[]>} The scan results.
Starts a LevelDB index scan and returns a Promise for the list of results .