Creates a FnOnce wrapper around a function, making it callable only once.
FnOnce
Tuple type of the function arguments.
Return type of the function.
The function to wrap.
A FnOnce instance that wraps the function.
const initialize = FnOnce(() => { console.log('Initializing...'); return { ready: true };});const result = initialize.call(); // Logs 'Initializing...', returns { ready: true }// initialize.call(); // Throws Error: FnOnce has already been consumed Copy
const initialize = FnOnce(() => { console.log('Initializing...'); return { ready: true };});const result = initialize.call(); // Logs 'Initializing...', returns { ready: true }// initialize.call(); // Throws Error: FnOnce has already been consumed
Creates a
FnOncewrapper around a function, making it callable only once.