dldr (pronounced "dataloader") is a minimalist JavaScript utility, currently at version 0.0.10, designed for efficiently batching and caching operations. It is particularly useful in data fetching scenarios, such as optimizing queries within GraphQL resolvers. The library distinguishes itself by its extremely small footprint (367B gzipped) and its use of `queueMicrotask` to schedule and execute batched load functions within the current event loop tick. This mechanism ensures that multiple requests for the same or different keys, made in quick succession within the same microtask queue, are consolidated into a single call to the underlying data fetching function. dldr offers both a basic batching mechanism and an extended version accessible via `dldr/cache` that incorporates an in-memory `Map`-based cache, preventing redundant data fetches for previously loaded keys. Its primary goal is to improve performance by reducing the number of requests to databases or APIs, positioning it as a lightweight alternative to more feature-rich dataloading solutions. While in early development, its API is straightforward, centered around `load` functions that accept an array of keys and return corresponding results.
npm install dldrVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `dldr` to batch multiple data fetching calls into a single underlying function execution and shows the `load.bind` pattern for convenience.
Ensure all batchable `load` calls are initiated within the same synchronous execution context or within the same microtask queue phase.
Pin to exact versions (`"dldr": "0.0.10"`) and carefully review the GitHub repository for changes when upgrading, particularly if new versions are released.
Ensure the first argument to `load` (your data fetching function) is a valid, callable function that accepts an array of keys.
Verify that `import { load } from 'dldr';` or `import { load } from 'dldr/cache';` is correctly specified and executed before calling `load.bind`.No dependency data recorded yet.