value-or-factory
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i value-or-factory

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

1.56 kB

Total Files

7

Last publish

Collaborators

  • ispb