Open ChuckJonas opened 6 years ago
I was able to just use the codes
property to achieve this:
import * as zipcodes from 'zipcodes';
const codeNames = Object.keys(zipcodes.codes);
export const findMatches = (search: string) => {
const matchingCodes = codeNames.filter((z) => z.includes(search));
return matchingCodes.map((m) => zipcodes.codes[m]);
};
Would be nice if there was a way to list codes based on a string compare of the code itsself.
EG:
zipcodes.lookupByCode('8300');
would return83001
,83002
,18300
,28300
, etc