Delay the evaluation of a paramless async function and cache the result. Version 1.1.0 is stable with no active development. It provides a simple thunk pattern for lazy initialization, caching the result after the first successful invocation. Supports both callback and Promise (via `thunky/promise`) styles. Lightweight with zero dependencies. Differentiators: minimal API, error handling that prevents caching on failure, and compatibility with Node.js and browsers via bundlers.
npm install thunkyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates both callback-based thunky and promise-based thunkyp, showing lazy evaluation and caching.
Migrate to thunky/promise and async/await for new code.
Update to thunky@1.1.0 or later.
Ensure your async function does not call the callback with an Error for caching to work.
Use default import: import thunky from 'thunky'
Run npm install thunky@1.1.0
No dependency data recorded yet.