aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/utilities/language-untilities.ts
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-04-11 20:02:33 +0800
committerGitHub <noreply@github.com>2019-04-11 20:02:33 +0800
commit1eb6d9abfc24eec380b7b5d7423102a53041239e (patch)
treed37779e900de492491c862eb64ba2e79cf10af83 /Timeline/ClientApp/src/app/utilities/language-untilities.ts
parent393ca55a960abc7d2343a8a36a093d253eddf134 (diff)
parentd328e1eac76d9e28563b118e42f8ee5cf5fe43d8 (diff)
downloadtimeline-1eb6d9abfc24eec380b7b5d7423102a53041239e.tar.gz
timeline-1eb6d9abfc24eec380b7b5d7423102a53041239e.tar.bz2
timeline-1eb6d9abfc24eec380b7b5d7423102a53041239e.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.ts10
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);
+ }
+}