This commit is contained in:
eewing
2026-02-17 14:10:16 -06:00
parent 2bca5834c5
commit cf73cd3b4c
11246 changed files with 1690552 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
import type { MaybeGetter } from "../../internal/types.js";
/**
* Resolves a value that may be a getter function or a direct value.
*
* If the input is a function, it will be invoked to retrieve the actual value.
* If the resolved value (or the input itself) is `undefined`, the optional
* `defaultValue` is returned instead.
*
* @template T - The expected return type.
* @param value - A value or a function that returns a value.
* @param defaultValue - A fallback value returned if the resolved value is `undefined`.
* @returns The resolved value or the default.
*/
export declare function extract<T>(value: MaybeGetter<T>): T;
export declare function extract<T>(value: MaybeGetter<T | undefined>, defaultValue: T): T;
+13
View File
@@ -0,0 +1,13 @@
import { isFunction } from "../../internal/utils/is.js";
export function extract(value, defaultValue) {
if (isFunction(value)) {
const getter = value;
const gotten = getter();
if (gotten === undefined)
return defaultValue;
return gotten;
}
if (value === undefined)
return defaultValue;
return value;
}
+1
View File
@@ -0,0 +1 @@
export { extract } from "./extract.svelte.js";
+1
View File
@@ -0,0 +1 @@
export { extract } from "./extract.svelte.js";