The type of value to store.
The initialization function that produces the value.
A new Lazy<T> instance.
// Basic usage
const lazy = Lazy(() => {
console.log('Initializing');
return 42;
});
console.log(lazy.isInitialized()); // false
console.log(lazy.force()); // logs "Initializing", returns 42
console.log(lazy.isInitialized()); // true
console.log(lazy.force()); // returns 42 (no log)
Creates a new
Lazy<T>with the given synchronous initialization function.The function is called at most once, on first access via
force().