diff --git a/.changeset/loud-rocks-sell.md b/.changeset/loud-rocks-sell.md new file mode 100644 index 00000000..28fe78b2 --- /dev/null +++ b/.changeset/loud-rocks-sell.md @@ -0,0 +1,5 @@ +--- +'@tanstack/pacer': patch +--- + +Removed auto-uuid key generation for devtools. Now in order for pacer devtools to detect a util, you must define a key option diff --git a/.cursorignore b/.cursorignore new file mode 100644 index 00000000..faba0f68 --- /dev/null +++ b/.cursorignore @@ -0,0 +1 @@ +**/reference/** \ No newline at end of file diff --git a/docs/devtools.md b/docs/devtools.md index c7ab01de..2d88cfee 100644 --- a/docs/devtools.md +++ b/docs/devtools.md @@ -89,11 +89,11 @@ import { pacerDevtoolsPlugin } from '@tanstack/react-pacer-devtools/production' ## Registering Utilities -Each utility should automatically be detected and displayed in the devtools. However, if you don't provide a `key` option to the utility, it will show with a uuid for its name. Give it an identifiable name with the `key` option. +Pacer utilities only register with the devtools when you pass a `key`. Keys are no longer generated automatically, so leave the option out if you do not want an instance to appear in the panels. ```tsx const debouncer = new Debouncer(myDebounceFn, { - key: 'My Debouncer', // friendly name for the utility instead of auto-generated uuid + key: 'My Debouncer', // friendly name shown in the devtools wait: 1000, }) ``` \ No newline at end of file diff --git a/docs/reference/classes/AsyncBatcher.md b/docs/reference/classes/AsyncBatcher.md index e1deaf92..22cc6222 100644 --- a/docs/reference/classes/AsyncBatcher.md +++ b/docs/reference/classes/AsyncBatcher.md @@ -139,7 +139,7 @@ Defined in: [async-batcher.ts:278](https://github.com/TanStack/pacer/blob/main/p ### key ```ts -key: string; +key: string | undefined; ``` Defined in: [async-batcher.ts:269](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L269) @@ -166,29 +166,13 @@ Defined in: [async-batcher.ts:266](https://github.com/TanStack/pacer/blob/main/p ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [async-batcher.ts:299](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L299) - -Emits a change event for the async batcher instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### abort() ```ts abort(): void; ``` -Defined in: [async-batcher.ts:493](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L493) +Defined in: [async-batcher.ts:488](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L488) Aborts all ongoing executions with the internal abort controllers. Does NOT cancel any pending execution that have not started yet. @@ -206,7 +190,7 @@ Does NOT clear out the items. addItem(item): Promise; ``` -Defined in: [async-batcher.ts:345](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L345) +Defined in: [async-batcher.ts:340](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L340) Adds an item to the async batcher If the batch size is reached, timeout occurs, or shouldProcess returns true, the batch will be processed @@ -235,7 +219,7 @@ The error from the batch function if no onError handler is configured or throwOn cancel(): void; ``` -Defined in: [async-batcher.ts:506](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L506) +Defined in: [async-batcher.ts:501](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L501) Cancels any pending execution that have not started yet. Does NOT abort any execution already in progress. @@ -253,7 +237,7 @@ Does NOT clear out the items. clear(): void; ``` -Defined in: [async-batcher.ts:454](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L454) +Defined in: [async-batcher.ts:449](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L449) Removes all items from the async batcher @@ -269,7 +253,7 @@ Removes all items from the async batcher flush(): Promise; ``` -Defined in: [async-batcher.ts:428](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L428) +Defined in: [async-batcher.ts:423](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L423) Processes the current batch of items immediately @@ -285,7 +269,7 @@ Processes the current batch of items immediately getAbortSignal(executeCount?): AbortSignal | null; ``` -Defined in: [async-batcher.ts:482](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L482) +Defined in: [async-batcher.ts:477](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L477) Returns the AbortSignal for a specific execution. If no executeCount is provided, returns the signal for the most recent execution. @@ -330,7 +314,7 @@ const batcher = new AsyncBatcher( peekAllItems(): TValue[]; ``` -Defined in: [async-batcher.ts:436](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L436) +Defined in: [async-batcher.ts:431](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L431) Returns a copy of all items in the async batcher @@ -346,7 +330,7 @@ Returns a copy of all items in the async batcher peekFailedItems(): TValue[]; ``` -Defined in: [async-batcher.ts:440](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L440) +Defined in: [async-batcher.ts:435](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L435) #### Returns @@ -360,7 +344,7 @@ Defined in: [async-batcher.ts:440](https://github.com/TanStack/pacer/blob/main/p reset(): void; ``` -Defined in: [async-batcher.ts:516](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L516) +Defined in: [async-batcher.ts:511](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L511) Resets the async batcher state to its default values @@ -376,7 +360,7 @@ Resets the async batcher state to its default values setOptions(newOptions): void; ``` -Defined in: [async-batcher.ts:304](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L304) +Defined in: [async-batcher.ts:299](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L299) Updates the async batcher options diff --git a/docs/reference/classes/AsyncDebouncer.md b/docs/reference/classes/AsyncDebouncer.md index 86114173..405aecb6 100644 --- a/docs/reference/classes/AsyncDebouncer.md +++ b/docs/reference/classes/AsyncDebouncer.md @@ -116,7 +116,7 @@ Defined in: [async-debouncer.ts:231](https://github.com/TanStack/pacer/blob/main ### key ```ts -key: string; +key: string | undefined; ``` Defined in: [async-debouncer.ts:222](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L222) @@ -143,29 +143,13 @@ Defined in: [async-debouncer.ts:219](https://github.com/TanStack/pacer/blob/main ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [async-debouncer.ts:252](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L252) - -Emits a change event for the async debouncer instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### abort() ```ts abort(): void; ``` -Defined in: [async-debouncer.ts:468](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L468) +Defined in: [async-debouncer.ts:463](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L463) Aborts all ongoing executions with the internal abort controllers. Does NOT cancel any pending execution that have not started yet. @@ -182,7 +166,7 @@ Does NOT cancel any pending execution that have not started yet. cancel(): void; ``` -Defined in: [async-debouncer.ts:480](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L480) +Defined in: [async-debouncer.ts:475](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L475) Cancels any pending execution that have not started yet. Does NOT abort any execution already in progress. @@ -199,7 +183,7 @@ Does NOT abort any execution already in progress. flush(): Promise | undefined>; ``` -Defined in: [async-debouncer.ts:403](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L403) +Defined in: [async-debouncer.ts:398](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L398) Processes the current pending execution immediately @@ -215,7 +199,7 @@ Processes the current pending execution immediately getAbortSignal(maybeExecuteCount?): AbortSignal | null; ``` -Defined in: [async-debouncer.ts:458](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L458) +Defined in: [async-debouncer.ts:453](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L453) Returns the AbortSignal for a specific execution. If no maybeExecuteCount is provided, returns the signal for the most recent execution. @@ -256,7 +240,7 @@ const debouncer = new AsyncDebouncer( maybeExecute(...args): Promise | undefined>; ``` -Defined in: [async-debouncer.ts:317](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L317) +Defined in: [async-debouncer.ts:312](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L312) Attempts to execute the debounced function. If a call is already in progress, it will be queued. @@ -292,7 +276,7 @@ The error from the debounced function if no onError handler is configured reset(): void; ``` -Defined in: [async-debouncer.ts:488](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L488) +Defined in: [async-debouncer.ts:483](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L483) Resets the debouncer state to its default values @@ -308,7 +292,7 @@ Resets the debouncer state to its default values setOptions(newOptions): void; ``` -Defined in: [async-debouncer.ts:257](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L257) +Defined in: [async-debouncer.ts:252](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L252) Updates the async debouncer options diff --git a/docs/reference/classes/AsyncQueuer.md b/docs/reference/classes/AsyncQueuer.md index 808e8e4f..9195bd94 100644 --- a/docs/reference/classes/AsyncQueuer.md +++ b/docs/reference/classes/AsyncQueuer.md @@ -135,7 +135,7 @@ Defined in: [async-queuer.ts:328](https://github.com/TanStack/pacer/blob/main/pa ### key ```ts -key: string; +key: string | undefined; ``` Defined in: [async-queuer.ts:319](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L319) @@ -162,29 +162,13 @@ Defined in: [async-queuer.ts:316](https://github.com/TanStack/pacer/blob/main/pa ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [async-queuer.ts:366](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L366) - -Emits a change event for the async queuer instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### abort() ```ts abort(): void; ``` -Defined in: [async-queuer.ts:836](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L836) +Defined in: [async-queuer.ts:831](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L831) Aborts all ongoing executions with the internal abort controllers. Does NOT clear out the items. @@ -204,7 +188,7 @@ addItem( runOnItemsChange): boolean; ``` -Defined in: [async-queuer.ts:474](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L474) +Defined in: [async-queuer.ts:469](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L469) Adds an item to the queue. If the queue is full, the item is rejected and onReject is called. Items can be inserted based on priority or at the front/back depending on configuration. @@ -242,7 +226,7 @@ queuer.addItem('task2', 'front'); clear(): void; ``` -Defined in: [async-queuer.ts:801](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L801) +Defined in: [async-queuer.ts:796](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L796) Removes all pending items from the queue. Does NOT affect active tasks. @@ -259,7 +243,7 @@ Does NOT affect active tasks. execute(position?): Promise; ``` -Defined in: [async-queuer.ts:609](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L609) +Defined in: [async-queuer.ts:604](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L604) Removes and returns the next item from the queue and executes the task function with it. @@ -289,7 +273,7 @@ queuer.execute('back'); flush(numberOfItems, position?): Promise; ``` -Defined in: [async-queuer.ts:657](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L657) +Defined in: [async-queuer.ts:652](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L652) Processes a specified number of items to execute immediately with no wait time If no numberOfItems is provided, all items will be processed @@ -316,7 +300,7 @@ If no numberOfItems is provided, all items will be processed flushAsBatch(batchFunction): Promise; ``` -Defined in: [async-queuer.ts:671](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L671) +Defined in: [async-queuer.ts:666](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L666) Processes all items in the queue as a batch using the provided function as an argument The queue is cleared after processing @@ -339,7 +323,7 @@ The queue is cleared after processing getAbortSignal(executeCount?): AbortSignal | null; ``` -Defined in: [async-queuer.ts:826](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L826) +Defined in: [async-queuer.ts:821](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L821) Returns the AbortSignal for a specific execution. If no executeCount is provided, returns the signal for the most recent execution. @@ -380,7 +364,7 @@ const queuer = new AsyncQueuer( getNextItem(position): TValue | undefined; ``` -Defined in: [async-queuer.ts:557](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L557) +Defined in: [async-queuer.ts:552](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L552) Removes and returns the next item from the queue without executing the task function. Use for manual queue management. Normally, use execute() to process items. @@ -412,7 +396,7 @@ queuer.getNextItem('back'); peekActiveItems(): TValue[]; ``` -Defined in: [async-queuer.ts:763](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L763) +Defined in: [async-queuer.ts:758](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L758) Returns the items currently being processed (active tasks). @@ -428,7 +412,7 @@ Returns the items currently being processed (active tasks). peekAllItems(): TValue[]; ``` -Defined in: [async-queuer.ts:756](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L756) +Defined in: [async-queuer.ts:751](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L751) Returns a copy of all items in the queue, including active and pending items. @@ -444,7 +428,7 @@ Returns a copy of all items in the queue, including active and pending items. peekNextItem(position): TValue | undefined; ``` -Defined in: [async-queuer.ts:746](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L746) +Defined in: [async-queuer.ts:741](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L741) Returns the next item in the queue without removing it. @@ -473,7 +457,7 @@ queuer.peekNextItem('back'); // back peekPendingItems(): TValue[]; ``` -Defined in: [async-queuer.ts:770](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L770) +Defined in: [async-queuer.ts:765](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L765) Returns the items waiting to be processed (pending tasks). @@ -489,7 +473,7 @@ Returns the items waiting to be processed (pending tasks). reset(): void; ``` -Defined in: [async-queuer.ts:847](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L847) +Defined in: [async-queuer.ts:842](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L842) Resets the queuer state to its default values @@ -505,7 +489,7 @@ Resets the queuer state to its default values setOptions(newOptions): void; ``` -Defined in: [async-queuer.ts:371](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L371) +Defined in: [async-queuer.ts:366](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L366) Updates the queuer options. New options are merged with existing options. @@ -527,7 +511,7 @@ Updates the queuer options. New options are merged with existing options. start(): void; ``` -Defined in: [async-queuer.ts:777](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L777) +Defined in: [async-queuer.ts:772](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L772) Starts processing items in the queue. If already running, does nothing. @@ -543,7 +527,7 @@ Starts processing items in the queue. If already running, does nothing. stop(): void; ``` -Defined in: [async-queuer.ts:787](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L787) +Defined in: [async-queuer.ts:782](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L782) Stops processing items in the queue. Does not clear the queue. diff --git a/docs/reference/classes/AsyncRateLimiter.md b/docs/reference/classes/AsyncRateLimiter.md index d9c72e4a..dabb9c7c 100644 --- a/docs/reference/classes/AsyncRateLimiter.md +++ b/docs/reference/classes/AsyncRateLimiter.md @@ -136,7 +136,7 @@ Defined in: [async-rate-limiter.ts:255](https://github.com/TanStack/pacer/blob/m ### key ```ts -key: string; +key: string | undefined; ``` Defined in: [async-rate-limiter.ts:249](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L249) @@ -163,29 +163,13 @@ Defined in: [async-rate-limiter.ts:246](https://github.com/TanStack/pacer/blob/m ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [async-rate-limiter.ts:279](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L279) - -Emits a change event for the async rate limiter instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### abort() ```ts abort(): void; ``` -Defined in: [async-rate-limiter.ts:538](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L538) +Defined in: [async-rate-limiter.ts:533](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L533) Aborts all ongoing executions with the internal abort controllers. Does NOT clear out the execution times or reset the rate limiter. @@ -202,7 +186,7 @@ Does NOT clear out the execution times or reset the rate limiter. getAbortSignal(maybeExecuteCount?): AbortSignal | null; ``` -Defined in: [async-rate-limiter.ts:528](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L528) +Defined in: [async-rate-limiter.ts:523](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L523) Returns the AbortSignal for a specific execution. If no maybeExecuteCount is provided, returns the signal for the most recent execution. @@ -243,7 +227,7 @@ const rateLimiter = new AsyncRateLimiter( getMsUntilNextWindow(): number; ``` -Defined in: [async-rate-limiter.ts:500](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L500) +Defined in: [async-rate-limiter.ts:495](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L495) Returns the number of milliseconds until the next execution will be possible For fixed windows, this is the time until the current window resets @@ -261,7 +245,7 @@ For sliding windows, this is the time until the oldest execution expires getRemainingInWindow(): number; ``` -Defined in: [async-rate-limiter.ts:490](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L490) +Defined in: [async-rate-limiter.ts:485](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L485) Returns the number of remaining executions allowed in the current window @@ -277,7 +261,7 @@ Returns the number of remaining executions allowed in the current window maybeExecute(...args): Promise | undefined>; ``` -Defined in: [async-rate-limiter.ts:357](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L357) +Defined in: [async-rate-limiter.ts:352](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L352) Attempts to execute the rate-limited function if within the configured limits. Will reject execution if the number of calls in the current window exceeds the limit. @@ -325,7 +309,7 @@ const result2 = await rateLimiter.maybeExecute('arg1', 'arg2'); // undefined reset(): void; ``` -Defined in: [async-rate-limiter.ts:549](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L549) +Defined in: [async-rate-limiter.ts:544](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L544) Resets the rate limiter state @@ -341,7 +325,7 @@ Resets the rate limiter state setOptions(newOptions): void; ``` -Defined in: [async-rate-limiter.ts:284](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L284) +Defined in: [async-rate-limiter.ts:279](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L279) Updates the async rate limiter options diff --git a/docs/reference/classes/AsyncRetryer.md b/docs/reference/classes/AsyncRetryer.md index 5f88d2d5..30814b9a 100644 --- a/docs/reference/classes/AsyncRetryer.md +++ b/docs/reference/classes/AsyncRetryer.md @@ -152,7 +152,7 @@ The async function to retry ### key ```ts -key: string; +key: string | undefined; ``` Defined in: [async-retryer.ts:292](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L292) @@ -189,29 +189,13 @@ Defined in: [async-retryer.ts:289](https://github.com/TanStack/pacer/blob/main/p ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [async-retryer.ts:325](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L325) - -Emits a change event for the async retryer instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### abort() ```ts abort(reason): void; ``` -Defined in: [async-retryer.ts:608](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L608) +Defined in: [async-retryer.ts:603](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L603) Cancels the current execution and any pending retries @@ -235,7 +219,7 @@ The reason for the abort (defaults to 'manual') execute(...args): Promise> | undefined>; ``` -Defined in: [async-retryer.ts:415](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L415) +Defined in: [async-retryer.ts:410](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L410) Executes the function with retry logic @@ -265,7 +249,7 @@ The last error if throwOnError is true and all retries fail getAbortSignal(): AbortSignal | null; ``` -Defined in: [async-retryer.ts:600](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L600) +Defined in: [async-retryer.ts:595](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L595) Returns the current AbortSignal for the executing operation. Use this signal in your async function to make it cancellable. @@ -298,7 +282,7 @@ retryer.abort() reset(): void; ``` -Defined in: [async-retryer.ts:628](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L628) +Defined in: [async-retryer.ts:623](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L623) Resets the retryer to its initial state @@ -314,7 +298,7 @@ Resets the retryer to its initial state setOptions(newOptions): void; ``` -Defined in: [async-retryer.ts:331](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L331) +Defined in: [async-retryer.ts:326](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L326) Updates the retryer options diff --git a/docs/reference/classes/AsyncThrottler.md b/docs/reference/classes/AsyncThrottler.md index 7cafba0f..9c85f23e 100644 --- a/docs/reference/classes/AsyncThrottler.md +++ b/docs/reference/classes/AsyncThrottler.md @@ -120,7 +120,7 @@ Defined in: [async-throttler.ts:243](https://github.com/TanStack/pacer/blob/main ### key ```ts -key: string; +key: string | undefined; ``` Defined in: [async-throttler.ts:234](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L234) @@ -147,29 +147,13 @@ Defined in: [async-throttler.ts:231](https://github.com/TanStack/pacer/blob/main ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [async-throttler.ts:264](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L264) - -Emits a change event for the async throttler instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### abort() ```ts abort(): void; ``` -Defined in: [async-throttler.ts:532](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L532) +Defined in: [async-throttler.ts:527](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L527) Aborts all ongoing executions with the internal abort controllers. Does NOT cancel any pending execution that have not started yet. @@ -186,7 +170,7 @@ Does NOT cancel any pending execution that have not started yet. cancel(): void; ``` -Defined in: [async-throttler.ts:542](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L542) +Defined in: [async-throttler.ts:537](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L537) Cancels any pending execution that have not started yet. Does NOT abort any execution already in progress. @@ -203,7 +187,7 @@ Does NOT abort any execution already in progress. flush(): Promise | undefined>; ``` -Defined in: [async-throttler.ts:461](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L461) +Defined in: [async-throttler.ts:456](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L456) Processes the current pending execution immediately @@ -219,7 +203,7 @@ Processes the current pending execution immediately getAbortSignal(maybeExecuteCount?): AbortSignal | null; ``` -Defined in: [async-throttler.ts:522](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L522) +Defined in: [async-throttler.ts:517](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L517) Returns the AbortSignal for a specific execution. If no maybeExecuteCount is provided, returns the signal for the most recent execution. @@ -264,7 +248,7 @@ const throttler = new AsyncThrottler( maybeExecute(...args): Promise | undefined>; ``` -Defined in: [async-throttler.ts:337](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L337) +Defined in: [async-throttler.ts:332](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L332) Attempts to execute the throttled function. The execution behavior depends on the throttler options: @@ -306,7 +290,7 @@ await throttled.maybeExecute('c', 'd'); reset(): void; ``` -Defined in: [async-throttler.ts:556](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L556) +Defined in: [async-throttler.ts:551](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L551) Resets the debouncer state to its default values @@ -322,7 +306,7 @@ Resets the debouncer state to its default values setOptions(newOptions): void; ``` -Defined in: [async-throttler.ts:269](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L269) +Defined in: [async-throttler.ts:264](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L264) Updates the async throttler options diff --git a/docs/reference/classes/Batcher.md b/docs/reference/classes/Batcher.md index 6221b763..1adbce9d 100644 --- a/docs/reference/classes/Batcher.md +++ b/docs/reference/classes/Batcher.md @@ -101,7 +101,7 @@ Defined in: [batcher.ts:154](https://github.com/TanStack/pacer/blob/main/package ### key ```ts -key: string; +key: string | undefined; ``` Defined in: [batcher.ts:149](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L149) @@ -128,29 +128,13 @@ Defined in: [batcher.ts:146](https://github.com/TanStack/pacer/blob/main/package ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [batcher.ts:174](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L174) - -Emits a change event for the batcher instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### addItem() ```ts addItem(item): void; ``` -Defined in: [batcher.ts:210](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L210) +Defined in: [batcher.ts:205](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L205) Adds an item to the batcher If the batch size is reached, timeout occurs, or shouldProcess returns true, the batch will be processed @@ -173,7 +157,7 @@ If the batch size is reached, timeout occurs, or shouldProcess returns true, the cancel(): void; ``` -Defined in: [batcher.ts:288](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L288) +Defined in: [batcher.ts:283](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L283) Cancels any pending execution that was scheduled. Does NOT clear out the items. @@ -190,7 +174,7 @@ Does NOT clear out the items. clear(): void; ``` -Defined in: [batcher.ts:280](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L280) +Defined in: [batcher.ts:275](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L275) Removes all items from the batcher @@ -206,7 +190,7 @@ Removes all items from the batcher flush(): void; ``` -Defined in: [batcher.ts:258](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L258) +Defined in: [batcher.ts:253](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L253) Processes the current batch of items immediately @@ -222,7 +206,7 @@ Processes the current batch of items immediately peekAllItems(): TValue[]; ``` -Defined in: [batcher.ts:266](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L266) +Defined in: [batcher.ts:261](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L261) Returns a copy of all items in the batcher @@ -238,7 +222,7 @@ Returns a copy of all items in the batcher reset(): void; ``` -Defined in: [batcher.ts:296](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L296) +Defined in: [batcher.ts:291](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L291) Resets the batcher state to its default values @@ -254,7 +238,7 @@ Resets the batcher state to its default values setOptions(newOptions): void; ``` -Defined in: [batcher.ts:179](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L179) +Defined in: [batcher.ts:174](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L174) Updates the batcher options diff --git a/docs/reference/classes/Debouncer.md b/docs/reference/classes/Debouncer.md index 29c206a8..d18f515b 100644 --- a/docs/reference/classes/Debouncer.md +++ b/docs/reference/classes/Debouncer.md @@ -84,7 +84,7 @@ Defined in: [debouncer.ts:151](https://github.com/TanStack/pacer/blob/main/packa ### key ```ts -key: string; +key: string | undefined; ``` Defined in: [debouncer.ts:146](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L146) @@ -111,29 +111,13 @@ Defined in: [debouncer.ts:143](https://github.com/TanStack/pacer/blob/main/packa ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [debouncer.ts:171](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L171) - -Emits a change event for the debouncer instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### cancel() ```ts cancel(): void; ``` -Defined in: [debouncer.ts:286](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L286) +Defined in: [debouncer.ts:281](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L281) Cancels any pending execution @@ -149,7 +133,7 @@ Cancels any pending execution flush(): void; ``` -Defined in: [debouncer.ts:269](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L269) +Defined in: [debouncer.ts:264](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L264) Processes the current pending execution immediately @@ -165,7 +149,7 @@ Processes the current pending execution immediately maybeExecute(...args): void; ``` -Defined in: [debouncer.ts:222](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L222) +Defined in: [debouncer.ts:217](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L217) Attempts to execute the debounced function If a call is already in progress, it will be queued @@ -188,7 +172,7 @@ If a call is already in progress, it will be queued reset(): void; ``` -Defined in: [debouncer.ts:297](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L297) +Defined in: [debouncer.ts:292](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L292) Resets the debouncer state to its default values @@ -204,7 +188,7 @@ Resets the debouncer state to its default values setOptions(newOptions): void; ``` -Defined in: [debouncer.ts:176](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L176) +Defined in: [debouncer.ts:171](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L171) Updates the debouncer options diff --git a/docs/reference/classes/Queuer.md b/docs/reference/classes/Queuer.md index fbe28946..4c63fc38 100644 --- a/docs/reference/classes/Queuer.md +++ b/docs/reference/classes/Queuer.md @@ -135,7 +135,7 @@ Defined in: [queuer.ts:278](https://github.com/TanStack/pacer/blob/main/packages ### key ```ts -key: string; +key: string | undefined; ``` Defined in: [queuer.ts:273](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L273) @@ -162,22 +162,6 @@ Defined in: [queuer.ts:270](https://github.com/TanStack/pacer/blob/main/packages ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [queuer.ts:315](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L315) - -Emits a change event for the queuer instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### addItem() ```ts @@ -187,7 +171,7 @@ addItem( runOnItemsChange): boolean; ``` -Defined in: [queuer.ts:404](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L404) +Defined in: [queuer.ts:399](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L399) Adds an item to the queue. If the queue is full, the item is rejected and onReject is called. Items can be inserted based on priority or at the front/back depending on configuration. @@ -226,7 +210,7 @@ queuer.addItem('task2', 'front'); clear(): void; ``` -Defined in: [queuer.ts:686](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L686) +Defined in: [queuer.ts:681](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L681) Removes all pending items from the queue. Does not affect items being processed. @@ -242,7 +226,7 @@ Removes all pending items from the queue. Does not affect items being processed. execute(position?): TValue | undefined; ``` -Defined in: [queuer.ts:540](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L540) +Defined in: [queuer.ts:535](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L535) Removes and returns the next item from the queue and processes it using the provided function. @@ -271,7 +255,7 @@ queuer.execute('back'); flush(numberOfItems, position?): void; ``` -Defined in: [queuer.ts:556](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L556) +Defined in: [queuer.ts:551](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L551) Processes a specified number of items to execute immediately with no wait time If no numberOfItems is provided, all items will be processed @@ -298,7 +282,7 @@ If no numberOfItems is provided, all items will be processed flushAsBatch(batchFunction): void; ``` -Defined in: [queuer.ts:571](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L571) +Defined in: [queuer.ts:566](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L566) Processes all items in the queue as a batch using the provided function as an argument The queue is cleared after processing @@ -321,7 +305,7 @@ The queue is cleared after processing getNextItem(position): TValue | undefined; ``` -Defined in: [queuer.ts:488](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L488) +Defined in: [queuer.ts:483](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L483) Removes and returns the next item from the queue without executing the function. Use for manual queue management. Normally, use execute() to process items. @@ -352,7 +336,7 @@ queuer.getNextItem('back'); peekAllItems(): TValue[]; ``` -Defined in: [queuer.ts:654](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L654) +Defined in: [queuer.ts:649](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L649) Returns a copy of all items in the queue. @@ -368,7 +352,7 @@ Returns a copy of all items in the queue. peekNextItem(position): TValue | undefined; ``` -Defined in: [queuer.ts:644](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L644) +Defined in: [queuer.ts:639](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L639) Returns the next item in the queue without removing it. @@ -396,7 +380,7 @@ queuer.peekNextItem('back'); // back reset(): void; ``` -Defined in: [queuer.ts:694](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L694) +Defined in: [queuer.ts:689](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L689) Resets the queuer state to its default values @@ -412,7 +396,7 @@ Resets the queuer state to its default values setOptions(newOptions): void; ``` -Defined in: [queuer.ts:320](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L320) +Defined in: [queuer.ts:315](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L315) Updates the queuer options. New options are merged with existing options. @@ -434,7 +418,7 @@ Updates the queuer options. New options are merged with existing options. start(): void; ``` -Defined in: [queuer.ts:661](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L661) +Defined in: [queuer.ts:656](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L656) Starts processing items in the queue. If already isRunning, does nothing. @@ -450,7 +434,7 @@ Starts processing items in the queue. If already isRunning, does nothing. stop(): void; ``` -Defined in: [queuer.ts:671](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L671) +Defined in: [queuer.ts:666](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L666) Stops processing items in the queue. Does not clear the queue. diff --git a/docs/reference/classes/RateLimiter.md b/docs/reference/classes/RateLimiter.md index aabc3629..103f70b4 100644 --- a/docs/reference/classes/RateLimiter.md +++ b/docs/reference/classes/RateLimiter.md @@ -97,7 +97,7 @@ Defined in: [rate-limiter.ts:164](https://github.com/TanStack/pacer/blob/main/pa ### key ```ts -key: string; +key: string | undefined; ``` Defined in: [rate-limiter.ts:159](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L159) @@ -124,29 +124,13 @@ Defined in: [rate-limiter.ts:157](https://github.com/TanStack/pacer/blob/main/pa ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [rate-limiter.ts:187](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L187) - -Emits a change event for the rate limiter instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### getMsUntilNextWindow() ```ts getMsUntilNextWindow(): number; ``` -Defined in: [rate-limiter.ts:359](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L359) +Defined in: [rate-limiter.ts:354](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L354) Returns the number of milliseconds until the next execution will be possible @@ -162,7 +146,7 @@ Returns the number of milliseconds until the next execution will be possible getRemainingInWindow(): number; ``` -Defined in: [rate-limiter.ts:351](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L351) +Defined in: [rate-limiter.ts:346](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L346) Returns the number of remaining executions allowed in the current window @@ -178,7 +162,7 @@ Returns the number of remaining executions allowed in the current window maybeExecute(...args): boolean; ``` -Defined in: [rate-limiter.ts:253](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L253) +Defined in: [rate-limiter.ts:248](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L248) Attempts to execute the rate-limited function if within the configured limits. Will reject execution if the number of calls in the current window exceeds the limit. @@ -213,7 +197,7 @@ rateLimiter.maybeExecute('arg1', 'arg2'); // false reset(): void; ``` -Defined in: [rate-limiter.ts:370](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L370) +Defined in: [rate-limiter.ts:365](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L365) Resets the rate limiter state @@ -229,7 +213,7 @@ Resets the rate limiter state setOptions(newOptions): void; ``` -Defined in: [rate-limiter.ts:192](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L192) +Defined in: [rate-limiter.ts:187](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L187) Updates the rate limiter options diff --git a/docs/reference/classes/Throttler.md b/docs/reference/classes/Throttler.md index 0c63a908..0c11bfaf 100644 --- a/docs/reference/classes/Throttler.md +++ b/docs/reference/classes/Throttler.md @@ -115,29 +115,13 @@ Defined in: [throttler.ts:151](https://github.com/TanStack/pacer/blob/main/packa ## Methods -### \_emit() - -```ts -_emit(): void; -``` - -Defined in: [throttler.ts:179](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L179) - -Emits a change event for the throttler instance. Mostly useful for devtools. - -#### Returns - -`void` - -*** - ### cancel() ```ts cancel(): void; ``` -Defined in: [throttler.ts:323](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L323) +Defined in: [throttler.ts:318](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L318) Cancels any pending trailing execution and clears internal state. @@ -159,7 +143,7 @@ Has no effect if there is no pending execution. flush(): void; ``` -Defined in: [throttler.ts:301](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L301) +Defined in: [throttler.ts:296](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L296) Processes the current pending execution immediately @@ -175,7 +159,7 @@ Processes the current pending execution immediately maybeExecute(...args): void; ``` -Defined in: [throttler.ts:242](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L242) +Defined in: [throttler.ts:237](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L237) Attempts to execute the throttled function. The execution behavior depends on the throttler options: @@ -217,7 +201,7 @@ throttled.maybeExecute('c', 'd'); reset(): void; ``` -Defined in: [throttler.ts:334](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L334) +Defined in: [throttler.ts:329](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L329) Resets the throttler state to its default values @@ -233,7 +217,7 @@ Resets the throttler state to its default values setOptions(newOptions): void; ``` -Defined in: [throttler.ts:184](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L184) +Defined in: [throttler.ts:179](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L179) Updates the throttler options diff --git a/docs/reference/functions/asyncBatch.md b/docs/reference/functions/asyncBatch.md index 8f4c8f4a..4bd1de20 100644 --- a/docs/reference/functions/asyncBatch.md +++ b/docs/reference/functions/asyncBatch.md @@ -9,7 +9,7 @@ title: asyncBatch function asyncBatch(fn, options): (item) => Promise; ``` -Defined in: [async-batcher.ts:587](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L587) +Defined in: [async-batcher.ts:582](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L582) Creates an async batcher that processes items in batches. diff --git a/docs/reference/functions/asyncDebounce.md b/docs/reference/functions/asyncDebounce.md index 7245d2e8..dc2ceaf6 100644 --- a/docs/reference/functions/asyncDebounce.md +++ b/docs/reference/functions/asyncDebounce.md @@ -9,7 +9,7 @@ title: asyncDebounce function asyncDebounce(fn, initialOptions): (...args) => Promise | undefined>; ``` -Defined in: [async-debouncer.ts:558](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L558) +Defined in: [async-debouncer.ts:553](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L553) Creates an async debounced function that delays execution until after a specified wait time. The debounced function will only execute once the wait period has elapsed without any new calls. diff --git a/docs/reference/functions/asyncQueue.md b/docs/reference/functions/asyncQueue.md index 843f8ad1..3fce7f4d 100644 --- a/docs/reference/functions/asyncQueue.md +++ b/docs/reference/functions/asyncQueue.md @@ -9,7 +9,7 @@ title: asyncQueue function asyncQueue(fn, initialOptions): (item, position, runOnItemsChange) => boolean; ``` -Defined in: [async-queuer.ts:919](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L919) +Defined in: [async-queuer.ts:914](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L914) Creates a new AsyncQueuer instance and returns a bound addItem function for adding tasks. The queuer is started automatically and ready to process items. diff --git a/docs/reference/functions/asyncRateLimit.md b/docs/reference/functions/asyncRateLimit.md index 63089c62..79a467c1 100644 --- a/docs/reference/functions/asyncRateLimit.md +++ b/docs/reference/functions/asyncRateLimit.md @@ -9,7 +9,7 @@ title: asyncRateLimit function asyncRateLimit(fn, initialOptions): (...args) => Promise | undefined>; ``` -Defined in: [async-rate-limiter.ts:640](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L640) +Defined in: [async-rate-limiter.ts:635](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-rate-limiter.ts#L635) Creates an async rate-limited function that will execute the provided function up to a maximum number of times within a time window. diff --git a/docs/reference/functions/asyncRetry.md b/docs/reference/functions/asyncRetry.md index 44018141..ddf3756f 100644 --- a/docs/reference/functions/asyncRetry.md +++ b/docs/reference/functions/asyncRetry.md @@ -9,7 +9,7 @@ title: asyncRetry function asyncRetry(fn, initialOptions): (...args) => Promise> | undefined>; ``` -Defined in: [async-retryer.ts:663](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L663) +Defined in: [async-retryer.ts:658](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-retryer.ts#L658) Creates a retry-enabled version of an async function. This is a convenience wrapper around the AsyncRetryer class that returns the execute method. diff --git a/docs/reference/functions/asyncThrottle.md b/docs/reference/functions/asyncThrottle.md index 270fcf59..6c74d5fb 100644 --- a/docs/reference/functions/asyncThrottle.md +++ b/docs/reference/functions/asyncThrottle.md @@ -9,7 +9,7 @@ title: asyncThrottle function asyncThrottle(fn, initialOptions): (...args) => Promise | undefined>; ``` -Defined in: [async-throttler.ts:626](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L626) +Defined in: [async-throttler.ts:621](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-throttler.ts#L621) Creates an async throttled function that limits how often the function can execute. The throttled function will execute at most once per wait period, even if called multiple times. diff --git a/docs/reference/functions/batch.md b/docs/reference/functions/batch.md index 794f35c1..50e7b269 100644 --- a/docs/reference/functions/batch.md +++ b/docs/reference/functions/batch.md @@ -9,7 +9,7 @@ title: batch function batch(fn, options): (item) => void; ``` -Defined in: [batcher.ts:322](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L322) +Defined in: [batcher.ts:317](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L317) Creates a batcher that processes items in batches. diff --git a/docs/reference/functions/createKey.md b/docs/reference/functions/createKey.md deleted file mode 100644 index 9ed412b7..00000000 --- a/docs/reference/functions/createKey.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -id: createKey -title: createKey ---- - -# Function: createKey() - -```ts -function createKey(key?): string; -``` - -Defined in: [utils.ts:14](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/utils.ts#L14) - -## Parameters - -### key? - -`string` - -## Returns - -`string` diff --git a/docs/reference/functions/debounce.md b/docs/reference/functions/debounce.md index 76080383..930f407b 100644 --- a/docs/reference/functions/debounce.md +++ b/docs/reference/functions/debounce.md @@ -9,7 +9,7 @@ title: debounce function debounce(fn, initialOptions): (...args) => void; ``` -Defined in: [debouncer.ts:329](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L329) +Defined in: [debouncer.ts:324](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/debouncer.ts#L324) Creates a debounced function that delays invoking the provided function until after a specified wait time. Multiple calls during the wait period will cancel previous pending invocations and reset the timer. diff --git a/docs/reference/functions/queue.md b/docs/reference/functions/queue.md index b7e89d84..54f302b4 100644 --- a/docs/reference/functions/queue.md +++ b/docs/reference/functions/queue.md @@ -9,7 +9,7 @@ title: queue function queue(fn, initialOptions): (item, position, runOnItemsChange) => boolean; ``` -Defined in: [queuer.ts:735](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L735) +Defined in: [queuer.ts:730](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L730) Creates a queue that processes items immediately upon addition. Items are processed sequentially in FIFO order by default. diff --git a/docs/reference/functions/rateLimit.md b/docs/reference/functions/rateLimit.md index b6a37937..4d79425e 100644 --- a/docs/reference/functions/rateLimit.md +++ b/docs/reference/functions/rateLimit.md @@ -9,7 +9,7 @@ title: rateLimit function rateLimit(fn, initialOptions): (...args) => boolean; ``` -Defined in: [rate-limiter.ts:424](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L424) +Defined in: [rate-limiter.ts:419](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/rate-limiter.ts#L419) Creates a rate-limited function that will execute the provided function up to a maximum number of times within a time window. diff --git a/docs/reference/functions/throttle.md b/docs/reference/functions/throttle.md index e2dd3d84..7b73ff78 100644 --- a/docs/reference/functions/throttle.md +++ b/docs/reference/functions/throttle.md @@ -9,7 +9,7 @@ title: throttle function throttle(fn, initialOptions): (...args) => void; ``` -Defined in: [throttler.ts:375](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L375) +Defined in: [throttler.ts:370](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/throttler.ts#L370) Creates a throttled function that limits how often the provided function can execute. diff --git a/docs/reference/index.md b/docs/reference/index.md index 006d9e4e..a6db5b46 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -72,7 +72,6 @@ title: "@tanstack/pacer" - [asyncThrottle](../functions/asyncThrottle.md) - [asyncThrottlerOptions](../functions/asyncThrottlerOptions.md) - [batch](../functions/batch.md) -- [createKey](../functions/createKey.md) - [debounce](../functions/debounce.md) - [debouncerOptions](../functions/debouncerOptions.md) - [isFunction](../functions/isFunction.md) diff --git a/docs/reference/variables/pacerEventClient.md b/docs/reference/variables/pacerEventClient.md index 6ce58ebf..6f98a5d6 100644 --- a/docs/reference/variables/pacerEventClient.md +++ b/docs/reference/variables/pacerEventClient.md @@ -9,4 +9,4 @@ title: pacerEventClient const pacerEventClient: PacerEventClient; ``` -Defined in: [event-client.ts:66](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/event-client.ts#L66) +Defined in: [event-client.ts:68](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/event-client.ts#L68) diff --git a/packages/pacer/src/async-batcher.ts b/packages/pacer/src/async-batcher.ts index 1a838da0..94d65854 100644 --- a/packages/pacer/src/async-batcher.ts +++ b/packages/pacer/src/async-batcher.ts @@ -1,6 +1,6 @@ import { Store } from '@tanstack/store' import { AsyncRetryer } from './async-retryer' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' import type { AsyncRetryerOptions } from './async-retryer' import type { OptionalKeys } from './types' @@ -266,7 +266,7 @@ export class AsyncBatcher { readonly store: Store>> = new Store( getDefaultAsyncBatcherState(), ) - key: string + key: string | undefined options: AsyncBatcherOptionsWithOptionalCallbacks asyncRetryers = new Map< number, @@ -278,7 +278,7 @@ export class AsyncBatcher { public fn: (items: Array) => Promise, initialOptions: AsyncBatcherOptions, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -293,11 +293,6 @@ export class AsyncBatcher { }) } - /** - * Emits a change event for the async batcher instance. Mostly useful for devtools. - */ - _emit = () => emitChange('AsyncBatcher', this) - /** * Updates the async batcher options */ diff --git a/packages/pacer/src/async-debouncer.ts b/packages/pacer/src/async-debouncer.ts index 8b54106b..e3a8b4e7 100644 --- a/packages/pacer/src/async-debouncer.ts +++ b/packages/pacer/src/async-debouncer.ts @@ -1,6 +1,6 @@ import { Store } from '@tanstack/store' import { AsyncRetryer } from './async-retryer' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' import type { AsyncRetryerOptions } from './async-retryer' import type { AnyAsyncFunction, OptionalKeys } from './types' @@ -219,7 +219,7 @@ export class AsyncDebouncer { readonly store: Store>> = new Store< AsyncDebouncerState >(getDefaultAsyncDebouncerState()) - key: string + key: string | undefined options: AsyncDebouncerOptions asyncRetryers = new Map>() #timeoutId: NodeJS.Timeout | null = null @@ -231,7 +231,7 @@ export class AsyncDebouncer { public fn: TFn, initialOptions: AsyncDebouncerOptions, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -246,11 +246,6 @@ export class AsyncDebouncer { }) } - /** - * Emits a change event for the async debouncer instance. Mostly useful for devtools. - */ - _emit = () => emitChange('AsyncDebouncer', this) - /** * Updates the async debouncer options */ diff --git a/packages/pacer/src/async-queuer.ts b/packages/pacer/src/async-queuer.ts index 0808d275..d26816ab 100644 --- a/packages/pacer/src/async-queuer.ts +++ b/packages/pacer/src/async-queuer.ts @@ -1,6 +1,6 @@ import { Store } from '@tanstack/store' import { AsyncRetryer } from './async-retryer' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' import type { AsyncRetryerOptions } from './async-retryer' import type { OptionalKeys } from './types' @@ -316,7 +316,7 @@ export class AsyncQueuer { readonly store: Store>> = new Store< AsyncQueuerState >(getDefaultAsyncQueuerState()) - key: string + key: string | undefined options: AsyncQueuerOptions asyncRetryers = new Map< number, @@ -328,7 +328,7 @@ export class AsyncQueuer { public fn: (item: TValue) => Promise, initialOptions: AsyncQueuerOptions = {}, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -360,11 +360,6 @@ export class AsyncQueuer { }) } - /** - * Emits a change event for the async queuer instance. Mostly useful for devtools. - */ - _emit = () => emitChange('AsyncQueuer', this) - /** * Updates the queuer options. New options are merged with existing options. */ diff --git a/packages/pacer/src/async-rate-limiter.ts b/packages/pacer/src/async-rate-limiter.ts index 299369ac..279db060 100644 --- a/packages/pacer/src/async-rate-limiter.ts +++ b/packages/pacer/src/async-rate-limiter.ts @@ -1,6 +1,6 @@ import { Store } from '@tanstack/store' import { AsyncRetryer } from './async-retryer' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' import type { AsyncRetryerOptions } from './async-retryer' import type { AnyAsyncFunction } from './types' @@ -246,7 +246,7 @@ export class AsyncRateLimiter { readonly store: Store>> = new Store< AsyncRateLimiterState >(getDefaultAsyncRateLimiterState()) - key: string + key: string | undefined options: AsyncRateLimiterOptions asyncRetryers = new Map>() #timeoutIds: Set = new Set() @@ -255,7 +255,7 @@ export class AsyncRateLimiter { public fn: TFn, initialOptions: AsyncRateLimiterOptions, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -273,11 +273,6 @@ export class AsyncRateLimiter { }) } - /** - * Emits a change event for the async rate limiter instance. Mostly useful for devtools. - */ - _emit = () => emitChange('AsyncRateLimiter', this) - /** * Updates the async rate limiter options */ diff --git a/packages/pacer/src/async-retryer.ts b/packages/pacer/src/async-retryer.ts index 8f9a23e2..edfbc88a 100644 --- a/packages/pacer/src/async-retryer.ts +++ b/packages/pacer/src/async-retryer.ts @@ -1,5 +1,5 @@ import { Store } from '@tanstack/store' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' import type { AnyAsyncFunction } from './types' @@ -289,7 +289,7 @@ export class AsyncRetryer { readonly store: Store>> = new Store( getDefaultAsyncRetryerState(), ) - key: string + key: string | undefined options: AsyncRetryerOptions & typeof defaultOptions #abortController: AbortController | null = null @@ -302,7 +302,7 @@ export class AsyncRetryer { public fn: TFn, initialOptions: AsyncRetryerOptions = {}, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -319,11 +319,6 @@ export class AsyncRetryer { }) } - /** - * Emits a change event for the async retryer instance. Mostly useful for devtools. - */ - _emit = () => emitChange('AsyncRetryer', this) - /** * Updates the retryer options * @param newOptions Partial options to merge with existing options diff --git a/packages/pacer/src/async-throttler.ts b/packages/pacer/src/async-throttler.ts index 9b261c39..8f14c70d 100644 --- a/packages/pacer/src/async-throttler.ts +++ b/packages/pacer/src/async-throttler.ts @@ -1,6 +1,6 @@ import { Store } from '@tanstack/store' import { AsyncRetryer } from './async-retryer' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' import type { AsyncRetryerOptions } from './async-retryer' import type { AnyAsyncFunction, OptionalKeys } from './types' @@ -231,7 +231,7 @@ export class AsyncThrottler { readonly store: Store>> = new Store< AsyncThrottlerState >(getDefaultAsyncThrottlerState()) - key: string + key: string | undefined options: AsyncThrottlerOptions asyncRetryers = new Map>() #timeoutId: NodeJS.Timeout | null = null @@ -243,7 +243,7 @@ export class AsyncThrottler { public fn: TFn, initialOptions: AsyncThrottlerOptions, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -258,11 +258,6 @@ export class AsyncThrottler { }) } - /** - * Emits a change event for the async throttler instance. Mostly useful for devtools. - */ - _emit = () => emitChange('AsyncThrottler', this) - /** * Updates the async throttler options */ diff --git a/packages/pacer/src/batcher.ts b/packages/pacer/src/batcher.ts index 681e6daf..2c6d843a 100644 --- a/packages/pacer/src/batcher.ts +++ b/packages/pacer/src/batcher.ts @@ -1,5 +1,5 @@ import { Store } from '@tanstack/store' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' import type { OptionalKeys } from './types' @@ -146,7 +146,7 @@ export class Batcher { readonly store: Store>> = new Store( getDefaultBatcherState(), ) - key: string + key: string | undefined options: BatcherOptionsWithOptionalCallbacks #timeoutId: NodeJS.Timeout | null = null @@ -154,7 +154,7 @@ export class Batcher { public fn: (items: Array) => void, initialOptions: BatcherOptions, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -168,11 +168,6 @@ export class Batcher { }) } - /** - * Emits a change event for the batcher instance. Mostly useful for devtools. - */ - _emit = () => emitChange('Batcher', this) - /** * Updates the batcher options */ diff --git a/packages/pacer/src/debouncer.ts b/packages/pacer/src/debouncer.ts index a8caf24e..216eec5c 100644 --- a/packages/pacer/src/debouncer.ts +++ b/packages/pacer/src/debouncer.ts @@ -1,5 +1,5 @@ import { Store } from '@tanstack/store' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' import type { AnyFunction } from './types' @@ -143,7 +143,7 @@ export class Debouncer { readonly store: Store>> = new Store( getDefaultDebouncerState(), ) - key: string + key: string | undefined options: DebouncerOptions #timeoutId: NodeJS.Timeout | undefined @@ -151,7 +151,7 @@ export class Debouncer { public fn: TFn, initialOptions: DebouncerOptions, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -165,11 +165,6 @@ export class Debouncer { }) } - /** - * Emits a change event for the debouncer instance. Mostly useful for devtools. - */ - _emit = () => emitChange('Debouncer', this) - /** * Updates the debouncer options */ diff --git a/packages/pacer/src/event-client.ts b/packages/pacer/src/event-client.ts index 255ebcd9..9d2b2799 100644 --- a/packages/pacer/src/event-client.ts +++ b/packages/pacer/src/event-client.ts @@ -60,7 +60,9 @@ export const emitChange = < event: TSuffix, payload: PacerEventMap[`pacer:${TSuffix}`], ) => { - pacerEventClient.emit(event, payload) + if (payload.key) { + pacerEventClient.emit(event, payload) + } } export const pacerEventClient = new PacerEventClient() diff --git a/packages/pacer/src/queuer.ts b/packages/pacer/src/queuer.ts index f4cb1425..ed5f0970 100644 --- a/packages/pacer/src/queuer.ts +++ b/packages/pacer/src/queuer.ts @@ -1,5 +1,5 @@ import { Store } from '@tanstack/store' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' export interface QueuerState { @@ -270,7 +270,7 @@ export class Queuer { readonly store: Store>> = new Store( getDefaultQueuerState(), ) - key: string + key: string | undefined options: QueuerOptions #timeoutId: NodeJS.Timeout | null = null @@ -278,7 +278,7 @@ export class Queuer { public fn: (item: TValue) => void, initialOptions: QueuerOptions = {}, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -309,11 +309,6 @@ export class Queuer { }) } - /** - * Emits a change event for the queuer instance. Mostly useful for devtools. - */ - _emit = () => emitChange('Queuer', this) - /** * Updates the queuer options. New options are merged with existing options. */ diff --git a/packages/pacer/src/rate-limiter.ts b/packages/pacer/src/rate-limiter.ts index 1a4a2f1c..5e34452d 100644 --- a/packages/pacer/src/rate-limiter.ts +++ b/packages/pacer/src/rate-limiter.ts @@ -1,5 +1,5 @@ import { Store } from '@tanstack/store' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' import type { AnyFunction } from './types' @@ -156,7 +156,7 @@ const defaultOptions: Omit< export class RateLimiter { readonly store: Store> = new Store(getDefaultRateLimiterState()) - key: string + key: string | undefined options: RateLimiterOptions #timeoutIds: Set = new Set() @@ -164,7 +164,7 @@ export class RateLimiter { public fn: TFn, initialOptions: RateLimiterOptions, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -181,11 +181,6 @@ export class RateLimiter { }) } - /** - * Emits a change event for the rate limiter instance. Mostly useful for devtools. - */ - _emit = () => emitChange('RateLimiter', this) - /** * Updates the rate limiter options */ diff --git a/packages/pacer/src/throttler.ts b/packages/pacer/src/throttler.ts index c88ccea0..048bff1d 100644 --- a/packages/pacer/src/throttler.ts +++ b/packages/pacer/src/throttler.ts @@ -1,5 +1,5 @@ import { Store } from '@tanstack/store' -import { createKey, parseFunctionOrValue } from './utils' +import { parseFunctionOrValue } from './utils' import { emitChange, pacerEventClient } from './event-client' import type { AnyFunction } from './types' @@ -159,7 +159,7 @@ export class Throttler { public fn: TFn, initialOptions: ThrottlerOptions, ) { - this.key = createKey(initialOptions.key) + this.key = initialOptions.key this.options = { ...defaultOptions, ...initialOptions, @@ -173,11 +173,6 @@ export class Throttler { }) } - /** - * Emits a change event for the throttler instance. Mostly useful for devtools. - */ - _emit = () => emitChange('Throttler', this) - /** * Updates the throttler options */ diff --git a/packages/pacer/src/utils.ts b/packages/pacer/src/utils.ts index ceb8b605..3a510d8e 100644 --- a/packages/pacer/src/utils.ts +++ b/packages/pacer/src/utils.ts @@ -10,18 +10,3 @@ export function parseFunctionOrValue>( ): T { return isFunction(value) ? value(...args) : value } - -export function createKey(key?: string): string { - if (key) { - return key - } - - if ( - typeof crypto !== 'undefined' && - typeof crypto.randomUUID === 'function' - ) { - return crypto.randomUUID() - } - - return '' -}