async function* paginate(fn, key, params={}) {
  let paging = {};

  do {
    const opts = {...params, ...paging};
    const page = await fn(opts).promise();
    const {[key]: results} = page;

    yield* results;

    paging = next(page);
  } while (paging);
}
/**
 * Async iterator over paginated results.
 * @param {function} fn     Bound AWS function which returns paginated results
 * @param {string} key      Response result key
 * @param {object} params   Params to pass to function each page
 * @yields {object}
 */
Async iterator over paginated results.
@param {function} fn     Bound AWS function which returns paginated results
@param {string} key      Response result key
@param {object} params   Params to pass to function each page
@yields {object}
Async iterator over paginated results . @param { function } fn Bound AWS function which returns paginated results @param { string } key Response result key @param { object } params Params to pass to function each page @yields { object }
async function* paginate(fn, key, params={}) {
  let paging = {};
  do {
    const opts = {...params, ...paging};
    const page = await fn(opts).promise();
    const {[key]: results} = page;
    yield* results;
    paging = next(page);
  } while (paging);
}
async function * paginate ( fn , key , params = { } ) { let paging = { } ; do { const opts = { ... params , ... paging } ; const page = await fn ( opts ) . promise ( ) ; const { [ key ] : results } = page ; yield * results ; paging = next ( page ) ; } while ( paging ) ; }
Async iterator over paginated results.
Async iterator over paginated results .