import type { BroadcastAreaData } from '../types/broadcastArea' import { BroadcastAreaLocation } from './broadcastAreaLocation' import { Collection } from '@freearhey/core' export class BroadcastArea { /** List of codes describing the broadcasting area (`r/`, `c/`, `s/`, `ct/`) */ codes: string[] constructor(data: BroadcastAreaData) { this.codes = data.codes || [] } /** @returns List of locations describing the broadcasting area */ getLocations(): Collection { return new Collection(this.codes).map( (code: string) => new BroadcastAreaLocation({ code }) ) } /** @returns JSON version of all data */ toJSON(): string { return JSON.stringify(this.toObject()) } /** @returns JS object with all data */ toObject(): BroadcastAreaData { return { codes: this.codes } } }