summaryrefslogtreecommitdiff
path: root/src/utils/types.ts
diff options
context:
space:
mode:
authorrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
committerrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
commitbce557cc2dc767628bed6aac87301a1be7c5431b (patch)
treeb51a051228d01fe3306cd7626d4a96768aadb944 /src/utils/types.ts
init commit
Diffstat (limited to 'src/utils/types.ts')
-rw-r--r--src/utils/types.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/utils/types.ts b/src/utils/types.ts
new file mode 100644
index 0000000..4cb85aa
--- /dev/null
+++ b/src/utils/types.ts
@@ -0,0 +1,17 @@
+/**
+ * Determine if {@linkcode input} matches the `"object"` type
+ */
+export function isObject(input: unknown): input is object {
+ return typeof input === 'object' && !!input;
+}
+
+type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
+
+/**
+ * Helper type for creating an exclusive union between two types
+ *
+ * @see {@link https://stackoverflow.com/a/53229567/2250435 | StackOverflow Post}
+ */
+export type XOR<T, U> = T | U extends object
+ ? (Without<T, U> & U) | (Without<U, T> & T)
+ : T | U;