import type { Faker } from '@faker-js/faker' export default class LocationGenerator { private generator: Faker private street: string private city: string private state: string private zip: string private country: string constructor (generator: Faker) { this.generator = generator this.street = this.generator.location.streetAddress() this.city = this.generator.location.city() this.state = this.generator.location.state() this.zip = this.generator.location.zipCode() this.country = this.generator.location.country() } public getAddress(): string { return `${this.street}, ${this.city}, ${this.state} ${this.zip} ${this.country}` } /** * Generates a string representation of the location. * - {street} - the street address * - {city} - the city * - {state} - the state * - {zip} - the zip code * - {country} - the country */ public toString(pattern?: string): string { if (!pattern) { return `${this.street}, ${this.city}, ${this.state} ${this.zip}` } return pattern .replace('{street}', this.street) .replace('{city}', this.city) .replace('{state}', this.state) .replace('{zip}', this.zip) .replace('{country}', this.country) } }