A simple utility type and function that allows you to pass and generate values that are either a value or a function that generates a value.
npm install value-or-factory
import { callOrGet, ValueOrFactory } from "value-or-factory"
function print(value: ValueOrFactory<string, [string]>) {
return callOrGet(value, "")
}
print("text")
print(() => "text")
print(initialText => initialText + "text")