Make outbox loader useful for non plain replaceables, add tap and bind

This commit is contained in:
Jon Staab
2026-02-18 15:27:34 -08:00
parent ca8a2754b9
commit e2f438799f
3 changed files with 28 additions and 3 deletions
+20
View File
@@ -57,6 +57,26 @@ export const always =
*/
export const not = (x: any, ...args: unknown[]) => !x
/**
* Bind function
* @param f - Function to bind
* @returns bound function
*/
export const bind = <F extends (...args: any[]) => any>(f: F, ...args: Parameters<F>) =>
f.bind(null, ...args)
/**
* Runs the provided function on the given value and returns the value
* @param f - Function to call
* @returns tapped function
*/
export const tap =
<T, F extends (x: T) => unknown>(f: F) =>
(x: T) => {
f(x)
return x
}
/**
* Deep equality comparison
* @param a - First value