From e9b1172d1504bcc73e5954679e8626ab56a933a9 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Wed, 17 Dec 2025 17:43:35 -0800 Subject: [PATCH] Add doLet util --- packages/lib/src/Tools.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/lib/src/Tools.ts b/packages/lib/src/Tools.ts index 05b0058..d1a3221 100644 --- a/packages/lib/src/Tools.ts +++ b/packages/lib/src/Tools.ts @@ -1084,11 +1084,19 @@ export const memoize = (f: (...args: Args) => T) => { } } +/** + * Executes a function on the given value + * @param x - The value + * @param f - Function to execute + * @returns result of f(x) + */ +export const doLet = (x: T, f: (x: T) => R) => f(x) + /** * Executes a function if the value is defined * @param x - The value to check * @param f - Function to execute if x is defined - * @returns Result of f(x) if x is defined, undefined otherwise + * @returns result of f(x) if x is defined, undefined otherwise */ export const ifLet = (x: T | undefined, f: (x: T) => void) => x === undefined ? undefined : f(x)