```ts
export function truncate(text: string, limit: number): string {

  // Throw Error if not enough digits were provided
  if (!Number.isInteger(limit) || limit < 3) {
    throw new Error('truncate called with invalid argument');
  }

  if (text.length > limit) {
    return text.slice(0, limit - 3) + "...";
  }
  else{
    return text;
  }
}
```