@tanstack/preact-pacer 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/dist/async-batcher/useAsyncBatchedCallback.d.ts +2 -4
  2. package/dist/async-batcher/useAsyncBatchedCallback.js +1 -2
  3. package/dist/async-batcher/useAsyncBatcher.d.ts +4 -7
  4. package/dist/async-batcher/useAsyncBatcher.js +1 -3
  5. package/dist/async-debouncer/useAsyncDebouncedCallback.d.ts +2 -4
  6. package/dist/async-debouncer/useAsyncDebouncedCallback.js +1 -2
  7. package/dist/async-debouncer/useAsyncDebouncer.d.ts +4 -6
  8. package/dist/async-debouncer/useAsyncDebouncer.js +1 -2
  9. package/dist/async-queuer/useAsyncQueuedState.d.ts +4 -6
  10. package/dist/async-queuer/useAsyncQueuedState.js +3 -4
  11. package/dist/async-queuer/useAsyncQueuer.d.ts +6 -8
  12. package/dist/async-queuer/useAsyncQueuer.js +3 -4
  13. package/dist/async-rate-limiter/useAsyncRateLimitedCallback.d.ts +2 -4
  14. package/dist/async-rate-limiter/useAsyncRateLimitedCallback.js +1 -2
  15. package/dist/async-rate-limiter/useAsyncRateLimiter.d.ts +4 -6
  16. package/dist/async-rate-limiter/useAsyncRateLimiter.js +1 -2
  17. package/dist/async-throttler/useAsyncThrottledCallback.d.ts +2 -4
  18. package/dist/async-throttler/useAsyncThrottledCallback.js +1 -2
  19. package/dist/async-throttler/useAsyncThrottler.d.ts +4 -6
  20. package/dist/async-throttler/useAsyncThrottler.js +1 -2
  21. package/dist/batcher/useBatchedCallback.d.ts +2 -4
  22. package/dist/batcher/useBatchedCallback.js +1 -2
  23. package/dist/batcher/useBatcher.d.ts +6 -10
  24. package/dist/batcher/useBatcher.js +3 -6
  25. package/dist/debouncer/useDebouncedCallback.d.ts +2 -4
  26. package/dist/debouncer/useDebouncedCallback.js +1 -2
  27. package/dist/debouncer/useDebouncedState.d.ts +2 -4
  28. package/dist/debouncer/useDebouncedState.js +1 -2
  29. package/dist/debouncer/useDebouncedValue.d.ts +2 -4
  30. package/dist/debouncer/useDebouncedValue.js +1 -2
  31. package/dist/debouncer/useDebouncer.d.ts +4 -6
  32. package/dist/debouncer/useDebouncer.js +1 -2
  33. package/dist/provider/PacerProvider.d.ts +6 -8
  34. package/dist/provider/PacerProvider.js +1 -2
  35. package/dist/queuer/useQueuedState.d.ts +2 -4
  36. package/dist/queuer/useQueuedState.js +1 -2
  37. package/dist/queuer/useQueuedValue.d.ts +2 -4
  38. package/dist/queuer/useQueuedValue.js +1 -2
  39. package/dist/queuer/useQueuer.d.ts +4 -6
  40. package/dist/queuer/useQueuer.js +1 -2
  41. package/dist/rate-limiter/useRateLimitedCallback.d.ts +2 -4
  42. package/dist/rate-limiter/useRateLimitedCallback.js +1 -2
  43. package/dist/rate-limiter/useRateLimitedState.d.ts +2 -4
  44. package/dist/rate-limiter/useRateLimitedState.js +1 -2
  45. package/dist/rate-limiter/useRateLimitedValue.d.ts +2 -4
  46. package/dist/rate-limiter/useRateLimitedValue.js +1 -2
  47. package/dist/rate-limiter/useRateLimiter.d.ts +4 -6
  48. package/dist/rate-limiter/useRateLimiter.js +1 -2
  49. package/dist/throttler/useThrottledCallback.d.ts +2 -4
  50. package/dist/throttler/useThrottledCallback.js +1 -2
  51. package/dist/throttler/useThrottledState.d.ts +2 -4
  52. package/dist/throttler/useThrottledState.js +1 -2
  53. package/dist/throttler/useThrottledValue.d.ts +2 -4
  54. package/dist/throttler/useThrottledValue.js +1 -2
  55. package/dist/throttler/useThrottler.d.ts +4 -6
  56. package/dist/throttler/useThrottler.js +1 -2
  57. package/package.json +22 -70
  58. package/dist/async-batcher/index.cjs +0 -13
  59. package/dist/async-batcher/index.d.cts +0 -4
  60. package/dist/async-batcher/useAsyncBatchedCallback.cjs +0 -51
  61. package/dist/async-batcher/useAsyncBatchedCallback.cjs.map +0 -1
  62. package/dist/async-batcher/useAsyncBatchedCallback.d.cts +0 -43
  63. package/dist/async-batcher/useAsyncBatchedCallback.js.map +0 -1
  64. package/dist/async-batcher/useAsyncBatcher.cjs +0 -217
  65. package/dist/async-batcher/useAsyncBatcher.cjs.map +0 -1
  66. package/dist/async-batcher/useAsyncBatcher.d.cts +0 -223
  67. package/dist/async-batcher/useAsyncBatcher.js.map +0 -1
  68. package/dist/async-debouncer/index.cjs +0 -13
  69. package/dist/async-debouncer/index.d.cts +0 -4
  70. package/dist/async-debouncer/useAsyncDebouncedCallback.cjs +0 -52
  71. package/dist/async-debouncer/useAsyncDebouncedCallback.cjs.map +0 -1
  72. package/dist/async-debouncer/useAsyncDebouncedCallback.d.cts +0 -47
  73. package/dist/async-debouncer/useAsyncDebouncedCallback.js.map +0 -1
  74. package/dist/async-debouncer/useAsyncDebouncer.cjs +0 -195
  75. package/dist/async-debouncer/useAsyncDebouncer.cjs.map +0 -1
  76. package/dist/async-debouncer/useAsyncDebouncer.d.cts +0 -202
  77. package/dist/async-debouncer/useAsyncDebouncer.js.map +0 -1
  78. package/dist/async-queuer/index.cjs +0 -13
  79. package/dist/async-queuer/index.d.cts +0 -4
  80. package/dist/async-queuer/useAsyncQueuedState.cjs +0 -154
  81. package/dist/async-queuer/useAsyncQueuedState.cjs.map +0 -1
  82. package/dist/async-queuer/useAsyncQueuedState.d.cts +0 -150
  83. package/dist/async-queuer/useAsyncQueuedState.js.map +0 -1
  84. package/dist/async-queuer/useAsyncQueuer.cjs +0 -217
  85. package/dist/async-queuer/useAsyncQueuer.cjs.map +0 -1
  86. package/dist/async-queuer/useAsyncQueuer.d.cts +0 -223
  87. package/dist/async-queuer/useAsyncQueuer.js.map +0 -1
  88. package/dist/async-rate-limiter/index.cjs +0 -13
  89. package/dist/async-rate-limiter/index.d.cts +0 -4
  90. package/dist/async-rate-limiter/useAsyncRateLimitedCallback.cjs +0 -65
  91. package/dist/async-rate-limiter/useAsyncRateLimitedCallback.cjs.map +0 -1
  92. package/dist/async-rate-limiter/useAsyncRateLimitedCallback.d.cts +0 -60
  93. package/dist/async-rate-limiter/useAsyncRateLimitedCallback.js.map +0 -1
  94. package/dist/async-rate-limiter/useAsyncRateLimiter.cjs +0 -209
  95. package/dist/async-rate-limiter/useAsyncRateLimiter.cjs.map +0 -1
  96. package/dist/async-rate-limiter/useAsyncRateLimiter.d.cts +0 -219
  97. package/dist/async-rate-limiter/useAsyncRateLimiter.js.map +0 -1
  98. package/dist/async-retryer/index.cjs +0 -8
  99. package/dist/async-retryer/index.d.cts +0 -1
  100. package/dist/async-throttler/index.cjs +0 -13
  101. package/dist/async-throttler/index.d.cts +0 -4
  102. package/dist/async-throttler/useAsyncThrottledCallback.cjs +0 -49
  103. package/dist/async-throttler/useAsyncThrottledCallback.cjs.map +0 -1
  104. package/dist/async-throttler/useAsyncThrottledCallback.d.cts +0 -44
  105. package/dist/async-throttler/useAsyncThrottledCallback.js.map +0 -1
  106. package/dist/async-throttler/useAsyncThrottler.cjs +0 -206
  107. package/dist/async-throttler/useAsyncThrottler.cjs.map +0 -1
  108. package/dist/async-throttler/useAsyncThrottler.d.cts +0 -213
  109. package/dist/async-throttler/useAsyncThrottler.js.map +0 -1
  110. package/dist/batcher/index.cjs +0 -13
  111. package/dist/batcher/index.d.cts +0 -4
  112. package/dist/batcher/useBatchedCallback.cjs +0 -47
  113. package/dist/batcher/useBatchedCallback.cjs.map +0 -1
  114. package/dist/batcher/useBatchedCallback.d.cts +0 -41
  115. package/dist/batcher/useBatchedCallback.js.map +0 -1
  116. package/dist/batcher/useBatcher.cjs +0 -165
  117. package/dist/batcher/useBatcher.cjs.map +0 -1
  118. package/dist/batcher/useBatcher.d.cts +0 -174
  119. package/dist/batcher/useBatcher.js.map +0 -1
  120. package/dist/debouncer/index.cjs +0 -17
  121. package/dist/debouncer/index.d.cts +0 -6
  122. package/dist/debouncer/useDebouncedCallback.cjs +0 -48
  123. package/dist/debouncer/useDebouncedCallback.cjs.map +0 -1
  124. package/dist/debouncer/useDebouncedCallback.d.cts +0 -43
  125. package/dist/debouncer/useDebouncedCallback.js.map +0 -1
  126. package/dist/debouncer/useDebouncedState.cjs +0 -89
  127. package/dist/debouncer/useDebouncedState.cjs.map +0 -1
  128. package/dist/debouncer/useDebouncedState.d.cts +0 -80
  129. package/dist/debouncer/useDebouncedState.js.map +0 -1
  130. package/dist/debouncer/useDebouncedValue.cjs +0 -96
  131. package/dist/debouncer/useDebouncedValue.cjs.map +0 -1
  132. package/dist/debouncer/useDebouncedValue.d.cts +0 -89
  133. package/dist/debouncer/useDebouncedValue.js.map +0 -1
  134. package/dist/debouncer/useDebouncer.cjs +0 -141
  135. package/dist/debouncer/useDebouncer.cjs.map +0 -1
  136. package/dist/debouncer/useDebouncer.d.cts +0 -151
  137. package/dist/debouncer/useDebouncer.js.map +0 -1
  138. package/dist/index.cjs +0 -67
  139. package/dist/index.d.cts +0 -30
  140. package/dist/provider/PacerProvider.cjs +0 -26
  141. package/dist/provider/PacerProvider.cjs.map +0 -1
  142. package/dist/provider/PacerProvider.d.cts +0 -28
  143. package/dist/provider/PacerProvider.js.map +0 -1
  144. package/dist/provider/index.cjs +0 -6
  145. package/dist/provider/index.d.cts +0 -2
  146. package/dist/queuer/index.cjs +0 -15
  147. package/dist/queuer/index.d.cts +0 -5
  148. package/dist/queuer/useQueuedState.cjs +0 -129
  149. package/dist/queuer/useQueuedState.cjs.map +0 -1
  150. package/dist/queuer/useQueuedState.d.cts +0 -121
  151. package/dist/queuer/useQueuedState.js.map +0 -1
  152. package/dist/queuer/useQueuedValue.cjs +0 -115
  153. package/dist/queuer/useQueuedValue.cjs.map +0 -1
  154. package/dist/queuer/useQueuedValue.d.cts +0 -104
  155. package/dist/queuer/useQueuedValue.js.map +0 -1
  156. package/dist/queuer/useQueuer.cjs +0 -176
  157. package/dist/queuer/useQueuer.cjs.map +0 -1
  158. package/dist/queuer/useQueuer.d.cts +0 -185
  159. package/dist/queuer/useQueuer.js.map +0 -1
  160. package/dist/rate-limiter/index.cjs +0 -17
  161. package/dist/rate-limiter/index.d.cts +0 -6
  162. package/dist/rate-limiter/useRateLimitedCallback.cjs +0 -65
  163. package/dist/rate-limiter/useRateLimitedCallback.cjs.map +0 -1
  164. package/dist/rate-limiter/useRateLimitedCallback.d.cts +0 -60
  165. package/dist/rate-limiter/useRateLimitedCallback.js.map +0 -1
  166. package/dist/rate-limiter/useRateLimitedState.cjs +0 -115
  167. package/dist/rate-limiter/useRateLimitedState.cjs.map +0 -1
  168. package/dist/rate-limiter/useRateLimitedState.d.cts +0 -106
  169. package/dist/rate-limiter/useRateLimitedState.js.map +0 -1
  170. package/dist/rate-limiter/useRateLimitedValue.cjs +0 -102
  171. package/dist/rate-limiter/useRateLimitedValue.cjs.map +0 -1
  172. package/dist/rate-limiter/useRateLimitedValue.d.cts +0 -95
  173. package/dist/rate-limiter/useRateLimitedValue.js.map +0 -1
  174. package/dist/rate-limiter/useRateLimiter.cjs +0 -167
  175. package/dist/rate-limiter/useRateLimiter.cjs.map +0 -1
  176. package/dist/rate-limiter/useRateLimiter.d.cts +0 -178
  177. package/dist/rate-limiter/useRateLimiter.js.map +0 -1
  178. package/dist/throttler/index.cjs +0 -17
  179. package/dist/throttler/index.d.cts +0 -6
  180. package/dist/throttler/useThrottledCallback.cjs +0 -49
  181. package/dist/throttler/useThrottledCallback.cjs.map +0 -1
  182. package/dist/throttler/useThrottledCallback.d.cts +0 -44
  183. package/dist/throttler/useThrottledCallback.js.map +0 -1
  184. package/dist/throttler/useThrottledState.cjs +0 -100
  185. package/dist/throttler/useThrottledState.cjs.map +0 -1
  186. package/dist/throttler/useThrottledState.d.cts +0 -91
  187. package/dist/throttler/useThrottledState.js.map +0 -1
  188. package/dist/throttler/useThrottledValue.cjs +0 -91
  189. package/dist/throttler/useThrottledValue.cjs.map +0 -1
  190. package/dist/throttler/useThrottledValue.d.cts +0 -84
  191. package/dist/throttler/useThrottledValue.js.map +0 -1
  192. package/dist/throttler/useThrottler.cjs +0 -146
  193. package/dist/throttler/useThrottler.cjs.map +0 -1
  194. package/dist/throttler/useThrottler.d.cts +0 -156
  195. package/dist/throttler/useThrottler.js.map +0 -1
  196. package/dist/types/index.cjs +0 -8
  197. package/dist/types/index.d.cts +0 -1
  198. package/dist/utils/index.cjs +0 -8
  199. package/dist/utils/index.d.cts +0 -1
  200. package/src/async-batcher/index.ts +0 -4
  201. package/src/async-batcher/useAsyncBatchedCallback.ts +0 -53
  202. package/src/async-batcher/useAsyncBatcher.ts +0 -293
  203. package/src/async-debouncer/index.ts +0 -5
  204. package/src/async-debouncer/useAsyncDebouncedCallback.ts +0 -55
  205. package/src/async-debouncer/useAsyncDebouncer.ts +0 -274
  206. package/src/async-queuer/index.ts +0 -4
  207. package/src/async-queuer/useAsyncQueuedState.ts +0 -165
  208. package/src/async-queuer/useAsyncQueuer.ts +0 -293
  209. package/src/async-rate-limiter/index.ts +0 -5
  210. package/src/async-rate-limiter/useAsyncRateLimitedCallback.ts +0 -68
  211. package/src/async-rate-limiter/useAsyncRateLimiter.ts +0 -294
  212. package/src/async-retryer/index.ts +0 -2
  213. package/src/async-throttler/index.ts +0 -5
  214. package/src/async-throttler/useAsyncThrottledCallback.ts +0 -52
  215. package/src/async-throttler/useAsyncThrottler.ts +0 -285
  216. package/src/batcher/index.ts +0 -4
  217. package/src/batcher/useBatchedCallback.ts +0 -46
  218. package/src/batcher/useBatcher.ts +0 -241
  219. package/src/debouncer/index.ts +0 -7
  220. package/src/debouncer/useDebouncedCallback.ts +0 -51
  221. package/src/debouncer/useDebouncedState.ts +0 -106
  222. package/src/debouncer/useDebouncedValue.ts +0 -109
  223. package/src/debouncer/useDebouncer.ts +0 -219
  224. package/src/index.ts +0 -56
  225. package/src/provider/PacerProvider.tsx +0 -70
  226. package/src/provider/index.ts +0 -1
  227. package/src/queuer/index.ts +0 -5
  228. package/src/queuer/useQueuedState.ts +0 -133
  229. package/src/queuer/useQueuedValue.ts +0 -129
  230. package/src/queuer/useQueuer.ts +0 -251
  231. package/src/rate-limiter/index.ts +0 -6
  232. package/src/rate-limiter/useRateLimitedCallback.ts +0 -68
  233. package/src/rate-limiter/useRateLimitedState.ts +0 -124
  234. package/src/rate-limiter/useRateLimitedValue.ts +0 -110
  235. package/src/rate-limiter/useRateLimiter.ts +0 -244
  236. package/src/throttler/index.ts +0 -7
  237. package/src/throttler/useThrottledCallback.ts +0 -52
  238. package/src/throttler/useThrottledState.ts +0 -118
  239. package/src/throttler/useThrottledValue.ts +0 -104
  240. package/src/throttler/useThrottler.ts +0 -224
  241. package/src/types/index.ts +0 -1
  242. package/src/utils/index.ts +0 -1
@@ -98,7 +98,5 @@ import { QueuerState } from "@tanstack/pacer/queuer";
98
98
  * const { size, isRunning, executionCount } = queuer.state;
99
99
  * ```
100
100
  */
101
- declare function useQueuedValue<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(initialValue: TValue, options?: PreactQueuerOptions<TValue, TSelected>, selector?: (state: QueuerState<TValue>) => TSelected): [TValue, PreactQueuer<TValue, TSelected>];
102
- //#endregion
103
- export { useQueuedValue };
104
- //# sourceMappingURL=useQueuedValue.d.ts.map
101
+ export declare function useQueuedValue<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(initialValue: TValue, options?: PreactQueuerOptions<TValue, TSelected>, selector?: (state: QueuerState<TValue>) => TSelected): [TValue, PreactQueuer<TValue, TSelected>];
102
+ //#endregion
@@ -111,5 +111,4 @@ function useQueuedValue(initialValue, options = {}, selector) {
111
111
  }
112
112
 
113
113
  //#endregion
114
- export { useQueuedValue };
115
- //# sourceMappingURL=useQueuedValue.js.map
114
+ export { useQueuedValue };
@@ -2,14 +2,14 @@ import { ComponentChildren } from "preact";
2
2
  import { Store } from "@tanstack/preact-store";
3
3
  import { Queuer, QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
4
4
  //#region src/queuer/useQueuer.d.ts
5
- interface PreactQueuerOptions<TValue, TSelected = {}> extends QueuerOptions<TValue> {
5
+ export interface PreactQueuerOptions<TValue, TSelected = {}> extends QueuerOptions<TValue> {
6
6
  /**
7
7
  * Optional callback invoked when the component unmounts. Receives the queuer instance.
8
8
  * When provided, replaces the default cleanup (stop); use it to call flush(), flushAsBatch(), stop(), add logging, etc.
9
9
  */
10
10
  onUnmount?: (queuer: PreactQueuer<TValue, TSelected>) => void;
11
11
  }
12
- interface PreactQueuer<TValue, TSelected = {}> extends Omit<Queuer<TValue>, 'store'> {
12
+ export interface PreactQueuer<TValue, TSelected = {}> extends Omit<Queuer<TValue>, 'store'> {
13
13
  /**
14
14
  * A Preact HOC (Higher Order Component) that allows you to subscribe to the queuer state.
15
15
  *
@@ -179,7 +179,5 @@ interface PreactQueuer<TValue, TSelected = {}> extends Omit<Queuer<TValue>, 'sto
179
179
  * const { size, isRunning, executionCount } = queue.state;
180
180
  * ```
181
181
  */
182
- declare function useQueuer<TValue, TSelected = {}>(fn: (item: TValue) => void, options?: PreactQueuerOptions<TValue, TSelected>, selector?: (state: QueuerState<TValue>) => TSelected): PreactQueuer<TValue, TSelected>;
183
- //#endregion
184
- export { PreactQueuer, PreactQueuerOptions, useQueuer };
185
- //# sourceMappingURL=useQueuer.d.ts.map
182
+ export declare function useQueuer<TValue, TSelected = {}>(fn: (item: TValue) => void, options?: PreactQueuerOptions<TValue, TSelected>, selector?: (state: QueuerState<TValue>) => TSelected): PreactQueuer<TValue, TSelected>;
183
+ //#endregion
@@ -172,5 +172,4 @@ function useQueuer(fn, options = {}, selector = () => ({})) {
172
172
  }
173
173
 
174
174
  //#endregion
175
- export { useQueuer };
176
- //# sourceMappingURL=useQueuer.js.map
175
+ export { useQueuer };
@@ -54,7 +54,5 @@ import { AnyFunction } from "@tanstack/pacer/types";
54
54
  * );
55
55
  * ```
56
56
  */
57
- declare function useRateLimitedCallback<TFn extends AnyFunction>(fn: TFn, options: PreactRateLimiterOptions<TFn, {}>): (...args: Parameters<TFn>) => boolean;
58
- //#endregion
59
- export { useRateLimitedCallback };
60
- //# sourceMappingURL=useRateLimitedCallback.d.ts.map
57
+ export declare function useRateLimitedCallback<TFn extends AnyFunction>(fn: TFn, options: PreactRateLimiterOptions<TFn, {}>): (...args: Parameters<TFn>) => boolean;
58
+ //#endregion
@@ -61,5 +61,4 @@ function useRateLimitedCallback(fn, options) {
61
61
  }
62
62
 
63
63
  //#endregion
64
- export { useRateLimitedCallback };
65
- //# sourceMappingURL=useRateLimitedCallback.js.map
64
+ export { useRateLimitedCallback };
@@ -100,7 +100,5 @@ import { RateLimiterState } from "@tanstack/pacer/rate-limiter";
100
100
  * const { executionCount, rejectionCount } = rateLimiter.state;
101
101
  * ```
102
102
  */
103
- declare function useRateLimitedState<TValue, TSelected = RateLimiterState>(value: TValue, options: PreactRateLimiterOptions<Dispatch<StateUpdater<TValue>>, TSelected>, selector?: (state: RateLimiterState) => TSelected): [TValue, Dispatch<StateUpdater<TValue>>, PreactRateLimiter<Dispatch<StateUpdater<TValue>>, TSelected>];
104
- //#endregion
105
- export { useRateLimitedState };
106
- //# sourceMappingURL=useRateLimitedState.d.ts.map
103
+ export declare function useRateLimitedState<TValue, TSelected = RateLimiterState>(value: TValue, options: PreactRateLimiterOptions<Dispatch<StateUpdater<TValue>>, TSelected>, selector?: (state: RateLimiterState) => TSelected): [TValue, Dispatch<StateUpdater<TValue>>, PreactRateLimiter<Dispatch<StateUpdater<TValue>>, TSelected>];
104
+ //#endregion
@@ -111,5 +111,4 @@ function useRateLimitedState(value, options, selector) {
111
111
  }
112
112
 
113
113
  //#endregion
114
- export { useRateLimitedState };
115
- //# sourceMappingURL=useRateLimitedState.js.map
114
+ export { useRateLimitedState };
@@ -89,7 +89,5 @@ import { RateLimiterState } from "@tanstack/pacer/rate-limiter";
89
89
  * const { executionCount, rejectionCount } = rateLimiter.state;
90
90
  * ```
91
91
  */
92
- declare function useRateLimitedValue<TValue, TSelected = RateLimiterState>(value: TValue, options: PreactRateLimiterOptions<Dispatch<StateUpdater<TValue>>, TSelected>, selector?: (state: RateLimiterState) => TSelected): [TValue, PreactRateLimiter<Dispatch<StateUpdater<TValue>>, TSelected>];
93
- //#endregion
94
- export { useRateLimitedValue };
95
- //# sourceMappingURL=useRateLimitedValue.d.ts.map
92
+ export declare function useRateLimitedValue<TValue, TSelected = RateLimiterState>(value: TValue, options: PreactRateLimiterOptions<Dispatch<StateUpdater<TValue>>, TSelected>, selector?: (state: RateLimiterState) => TSelected): [TValue, PreactRateLimiter<Dispatch<StateUpdater<TValue>>, TSelected>];
93
+ //#endregion
@@ -98,5 +98,4 @@ function useRateLimitedValue(value, options, selector) {
98
98
  }
99
99
 
100
100
  //#endregion
101
- export { useRateLimitedValue };
102
- //# sourceMappingURL=useRateLimitedValue.js.map
101
+ export { useRateLimitedValue };
@@ -3,14 +3,14 @@ import { Store } from "@tanstack/preact-store";
3
3
  import { RateLimiter, RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
4
4
  import { AnyFunction } from "@tanstack/pacer/types";
5
5
  //#region src/rate-limiter/useRateLimiter.d.ts
6
- interface PreactRateLimiterOptions<TFn extends AnyFunction, TSelected = {}> extends RateLimiterOptions<TFn> {
6
+ export interface PreactRateLimiterOptions<TFn extends AnyFunction, TSelected = {}> extends RateLimiterOptions<TFn> {
7
7
  /**
8
8
  * Optional callback invoked when the component unmounts. Receives the rate limiter instance.
9
9
  * When provided, replaces the default cleanup; use it to call reset(), add logging, etc.
10
10
  */
11
11
  onUnmount?: (rateLimiter: PreactRateLimiter<TFn, TSelected>) => void;
12
12
  }
13
- interface PreactRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit<RateLimiter<TFn>, 'store'> {
13
+ export interface PreactRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit<RateLimiter<TFn>, 'store'> {
14
14
  /**
15
15
  * A Preact HOC (Higher Order Component) that allows you to subscribe to the rate limiter state.
16
16
  *
@@ -172,7 +172,5 @@ interface PreactRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omi
172
172
  * const { executionCount, rejectionCount } = rateLimiter.state;
173
173
  * ```
174
174
  */
175
- declare function useRateLimiter<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: PreactRateLimiterOptions<TFn, TSelected>, selector?: (state: RateLimiterState) => TSelected): PreactRateLimiter<TFn, TSelected>;
176
- //#endregion
177
- export { PreactRateLimiter, PreactRateLimiterOptions, useRateLimiter };
178
- //# sourceMappingURL=useRateLimiter.d.ts.map
175
+ export declare function useRateLimiter<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: PreactRateLimiterOptions<TFn, TSelected>, selector?: (state: RateLimiterState) => TSelected): PreactRateLimiter<TFn, TSelected>;
176
+ //#endregion
@@ -163,5 +163,4 @@ function useRateLimiter(fn, options, selector = () => ({})) {
163
163
  }
164
164
 
165
165
  //#endregion
166
- export { useRateLimiter };
167
- //# sourceMappingURL=useRateLimiter.js.map
166
+ export { useRateLimiter };
@@ -38,7 +38,5 @@ import { AnyFunction } from "@tanstack/pacer/types";
38
38
  * }, [handleResize]);
39
39
  * ```
40
40
  */
41
- declare function useThrottledCallback<TFn extends AnyFunction>(fn: TFn, options: PreactThrottlerOptions<TFn, {}>): (...args: Parameters<TFn>) => void;
42
- //#endregion
43
- export { useThrottledCallback };
44
- //# sourceMappingURL=useThrottledCallback.d.ts.map
41
+ export declare function useThrottledCallback<TFn extends AnyFunction>(fn: TFn, options: PreactThrottlerOptions<TFn, {}>): (...args: Parameters<TFn>) => void;
42
+ //#endregion
@@ -45,5 +45,4 @@ function useThrottledCallback(fn, options) {
45
45
  }
46
46
 
47
47
  //#endregion
48
- export { useThrottledCallback };
49
- //# sourceMappingURL=useThrottledCallback.js.map
48
+ export { useThrottledCallback };
@@ -85,7 +85,5 @@ import { ThrottlerState } from "@tanstack/pacer/throttler";
85
85
  * const { executionCount, isPending } = throttler.state;
86
86
  * ```
87
87
  */
88
- declare function useThrottledState<TValue, TSelected = ThrottlerState<Dispatch<StateUpdater<TValue>>>>(value: TValue, options: PreactThrottlerOptions<Dispatch<StateUpdater<TValue>>, TSelected>, selector?: (state: ThrottlerState<Dispatch<StateUpdater<TValue>>>) => TSelected): [TValue, Dispatch<StateUpdater<TValue>>, PreactThrottler<Dispatch<StateUpdater<TValue>>, TSelected>];
89
- //#endregion
90
- export { useThrottledState };
91
- //# sourceMappingURL=useThrottledState.d.ts.map
88
+ export declare function useThrottledState<TValue, TSelected = ThrottlerState<Dispatch<StateUpdater<TValue>>>>(value: TValue, options: PreactThrottlerOptions<Dispatch<StateUpdater<TValue>>, TSelected>, selector?: (state: ThrottlerState<Dispatch<StateUpdater<TValue>>>) => TSelected): [TValue, Dispatch<StateUpdater<TValue>>, PreactThrottler<Dispatch<StateUpdater<TValue>>, TSelected>];
89
+ //#endregion
@@ -96,5 +96,4 @@ function useThrottledState(value, options, selector) {
96
96
  }
97
97
 
98
98
  //#endregion
99
- export { useThrottledState };
100
- //# sourceMappingURL=useThrottledState.js.map
99
+ export { useThrottledState };
@@ -78,7 +78,5 @@ import { ThrottlerState } from "@tanstack/pacer/throttler";
78
78
  * const { executionCount, isPending } = throttler.state;
79
79
  * ```
80
80
  */
81
- declare function useThrottledValue<TValue, TSelected = ThrottlerState<Dispatch<StateUpdater<TValue>>>>(value: TValue, options: PreactThrottlerOptions<Dispatch<StateUpdater<TValue>>, TSelected>, selector?: (state: ThrottlerState<Dispatch<StateUpdater<TValue>>>) => TSelected): [TValue, PreactThrottler<Dispatch<StateUpdater<TValue>>, TSelected>];
82
- //#endregion
83
- export { useThrottledValue };
84
- //# sourceMappingURL=useThrottledValue.d.ts.map
81
+ export declare function useThrottledValue<TValue, TSelected = ThrottlerState<Dispatch<StateUpdater<TValue>>>>(value: TValue, options: PreactThrottlerOptions<Dispatch<StateUpdater<TValue>>, TSelected>, selector?: (state: ThrottlerState<Dispatch<StateUpdater<TValue>>>) => TSelected): [TValue, PreactThrottler<Dispatch<StateUpdater<TValue>>, TSelected>];
82
+ //#endregion
@@ -87,5 +87,4 @@ function useThrottledValue(value, options, selector) {
87
87
  }
88
88
 
89
89
  //#endregion
90
- export { useThrottledValue };
91
- //# sourceMappingURL=useThrottledValue.js.map
90
+ export { useThrottledValue };
@@ -3,14 +3,14 @@ import { Store } from "@tanstack/preact-store";
3
3
  import { Throttler, ThrottlerOptions, ThrottlerState } from "@tanstack/pacer/throttler";
4
4
  import { AnyFunction } from "@tanstack/pacer/types";
5
5
  //#region src/throttler/useThrottler.d.ts
6
- interface PreactThrottlerOptions<TFn extends AnyFunction, TSelected = {}> extends ThrottlerOptions<TFn> {
6
+ export interface PreactThrottlerOptions<TFn extends AnyFunction, TSelected = {}> extends ThrottlerOptions<TFn> {
7
7
  /**
8
8
  * Optional callback invoked when the component unmounts. Receives the throttler instance.
9
9
  * When provided, replaces the default cleanup (cancel); use it to call flush(), reset(), cancel(), add logging, etc.
10
10
  */
11
11
  onUnmount?: (throttler: PreactThrottler<TFn, TSelected>) => void;
12
12
  }
13
- interface PreactThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit<Throttler<TFn>, 'store'> {
13
+ export interface PreactThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit<Throttler<TFn>, 'store'> {
14
14
  /**
15
15
  * A Preact HOC (Higher Order Component) that allows you to subscribe to the throttler state.
16
16
  *
@@ -150,7 +150,5 @@ interface PreactThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit<
150
150
  * const { executionCount, isPending } = throttler.state;
151
151
  * ```
152
152
  */
153
- declare function useThrottler<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: PreactThrottlerOptions<TFn, TSelected>, selector?: (state: ThrottlerState<TFn>) => TSelected): PreactThrottler<TFn, TSelected>;
154
- //#endregion
155
- export { PreactThrottler, PreactThrottlerOptions, useThrottler };
156
- //# sourceMappingURL=useThrottler.d.ts.map
153
+ export declare function useThrottler<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: PreactThrottlerOptions<TFn, TSelected>, selector?: (state: ThrottlerState<TFn>) => TSelected): PreactThrottler<TFn, TSelected>;
154
+ //#endregion
@@ -142,5 +142,4 @@ function useThrottler(fn, options, selector = () => ({})) {
142
142
  }
143
143
 
144
144
  //#endregion
145
- export { useThrottler };
146
- //# sourceMappingURL=useThrottler.js.map
145
+ export { useThrottler };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/preact-pacer",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Utilities for debouncing and throttling functions in Preact.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -23,83 +23,35 @@
23
23
  "async"
24
24
  ],
25
25
  "type": "module",
26
- "types": "./dist/index.d.cts",
27
- "main": "./dist/index.cjs",
28
- "module": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
29
27
  "exports": {
30
- ".": {
31
- "import": "./dist/index.js",
32
- "require": "./dist/index.cjs"
33
- },
34
- "./async-batcher": {
35
- "import": "./dist/async-batcher/index.js",
36
- "require": "./dist/async-batcher/index.cjs"
37
- },
38
- "./async-debouncer": {
39
- "import": "./dist/async-debouncer/index.js",
40
- "require": "./dist/async-debouncer/index.cjs"
41
- },
42
- "./async-queuer": {
43
- "import": "./dist/async-queuer/index.js",
44
- "require": "./dist/async-queuer/index.cjs"
45
- },
46
- "./async-rate-limiter": {
47
- "import": "./dist/async-rate-limiter/index.js",
48
- "require": "./dist/async-rate-limiter/index.cjs"
49
- },
50
- "./async-retryer": {
51
- "import": "./dist/async-retryer/index.js",
52
- "require": "./dist/async-retryer/index.cjs"
53
- },
54
- "./async-throttler": {
55
- "import": "./dist/async-throttler/index.js",
56
- "require": "./dist/async-throttler/index.cjs"
57
- },
58
- "./batcher": {
59
- "import": "./dist/batcher/index.js",
60
- "require": "./dist/batcher/index.cjs"
61
- },
62
- "./debouncer": {
63
- "import": "./dist/debouncer/index.js",
64
- "require": "./dist/debouncer/index.cjs"
65
- },
66
- "./provider": {
67
- "import": "./dist/provider/index.js",
68
- "require": "./dist/provider/index.cjs"
69
- },
70
- "./queuer": {
71
- "import": "./dist/queuer/index.js",
72
- "require": "./dist/queuer/index.cjs"
73
- },
74
- "./rate-limiter": {
75
- "import": "./dist/rate-limiter/index.js",
76
- "require": "./dist/rate-limiter/index.cjs"
77
- },
78
- "./throttler": {
79
- "import": "./dist/throttler/index.js",
80
- "require": "./dist/throttler/index.cjs"
81
- },
82
- "./types": {
83
- "import": "./dist/types/index.js",
84
- "require": "./dist/types/index.cjs"
85
- },
86
- "./utils": {
87
- "import": "./dist/utils/index.js",
88
- "require": "./dist/utils/index.cjs"
89
- },
28
+ ".": "./dist/index.js",
29
+ "./async-batcher": "./dist/async-batcher/index.js",
30
+ "./async-debouncer": "./dist/async-debouncer/index.js",
31
+ "./async-queuer": "./dist/async-queuer/index.js",
32
+ "./async-rate-limiter": "./dist/async-rate-limiter/index.js",
33
+ "./async-retryer": "./dist/async-retryer/index.js",
34
+ "./async-throttler": "./dist/async-throttler/index.js",
35
+ "./batcher": "./dist/batcher/index.js",
36
+ "./debouncer": "./dist/debouncer/index.js",
37
+ "./provider": "./dist/provider/index.js",
38
+ "./queuer": "./dist/queuer/index.js",
39
+ "./rate-limiter": "./dist/rate-limiter/index.js",
40
+ "./throttler": "./dist/throttler/index.js",
41
+ "./types": "./dist/types/index.js",
42
+ "./utils": "./dist/utils/index.js",
90
43
  "./package.json": "./package.json"
91
44
  },
92
45
  "sideEffects": false,
93
46
  "engines": {
94
- "node": ">=18"
47
+ "node": ">=20"
95
48
  },
96
49
  "files": [
97
- "dist",
98
- "src"
50
+ "dist"
99
51
  ],
100
52
  "dependencies": {
101
- "@tanstack/preact-store": "^0.13.2",
102
- "@tanstack/pacer": "0.22.0"
53
+ "@tanstack/pacer": "0.23.0",
54
+ "@tanstack/preact-store": "^0.13.3"
103
55
  },
104
56
  "devDependencies": {
105
57
  "@preact/preset-vite": "^2.10.6",
@@ -116,7 +68,7 @@
116
68
  "test:lib": "vitest --passWithNoTests",
117
69
  "test:lib:dev": "pnpm test:lib --watch",
118
70
  "test:types": "tsc",
119
- "test:build": "publint --strict",
71
+ "test:build": "publint --strict && node ../../scripts/verify-package.ts",
120
72
  "build": "tsdown"
121
73
  }
122
74
  }
@@ -1,13 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_useAsyncBatcher = require('./useAsyncBatcher.cjs');
3
- const require_useAsyncBatchedCallback = require('./useAsyncBatchedCallback.cjs');
4
-
5
- exports.useAsyncBatchedCallback = require_useAsyncBatchedCallback.useAsyncBatchedCallback;
6
- exports.useAsyncBatcher = require_useAsyncBatcher.useAsyncBatcher;
7
- var _tanstack_pacer_async_batcher = require("@tanstack/pacer/async-batcher");
8
- Object.keys(_tanstack_pacer_async_batcher).forEach(function (k) {
9
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
10
- enumerable: true,
11
- get: function () { return _tanstack_pacer_async_batcher[k]; }
12
- });
13
- });
@@ -1,4 +0,0 @@
1
- import { PreactAsyncBatcher, PreactAsyncBatcherOptions, useAsyncBatcher } from "./useAsyncBatcher.cjs";
2
- import { useAsyncBatchedCallback } from "./useAsyncBatchedCallback.cjs";
3
- export * from "@tanstack/pacer/async-batcher";
4
- export { PreactAsyncBatcher, PreactAsyncBatcherOptions, useAsyncBatchedCallback, useAsyncBatcher };
@@ -1,51 +0,0 @@
1
- const require_useAsyncBatcher = require('./useAsyncBatcher.cjs');
2
- let preact_hooks = require("preact/hooks");
3
-
4
- //#region src/async-batcher/useAsyncBatchedCallback.ts
5
- /**
6
- * A Preact hook that creates a batched version of an async callback function.
7
- * This hook is a convenient wrapper around the `useAsyncBatcher` hook,
8
- * providing a stable, batched async function reference for use in Preact components.
9
- *
10
- * The batched async function will collect individual calls into batches and execute them
11
- * when batch conditions are met (max size reached, wait time elapsed, or custom logic).
12
- * The returned function always returns a promise that resolves with undefined (since the
13
- * batch function processes multiple items together).
14
- *
15
- * This hook provides a simpler API compared to `useAsyncBatcher`, making it ideal for basic
16
- * async batching needs. However, it does not expose the underlying AsyncBatcher instance.
17
- *
18
- * For advanced usage requiring features like:
19
- * - Manual batch execution
20
- * - Access to batch results and state
21
- * - Custom useCallback dependencies
22
- *
23
- * Consider using the `useAsyncBatcher` hook instead.
24
- *
25
- * @example
26
- * ```tsx
27
- * // Batch API requests
28
- * const batchApiCall = useAsyncBatchedCallback(async (requests: ApiRequest[]) => {
29
- * const results = await Promise.all(requests.map(req => fetch(req.url)));
30
- * return results.map(res => res.json());
31
- * }, {
32
- * maxSize: 10, // Process when 10 requests collected
33
- * wait: 1000 // Or after 1 second
34
- * });
35
- *
36
- * // Use in event handlers
37
- * <button onClick={() => batchApiCall({ url: '/api/analytics', data: eventData })}>
38
- * Track Event
39
- * </button>
40
- * ```
41
- */
42
- function useAsyncBatchedCallback(fn, options) {
43
- const asyncBatchedFn = require_useAsyncBatcher.useAsyncBatcher(fn, options).addItem;
44
- return (0, preact_hooks.useCallback)(async (item) => {
45
- await asyncBatchedFn(item);
46
- }, [asyncBatchedFn]);
47
- }
48
-
49
- //#endregion
50
- exports.useAsyncBatchedCallback = useAsyncBatchedCallback;
51
- //# sourceMappingURL=useAsyncBatchedCallback.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAsyncBatchedCallback.cjs","names":["useAsyncBatcher","useCallback"],"sources":["../../src/async-batcher/useAsyncBatchedCallback.ts"],"sourcesContent":["import { useCallback } from 'preact/hooks'\nimport { useAsyncBatcher } from './useAsyncBatcher'\nimport type { PreactAsyncBatcherOptions } from './useAsyncBatcher'\n\n/**\n * A Preact hook that creates a batched version of an async callback function.\n * This hook is a convenient wrapper around the `useAsyncBatcher` hook,\n * providing a stable, batched async function reference for use in Preact components.\n *\n * The batched async function will collect individual calls into batches and execute them\n * when batch conditions are met (max size reached, wait time elapsed, or custom logic).\n * The returned function always returns a promise that resolves with undefined (since the\n * batch function processes multiple items together).\n *\n * This hook provides a simpler API compared to `useAsyncBatcher`, making it ideal for basic\n * async batching needs. However, it does not expose the underlying AsyncBatcher instance.\n *\n * For advanced usage requiring features like:\n * - Manual batch execution\n * - Access to batch results and state\n * - Custom useCallback dependencies\n *\n * Consider using the `useAsyncBatcher` hook instead.\n *\n * @example\n * ```tsx\n * // Batch API requests\n * const batchApiCall = useAsyncBatchedCallback(async (requests: ApiRequest[]) => {\n * const results = await Promise.all(requests.map(req => fetch(req.url)));\n * return results.map(res => res.json());\n * }, {\n * maxSize: 10, // Process when 10 requests collected\n * wait: 1000 // Or after 1 second\n * });\n *\n * // Use in event handlers\n * <button onClick={() => batchApiCall({ url: '/api/analytics', data: eventData })}>\n * Track Event\n * </button>\n * ```\n */\nexport function useAsyncBatchedCallback<TValue>(\n fn: (items: Array<TValue>) => Promise<unknown>,\n options: PreactAsyncBatcherOptions<TValue, {}>,\n): (item: TValue) => Promise<void> {\n const asyncBatchedFn = useAsyncBatcher(fn, options).addItem\n return useCallback(\n async (item: TValue) => {\n await asyncBatchedFn(item)\n },\n [asyncBatchedFn],\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,wBACd,IACA,SACiC;CACjC,MAAM,iBAAiBA,wCAAgB,IAAI,OAAO,CAAC,CAAC;CACpD,WAAOC,0BACL,OAAO,SAAiB;EACtB,MAAM,eAAe,IAAI;CAC3B,GACA,CAAC,cAAc,CACjB;AACF"}
@@ -1,43 +0,0 @@
1
- import { PreactAsyncBatcherOptions } from "./useAsyncBatcher.cjs";
2
- //#region src/async-batcher/useAsyncBatchedCallback.d.ts
3
- /**
4
- * A Preact hook that creates a batched version of an async callback function.
5
- * This hook is a convenient wrapper around the `useAsyncBatcher` hook,
6
- * providing a stable, batched async function reference for use in Preact components.
7
- *
8
- * The batched async function will collect individual calls into batches and execute them
9
- * when batch conditions are met (max size reached, wait time elapsed, or custom logic).
10
- * The returned function always returns a promise that resolves with undefined (since the
11
- * batch function processes multiple items together).
12
- *
13
- * This hook provides a simpler API compared to `useAsyncBatcher`, making it ideal for basic
14
- * async batching needs. However, it does not expose the underlying AsyncBatcher instance.
15
- *
16
- * For advanced usage requiring features like:
17
- * - Manual batch execution
18
- * - Access to batch results and state
19
- * - Custom useCallback dependencies
20
- *
21
- * Consider using the `useAsyncBatcher` hook instead.
22
- *
23
- * @example
24
- * ```tsx
25
- * // Batch API requests
26
- * const batchApiCall = useAsyncBatchedCallback(async (requests: ApiRequest[]) => {
27
- * const results = await Promise.all(requests.map(req => fetch(req.url)));
28
- * return results.map(res => res.json());
29
- * }, {
30
- * maxSize: 10, // Process when 10 requests collected
31
- * wait: 1000 // Or after 1 second
32
- * });
33
- *
34
- * // Use in event handlers
35
- * <button onClick={() => batchApiCall({ url: '/api/analytics', data: eventData })}>
36
- * Track Event
37
- * </button>
38
- * ```
39
- */
40
- declare function useAsyncBatchedCallback<TValue>(fn: (items: Array<TValue>) => Promise<unknown>, options: PreactAsyncBatcherOptions<TValue, {}>): (item: TValue) => Promise<void>;
41
- //#endregion
42
- export { useAsyncBatchedCallback };
43
- //# sourceMappingURL=useAsyncBatchedCallback.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAsyncBatchedCallback.js","names":[],"sources":["../../src/async-batcher/useAsyncBatchedCallback.ts"],"sourcesContent":["import { useCallback } from 'preact/hooks'\nimport { useAsyncBatcher } from './useAsyncBatcher'\nimport type { PreactAsyncBatcherOptions } from './useAsyncBatcher'\n\n/**\n * A Preact hook that creates a batched version of an async callback function.\n * This hook is a convenient wrapper around the `useAsyncBatcher` hook,\n * providing a stable, batched async function reference for use in Preact components.\n *\n * The batched async function will collect individual calls into batches and execute them\n * when batch conditions are met (max size reached, wait time elapsed, or custom logic).\n * The returned function always returns a promise that resolves with undefined (since the\n * batch function processes multiple items together).\n *\n * This hook provides a simpler API compared to `useAsyncBatcher`, making it ideal for basic\n * async batching needs. However, it does not expose the underlying AsyncBatcher instance.\n *\n * For advanced usage requiring features like:\n * - Manual batch execution\n * - Access to batch results and state\n * - Custom useCallback dependencies\n *\n * Consider using the `useAsyncBatcher` hook instead.\n *\n * @example\n * ```tsx\n * // Batch API requests\n * const batchApiCall = useAsyncBatchedCallback(async (requests: ApiRequest[]) => {\n * const results = await Promise.all(requests.map(req => fetch(req.url)));\n * return results.map(res => res.json());\n * }, {\n * maxSize: 10, // Process when 10 requests collected\n * wait: 1000 // Or after 1 second\n * });\n *\n * // Use in event handlers\n * <button onClick={() => batchApiCall({ url: '/api/analytics', data: eventData })}>\n * Track Event\n * </button>\n * ```\n */\nexport function useAsyncBatchedCallback<TValue>(\n fn: (items: Array<TValue>) => Promise<unknown>,\n options: PreactAsyncBatcherOptions<TValue, {}>,\n): (item: TValue) => Promise<void> {\n const asyncBatchedFn = useAsyncBatcher(fn, options).addItem\n return useCallback(\n async (item: TValue) => {\n await asyncBatchedFn(item)\n },\n [asyncBatchedFn],\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,wBACd,IACA,SACiC;CACjC,MAAM,iBAAiB,gBAAgB,IAAI,OAAO,CAAC,CAAC;CACpD,OAAO,YACL,OAAO,SAAiB;EACtB,MAAM,eAAe,IAAI;CAC3B,GACA,CAAC,cAAc,CACjB;AACF"}