about summary refs log tree commit diff
path: root/src/state/lib/type-guards.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/lib/type-guards.ts')
-rw-r--r--src/state/lib/type-guards.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/state/lib/type-guards.ts b/src/state/lib/type-guards.ts
new file mode 100644
index 000000000..4ae31f3ac
--- /dev/null
+++ b/src/state/lib/type-guards.ts
@@ -0,0 +1,10 @@
+export function isObj(v: unknown): v is Record<string, unknown> {
+  return !!v && typeof v === 'object'
+}
+
+export function hasProp<K extends PropertyKey>(
+  data: object,
+  prop: K,
+): data is Record<K, unknown> {
+  return prop in data
+}