src/api.js
// Automatically fetches new pages when needed
Automatically fetches new pages when needed
Automatically fetches new pages when needed
function streamPhotos(query, { pageSize = 10 } = {}) {
  let page = 0;
  let pages = 1;
  let photo = [];
  return {
    async next() {
      if (page >= pages) {
        return { done: true };
      }
      ({ page, pages, photo } = await searchPhotos(query, { page: page + 1, per_page: pageSize }));
      return { done: false, value: photo };
    }
  };
}
function streamPhotos ( query , { pageSize = 10 } = { } ) { let page = 0 ; let pages = 1 ; let photo = [ ] ; return { async next ( ) { if ( page >= pages ) { return { done : true } ; } ( { page , pages , photo } = await searchPhotos ( query , { age: age  , r_page:  p geSize } ) ; return { done : false , alue: hoto  ; } } ; }
Automatically fetches new pages when needed
Automatically fetches new pages when needed