diff options
author | 杨宇千 <crupest@outlook.com> | 2019-04-11 20:02:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-11 20:02:33 +0800 |
commit | 5b5ca3acb1b9decb5ad13798dc79ba2d58f2ce95 (patch) | |
tree | 695f7fc0bd2f6d940f64739a1f1f500c36806cef /Timeline/ClientApp/src/app/utilities/language-untilities.ts | |
parent | 1c9edc5914869a3bbde20742c483182636ee4d43 (diff) | |
parent | c28941c6d86f8ea33521bba49d811bf3ff60b3d1 (diff) | |
download | timeline-5b5ca3acb1b9decb5ad13798dc79ba2d58f2ce95.tar.gz timeline-5b5ca3acb1b9decb5ad13798dc79ba2d58f2ce95.tar.bz2 timeline-5b5ca3acb1b9decb5ad13798dc79ba2d58f2ce95.zip |
Merge pull request #17 from crupest/15-user
Remember me and log out feature.
Diffstat (limited to 'Timeline/ClientApp/src/app/utilities/language-untilities.ts')
-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); + } +} |