node-osmosis icon indicating copy to clipboard operation
node-osmosis copied to clipboard

How to indicate it's the last page in a paginate function? done isn't accessible

Open tttp opened this issue 6 years ago • 0 comments

Hi,

I'm using a not very documented feature, hopefully it's meant to be a stable one: using a function on paginate:

function mypaginate(context,data) {
  // do things to find the params for the next page
  if (next_page) {
      return {page: 42,other_param:whatever...}
  } else { // how to tell there isn't a new page?
     // i want to make it done("no more pages")
     return "404_does_not_exists"; // this is a hack, that will happen to be returning an invalid url
  }
}

osmosis...
   .paginate(mypaginate)

in the "normal" pagination mode (with selector) it does call return done('no URL found in ' + selector), but the callback function isn't available from the pagination function

Could I PR a change so if the pagination function returns null or false, it means it will call done('no URL found') instead of trying to fetch the page no matter what?

tttp avatar Aug 13 '18 09:08 tttp