0.0.1 • Published 1 year ago

value-or-factory v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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")

License

MIT