← back to Professional Directory
agents/shared/la-zips.js
23 lines
/**
* LA County ZIP set — sourced from db/la_zips.sql.
* Exposed both as Set<string> and as an async DB lookup for importers
* that prefer to filter inside Postgres.
*/
const { query } = require('./db');
let cachedSet = null;
async function laZipSet() {
if (cachedSet) return cachedSet;
const r = await query('SELECT zip FROM la_zips', []);
cachedSet = new Set(r.rows.map(row => row.zip));
return cachedSet;
}
function isLaZip(zip5, set) {
if (!zip5) return false;
return set.has(String(zip5).slice(0, 5));
}
module.exports = { laZipSet, isLaZip };