Skip to content

Latest commit

 

History

History
28 lines (18 loc) · 538 Bytes

README.md

File metadata and controls

28 lines (18 loc) · 538 Bytes

ValueOrFactory

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 value-or-factory

Usage

import { callOrGet, ValueOrFactory } from "value-or-factory"

function print(value: ValueOrFactory<string, [string]>) {
 return callOrGet(value, "")
}

print("text")
print(() => "text")
print(initialText => initialText + "text")

License

MIT