mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Extract BaseStore deps into constructor argument
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
1c277a96fb
commit
3dce6f916e
17 files changed
+153
-70
No files matched your search
@@ -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";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user