src/events/crawler/tasks/scrapeData/runScraper.js
/*
  Add output data to the cases array. Input can be either an object or an array
*/
Add output data to the cases array. Input can be either an object or an array
Add output data to the cases array . Input can be either an object or an array
function addData(cases, location, result) {
  if (Array.isArray(result)) {
    if (result.length === 0) {
      throw new Error(`Invalid data: scraper for ${geography.getName(location)} returned 0 rows`);
    }
    for (const data of result) {
      if (isValid(data, location)) {
        cases.push(addLocationToData(data, location));
      }
    }
  } else if (isValid(result, location)) {
    cases.push(addLocationToData(result, location));
  }
}
function addData ( cases , location , result ) { if ( Array . isArray ( result ) ) { if ( result . length === 0 ) { throw new Error ( ` ${ geography . getName ( location ) } ` ) ; } for ( const data of result ) { if ( isValid ( data , location ) ) { cases . push ( addLocationToData ( data , location ) ) ; } } } else if ( isValid ( result , location ) ) { cases . push ( addLocationToData ( result , location ) ) ; } }
Add output data to the cases array.
Add output data to the cases array .