UNPKG

mindee

Version:

Mindee Client Library for Node.js

37 lines (36 loc) 1.37 kB
import { StringField } from "./text.js"; /** * A field containing a detailed address value broken down into components * (street number, city, postal code, …) while still exposing the full * address string through {@link StringField.value}. */ export class AddressField extends StringField { constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) { super({ prediction, valueKey, reconstructed, pageId }); // Populate the sub-components if they exist in the prediction object if (prediction["street_number"]) { this.streetNumber = prediction["street_number"]; } if (prediction["street_name"]) { this.streetName = prediction["street_name"]; } if (prediction["po_box"]) { this.poBox = prediction["po_box"]; } if (prediction["address_complement"]) { this.addressComplement = prediction["address_complement"]; } if (prediction["city"]) { this.city = prediction["city"]; } if (prediction["postal_code"]) { this.postalCode = prediction["postal_code"]; } if (prediction["state"]) { this.state = prediction["state"]; } if (prediction["country"]) { this.country = prediction["country"]; } } }