Skip to content

sampbarrow/call-or-get

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages