CallOrGet
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.
Installation
npm install call-or-get
Usage
import { callOrGet, ValueOrFactory } from "call-or-get"
function print(value: ValueOrFactory<string, [string]>) {
return callOrGet(value, "")
}
print("text")
print(() => "text")
print(initialText => initialText + "text")