Pacer Docs
API Reference
Debouncer API Reference
- DebouncerOptions
- DebouncerState
- AsyncDebouncerOptions
- AsyncDebouncerState
- debounce
- asyncDebounce
- Debouncer
- AsyncDebouncer
- ReactDebouncerOptions
- ReactAsyncDebouncerOptions
- ReactDebouncer
- ReactAsyncDebouncer
- useDebouncer
- useDebouncedCallback
- useDebouncedState
- useDebouncedValue
- useAsyncDebouncer
- useAsyncDebouncedCallback
Throttler API Reference
- ThrottlerOptions
- ThrottlerState
- AsyncThrottlerOptions
- AsyncThrottlerState
- throttle
- asyncThrottle
- Throttler
- AsyncThrottler
- ReactThrottlerOptions
- ReactAsyncThrottlerOptions
- ReactThrottler
- ReactAsyncThrottler
- useThrottler
- useThrottledCallback
- useThrottledState
- useThrottledValue
- useAsyncThrottler
- useAsyncThrottledCallback
Rate Limiter API Reference
Queue API Reference
AI/LLM: This documentation page is available in plain markdown format at/pacer/latest/docs/reference/functions/batch.md
Batcher API Reference
batch
ts
function batch<TValue>(fn, options): (item) => void;Defined in: batcher.ts:323
Creates a batcher that processes items in batches.
This synchronous version is lighter weight and often all you need - upgrade to asyncBatch when you need promises, retry support, abort/cancel capabilities, or advanced error handling.
Type Parameters#
TValue#
TValue
Parameters#
fn#
(items) => void
options#
BatcherOptions<TValue>
Returns#
ts
(item): void;Adds an item to the batcher If the batch size is reached, timeout occurs, or shouldProcess returns true, the batch will be processed
Parameters#
item#
TValue
Returns#
void
Example#
ts
const batchItems = batch<number>(
(items) => console.log('Processing:', items),
{
maxSize: 3,
onExecute: (batch, batcher) => console.log('Batch executed:', batch)
}
);
batchItems(1);
batchItems(2);
batchItems(3); // Triggers batch processing