Skip to content

typeclasses/lazy-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lazy

Very small utility for at-most-once evaluation. It is useful for defining a fetch that may be expensive for a value that won't change.

Example of using the once function:

// getThing has type () => Thing
const getThing = once<Thing>(() => {
  return ...; // This will run at most once
});

It is fine if the fetch is asynchronous. This works too:

// getThing has type () => Promise<Thing>
const getThing = once<Promise<Thing>>(async () => {
  return ...;
});

About

Very small TypeScript utility for at-most-once evaluation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published