aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/utilities/language-untilities.ts
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-03-11 21:01:28 +0800
committercrupest <crupest@outlook.com>2019-03-11 21:01:28 +0800
commit4f7eba96dfdcd831c7a40dee035b8871df8d452b (patch)
treefa18c63d9530364b557066ffcb703c927b17213f /Timeline/ClientApp/src/app/utilities/language-untilities.ts
parent8caef17dd3e455de27f44d13751c27ee4dfe2e1e (diff)
downloadtimeline-4f7eba96dfdcd831c7a40dee035b8871df8d452b.tar.gz
timeline-4f7eba96dfdcd831c7a40dee035b8871df8d452b.tar.bz2
timeline-4f7eba96dfdcd831c7a40dee035b8871df8d452b.zip
Use strict check of typescript compiler.
Diffstat (limited to 'Timeline/ClientApp/src/app/utilities/language-untilities.ts')
-rw-r--r--Timeline/ClientApp/src/app/utilities/language-untilities.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/Timeline/ClientApp/src/app/utilities/language-untilities.ts b/Timeline/ClientApp/src/app/utilities/language-untilities.ts
new file mode 100644
index 00000000..f898039a
--- /dev/null
+++ b/Timeline/ClientApp/src/app/utilities/language-untilities.ts
@@ -0,0 +1,9 @@
+export function nullIfUndefined<T>(value: T | undefined): T | null {
+ return value === undefined ? null : value;
+}
+
+export function throwIfFalsy(value: any, name: string = '<unknown name>') {
+ if (!value) {
+ throw new Error(name + ' is falsy.');
+ }
+}