@tanstack/angular-pacer 0.23.1 → 0.25.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 (250) hide show
  1. package/README.md +21 -6
  2. package/dist/async-batcher/injectAsyncBatchedCallback.d.ts +2 -5
  3. package/dist/async-batcher/injectAsyncBatchedCallback.js +1 -2
  4. package/dist/async-batcher/injectAsyncBatcher.d.ts +4 -7
  5. package/dist/async-batcher/injectAsyncBatcher.js +1 -2
  6. package/dist/async-debouncer/injectAsyncDebouncedCallback.d.ts +2 -5
  7. package/dist/async-debouncer/injectAsyncDebouncedCallback.js +1 -2
  8. package/dist/async-debouncer/injectAsyncDebouncer.d.ts +4 -7
  9. package/dist/async-debouncer/injectAsyncDebouncer.js +1 -2
  10. package/dist/async-queuer/injectAsyncQueuedSignal.d.ts +3 -6
  11. package/dist/async-queuer/injectAsyncQueuedSignal.js +1 -2
  12. package/dist/async-queuer/injectAsyncQueuer.d.ts +4 -7
  13. package/dist/async-queuer/injectAsyncQueuer.js +1 -2
  14. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.ts +2 -5
  15. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js +1 -2
  16. package/dist/async-rate-limiter/injectAsyncRateLimiter.d.ts +4 -7
  17. package/dist/async-rate-limiter/injectAsyncRateLimiter.js +1 -2
  18. package/dist/async-throttler/injectAsyncThrottledCallback.d.ts +2 -5
  19. package/dist/async-throttler/injectAsyncThrottledCallback.js +1 -2
  20. package/dist/async-throttler/injectAsyncThrottler.d.ts +4 -7
  21. package/dist/async-throttler/injectAsyncThrottler.js +1 -2
  22. package/dist/batcher/injectBatchedCallback.d.ts +2 -5
  23. package/dist/batcher/injectBatchedCallback.js +1 -2
  24. package/dist/batcher/injectBatcher.d.ts +4 -7
  25. package/dist/batcher/injectBatcher.js +1 -2
  26. package/dist/debouncer/injectDebouncedCallback.d.ts +2 -5
  27. package/dist/debouncer/injectDebouncedCallback.js +1 -2
  28. package/dist/debouncer/injectDebouncedSignal.d.ts +3 -6
  29. package/dist/debouncer/injectDebouncedSignal.js +1 -2
  30. package/dist/debouncer/injectDebouncedValue.d.ts +3 -6
  31. package/dist/debouncer/injectDebouncedValue.js +1 -2
  32. package/dist/debouncer/injectDebouncer.d.ts +4 -7
  33. package/dist/debouncer/injectDebouncer.js +1 -2
  34. package/dist/provider/pacer-context.d.ts +4 -7
  35. package/dist/provider/pacer-context.js +1 -2
  36. package/dist/provider/pacer-provider.d.ts +2 -5
  37. package/dist/provider/pacer-provider.js +1 -2
  38. package/dist/queuer/injectQueuedSignal.d.ts +3 -6
  39. package/dist/queuer/injectQueuedSignal.js +1 -2
  40. package/dist/queuer/injectQueuedValue.d.ts +3 -6
  41. package/dist/queuer/injectQueuedValue.js +1 -2
  42. package/dist/queuer/injectQueuer.d.ts +4 -7
  43. package/dist/queuer/injectQueuer.js +1 -2
  44. package/dist/rate-limiter/injectRateLimitedCallback.d.ts +2 -5
  45. package/dist/rate-limiter/injectRateLimitedCallback.js +1 -2
  46. package/dist/rate-limiter/injectRateLimitedSignal.d.ts +3 -6
  47. package/dist/rate-limiter/injectRateLimitedSignal.js +1 -2
  48. package/dist/rate-limiter/injectRateLimitedValue.d.ts +3 -6
  49. package/dist/rate-limiter/injectRateLimitedValue.js +1 -2
  50. package/dist/rate-limiter/injectRateLimiter.d.ts +4 -7
  51. package/dist/rate-limiter/injectRateLimiter.js +1 -2
  52. package/dist/throttler/injectThrottledCallback.d.ts +2 -5
  53. package/dist/throttler/injectThrottledCallback.js +1 -2
  54. package/dist/throttler/injectThrottledSignal.d.ts +3 -8
  55. package/dist/throttler/injectThrottledSignal.js +1 -4
  56. package/dist/throttler/injectThrottledValue.d.ts +3 -8
  57. package/dist/throttler/injectThrottledValue.js +1 -2
  58. package/dist/throttler/injectThrottler.d.ts +4 -9
  59. package/dist/throttler/injectThrottler.js +1 -4
  60. package/package.json +25 -72
  61. package/dist/async-batcher/index.cjs +0 -13
  62. package/dist/async-batcher/index.d.cts +0 -4
  63. package/dist/async-batcher/injectAsyncBatchedCallback.cjs +0 -49
  64. package/dist/async-batcher/injectAsyncBatchedCallback.cjs.map +0 -1
  65. package/dist/async-batcher/injectAsyncBatchedCallback.d.cts +0 -45
  66. package/dist/async-batcher/injectAsyncBatchedCallback.js.map +0 -1
  67. package/dist/async-batcher/injectAsyncBatcher.cjs +0 -85
  68. package/dist/async-batcher/injectAsyncBatcher.cjs.map +0 -1
  69. package/dist/async-batcher/injectAsyncBatcher.d.cts +0 -85
  70. package/dist/async-batcher/injectAsyncBatcher.js.map +0 -1
  71. package/dist/async-debouncer/index.cjs +0 -13
  72. package/dist/async-debouncer/index.d.cts +0 -4
  73. package/dist/async-debouncer/injectAsyncDebouncedCallback.cjs +0 -49
  74. package/dist/async-debouncer/injectAsyncDebouncedCallback.cjs.map +0 -1
  75. package/dist/async-debouncer/injectAsyncDebouncedCallback.d.cts +0 -43
  76. package/dist/async-debouncer/injectAsyncDebouncedCallback.js.map +0 -1
  77. package/dist/async-debouncer/injectAsyncDebouncer.cjs +0 -107
  78. package/dist/async-debouncer/injectAsyncDebouncer.cjs.map +0 -1
  79. package/dist/async-debouncer/injectAsyncDebouncer.d.cts +0 -108
  80. package/dist/async-debouncer/injectAsyncDebouncer.js.map +0 -1
  81. package/dist/async-queuer/index.cjs +0 -13
  82. package/dist/async-queuer/index.d.cts +0 -4
  83. package/dist/async-queuer/injectAsyncQueuedSignal.cjs +0 -53
  84. package/dist/async-queuer/injectAsyncQueuedSignal.cjs.map +0 -1
  85. package/dist/async-queuer/injectAsyncQueuedSignal.d.cts +0 -50
  86. package/dist/async-queuer/injectAsyncQueuedSignal.js.map +0 -1
  87. package/dist/async-queuer/injectAsyncQueuer.cjs +0 -85
  88. package/dist/async-queuer/injectAsyncQueuer.cjs.map +0 -1
  89. package/dist/async-queuer/injectAsyncQueuer.d.cts +0 -85
  90. package/dist/async-queuer/injectAsyncQueuer.js.map +0 -1
  91. package/dist/async-rate-limiter/index.cjs +0 -13
  92. package/dist/async-rate-limiter/index.d.cts +0 -4
  93. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.cjs +0 -52
  94. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.cjs.map +0 -1
  95. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.cts +0 -46
  96. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js.map +0 -1
  97. package/dist/async-rate-limiter/injectAsyncRateLimiter.cjs +0 -69
  98. package/dist/async-rate-limiter/injectAsyncRateLimiter.cjs.map +0 -1
  99. package/dist/async-rate-limiter/injectAsyncRateLimiter.d.cts +0 -72
  100. package/dist/async-rate-limiter/injectAsyncRateLimiter.js.map +0 -1
  101. package/dist/async-retryer/index.cjs +0 -9
  102. package/dist/async-retryer/index.d.cts +0 -1
  103. package/dist/async-throttler/index.cjs +0 -13
  104. package/dist/async-throttler/index.d.cts +0 -4
  105. package/dist/async-throttler/injectAsyncThrottledCallback.cjs +0 -50
  106. package/dist/async-throttler/injectAsyncThrottledCallback.cjs.map +0 -1
  107. package/dist/async-throttler/injectAsyncThrottledCallback.d.cts +0 -44
  108. package/dist/async-throttler/injectAsyncThrottledCallback.js.map +0 -1
  109. package/dist/async-throttler/injectAsyncThrottler.cjs +0 -86
  110. package/dist/async-throttler/injectAsyncThrottler.cjs.map +0 -1
  111. package/dist/async-throttler/injectAsyncThrottler.d.cts +0 -87
  112. package/dist/async-throttler/injectAsyncThrottler.js.map +0 -1
  113. package/dist/batcher/index.cjs +0 -13
  114. package/dist/batcher/index.d.cts +0 -4
  115. package/dist/batcher/injectBatchedCallback.cjs +0 -47
  116. package/dist/batcher/injectBatchedCallback.cjs.map +0 -1
  117. package/dist/batcher/injectBatchedCallback.d.cts +0 -43
  118. package/dist/batcher/injectBatchedCallback.js.map +0 -1
  119. package/dist/batcher/injectBatcher.cjs +0 -75
  120. package/dist/batcher/injectBatcher.cjs.map +0 -1
  121. package/dist/batcher/injectBatcher.d.cts +0 -77
  122. package/dist/batcher/injectBatcher.js.map +0 -1
  123. package/dist/debouncer/index.cjs +0 -17
  124. package/dist/debouncer/index.d.cts +0 -6
  125. package/dist/debouncer/injectDebouncedCallback.cjs +0 -46
  126. package/dist/debouncer/injectDebouncedCallback.cjs.map +0 -1
  127. package/dist/debouncer/injectDebouncedCallback.d.cts +0 -43
  128. package/dist/debouncer/injectDebouncedCallback.js.map +0 -1
  129. package/dist/debouncer/injectDebouncedSignal.cjs +0 -68
  130. package/dist/debouncer/injectDebouncedSignal.cjs.map +0 -1
  131. package/dist/debouncer/injectDebouncedSignal.d.cts +0 -60
  132. package/dist/debouncer/injectDebouncedSignal.js.map +0 -1
  133. package/dist/debouncer/injectDebouncedValue.cjs +0 -17
  134. package/dist/debouncer/injectDebouncedValue.cjs.map +0 -1
  135. package/dist/debouncer/injectDebouncedValue.d.cts +0 -76
  136. package/dist/debouncer/injectDebouncedValue.js.map +0 -1
  137. package/dist/debouncer/injectDebouncer.cjs +0 -95
  138. package/dist/debouncer/injectDebouncer.cjs.map +0 -1
  139. package/dist/debouncer/injectDebouncer.d.cts +0 -98
  140. package/dist/debouncer/injectDebouncer.js.map +0 -1
  141. package/dist/index.cjs +0 -65
  142. package/dist/index.d.cts +0 -30
  143. package/dist/provider/index.cjs +0 -7
  144. package/dist/provider/index.d.cts +0 -3
  145. package/dist/provider/pacer-context.cjs +0 -20
  146. package/dist/provider/pacer-context.cjs.map +0 -1
  147. package/dist/provider/pacer-context.d.cts +0 -21
  148. package/dist/provider/pacer-context.js.map +0 -1
  149. package/dist/provider/pacer-provider.cjs +0 -41
  150. package/dist/provider/pacer-provider.cjs.map +0 -1
  151. package/dist/provider/pacer-provider.d.cts +0 -36
  152. package/dist/provider/pacer-provider.js.map +0 -1
  153. package/dist/queuer/index.cjs +0 -15
  154. package/dist/queuer/index.d.cts +0 -5
  155. package/dist/queuer/injectQueuedSignal.cjs +0 -47
  156. package/dist/queuer/injectQueuedSignal.cjs.map +0 -1
  157. package/dist/queuer/injectQueuedSignal.d.cts +0 -44
  158. package/dist/queuer/injectQueuedSignal.js.map +0 -1
  159. package/dist/queuer/injectQueuedValue.cjs +0 -23
  160. package/dist/queuer/injectQueuedValue.cjs.map +0 -1
  161. package/dist/queuer/injectQueuedValue.d.cts +0 -34
  162. package/dist/queuer/injectQueuedValue.js.map +0 -1
  163. package/dist/queuer/injectQueuer.cjs +0 -80
  164. package/dist/queuer/injectQueuer.cjs.map +0 -1
  165. package/dist/queuer/injectQueuer.d.cts +0 -82
  166. package/dist/queuer/injectQueuer.js.map +0 -1
  167. package/dist/rate-limiter/index.cjs +0 -17
  168. package/dist/rate-limiter/index.d.cts +0 -6
  169. package/dist/rate-limiter/injectRateLimitedCallback.cjs +0 -45
  170. package/dist/rate-limiter/injectRateLimitedCallback.cjs.map +0 -1
  171. package/dist/rate-limiter/injectRateLimitedCallback.d.cts +0 -42
  172. package/dist/rate-limiter/injectRateLimitedCallback.js.map +0 -1
  173. package/dist/rate-limiter/injectRateLimitedSignal.cjs +0 -62
  174. package/dist/rate-limiter/injectRateLimitedSignal.cjs.map +0 -1
  175. package/dist/rate-limiter/injectRateLimitedSignal.d.cts +0 -54
  176. package/dist/rate-limiter/injectRateLimitedSignal.js.map +0 -1
  177. package/dist/rate-limiter/injectRateLimitedValue.cjs +0 -17
  178. package/dist/rate-limiter/injectRateLimitedValue.cjs.map +0 -1
  179. package/dist/rate-limiter/injectRateLimitedValue.d.cts +0 -49
  180. package/dist/rate-limiter/injectRateLimitedValue.js.map +0 -1
  181. package/dist/rate-limiter/injectRateLimiter.cjs +0 -100
  182. package/dist/rate-limiter/injectRateLimiter.cjs.map +0 -1
  183. package/dist/rate-limiter/injectRateLimiter.d.cts +0 -103
  184. package/dist/rate-limiter/injectRateLimiter.js.map +0 -1
  185. package/dist/throttler/index.cjs +0 -17
  186. package/dist/throttler/index.d.cts +0 -6
  187. package/dist/throttler/injectThrottledCallback.cjs +0 -45
  188. package/dist/throttler/injectThrottledCallback.cjs.map +0 -1
  189. package/dist/throttler/injectThrottledCallback.d.cts +0 -42
  190. package/dist/throttler/injectThrottledCallback.js.map +0 -1
  191. package/dist/throttler/injectThrottledSignal.cjs +0 -69
  192. package/dist/throttler/injectThrottledSignal.cjs.map +0 -1
  193. package/dist/throttler/injectThrottledSignal.d.cts +0 -61
  194. package/dist/throttler/injectThrottledSignal.js.map +0 -1
  195. package/dist/throttler/injectThrottledValue.cjs +0 -17
  196. package/dist/throttler/injectThrottledValue.cjs.map +0 -1
  197. package/dist/throttler/injectThrottledValue.d.cts +0 -74
  198. package/dist/throttler/injectThrottledValue.js.map +0 -1
  199. package/dist/throttler/injectThrottler.cjs +0 -95
  200. package/dist/throttler/injectThrottler.cjs.map +0 -1
  201. package/dist/throttler/injectThrottler.d.cts +0 -98
  202. package/dist/throttler/injectThrottler.js.map +0 -1
  203. package/dist/types/index.cjs +0 -9
  204. package/dist/types/index.d.cts +0 -1
  205. package/dist/utils/index.cjs +0 -9
  206. package/dist/utils/index.d.cts +0 -1
  207. package/src/async-batcher/index.ts +0 -4
  208. package/src/async-batcher/injectAsyncBatchedCallback.ts +0 -48
  209. package/src/async-batcher/injectAsyncBatcher.ts +0 -126
  210. package/src/async-debouncer/index.ts +0 -4
  211. package/src/async-debouncer/injectAsyncDebouncedCallback.ts +0 -50
  212. package/src/async-debouncer/injectAsyncDebouncer.ts +0 -152
  213. package/src/async-queuer/index.ts +0 -4
  214. package/src/async-queuer/injectAsyncQueuedSignal.ts +0 -74
  215. package/src/async-queuer/injectAsyncQueuer.ts +0 -126
  216. package/src/async-rate-limiter/index.ts +0 -4
  217. package/src/async-rate-limiter/injectAsyncRateLimitedCallback.ts +0 -52
  218. package/src/async-rate-limiter/injectAsyncRateLimiter.ts +0 -115
  219. package/src/async-retryer/index.ts +0 -1
  220. package/src/async-throttler/index.ts +0 -4
  221. package/src/async-throttler/injectAsyncThrottledCallback.ts +0 -50
  222. package/src/async-throttler/injectAsyncThrottler.ts +0 -131
  223. package/src/batcher/index.ts +0 -4
  224. package/src/batcher/injectBatchedCallback.ts +0 -46
  225. package/src/batcher/injectBatcher.ts +0 -114
  226. package/src/debouncer/index.ts +0 -6
  227. package/src/debouncer/injectDebouncedCallback.ts +0 -46
  228. package/src/debouncer/injectDebouncedSignal.ts +0 -94
  229. package/src/debouncer/injectDebouncedValue.ts +0 -126
  230. package/src/debouncer/injectDebouncer.ts +0 -137
  231. package/src/index.ts +0 -40
  232. package/src/provider/index.ts +0 -2
  233. package/src/provider/pacer-context.ts +0 -46
  234. package/src/provider/pacer-provider.ts +0 -38
  235. package/src/queuer/index.ts +0 -5
  236. package/src/queuer/injectQueuedSignal.ts +0 -65
  237. package/src/queuer/injectQueuedValue.ts +0 -101
  238. package/src/queuer/injectQueuer.ts +0 -118
  239. package/src/rate-limiter/index.ts +0 -6
  240. package/src/rate-limiter/injectRateLimitedCallback.ts +0 -45
  241. package/src/rate-limiter/injectRateLimitedSignal.ts +0 -88
  242. package/src/rate-limiter/injectRateLimitedValue.ts +0 -99
  243. package/src/rate-limiter/injectRateLimiter.ts +0 -140
  244. package/src/throttler/index.ts +0 -6
  245. package/src/throttler/injectThrottledCallback.ts +0 -45
  246. package/src/throttler/injectThrottledSignal.ts +0 -95
  247. package/src/throttler/injectThrottledValue.ts +0 -124
  248. package/src/throttler/injectThrottler.ts +0 -137
  249. package/src/types/index.ts +0 -1
  250. package/src/utils/index.ts +0 -1
@@ -1,13 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_injectAsyncThrottler = require('./injectAsyncThrottler.cjs');
3
- const require_injectAsyncThrottledCallback = require('./injectAsyncThrottledCallback.cjs');
4
-
5
- exports.injectAsyncThrottledCallback = require_injectAsyncThrottledCallback.injectAsyncThrottledCallback;
6
- exports.injectAsyncThrottler = require_injectAsyncThrottler.injectAsyncThrottler;
7
- var _tanstack_pacer_async_throttler = require("@tanstack/pacer/async-throttler");
8
- Object.keys(_tanstack_pacer_async_throttler).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_throttler[k]; }
12
- });
13
- });
@@ -1,4 +0,0 @@
1
- import { injectAsyncThrottledCallback } from "./injectAsyncThrottledCallback.cjs";
2
- import { AngularAsyncThrottler, AngularAsyncThrottlerOptions, injectAsyncThrottler } from "./injectAsyncThrottler.cjs";
3
- export * from "@tanstack/pacer/async-throttler";
4
- export { AngularAsyncThrottler, AngularAsyncThrottlerOptions, injectAsyncThrottledCallback, injectAsyncThrottler };
@@ -1,50 +0,0 @@
1
- const require_injectAsyncThrottler = require('./injectAsyncThrottler.cjs');
2
-
3
- //#region src/async-throttler/injectAsyncThrottledCallback.ts
4
- /**
5
- * An Angular function that creates an async throttled version of a callback function.
6
- * This function is essentially a wrapper around `injectAsyncThrottler` that provides
7
- * a simplified API for basic async throttling needs.
8
- *
9
- * The throttled function will execute at most once within the specified wait time.
10
- *
11
- * This function provides a simpler API compared to `injectAsyncThrottler`, making it ideal for basic
12
- * async throttling needs. However, it does not expose the underlying AsyncThrottler instance.
13
- *
14
- * For advanced usage requiring features like:
15
- * - Manual cancellation
16
- * - Access to execution counts
17
- * - Error handling callbacks
18
- * - Retry support
19
- *
20
- * Consider using the `injectAsyncThrottler` function instead.
21
- *
22
- * @example
23
- * ```ts
24
- * // Throttle an async update handler
25
- * const handleUpdate = injectAsyncThrottledCallback(
26
- * async (data: Data) => {
27
- * const response = await fetch('/api/update', {
28
- * method: 'POST',
29
- * body: JSON.stringify(data)
30
- * });
31
- * return response.json();
32
- * },
33
- * { wait: 1000 }
34
- * );
35
- *
36
- * // Use in an event handler
37
- * const result = await handleUpdate(updateData);
38
- * ```
39
- */
40
- function injectAsyncThrottledCallback(fn, options) {
41
- const throttler = require_injectAsyncThrottler.injectAsyncThrottler(fn, options);
42
- return async (...args) => {
43
- const result = await throttler.maybeExecute(...args);
44
- return result !== void 0 ? await result : void 0;
45
- };
46
- }
47
-
48
- //#endregion
49
- exports.injectAsyncThrottledCallback = injectAsyncThrottledCallback;
50
- //# sourceMappingURL=injectAsyncThrottledCallback.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncThrottledCallback.cjs","names":["injectAsyncThrottler"],"sources":["../../src/async-throttler/injectAsyncThrottledCallback.ts"],"sourcesContent":["import { injectAsyncThrottler } from './injectAsyncThrottler'\nimport type { AsyncThrottlerOptions } from '@tanstack/pacer/async-throttler'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates an async throttled version of a callback function.\n * This function is essentially a wrapper around `injectAsyncThrottler` that provides\n * a simplified API for basic async throttling needs.\n *\n * The throttled function will execute at most once within the specified wait time.\n *\n * This function provides a simpler API compared to `injectAsyncThrottler`, making it ideal for basic\n * async throttling needs. However, it does not expose the underlying AsyncThrottler instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - Error handling callbacks\n * - Retry support\n *\n * Consider using the `injectAsyncThrottler` function instead.\n *\n * @example\n * ```ts\n * // Throttle an async update handler\n * const handleUpdate = injectAsyncThrottledCallback(\n * async (data: Data) => {\n * const response = await fetch('/api/update', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * { wait: 1000 }\n * );\n *\n * // Use in an event handler\n * const result = await handleUpdate(updateData);\n * ```\n */\nexport function injectAsyncThrottledCallback<TFn extends AnyAsyncFunction>(\n fn: TFn,\n options: AsyncThrottlerOptions<TFn>,\n): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined> {\n const throttler = injectAsyncThrottler(fn, options)\n return async (...args: Parameters<TFn>) => {\n const result = await throttler.maybeExecute(...args)\n return result !== undefined ? await result : undefined\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,6BACd,IACA,SAC6E;CAC7E,MAAM,YAAYA,kDAAqB,IAAI,QAAQ;CACnD,OAAO,OAAO,GAAG,SAA0B;EACzC,MAAM,SAAS,MAAM,UAAU,aAAa,GAAG,KAAK;EACpD,OAAO,WAAW,SAAY,MAAM,SAAS"}
@@ -1,44 +0,0 @@
1
- import { AnyAsyncFunction } from "@tanstack/pacer/types";
2
- import { AsyncThrottlerOptions } from "@tanstack/pacer/async-throttler";
3
-
4
- //#region src/async-throttler/injectAsyncThrottledCallback.d.ts
5
- /**
6
- * An Angular function that creates an async throttled version of a callback function.
7
- * This function is essentially a wrapper around `injectAsyncThrottler` that provides
8
- * a simplified API for basic async throttling needs.
9
- *
10
- * The throttled function will execute at most once within the specified wait time.
11
- *
12
- * This function provides a simpler API compared to `injectAsyncThrottler`, making it ideal for basic
13
- * async throttling needs. However, it does not expose the underlying AsyncThrottler instance.
14
- *
15
- * For advanced usage requiring features like:
16
- * - Manual cancellation
17
- * - Access to execution counts
18
- * - Error handling callbacks
19
- * - Retry support
20
- *
21
- * Consider using the `injectAsyncThrottler` function instead.
22
- *
23
- * @example
24
- * ```ts
25
- * // Throttle an async update handler
26
- * const handleUpdate = injectAsyncThrottledCallback(
27
- * async (data: Data) => {
28
- * const response = await fetch('/api/update', {
29
- * method: 'POST',
30
- * body: JSON.stringify(data)
31
- * });
32
- * return response.json();
33
- * },
34
- * { wait: 1000 }
35
- * );
36
- *
37
- * // Use in an event handler
38
- * const result = await handleUpdate(updateData);
39
- * ```
40
- */
41
- declare function injectAsyncThrottledCallback<TFn extends AnyAsyncFunction>(fn: TFn, options: AsyncThrottlerOptions<TFn>): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined>;
42
- //#endregion
43
- export { injectAsyncThrottledCallback };
44
- //# sourceMappingURL=injectAsyncThrottledCallback.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncThrottledCallback.js","names":[],"sources":["../../src/async-throttler/injectAsyncThrottledCallback.ts"],"sourcesContent":["import { injectAsyncThrottler } from './injectAsyncThrottler'\nimport type { AsyncThrottlerOptions } from '@tanstack/pacer/async-throttler'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates an async throttled version of a callback function.\n * This function is essentially a wrapper around `injectAsyncThrottler` that provides\n * a simplified API for basic async throttling needs.\n *\n * The throttled function will execute at most once within the specified wait time.\n *\n * This function provides a simpler API compared to `injectAsyncThrottler`, making it ideal for basic\n * async throttling needs. However, it does not expose the underlying AsyncThrottler instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - Error handling callbacks\n * - Retry support\n *\n * Consider using the `injectAsyncThrottler` function instead.\n *\n * @example\n * ```ts\n * // Throttle an async update handler\n * const handleUpdate = injectAsyncThrottledCallback(\n * async (data: Data) => {\n * const response = await fetch('/api/update', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * { wait: 1000 }\n * );\n *\n * // Use in an event handler\n * const result = await handleUpdate(updateData);\n * ```\n */\nexport function injectAsyncThrottledCallback<TFn extends AnyAsyncFunction>(\n fn: TFn,\n options: AsyncThrottlerOptions<TFn>,\n): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined> {\n const throttler = injectAsyncThrottler(fn, options)\n return async (...args: Parameters<TFn>) => {\n const result = await throttler.maybeExecute(...args)\n return result !== undefined ? await result : undefined\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,6BACd,IACA,SAC6E;CAC7E,MAAM,YAAY,qBAAqB,IAAI,QAAQ;CACnD,OAAO,OAAO,GAAG,SAA0B;EACzC,MAAM,SAAS,MAAM,UAAU,aAAa,GAAG,KAAK;EACpD,OAAO,WAAW,SAAY,MAAM,SAAS"}
@@ -1,86 +0,0 @@
1
- const require_pacer_context = require('../provider/pacer-context.cjs');
2
- let _angular_core = require("@angular/core");
3
- let _tanstack_angular_store = require("@tanstack/angular-store");
4
- let _tanstack_pacer_async_throttler = require("@tanstack/pacer/async-throttler");
5
-
6
- //#region src/async-throttler/injectAsyncThrottler.ts
7
- /**
8
- * An Angular function that creates and manages an AsyncThrottler instance.
9
- *
10
- * This is a lower-level function that provides direct access to the AsyncThrottler's functionality.
11
- * This allows you to integrate it with any state management solution you prefer.
12
- *
13
- * This function provides async throttling functionality with promise support, error handling,
14
- * retry capabilities, and abort support.
15
- *
16
- * The throttler will execute the function at most once within the specified wait time.
17
- *
18
- * ## State Management and Selector
19
- *
20
- * The function uses TanStack Store for state management and wraps it with Angular signals.
21
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
22
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
23
- *
24
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
25
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
26
- * full control over when your component tracks state changes.
27
- *
28
- * ## Cleanup on Destroy
29
- *
30
- * By default, the function cancels any pending execution and aborts in-flight work when the component is destroyed.
31
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
32
- *
33
- * ```ts
34
- * const throttler = injectAsyncThrottler(fn, {
35
- * wait: 1000,
36
- * onUnmount: (t) => t.flush()
37
- * });
38
- * ```
39
- *
40
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
41
- *
42
- * @example
43
- * ```ts
44
- * // Default behavior - no reactive state subscriptions
45
- * const throttler = injectAsyncThrottler(
46
- * async (data: Data) => {
47
- * const response = await fetch('/api/update', {
48
- * method: 'POST',
49
- * body: JSON.stringify(data)
50
- * });
51
- * return response.json();
52
- * },
53
- * { wait: 1000 }
54
- * );
55
- *
56
- * // In an event handler
57
- * const handleUpdate = async (data: Data) => {
58
- * const result = await throttler.maybeExecute(data);
59
- * console.log('Update result:', result);
60
- * };
61
- * ```
62
- */
63
- function injectAsyncThrottler(fn, options, selector = () => ({})) {
64
- const mergedOptions = {
65
- ...require_pacer_context.injectPacerOptions().asyncThrottler,
66
- ...options
67
- };
68
- const throttler = new _tanstack_pacer_async_throttler.AsyncThrottler(fn, mergedOptions);
69
- const state = (0, _tanstack_angular_store.injectSelector)(throttler.store, selector);
70
- const result = {
71
- ...throttler,
72
- state
73
- };
74
- (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true })?.onDestroy(() => {
75
- if (mergedOptions.onUnmount) mergedOptions.onUnmount(result);
76
- else {
77
- throttler.cancel();
78
- throttler.abort();
79
- }
80
- });
81
- return result;
82
- }
83
-
84
- //#endregion
85
- exports.injectAsyncThrottler = injectAsyncThrottler;
86
- //# sourceMappingURL=injectAsyncThrottler.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncThrottler.cjs","names":["injectPacerOptions","AsyncThrottler","DestroyRef"],"sources":["../../src/async-throttler/injectAsyncThrottler.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncThrottler } from '@tanstack/pacer/async-throttler'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\nimport type {\n AsyncThrottlerOptions,\n AsyncThrottlerState,\n} from '@tanstack/pacer/async-throttler'\n\nexport interface AngularAsyncThrottlerOptions<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends AsyncThrottlerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the throttler instance.\n * When provided, replaces the default cleanup (cancel + abort); use it to call flush(), cancel(), add logging, etc.\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n */\n onUnmount?: (throttler: AngularAsyncThrottler<TFn, TSelected>) => void\n}\n\nexport interface AngularAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncThrottler<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the async throttler state changes\n *\n * Use this instead of `throttler.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `throttler.state` instead of `throttler.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<AsyncThrottlerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncThrottler instance.\n *\n * This is a lower-level function that provides direct access to the AsyncThrottler's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides async throttling functionality with promise support, error handling,\n * retry capabilities, and abort support.\n *\n * The throttler will execute the function at most once within the specified wait time.\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending execution and aborts in-flight work when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```ts\n * const throttler = injectAsyncThrottler(fn, {\n * wait: 1000,\n * onUnmount: (t) => t.flush()\n * });\n * ```\n *\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const throttler = injectAsyncThrottler(\n * async (data: Data) => {\n * const response = await fetch('/api/update', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * { wait: 1000 }\n * );\n *\n * // In an event handler\n * const handleUpdate = async (data: Data) => {\n * const result = await throttler.maybeExecute(data);\n * console.log('Update result:', result);\n * };\n * ```\n */\nexport function injectAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AngularAsyncThrottlerOptions<TFn, TSelected>,\n selector: (state: AsyncThrottlerState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncThrottler<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncThrottler,\n ...options,\n } as AngularAsyncThrottlerOptions<TFn, TSelected>\n\n const throttler = new AsyncThrottler<TFn>(fn, mergedOptions)\n const state = injectSelector(throttler.store, selector)\n\n const result = {\n ...throttler,\n state,\n } as AngularAsyncThrottler<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n throttler.cancel()\n throttler.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,SAAgB,qBAId,IACA,SACA,kBACG,EAAE,GACkC;CACvC,MAAM,gBAAgB;EACpB,GAAGA,0CAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,YAAY,IAAIC,+CAAoB,IAAI,cAAc;CAC5D,MAAM,oDAAuB,UAAU,OAAO,SAAS;CAEvD,MAAM,SAAS;EACb,GAAG;EACH;EACD;CAGD,0BAD0BC,0BAAY,EAAE,UAAU,MAAM,CAC9C,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,OAAO;OAC1B;GACL,UAAU,QAAQ;GAClB,UAAU,OAAO;;GAEnB;CAEF,OAAO"}
@@ -1,87 +0,0 @@
1
- import { Signal } from "@angular/core";
2
- import { Store } from "@tanstack/angular-store";
3
- import { AnyAsyncFunction } from "@tanstack/pacer/types";
4
- import { AsyncThrottler, AsyncThrottlerOptions, AsyncThrottlerState } from "@tanstack/pacer/async-throttler";
5
-
6
- //#region src/async-throttler/injectAsyncThrottler.d.ts
7
- interface AngularAsyncThrottlerOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncThrottlerOptions<TFn> {
8
- /**
9
- * Optional callback invoked when the component is destroyed. Receives the throttler instance.
10
- * When provided, replaces the default cleanup (cancel + abort); use it to call flush(), cancel(), add logging, etc.
11
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
12
- */
13
- onUnmount?: (throttler: AngularAsyncThrottler<TFn, TSelected>) => void;
14
- }
15
- interface AngularAsyncThrottler<TFn extends AnyAsyncFunction, TSelected = {}> extends Omit<AsyncThrottler<TFn>, 'store'> {
16
- /**
17
- * Reactive state signal that will be updated when the async throttler state changes
18
- *
19
- * Use this instead of `throttler.store.state`
20
- */
21
- readonly state: Signal<Readonly<TSelected>>;
22
- /**
23
- * @deprecated Use `throttler.state` instead of `throttler.store.state` if you want to read reactive state.
24
- * The state on the store object is not reactive in Angular signals.
25
- */
26
- readonly store: Store<Readonly<AsyncThrottlerState<TFn>>>;
27
- }
28
- /**
29
- * An Angular function that creates and manages an AsyncThrottler instance.
30
- *
31
- * This is a lower-level function that provides direct access to the AsyncThrottler's functionality.
32
- * This allows you to integrate it with any state management solution you prefer.
33
- *
34
- * This function provides async throttling functionality with promise support, error handling,
35
- * retry capabilities, and abort support.
36
- *
37
- * The throttler will execute the function at most once within the specified wait time.
38
- *
39
- * ## State Management and Selector
40
- *
41
- * The function uses TanStack Store for state management and wraps it with Angular signals.
42
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
43
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
44
- *
45
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
46
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
47
- * full control over when your component tracks state changes.
48
- *
49
- * ## Cleanup on Destroy
50
- *
51
- * By default, the function cancels any pending execution and aborts in-flight work when the component is destroyed.
52
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
53
- *
54
- * ```ts
55
- * const throttler = injectAsyncThrottler(fn, {
56
- * wait: 1000,
57
- * onUnmount: (t) => t.flush()
58
- * });
59
- * ```
60
- *
61
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
62
- *
63
- * @example
64
- * ```ts
65
- * // Default behavior - no reactive state subscriptions
66
- * const throttler = injectAsyncThrottler(
67
- * async (data: Data) => {
68
- * const response = await fetch('/api/update', {
69
- * method: 'POST',
70
- * body: JSON.stringify(data)
71
- * });
72
- * return response.json();
73
- * },
74
- * { wait: 1000 }
75
- * );
76
- *
77
- * // In an event handler
78
- * const handleUpdate = async (data: Data) => {
79
- * const result = await throttler.maybeExecute(data);
80
- * console.log('Update result:', result);
81
- * };
82
- * ```
83
- */
84
- declare function injectAsyncThrottler<TFn extends AnyAsyncFunction, TSelected = {}>(fn: TFn, options: AngularAsyncThrottlerOptions<TFn, TSelected>, selector?: (state: AsyncThrottlerState<TFn>) => TSelected): AngularAsyncThrottler<TFn, TSelected>;
85
- //#endregion
86
- export { AngularAsyncThrottler, AngularAsyncThrottlerOptions, injectAsyncThrottler };
87
- //# sourceMappingURL=injectAsyncThrottler.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncThrottler.js","names":[],"sources":["../../src/async-throttler/injectAsyncThrottler.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncThrottler } from '@tanstack/pacer/async-throttler'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\nimport type {\n AsyncThrottlerOptions,\n AsyncThrottlerState,\n} from '@tanstack/pacer/async-throttler'\n\nexport interface AngularAsyncThrottlerOptions<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends AsyncThrottlerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the throttler instance.\n * When provided, replaces the default cleanup (cancel + abort); use it to call flush(), cancel(), add logging, etc.\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n */\n onUnmount?: (throttler: AngularAsyncThrottler<TFn, TSelected>) => void\n}\n\nexport interface AngularAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncThrottler<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the async throttler state changes\n *\n * Use this instead of `throttler.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `throttler.state` instead of `throttler.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<AsyncThrottlerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncThrottler instance.\n *\n * This is a lower-level function that provides direct access to the AsyncThrottler's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides async throttling functionality with promise support, error handling,\n * retry capabilities, and abort support.\n *\n * The throttler will execute the function at most once within the specified wait time.\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending execution and aborts in-flight work when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```ts\n * const throttler = injectAsyncThrottler(fn, {\n * wait: 1000,\n * onUnmount: (t) => t.flush()\n * });\n * ```\n *\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const throttler = injectAsyncThrottler(\n * async (data: Data) => {\n * const response = await fetch('/api/update', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * { wait: 1000 }\n * );\n *\n * // In an event handler\n * const handleUpdate = async (data: Data) => {\n * const result = await throttler.maybeExecute(data);\n * console.log('Update result:', result);\n * };\n * ```\n */\nexport function injectAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AngularAsyncThrottlerOptions<TFn, TSelected>,\n selector: (state: AsyncThrottlerState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncThrottler<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncThrottler,\n ...options,\n } as AngularAsyncThrottlerOptions<TFn, TSelected>\n\n const throttler = new AsyncThrottler<TFn>(fn, mergedOptions)\n const state = injectSelector(throttler.store, selector)\n\n const result = {\n ...throttler,\n state,\n } as AngularAsyncThrottler<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n throttler.cancel()\n throttler.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,SAAgB,qBAId,IACA,SACA,kBACG,EAAE,GACkC;CACvC,MAAM,gBAAgB;EACpB,GAAG,oBAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,YAAY,IAAI,eAAoB,IAAI,cAAc;CAC5D,MAAM,QAAQ,eAAe,UAAU,OAAO,SAAS;CAEvD,MAAM,SAAS;EACb,GAAG;EACH;EACD;CAGD,AADmB,OAAO,YAAY,EAAE,UAAU,MAAM,CAC9C,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,OAAO;OAC1B;GACL,UAAU,QAAQ;GAClB,UAAU,OAAO;;GAEnB;CAEF,OAAO"}
@@ -1,13 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_injectBatcher = require('./injectBatcher.cjs');
3
- const require_injectBatchedCallback = require('./injectBatchedCallback.cjs');
4
-
5
- exports.injectBatchedCallback = require_injectBatchedCallback.injectBatchedCallback;
6
- exports.injectBatcher = require_injectBatcher.injectBatcher;
7
- var _tanstack_pacer_batcher = require("@tanstack/pacer/batcher");
8
- Object.keys(_tanstack_pacer_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_batcher[k]; }
12
- });
13
- });
@@ -1,4 +0,0 @@
1
- import { injectBatchedCallback } from "./injectBatchedCallback.cjs";
2
- import { AngularBatcher, AngularBatcherOptions, injectBatcher } from "./injectBatcher.cjs";
3
- export * from "@tanstack/pacer/batcher";
4
- export { AngularBatcher, AngularBatcherOptions, injectBatchedCallback, injectBatcher };
@@ -1,47 +0,0 @@
1
- const require_injectBatcher = require('./injectBatcher.cjs');
2
-
3
- //#region src/batcher/injectBatchedCallback.ts
4
- /**
5
- * An Angular function that creates a batched version of a callback function.
6
- * This function is essentially a wrapper around `injectBatcher` that provides
7
- * a simplified API for basic batching needs.
8
- *
9
- * The batched function will collect items and process them in batches based on
10
- * the configured conditions (maxSize, wait time, etc.).
11
- *
12
- * This function provides a simpler API compared to `injectBatcher`, making it ideal for basic
13
- * batching needs. However, it does not expose the underlying Batcher instance.
14
- *
15
- * For advanced usage requiring features like:
16
- * - Manual flushing
17
- * - Access to batch state
18
- * - State tracking
19
- *
20
- * Consider using the `injectBatcher` function instead.
21
- *
22
- * @example
23
- * ```ts
24
- * // Batch API calls
25
- * const batchApiCall = injectBatchedCallback(
26
- * (items) => {
27
- * return fetch('/api/batch', {
28
- * method: 'POST',
29
- * body: JSON.stringify(items)
30
- * });
31
- * },
32
- * { maxSize: 10, wait: 1000 }
33
- * );
34
- *
35
- * // Items will be batched and sent together
36
- * batchApiCall('item1');
37
- * batchApiCall('item2');
38
- * ```
39
- */
40
- function injectBatchedCallback(fn, options) {
41
- const batcher = require_injectBatcher.injectBatcher(fn, options);
42
- return (item) => batcher.addItem(item);
43
- }
44
-
45
- //#endregion
46
- exports.injectBatchedCallback = injectBatchedCallback;
47
- //# sourceMappingURL=injectBatchedCallback.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectBatchedCallback.cjs","names":["injectBatcher"],"sources":["../../src/batcher/injectBatchedCallback.ts"],"sourcesContent":["import { injectBatcher } from './injectBatcher'\nimport type { BatcherOptions } from '@tanstack/pacer/batcher'\n\n/**\n * An Angular function that creates a batched version of a callback function.\n * This function is essentially a wrapper around `injectBatcher` that provides\n * a simplified API for basic batching needs.\n *\n * The batched function will collect items and process them in batches based on\n * the configured conditions (maxSize, wait time, etc.).\n *\n * This function provides a simpler API compared to `injectBatcher`, making it ideal for basic\n * batching needs. However, it does not expose the underlying Batcher instance.\n *\n * For advanced usage requiring features like:\n * - Manual flushing\n * - Access to batch state\n * - State tracking\n *\n * Consider using the `injectBatcher` function instead.\n *\n * @example\n * ```ts\n * // Batch API calls\n * const batchApiCall = injectBatchedCallback(\n * (items) => {\n * return fetch('/api/batch', {\n * method: 'POST',\n * body: JSON.stringify(items)\n * });\n * },\n * { maxSize: 10, wait: 1000 }\n * );\n *\n * // Items will be batched and sent together\n * batchApiCall('item1');\n * batchApiCall('item2');\n * ```\n */\nexport function injectBatchedCallback<TValue>(\n fn: (items: Array<TValue>) => void,\n options: BatcherOptions<TValue>,\n): (item: TValue) => void {\n const batcher = injectBatcher(fn, options)\n return (item: TValue) => batcher.addItem(item)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,sBACd,IACA,SACwB;CACxB,MAAM,UAAUA,oCAAc,IAAI,QAAQ;CAC1C,QAAQ,SAAiB,QAAQ,QAAQ,KAAK"}
@@ -1,43 +0,0 @@
1
- import { BatcherOptions } from "@tanstack/pacer/batcher";
2
-
3
- //#region src/batcher/injectBatchedCallback.d.ts
4
- /**
5
- * An Angular function that creates a batched version of a callback function.
6
- * This function is essentially a wrapper around `injectBatcher` that provides
7
- * a simplified API for basic batching needs.
8
- *
9
- * The batched function will collect items and process them in batches based on
10
- * the configured conditions (maxSize, wait time, etc.).
11
- *
12
- * This function provides a simpler API compared to `injectBatcher`, making it ideal for basic
13
- * batching needs. However, it does not expose the underlying Batcher instance.
14
- *
15
- * For advanced usage requiring features like:
16
- * - Manual flushing
17
- * - Access to batch state
18
- * - State tracking
19
- *
20
- * Consider using the `injectBatcher` function instead.
21
- *
22
- * @example
23
- * ```ts
24
- * // Batch API calls
25
- * const batchApiCall = injectBatchedCallback(
26
- * (items) => {
27
- * return fetch('/api/batch', {
28
- * method: 'POST',
29
- * body: JSON.stringify(items)
30
- * });
31
- * },
32
- * { maxSize: 10, wait: 1000 }
33
- * );
34
- *
35
- * // Items will be batched and sent together
36
- * batchApiCall('item1');
37
- * batchApiCall('item2');
38
- * ```
39
- */
40
- declare function injectBatchedCallback<TValue>(fn: (items: Array<TValue>) => void, options: BatcherOptions<TValue>): (item: TValue) => void;
41
- //#endregion
42
- export { injectBatchedCallback };
43
- //# sourceMappingURL=injectBatchedCallback.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectBatchedCallback.js","names":[],"sources":["../../src/batcher/injectBatchedCallback.ts"],"sourcesContent":["import { injectBatcher } from './injectBatcher'\nimport type { BatcherOptions } from '@tanstack/pacer/batcher'\n\n/**\n * An Angular function that creates a batched version of a callback function.\n * This function is essentially a wrapper around `injectBatcher` that provides\n * a simplified API for basic batching needs.\n *\n * The batched function will collect items and process them in batches based on\n * the configured conditions (maxSize, wait time, etc.).\n *\n * This function provides a simpler API compared to `injectBatcher`, making it ideal for basic\n * batching needs. However, it does not expose the underlying Batcher instance.\n *\n * For advanced usage requiring features like:\n * - Manual flushing\n * - Access to batch state\n * - State tracking\n *\n * Consider using the `injectBatcher` function instead.\n *\n * @example\n * ```ts\n * // Batch API calls\n * const batchApiCall = injectBatchedCallback(\n * (items) => {\n * return fetch('/api/batch', {\n * method: 'POST',\n * body: JSON.stringify(items)\n * });\n * },\n * { maxSize: 10, wait: 1000 }\n * );\n *\n * // Items will be batched and sent together\n * batchApiCall('item1');\n * batchApiCall('item2');\n * ```\n */\nexport function injectBatchedCallback<TValue>(\n fn: (items: Array<TValue>) => void,\n options: BatcherOptions<TValue>,\n): (item: TValue) => void {\n const batcher = injectBatcher(fn, options)\n return (item: TValue) => batcher.addItem(item)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,sBACd,IACA,SACwB;CACxB,MAAM,UAAU,cAAc,IAAI,QAAQ;CAC1C,QAAQ,SAAiB,QAAQ,QAAQ,KAAK"}
@@ -1,75 +0,0 @@
1
- const require_pacer_context = require('../provider/pacer-context.cjs');
2
- let _angular_core = require("@angular/core");
3
- let _tanstack_angular_store = require("@tanstack/angular-store");
4
- let _tanstack_pacer_batcher = require("@tanstack/pacer/batcher");
5
-
6
- //#region src/batcher/injectBatcher.ts
7
- /**
8
- * An Angular function that creates and manages a Batcher instance.
9
- *
10
- * This is a lower-level function that provides direct access to the Batcher's functionality.
11
- * This allows you to integrate it with any state management solution you prefer.
12
- *
13
- * The Batcher collects items and processes them in batches based on configurable conditions:
14
- * - Maximum batch size
15
- * - Time-based batching (process after X milliseconds)
16
- * - Custom batch processing logic via getShouldExecute
17
- *
18
- * ## State Management and Selector
19
- *
20
- * The function uses TanStack Store for state management and wraps it with Angular signals.
21
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
22
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
23
- *
24
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
25
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
26
- * full control over when your component tracks state changes.
27
- *
28
- * ## Cleanup on Destroy
29
- *
30
- * By default, the function cancels any pending batch when the component is destroyed.
31
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
32
- *
33
- * ```ts
34
- * const batcher = injectBatcher(fn, {
35
- * maxSize: 5,
36
- * onUnmount: (b) => b.flush()
37
- * });
38
- * ```
39
- *
40
- * @example
41
- * ```ts
42
- * // Default behavior - no reactive state subscriptions
43
- * const batcher = injectBatcher(
44
- * (items) => console.log('Processing batch:', items),
45
- * { maxSize: 5, wait: 2000 }
46
- * );
47
- *
48
- * // Add items
49
- * batcher.addItem('task1');
50
- *
51
- * // Access the selected state
52
- * const { items, isPending } = batcher.state();
53
- * ```
54
- */
55
- function injectBatcher(fn, options = {}, selector = () => ({})) {
56
- const mergedOptions = {
57
- ...require_pacer_context.injectPacerOptions().batcher,
58
- ...options
59
- };
60
- const batcher = new _tanstack_pacer_batcher.Batcher(fn, mergedOptions);
61
- const state = (0, _tanstack_angular_store.injectSelector)(batcher.store, selector);
62
- const result = {
63
- ...batcher,
64
- state
65
- };
66
- (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true })?.onDestroy(() => {
67
- if (mergedOptions.onUnmount) mergedOptions.onUnmount(result);
68
- else batcher.cancel();
69
- });
70
- return result;
71
- }
72
-
73
- //#endregion
74
- exports.injectBatcher = injectBatcher;
75
- //# sourceMappingURL=injectBatcher.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectBatcher.cjs","names":["injectPacerOptions","Batcher","DestroyRef"],"sources":["../../src/batcher/injectBatcher.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Batcher } from '@tanstack/pacer/batcher'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { BatcherOptions, BatcherState } from '@tanstack/pacer/batcher'\n\nexport interface AngularBatcherOptions<\n TValue,\n TSelected = {},\n> extends BatcherOptions<TValue> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the batcher instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (batcher: AngularBatcher<TValue, TSelected>) => void\n}\n\nexport interface AngularBatcher<TValue, TSelected = {}> extends Omit<\n Batcher<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the batcher state changes\n *\n * Use this instead of `batcher.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `batcher.state` instead of `batcher.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<BatcherState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages a Batcher instance.\n *\n * This is a lower-level function that provides direct access to the Batcher's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The Batcher collects items and processes them in batches based on configurable conditions:\n * - Maximum batch size\n * - Time-based batching (process after X milliseconds)\n * - Custom batch processing logic via getShouldExecute\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending batch when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```ts\n * const batcher = injectBatcher(fn, {\n * maxSize: 5,\n * onUnmount: (b) => b.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const batcher = injectBatcher(\n * (items) => console.log('Processing batch:', items),\n * { maxSize: 5, wait: 2000 }\n * );\n *\n * // Add items\n * batcher.addItem('task1');\n *\n * // Access the selected state\n * const { items, isPending } = batcher.state();\n * ```\n */\nexport function injectBatcher<TValue, TSelected = {}>(\n fn: (items: Array<TValue>) => void,\n options: AngularBatcherOptions<TValue, TSelected> = {},\n selector: (state: BatcherState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): AngularBatcher<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().batcher,\n ...options,\n } as AngularBatcherOptions<TValue, TSelected>\n\n const batcher = new Batcher<TValue>(fn, mergedOptions)\n const state = injectSelector(batcher.store, selector)\n\n const result = {\n ...batcher,\n state,\n } as AngularBatcher<TValue, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n batcher.cancel()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,SAAgB,cACd,IACA,UAAoD,EAAE,EACtD,kBACG,EAAE,GAC8B;CACnC,MAAM,gBAAgB;EACpB,GAAGA,0CAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,UAAU,IAAIC,gCAAgB,IAAI,cAAc;CACtD,MAAM,oDAAuB,QAAQ,OAAO,SAAS;CAErD,MAAM,SAAS;EACb,GAAG;EACH;EACD;CAGD,0BAD0BC,0BAAY,EAAE,UAAU,MAAM,CAC9C,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,OAAO;OAE/B,QAAQ,QAAQ;GAElB;CAEF,OAAO"}
@@ -1,77 +0,0 @@
1
- import { Signal } from "@angular/core";
2
- import { Store } from "@tanstack/angular-store";
3
- import { Batcher, BatcherOptions, BatcherState } from "@tanstack/pacer/batcher";
4
-
5
- //#region src/batcher/injectBatcher.d.ts
6
- interface AngularBatcherOptions<TValue, TSelected = {}> extends BatcherOptions<TValue> {
7
- /**
8
- * Optional callback invoked when the component is destroyed. Receives the batcher instance.
9
- * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.
10
- */
11
- onUnmount?: (batcher: AngularBatcher<TValue, TSelected>) => void;
12
- }
13
- interface AngularBatcher<TValue, TSelected = {}> extends Omit<Batcher<TValue>, 'store'> {
14
- /**
15
- * Reactive state signal that will be updated when the batcher state changes
16
- *
17
- * Use this instead of `batcher.store.state`
18
- */
19
- readonly state: Signal<Readonly<TSelected>>;
20
- /**
21
- * @deprecated Use `batcher.state` instead of `batcher.store.state` if you want to read reactive state.
22
- * The state on the store object is not reactive in Angular signals.
23
- */
24
- readonly store: Store<Readonly<BatcherState<TValue>>>;
25
- }
26
- /**
27
- * An Angular function that creates and manages a Batcher instance.
28
- *
29
- * This is a lower-level function that provides direct access to the Batcher's functionality.
30
- * This allows you to integrate it with any state management solution you prefer.
31
- *
32
- * The Batcher collects items and processes them in batches based on configurable conditions:
33
- * - Maximum batch size
34
- * - Time-based batching (process after X milliseconds)
35
- * - Custom batch processing logic via getShouldExecute
36
- *
37
- * ## State Management and Selector
38
- *
39
- * The function uses TanStack Store for state management and wraps it with Angular signals.
40
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
41
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
42
- *
43
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
44
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
45
- * full control over when your component tracks state changes.
46
- *
47
- * ## Cleanup on Destroy
48
- *
49
- * By default, the function cancels any pending batch when the component is destroyed.
50
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
51
- *
52
- * ```ts
53
- * const batcher = injectBatcher(fn, {
54
- * maxSize: 5,
55
- * onUnmount: (b) => b.flush()
56
- * });
57
- * ```
58
- *
59
- * @example
60
- * ```ts
61
- * // Default behavior - no reactive state subscriptions
62
- * const batcher = injectBatcher(
63
- * (items) => console.log('Processing batch:', items),
64
- * { maxSize: 5, wait: 2000 }
65
- * );
66
- *
67
- * // Add items
68
- * batcher.addItem('task1');
69
- *
70
- * // Access the selected state
71
- * const { items, isPending } = batcher.state();
72
- * ```
73
- */
74
- declare function injectBatcher<TValue, TSelected = {}>(fn: (items: Array<TValue>) => void, options?: AngularBatcherOptions<TValue, TSelected>, selector?: (state: BatcherState<TValue>) => TSelected): AngularBatcher<TValue, TSelected>;
75
- //#endregion
76
- export { AngularBatcher, AngularBatcherOptions, injectBatcher };
77
- //# sourceMappingURL=injectBatcher.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectBatcher.js","names":[],"sources":["../../src/batcher/injectBatcher.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Batcher } from '@tanstack/pacer/batcher'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { BatcherOptions, BatcherState } from '@tanstack/pacer/batcher'\n\nexport interface AngularBatcherOptions<\n TValue,\n TSelected = {},\n> extends BatcherOptions<TValue> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the batcher instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (batcher: AngularBatcher<TValue, TSelected>) => void\n}\n\nexport interface AngularBatcher<TValue, TSelected = {}> extends Omit<\n Batcher<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the batcher state changes\n *\n * Use this instead of `batcher.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `batcher.state` instead of `batcher.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<BatcherState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages a Batcher instance.\n *\n * This is a lower-level function that provides direct access to the Batcher's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The Batcher collects items and processes them in batches based on configurable conditions:\n * - Maximum batch size\n * - Time-based batching (process after X milliseconds)\n * - Custom batch processing logic via getShouldExecute\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending batch when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```ts\n * const batcher = injectBatcher(fn, {\n * maxSize: 5,\n * onUnmount: (b) => b.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const batcher = injectBatcher(\n * (items) => console.log('Processing batch:', items),\n * { maxSize: 5, wait: 2000 }\n * );\n *\n * // Add items\n * batcher.addItem('task1');\n *\n * // Access the selected state\n * const { items, isPending } = batcher.state();\n * ```\n */\nexport function injectBatcher<TValue, TSelected = {}>(\n fn: (items: Array<TValue>) => void,\n options: AngularBatcherOptions<TValue, TSelected> = {},\n selector: (state: BatcherState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): AngularBatcher<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().batcher,\n ...options,\n } as AngularBatcherOptions<TValue, TSelected>\n\n const batcher = new Batcher<TValue>(fn, mergedOptions)\n const state = injectSelector(batcher.store, selector)\n\n const result = {\n ...batcher,\n state,\n } as AngularBatcher<TValue, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n batcher.cancel()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,SAAgB,cACd,IACA,UAAoD,EAAE,EACtD,kBACG,EAAE,GAC8B;CACnC,MAAM,gBAAgB;EACpB,GAAG,oBAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,UAAU,IAAI,QAAgB,IAAI,cAAc;CACtD,MAAM,QAAQ,eAAe,QAAQ,OAAO,SAAS;CAErD,MAAM,SAAS;EACb,GAAG;EACH;EACD;CAGD,AADmB,OAAO,YAAY,EAAE,UAAU,MAAM,CAC9C,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,OAAO;OAE/B,QAAQ,QAAQ;GAElB;CAEF,OAAO"}