diff options
Diffstat (limited to 'Timeline/ClientApp/src/app/utilities')
-rw-r--r-- | Timeline/ClientApp/src/app/utilities/language-untilities.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Timeline/ClientApp/src/app/utilities/language-untilities.ts b/Timeline/ClientApp/src/app/utilities/language-untilities.ts index be9df2dc..94434665 100644 --- a/Timeline/ClientApp/src/app/utilities/language-untilities.ts +++ b/Timeline/ClientApp/src/app/utilities/language-untilities.ts @@ -3,10 +3,16 @@ export function nullIfUndefined<T>(value: T | undefined): T | null { } export function throwIfNullOrUndefined<T>(value: T | null | undefined, - lazyMessage: () => string = () => 'Value mustn\'t be falsy'): T | never { + message: string | (() => string) = 'Value mustn\'t be null or undefined'): T | never { if (value === null || value === undefined) { - throw new Error(lazyMessage()); + throw new Error(typeof message === 'string' ? message : message()); } else { return value; } } + +export function repeat(time: number, action: (index?: number) => void) { + for (let i = 0; i < time; i++) { + action(i); + } +} |