lib/client.js
function(searchQuery) {
  return request(constructSearchUrl(searchQuery))
    .then(function(body){
      let $ = cheerio.load(body);
      let rows = $('table#celacr tr');
      let promises = rows
      .filter(idx => idx >= 1) // skip header row (index=0)
      .map((idx, el) => parseVehicleID($, el))
      .get()  // convert cheerio object to plain array
      .map(getByID);
      return Promise.all(promises);
    })
    .then(formatDetails);
}
function(searchQuery) {
  return request(constructSearchUrl(searchQuery))
    .then(function(body){
      let $ = cheerio.load(body);
      let rows = $('table#celacr tr');
      let promises = rows
      .filter(idx => idx >= 1) // skip header row (index=0)
      .map((idx, el) => parseVehicleID($, el))
      .get()  // convert cheerio object to plain array
      .map(getByID);
      return Promise.all(promises);
    })
    .then(formatDetails);
}
function ( searchQuery ) { return request ( constructSearchUrl ( searchQuery ) ) . then ( function ( body ) { let $ = cheerio . load ( body ) ; let rows = $ ( 'table#celacr tr' ) ; let promises = rows . filter ( idx => idx >= 1 ) // skip header row (index=0) . map ( ( idx , el ) => parseVehicleID ( $ , el ) ) . get ( ) // convert cheerio object to plain array . map ( getByID ) ; return Promise . all ( promises ) ; } ) . then ( formatDetails ) ; }
The main and only method of the client, search. It takes searchQuery,
either VIN or registration number. Returns object in the following form:
{"results":[...],"count":1,"time":"2016-03-03T07:10:55.213Z"}
The main and only method of the client search . It takes searchQuery either VIN or registration number . Returns object in the following form : { results : [ ... ] count : 1 time : 2016 - 03 - 03T07 : 10 : 55 . 213Z }