Your IP : 216.73.216.86


Current Path : /var/www/homesaver/www/bitrix/js/location/core/src/entity/address/
Upload File :
Current File : /var/www/homesaver/www/bitrix/js/location/core/src/entity/address/addresslinkcollection.js

import AddressLink from "./addresslink";

export default class AddressLinkCollection
{
	#links = [];

	constructor(props = {})
	{
		this.links = !!props.links ? props.links : [];
	}

	set links(links: Array): void
	{
		if(!Array.isArray(links))
		{
			throw new Error('links must be array!');
		}

		for(let link of links)
		{
			this.addLink(link);
		}
	}

	get links()
	{
		return this.#links;
	}

	addLink(link: AddressLink)
	{
		if(!(link instanceof AddressLink))
		{
			throw new Error('Argument link must be instance of Field!');
		}

		this.#links.push(link);
	}

	clearLinks()
	{
		this.#links = [];
	}
}