UNPKG

restaurants

Version:

Search a service and get a list of restaurants.

36 lines (30 loc) 593 B
/** * Dependencies */ var whilst = require('async').whilst; /** * Expose `getAll` */ module.exports = function(query, max_limit, max_offset, find, callback) { var offset = 0 , data = []; whilst( function() { return offset <= max_offset; } , function(next) { find(query, max_limit, offset, function(err, restaurants) { if (err) { next(err); } else { data = data.concat(restaurants); offset += max_limit; next(); } }); } , function(err) { callback(err, data); } ); };