Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 11x 11x 11x 11x 11x 11x 1x 10x 10x | 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 {
Iif (!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)
}
}
|