<script lang="ts">
	import { onDestroy, onMount } from 'svelte';

	export let max: number | undefined = undefined;
	export let perMs = 1000;
	export let start = '';

	let dots = start;
	let interval: NodeJS.Timeout;

	onMount(() => {
		interval = setInterval(() => {
			dots += '.';

			if (max && dots.length > max) dots = '';
		}, perMs);
	});

	onDestroy(() => clearInterval(interval));
</script>

{dots}
