Reference · Parsing, formatting and shared types
AddressDifferencetype
One part on which two addresses differ, with both values and the kind of difference.
Import it
import type { AddressDifference } from "@johnmorrisdotca/address-plus";
Definition
interface AddressDifference {
field: keyof ParsedAddress;
value1: string | undefined;
value2: string | undefined;
type: "missing" | "different" | "similar" | "typo";
confidence: number;
}
Members
| Name | Type | Description |
|---|---|---|
field | keyof ParsedAddress | |
value1 | string | undefined | |
value2 | string | undefined | |
type | "missing" | "different" | "similar" | "typo" | |
confidence | number |
Examples
import { getAddressSimilarity, parseLocation } from "@johnmorrisdotca/address-plus";
import type { AddressDifference } from "@johnmorrisdotca/address-plus";
const parsedAddress1=parseLocation("123 Main St, Anytown, NY 12345");
if (!parsedAddress1) throw new Error("The example address did not parse.");
const parsedAddress2=parseLocation("125 Main St, Anytown, NY 12345");
if (!parsedAddress2) throw new Error("The example address did not parse.");
console.log(getAddressSimilarity(parsedAddress1, parsedAddress2).differences[0]);
// → {"field":"number","value1":"123","value2":"125","type":"typo","confidence":0.6}{
field: 'number',
value1: '123',
value2: '125',
type: 'typo',
confidence: 0.6
}What it prints (run when this page was built)