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
commit6e8434fa885bdb7ef9fd0f09a8cd29c0e17cef5b (patch)
treeee57954f1bbe2c1b944d648b2887fc63a865a289 /Timeline/ClientApp/src/app/utilities/language-untilities.ts
parent6f02dc7094d1304501e7ffd6c39ecf89369202c7 (diff)
downloadtimeline-6e8434fa885bdb7ef9fd0f09a8cd29c0e17cef5b.tar.gz
timeline-6e8434fa885bdb7ef9fd0f09a8cd29c0e17cef5b.tar.bz2
timeline-6e8434fa885bdb7ef9fd0f09a8cd29c0e17cef5b.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.');
+ }
+}