Extract BaseStore deps into constructor argument

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2022-12-06 09:18:58 -05:00
1 parent 1c277a96fb
commit 3dce6f916e
17 files changed
+153 -70

No files matched your search

+13
View File
@@ -123,6 +123,10 @@ export function isDefined<T>(val: T | undefined | null): val is T {
return val != null;
}
export function isFunction(val: unknown): val is (...args: unknown[]) => unknown {
return typeof val === "function";
}
/**
* Checks if the value in the second position is non-nullable
*/
@@ -146,6 +150,15 @@ export function hasDefiniteField<Field extends keyof T, T>(field: Field): (val:
return (val): val is T & { [f in Field]-?: NonNullable<T[Field]> } => val[field] != null;
}
export function isPromiseLike(res: unknown): res is (Promise<unknown> | { then: () => unknown }) {
if (res instanceof Promise) {
return true;
}
return isObject(res)
&& hasTypedProperty(res, "then", isFunction);
}
export function isPromiseSettledRejected<T>(result: PromiseSettledResult<T>): result is PromiseRejectedResult {
return result.status === "rejected";
}