You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zipcoder.js 708B

12345678910111213141516171819202122232425
  1. const config = require('../../../db/data-generator/config.json')
  2. /**
  3. * Grab the zip code string
  4. */
  5. const getZipCodeFromProfile = profile => {
  6. // There should only be one zip code entry per profile
  7. let zipRes = profile.responses.find(
  8. res => res.response_key_id == config.zipcodeKey,
  9. )
  10. return zipRes.val
  11. }
  12. const filterByDistance = (profileList, max) => {
  13. return profileList.filter(profile => {
  14. const profileDistance = Math.floor(parseFloat(profile.distance) * 100)
  15. const adjustedMaxDistance = Math.floor(parseFloat(max) * 100)
  16. return profileDistance <= adjustedMaxDistance
  17. })
  18. }
  19. module.exports = {
  20. getZipCodeFromProfile,
  21. filterByDistance,
  22. }