Function: generalizeZip()
generalizeZip(
zip):GeneralizeOutcome|null
Generalize a ZIP code to its safe form (§164.514(b)(2)(i)(B)): the initial three digits, or 000
when those three digits name an area with ≤ 20,000 people (the cited restricted list). Fails closed
(null) when three leading digits cannot be read.
Parameters
zip
string
The ZIP code (5-digit, ZIP+4, or any form beginning with digits).
Returns
GeneralizeOutcome | null
The { value, residual } outcome - residual: false for 000, true for a kept prefix -
or null if fewer than three leading digits are present.
Example
import { generalizeZip } from "@cosyte/deid";
generalizeZip("90210")?.value; // => "902"
generalizeZip("03601")?.value; // => "000" (036 is a restricted prefix)