@tanstack/angular-pacer 0.24.0 → 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 +4 -4
  2. package/dist/async-batcher/injectAsyncBatchedCallback.d.ts +2 -4
  3. package/dist/async-batcher/injectAsyncBatchedCallback.js +1 -2
  4. package/dist/async-batcher/injectAsyncBatcher.d.ts +4 -6
  5. package/dist/async-batcher/injectAsyncBatcher.js +1 -2
  6. package/dist/async-debouncer/injectAsyncDebouncedCallback.d.ts +2 -4
  7. package/dist/async-debouncer/injectAsyncDebouncedCallback.js +1 -2
  8. package/dist/async-debouncer/injectAsyncDebouncer.d.ts +4 -6
  9. package/dist/async-debouncer/injectAsyncDebouncer.js +1 -2
  10. package/dist/async-queuer/injectAsyncQueuedSignal.d.ts +3 -5
  11. package/dist/async-queuer/injectAsyncQueuedSignal.js +1 -2
  12. package/dist/async-queuer/injectAsyncQueuer.d.ts +4 -6
  13. package/dist/async-queuer/injectAsyncQueuer.js +1 -2
  14. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.ts +2 -4
  15. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js +1 -2
  16. package/dist/async-rate-limiter/injectAsyncRateLimiter.d.ts +4 -6
  17. package/dist/async-rate-limiter/injectAsyncRateLimiter.js +1 -2
  18. package/dist/async-throttler/injectAsyncThrottledCallback.d.ts +2 -4
  19. package/dist/async-throttler/injectAsyncThrottledCallback.js +1 -2
  20. package/dist/async-throttler/injectAsyncThrottler.d.ts +4 -6
  21. package/dist/async-throttler/injectAsyncThrottler.js +1 -2
  22. package/dist/batcher/injectBatchedCallback.d.ts +2 -4
  23. package/dist/batcher/injectBatchedCallback.js +1 -2
  24. package/dist/batcher/injectBatcher.d.ts +4 -6
  25. package/dist/batcher/injectBatcher.js +1 -2
  26. package/dist/debouncer/injectDebouncedCallback.d.ts +2 -4
  27. package/dist/debouncer/injectDebouncedCallback.js +1 -2
  28. package/dist/debouncer/injectDebouncedSignal.d.ts +3 -5
  29. package/dist/debouncer/injectDebouncedSignal.js +1 -2
  30. package/dist/debouncer/injectDebouncedValue.d.ts +3 -5
  31. package/dist/debouncer/injectDebouncedValue.js +1 -2
  32. package/dist/debouncer/injectDebouncer.d.ts +4 -6
  33. package/dist/debouncer/injectDebouncer.js +1 -2
  34. package/dist/provider/pacer-context.d.ts +4 -6
  35. package/dist/provider/pacer-context.js +1 -2
  36. package/dist/provider/pacer-provider.d.ts +2 -4
  37. package/dist/provider/pacer-provider.js +1 -2
  38. package/dist/queuer/injectQueuedSignal.d.ts +3 -5
  39. package/dist/queuer/injectQueuedSignal.js +1 -2
  40. package/dist/queuer/injectQueuedValue.d.ts +3 -5
  41. package/dist/queuer/injectQueuedValue.js +1 -2
  42. package/dist/queuer/injectQueuer.d.ts +4 -6
  43. package/dist/queuer/injectQueuer.js +1 -2
  44. package/dist/rate-limiter/injectRateLimitedCallback.d.ts +2 -4
  45. package/dist/rate-limiter/injectRateLimitedCallback.js +1 -2
  46. package/dist/rate-limiter/injectRateLimitedSignal.d.ts +3 -5
  47. package/dist/rate-limiter/injectRateLimitedSignal.js +1 -2
  48. package/dist/rate-limiter/injectRateLimitedValue.d.ts +3 -5
  49. package/dist/rate-limiter/injectRateLimitedValue.js +1 -2
  50. package/dist/rate-limiter/injectRateLimiter.d.ts +4 -6
  51. package/dist/rate-limiter/injectRateLimiter.js +1 -2
  52. package/dist/throttler/injectThrottledCallback.d.ts +2 -4
  53. package/dist/throttler/injectThrottledCallback.js +1 -2
  54. package/dist/throttler/injectThrottledSignal.d.ts +3 -7
  55. package/dist/throttler/injectThrottledSignal.js +1 -4
  56. package/dist/throttler/injectThrottledValue.d.ts +3 -7
  57. package/dist/throttler/injectThrottledValue.js +1 -2
  58. package/dist/throttler/injectThrottler.d.ts +4 -8
  59. package/dist/throttler/injectThrottler.js +1 -4
  60. package/package.json +24 -71
  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 -44
  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 -84
  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 -42
  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 -107
  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 -49
  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 -84
  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 -45
  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 -71
  100. package/dist/async-rate-limiter/injectAsyncRateLimiter.js.map +0 -1
  101. package/dist/async-retryer/index.cjs +0 -8
  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 -43
  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 -86
  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 -42
  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 -76
  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 -42
  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 -59
  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 -75
  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 -97
  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 -20
  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 -35
  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 -43
  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 -33
  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 -81
  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 -41
  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 -53
  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 -48
  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 -102
  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 -41
  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 -60
  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 -73
  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 -97
  202. package/dist/throttler/injectThrottler.js.map +0 -1
  203. package/dist/types/index.cjs +0 -8
  204. package/dist/types/index.d.cts +0 -1
  205. package/dist/utils/index.cjs +0 -8
  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 -125
  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 -99
  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 -98
  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 -123
  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,41 +0,0 @@
1
- import { AnyFunction } from "@tanstack/pacer/types";
2
- import { RateLimiterOptions } from "@tanstack/pacer/rate-limiter";
3
- //#region src/rate-limiter/injectRateLimitedCallback.d.ts
4
- /**
5
- * An Angular function that creates a rate-limited version of a callback function.
6
- * This function is essentially a wrapper around `injectRateLimiter` that provides
7
- * a simplified API for basic rate limiting needs.
8
- *
9
- * Rate limiting is a simple "hard limit" approach - it allows all calls until the limit
10
- * is reached, then blocks subsequent calls until the window resets. Unlike throttling
11
- * or debouncing, it does not attempt to space out or intelligently collapse calls.
12
- *
13
- * This function provides a simpler API compared to `injectRateLimiter`, making it ideal for basic
14
- * rate limiting needs. However, it does not expose the underlying RateLimiter instance.
15
- *
16
- * For advanced usage requiring features like:
17
- * - Manual cancellation/reset
18
- * - Access to execution counts
19
- * - State tracking
20
- *
21
- * Consider using the `injectRateLimiter` function instead.
22
- *
23
- * @example
24
- * ```ts
25
- * // Rate limit API calls to maximum 5 calls per minute
26
- * const makeApiCall = injectRateLimitedCallback(
27
- * (data: ApiData) => {
28
- * return fetch('/api/endpoint', { method: 'POST', body: JSON.stringify(data) });
29
- * },
30
- * {
31
- * limit: 5,
32
- * window: 60000, // 1 minute
33
- * windowType: 'sliding',
34
- * }
35
- * );
36
- * ```
37
- */
38
- declare function injectRateLimitedCallback<TFn extends AnyFunction>(fn: TFn, options: RateLimiterOptions<TFn>): (...args: Parameters<TFn>) => boolean;
39
- //#endregion
40
- export { injectRateLimitedCallback };
41
- //# sourceMappingURL=injectRateLimitedCallback.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectRateLimitedCallback.js","names":[],"sources":["../../src/rate-limiter/injectRateLimitedCallback.ts"],"sourcesContent":["import { injectRateLimiter } from './injectRateLimiter'\nimport type { RateLimiterOptions } from '@tanstack/pacer/rate-limiter'\nimport type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates a rate-limited version of a callback function.\n * This function is essentially a wrapper around `injectRateLimiter` that provides\n * a simplified API for basic rate limiting needs.\n *\n * Rate limiting is a simple \"hard limit\" approach - it allows all calls until the limit\n * is reached, then blocks subsequent calls until the window resets. Unlike throttling\n * or debouncing, it does not attempt to space out or intelligently collapse calls.\n *\n * This function provides a simpler API compared to `injectRateLimiter`, making it ideal for basic\n * rate limiting needs. However, it does not expose the underlying RateLimiter instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation/reset\n * - Access to execution counts\n * - State tracking\n *\n * Consider using the `injectRateLimiter` function instead.\n *\n * @example\n * ```ts\n * // Rate limit API calls to maximum 5 calls per minute\n * const makeApiCall = injectRateLimitedCallback(\n * (data: ApiData) => {\n * return fetch('/api/endpoint', { method: 'POST', body: JSON.stringify(data) });\n * },\n * {\n * limit: 5,\n * window: 60000, // 1 minute\n * windowType: 'sliding',\n * }\n * );\n * ```\n */\nexport function injectRateLimitedCallback<TFn extends AnyFunction>(\n fn: TFn,\n options: RateLimiterOptions<TFn>,\n): (...args: Parameters<TFn>) => boolean {\n const rateLimiter = injectRateLimiter(fn, options)\n return (...args: Parameters<TFn>) => rateLimiter.maybeExecute(...args)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,0BACd,IACA,SACuC;CACvC,MAAM,cAAc,kBAAkB,IAAI,OAAO;CACjD,QAAQ,GAAG,SAA0B,YAAY,aAAa,GAAG,IAAI;AACvE"}
@@ -1,62 +0,0 @@
1
- const require_injectRateLimiter = require('./injectRateLimiter.cjs');
2
- let _angular_core = require("@angular/core");
3
-
4
- //#region src/rate-limiter/injectRateLimitedSignal.ts
5
- /**
6
- * An Angular function that creates a rate-limited state signal, combining Angular's signal with rate limiting functionality.
7
- * This function provides both the current rate-limited value and methods to update it.
8
- *
9
- * Rate limiting is a simple "hard limit" approach - it allows all updates until the limit is reached, then blocks
10
- * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out
11
- * or intelligently collapse updates.
12
- *
13
- * The function returns a callable object:
14
- * - `rateLimited()`: Get the current rate-limited value
15
- * - `rateLimited.set(...)`: Set or update the rate-limited value (rate-limited via maybeExecute)
16
- * - `rateLimited.rateLimiter`: The rate limiter instance with additional control methods and state signals
17
- *
18
- * ## State Management and Selector
19
- *
20
- * The function uses TanStack Store for reactive state management via the underlying rate limiter instance.
21
- * The `selector` parameter allows you to specify which rate limiter state changes will trigger signal updates,
22
- * optimizing performance by preventing unnecessary subscriptions 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
- * @example
29
- * ```ts
30
- * // Default behavior - no reactive state subscriptions
31
- * const rateLimited = injectRateLimitedSignal(0, {
32
- * limit: 5,
33
- * window: 60000,
34
- * windowType: 'sliding'
35
- * });
36
- *
37
- * // Opt-in to reactive updates when limit state changes
38
- * const rateLimited = injectRateLimitedSignal(
39
- * 0,
40
- * { limit: 5, window: 60000 },
41
- * (state) => ({ rejectionCount: state.rejectionCount })
42
- * );
43
- * ```
44
- */
45
- function injectRateLimitedSignal(value, initialOptions, selector) {
46
- const rateLimitedValue = (0, _angular_core.signal)(value);
47
- const rateLimiter = require_injectRateLimiter.injectRateLimiter((newValue) => {
48
- if (typeof newValue === "function") rateLimitedValue.update(newValue);
49
- else rateLimitedValue.set(newValue);
50
- }, initialOptions, selector);
51
- const set = (newValue) => {
52
- rateLimiter.maybeExecute(newValue);
53
- };
54
- return Object.assign(() => rateLimitedValue(), {
55
- set,
56
- rateLimiter
57
- });
58
- }
59
-
60
- //#endregion
61
- exports.injectRateLimitedSignal = injectRateLimitedSignal;
62
- //# sourceMappingURL=injectRateLimitedSignal.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectRateLimitedSignal.cjs","names":["signal","injectRateLimiter"],"sources":["../../src/rate-limiter/injectRateLimitedSignal.ts"],"sourcesContent":["import { signal } from '@angular/core'\nimport { injectRateLimiter } from './injectRateLimiter'\nimport type { AngularRateLimiter } from './injectRateLimiter'\nimport type {\n RateLimiterOptions,\n RateLimiterState,\n} from '@tanstack/pacer/rate-limiter'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\nexport interface RateLimitedSignal<TValue, TSelected = {}> {\n (): TValue\n set: Setter<TValue>\n rateLimiter: AngularRateLimiter<Setter<TValue>, TSelected>\n}\n\n/**\n * An Angular function that creates a rate-limited state signal, combining Angular's signal with rate limiting functionality.\n * This function provides both the current rate-limited value and methods to update it.\n *\n * Rate limiting is a simple \"hard limit\" approach - it allows all updates until the limit is reached, then blocks\n * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out\n * or intelligently collapse updates.\n *\n * The function returns a callable object:\n * - `rateLimited()`: Get the current rate-limited value\n * - `rateLimited.set(...)`: Set or update the rate-limited value (rate-limited via maybeExecute)\n * - `rateLimited.rateLimiter`: The rate limiter instance with additional control methods and state signals\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying rate limiter instance.\n * The `selector` parameter allows you to specify which rate limiter state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions 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 * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const rateLimited = injectRateLimitedSignal(0, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding'\n * });\n *\n * // Opt-in to reactive updates when limit state changes\n * const rateLimited = injectRateLimitedSignal(\n * 0,\n * { limit: 5, window: 60000 },\n * (state) => ({ rejectionCount: state.rejectionCount })\n * );\n * ```\n */\nexport function injectRateLimitedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: RateLimiterOptions<Setter<TValue>>,\n selector?: (state: RateLimiterState) => TSelected,\n): RateLimitedSignal<TValue, TSelected> {\n const rateLimitedValue = signal<TValue>(value)\n\n const rateLimiter = injectRateLimiter(\n (newValue: TValue | ((prev: TValue) => TValue)) => {\n if (typeof newValue === 'function') {\n rateLimitedValue.update(newValue as (prev: TValue) => TValue)\n } else {\n rateLimitedValue.set(newValue)\n }\n },\n initialOptions,\n selector,\n )\n\n const set: Setter<TValue> = (\n newValue: TValue | ((prev: TValue) => TValue),\n ) => {\n rateLimiter.maybeExecute(newValue)\n }\n\n const rateLimited = Object.assign(() => rateLimitedValue(), {\n set,\n rateLimiter,\n }) as RateLimitedSignal<TValue, TSelected>\n\n return rateLimited\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,wBACd,OACA,gBACA,UACsC;CACtC,MAAM,uBAAmBA,sBAAe,KAAK;CAE7C,MAAM,cAAcC,6CACjB,aAAkD;EACjD,IAAI,OAAO,aAAa,YACtB,iBAAiB,OAAO,QAAoC;OAE5D,iBAAiB,IAAI,QAAQ;CAEjC,GACA,gBACA,QACF;CAEA,MAAM,OACJ,aACG;EACH,YAAY,aAAa,QAAQ;CACnC;CAOA,OALoB,OAAO,aAAa,iBAAiB,GAAG;EAC1D;EACA;CACF,CAEiB;AACnB"}
@@ -1,53 +0,0 @@
1
- import { AngularRateLimiter } from "./injectRateLimiter.cjs";
2
- import { RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
3
- //#region src/rate-limiter/injectRateLimitedSignal.d.ts
4
- type Setter<T> = (value: T | ((prev: T) => T)) => void;
5
- interface RateLimitedSignal<TValue, TSelected = {}> {
6
- (): TValue;
7
- set: Setter<TValue>;
8
- rateLimiter: AngularRateLimiter<Setter<TValue>, TSelected>;
9
- }
10
- /**
11
- * An Angular function that creates a rate-limited state signal, combining Angular's signal with rate limiting functionality.
12
- * This function provides both the current rate-limited value and methods to update it.
13
- *
14
- * Rate limiting is a simple "hard limit" approach - it allows all updates until the limit is reached, then blocks
15
- * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out
16
- * or intelligently collapse updates.
17
- *
18
- * The function returns a callable object:
19
- * - `rateLimited()`: Get the current rate-limited value
20
- * - `rateLimited.set(...)`: Set or update the rate-limited value (rate-limited via maybeExecute)
21
- * - `rateLimited.rateLimiter`: The rate limiter instance with additional control methods and state signals
22
- *
23
- * ## State Management and Selector
24
- *
25
- * The function uses TanStack Store for reactive state management via the underlying rate limiter instance.
26
- * The `selector` parameter allows you to specify which rate limiter state changes will trigger signal updates,
27
- * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
28
- *
29
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
30
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
31
- * full control over when your component tracks state changes.
32
- *
33
- * @example
34
- * ```ts
35
- * // Default behavior - no reactive state subscriptions
36
- * const rateLimited = injectRateLimitedSignal(0, {
37
- * limit: 5,
38
- * window: 60000,
39
- * windowType: 'sliding'
40
- * });
41
- *
42
- * // Opt-in to reactive updates when limit state changes
43
- * const rateLimited = injectRateLimitedSignal(
44
- * 0,
45
- * { limit: 5, window: 60000 },
46
- * (state) => ({ rejectionCount: state.rejectionCount })
47
- * );
48
- * ```
49
- */
50
- declare function injectRateLimitedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): RateLimitedSignal<TValue, TSelected>;
51
- //#endregion
52
- export { RateLimitedSignal, injectRateLimitedSignal };
53
- //# sourceMappingURL=injectRateLimitedSignal.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectRateLimitedSignal.js","names":[],"sources":["../../src/rate-limiter/injectRateLimitedSignal.ts"],"sourcesContent":["import { signal } from '@angular/core'\nimport { injectRateLimiter } from './injectRateLimiter'\nimport type { AngularRateLimiter } from './injectRateLimiter'\nimport type {\n RateLimiterOptions,\n RateLimiterState,\n} from '@tanstack/pacer/rate-limiter'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\nexport interface RateLimitedSignal<TValue, TSelected = {}> {\n (): TValue\n set: Setter<TValue>\n rateLimiter: AngularRateLimiter<Setter<TValue>, TSelected>\n}\n\n/**\n * An Angular function that creates a rate-limited state signal, combining Angular's signal with rate limiting functionality.\n * This function provides both the current rate-limited value and methods to update it.\n *\n * Rate limiting is a simple \"hard limit\" approach - it allows all updates until the limit is reached, then blocks\n * subsequent updates until the window resets. Unlike throttling or debouncing, it does not attempt to space out\n * or intelligently collapse updates.\n *\n * The function returns a callable object:\n * - `rateLimited()`: Get the current rate-limited value\n * - `rateLimited.set(...)`: Set or update the rate-limited value (rate-limited via maybeExecute)\n * - `rateLimited.rateLimiter`: The rate limiter instance with additional control methods and state signals\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying rate limiter instance.\n * The `selector` parameter allows you to specify which rate limiter state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions 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 * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const rateLimited = injectRateLimitedSignal(0, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding'\n * });\n *\n * // Opt-in to reactive updates when limit state changes\n * const rateLimited = injectRateLimitedSignal(\n * 0,\n * { limit: 5, window: 60000 },\n * (state) => ({ rejectionCount: state.rejectionCount })\n * );\n * ```\n */\nexport function injectRateLimitedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: RateLimiterOptions<Setter<TValue>>,\n selector?: (state: RateLimiterState) => TSelected,\n): RateLimitedSignal<TValue, TSelected> {\n const rateLimitedValue = signal<TValue>(value)\n\n const rateLimiter = injectRateLimiter(\n (newValue: TValue | ((prev: TValue) => TValue)) => {\n if (typeof newValue === 'function') {\n rateLimitedValue.update(newValue as (prev: TValue) => TValue)\n } else {\n rateLimitedValue.set(newValue)\n }\n },\n initialOptions,\n selector,\n )\n\n const set: Setter<TValue> = (\n newValue: TValue | ((prev: TValue) => TValue),\n ) => {\n rateLimiter.maybeExecute(newValue)\n }\n\n const rateLimited = Object.assign(() => rateLimitedValue(), {\n set,\n rateLimiter,\n }) as RateLimitedSignal<TValue, TSelected>\n\n return rateLimited\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,wBACd,OACA,gBACA,UACsC;CACtC,MAAM,mBAAmB,OAAe,KAAK;CAE7C,MAAM,cAAc,mBACjB,aAAkD;EACjD,IAAI,OAAO,aAAa,YACtB,iBAAiB,OAAO,QAAoC;OAE5D,iBAAiB,IAAI,QAAQ;CAEjC,GACA,gBACA,QACF;CAEA,MAAM,OACJ,aACG;EACH,YAAY,aAAa,QAAQ;CACnC;CAOA,OALoB,OAAO,aAAa,iBAAiB,GAAG;EAC1D;EACA;CACF,CAEiB;AACnB"}
@@ -1,17 +0,0 @@
1
- const require_injectRateLimitedSignal = require('./injectRateLimitedSignal.cjs');
2
- let _angular_core = require("@angular/core");
3
-
4
- //#region src/rate-limiter/injectRateLimitedValue.ts
5
- function injectRateLimitedValue(value, initialValueOrOptions, initialOptionsOrSelector, maybeSelector) {
6
- const hasInitialValue = initialOptionsOrSelector !== void 0 && !(typeof initialOptionsOrSelector === "function") || maybeSelector !== void 0;
7
- const rateLimited = require_injectRateLimitedSignal.injectRateLimitedSignal(hasInitialValue ? initialValueOrOptions : void 0, hasInitialValue ? initialOptionsOrSelector : initialValueOrOptions, hasInitialValue ? maybeSelector : initialOptionsOrSelector);
8
- (0, _angular_core.effect)(() => {
9
- const latest = value();
10
- rateLimited.set(latest);
11
- });
12
- return rateLimited;
13
- }
14
-
15
- //#endregion
16
- exports.injectRateLimitedValue = injectRateLimitedValue;
17
- //# sourceMappingURL=injectRateLimitedValue.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectRateLimitedValue.cjs","names":["injectRateLimitedSignal"],"sources":["../../src/rate-limiter/injectRateLimitedValue.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport { injectRateLimitedSignal } from './injectRateLimitedSignal'\nimport type { RateLimitedSignal } from './injectRateLimitedSignal'\nimport type { Signal } from '@angular/core'\nimport type {\n RateLimiterOptions,\n RateLimiterState,\n} from '@tanstack/pacer/rate-limiter'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\n/**\n * An Angular function that creates a rate-limited value that updates at most a certain number of times within a time window.\n * Unlike injectRateLimitedSignal, this function automatically tracks changes to the input signal\n * and updates the rate-limited value accordingly.\n *\n * The rate-limited value will update according to the configured rate limit, blocking updates\n * once the limit is reached until the window resets.\n *\n * The function returns a rate-limited signal object containing:\n * - A Signal that provides the current rate-limited value\n * - The rate limiter instance with control methods\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying rate limiter instance.\n * The `selector` parameter allows you to specify which rate limiter state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions 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 * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const value = signal(0)\n * const rateLimited = injectRateLimitedValue(value, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding',\n * })\n *\n * // rateLimited() will update at most 5 times per 60 seconds\n * effect(() => {\n * updateUI(rateLimited())\n * })\n * ```\n */\nexport function injectRateLimitedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialOptions: RateLimiterOptions<Setter<TValue>>,\n selector?: (state: RateLimiterState) => TSelected,\n): RateLimitedSignal<TValue, TSelected>\nexport function injectRateLimitedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValue: TValue,\n initialOptions: RateLimiterOptions<Setter<TValue>>,\n selector?: (state: RateLimiterState) => TSelected,\n): RateLimitedSignal<TValue, TSelected>\nexport function injectRateLimitedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValueOrOptions: TValue | RateLimiterOptions<Setter<TValue>>,\n initialOptionsOrSelector?:\n | RateLimiterOptions<Setter<TValue>>\n | ((state: RateLimiterState) => TSelected),\n maybeSelector?: (state: RateLimiterState) => TSelected,\n): RateLimitedSignal<TValue, TSelected> {\n const hasSelector = typeof initialOptionsOrSelector === 'function'\n\n const hasInitialValue =\n (initialOptionsOrSelector !== undefined && !hasSelector) ||\n maybeSelector !== undefined\n\n const initialValue = hasInitialValue\n ? (initialValueOrOptions as TValue)\n : (undefined as unknown as TValue)\n const initialOptions = hasInitialValue\n ? (initialOptionsOrSelector as RateLimiterOptions<Setter<TValue>>)\n : (initialValueOrOptions as RateLimiterOptions<Setter<TValue>>)\n const selector = hasInitialValue\n ? maybeSelector\n : (initialOptionsOrSelector as\n ((state: RateLimiterState) => TSelected) | undefined)\n\n const rateLimited = injectRateLimitedSignal(\n initialValue,\n initialOptions,\n selector,\n )\n\n effect(() => {\n const latest = value()\n rateLimited.set(latest)\n })\n\n return rateLimited\n}\n"],"mappings":";;;;AA4DA,SAAgB,uBACd,OACA,uBACA,0BAGA,eACsC;CAGtC,MAAM,kBACH,6BAA6B,UAAa,EAHzB,OAAO,6BAA6B,eAItD,kBAAkB;CAapB,MAAM,cAAcA,wDAXC,kBAChB,wBACA,QACkB,kBAClB,2BACA,uBACY,kBACb,gBACC,wBAOL;CAEA,gCAAa;EACX,MAAM,SAAS,MAAM;EACrB,YAAY,IAAI,MAAM;CACxB,CAAC;CAED,OAAO;AACT"}
@@ -1,48 +0,0 @@
1
- import { RateLimitedSignal } from "./injectRateLimitedSignal.cjs";
2
- import { Signal } from "@angular/core";
3
- import { RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
4
- //#region src/rate-limiter/injectRateLimitedValue.d.ts
5
- type Setter<T> = (value: T | ((prev: T) => T)) => void;
6
- /**
7
- * An Angular function that creates a rate-limited value that updates at most a certain number of times within a time window.
8
- * Unlike injectRateLimitedSignal, this function automatically tracks changes to the input signal
9
- * and updates the rate-limited value accordingly.
10
- *
11
- * The rate-limited value will update according to the configured rate limit, blocking updates
12
- * once the limit is reached until the window resets.
13
- *
14
- * The function returns a rate-limited signal object containing:
15
- * - A Signal that provides the current rate-limited value
16
- * - The rate limiter instance with control methods
17
- *
18
- * ## State Management and Selector
19
- *
20
- * The function uses TanStack Store for reactive state management via the underlying rate limiter instance.
21
- * The `selector` parameter allows you to specify which rate limiter state changes will trigger signal updates,
22
- * optimizing performance by preventing unnecessary subscriptions 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
- * @example
29
- * ```ts
30
- * // Default behavior - no reactive state subscriptions
31
- * const value = signal(0)
32
- * const rateLimited = injectRateLimitedValue(value, {
33
- * limit: 5,
34
- * window: 60000,
35
- * windowType: 'sliding',
36
- * })
37
- *
38
- * // rateLimited() will update at most 5 times per 60 seconds
39
- * effect(() => {
40
- * updateUI(rateLimited())
41
- * })
42
- * ```
43
- */
44
- declare function injectRateLimitedValue<TValue, TSelected = {}>(value: Signal<TValue>, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): RateLimitedSignal<TValue, TSelected>;
45
- declare function injectRateLimitedValue<TValue, TSelected = {}>(value: Signal<TValue>, initialValue: TValue, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): RateLimitedSignal<TValue, TSelected>;
46
- //#endregion
47
- export { injectRateLimitedValue };
48
- //# sourceMappingURL=injectRateLimitedValue.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectRateLimitedValue.js","names":[],"sources":["../../src/rate-limiter/injectRateLimitedValue.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport { injectRateLimitedSignal } from './injectRateLimitedSignal'\nimport type { RateLimitedSignal } from './injectRateLimitedSignal'\nimport type { Signal } from '@angular/core'\nimport type {\n RateLimiterOptions,\n RateLimiterState,\n} from '@tanstack/pacer/rate-limiter'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\n/**\n * An Angular function that creates a rate-limited value that updates at most a certain number of times within a time window.\n * Unlike injectRateLimitedSignal, this function automatically tracks changes to the input signal\n * and updates the rate-limited value accordingly.\n *\n * The rate-limited value will update according to the configured rate limit, blocking updates\n * once the limit is reached until the window resets.\n *\n * The function returns a rate-limited signal object containing:\n * - A Signal that provides the current rate-limited value\n * - The rate limiter instance with control methods\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying rate limiter instance.\n * The `selector` parameter allows you to specify which rate limiter state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions 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 * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const value = signal(0)\n * const rateLimited = injectRateLimitedValue(value, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding',\n * })\n *\n * // rateLimited() will update at most 5 times per 60 seconds\n * effect(() => {\n * updateUI(rateLimited())\n * })\n * ```\n */\nexport function injectRateLimitedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialOptions: RateLimiterOptions<Setter<TValue>>,\n selector?: (state: RateLimiterState) => TSelected,\n): RateLimitedSignal<TValue, TSelected>\nexport function injectRateLimitedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValue: TValue,\n initialOptions: RateLimiterOptions<Setter<TValue>>,\n selector?: (state: RateLimiterState) => TSelected,\n): RateLimitedSignal<TValue, TSelected>\nexport function injectRateLimitedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValueOrOptions: TValue | RateLimiterOptions<Setter<TValue>>,\n initialOptionsOrSelector?:\n | RateLimiterOptions<Setter<TValue>>\n | ((state: RateLimiterState) => TSelected),\n maybeSelector?: (state: RateLimiterState) => TSelected,\n): RateLimitedSignal<TValue, TSelected> {\n const hasSelector = typeof initialOptionsOrSelector === 'function'\n\n const hasInitialValue =\n (initialOptionsOrSelector !== undefined && !hasSelector) ||\n maybeSelector !== undefined\n\n const initialValue = hasInitialValue\n ? (initialValueOrOptions as TValue)\n : (undefined as unknown as TValue)\n const initialOptions = hasInitialValue\n ? (initialOptionsOrSelector as RateLimiterOptions<Setter<TValue>>)\n : (initialValueOrOptions as RateLimiterOptions<Setter<TValue>>)\n const selector = hasInitialValue\n ? maybeSelector\n : (initialOptionsOrSelector as\n ((state: RateLimiterState) => TSelected) | undefined)\n\n const rateLimited = injectRateLimitedSignal(\n initialValue,\n initialOptions,\n selector,\n )\n\n effect(() => {\n const latest = value()\n rateLimited.set(latest)\n })\n\n return rateLimited\n}\n"],"mappings":";;;;AA4DA,SAAgB,uBACd,OACA,uBACA,0BAGA,eACsC;CAGtC,MAAM,kBACH,6BAA6B,UAAa,EAHzB,OAAO,6BAA6B,eAItD,kBAAkB;CAapB,MAAM,cAAc,wBAXC,kBAChB,wBACA,QACkB,kBAClB,2BACA,uBACY,kBACb,gBACC,wBAOL;CAEA,aAAa;EACX,MAAM,SAAS,MAAM;EACrB,YAAY,IAAI,MAAM;CACxB,CAAC;CAED,OAAO;AACT"}
@@ -1,100 +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_rate_limiter = require("@tanstack/pacer/rate-limiter");
5
-
6
- //#region src/rate-limiter/injectRateLimiter.ts
7
- /**
8
- * An Angular function that creates and manages a RateLimiter instance.
9
- *
10
- * This is a lower-level function that provides direct access to the RateLimiter's functionality.
11
- * This allows you to integrate it with any state management solution you prefer.
12
- *
13
- * Rate limiting is a simple "hard limit" approach that allows executions until a maximum count is reached within
14
- * a time window, then blocks all subsequent calls until the window resets. Unlike throttling or debouncing,
15
- * it does not attempt to space out or collapse executions intelligently.
16
- *
17
- * The rate limiter supports two types of windows:
18
- * - 'fixed': A strict window that resets after the window period. All executions within the window count
19
- * towards the limit, and the window resets completely after the period.
20
- * - 'sliding': A rolling window that allows executions as old ones expire. This provides a more
21
- * consistent rate of execution over time.
22
- *
23
- * For smoother execution patterns:
24
- * - Use throttling when you want consistent spacing between executions (e.g. UI updates)
25
- * - Use debouncing when you want to collapse rapid-fire events (e.g. search input)
26
- * - Use rate limiting only when you need to enforce hard limits (e.g. API rate limits)
27
- *
28
- * ## State Management and Selector
29
- *
30
- * The function uses TanStack Store for state management and wraps it with Angular signals.
31
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
32
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
33
- *
34
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
35
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
36
- * full control over when your component tracks state changes.
37
- *
38
- * Available state properties:
39
- * - `executionCount`: Number of function executions that have been completed
40
- * - `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations
41
- * - `rejectionCount`: Number of function executions that have been rejected due to rate limiting
42
- *
43
- * ## Cleanup on Destroy
44
- *
45
- * Use the `onUnmount` option to run a callback when the component is destroyed.
46
- *
47
- * @example
48
- * ```ts
49
- * // Default behavior - no reactive state subscriptions
50
- * const rateLimiter = injectRateLimiter(apiCall, {
51
- * limit: 5,
52
- * window: 60000,
53
- * windowType: 'sliding',
54
- * });
55
- *
56
- * // Opt-in to track execution count changes
57
- * const rateLimiter = injectRateLimiter(
58
- * apiCall,
59
- * {
60
- * limit: 5,
61
- * window: 60000,
62
- * windowType: 'sliding',
63
- * },
64
- * (state) => ({ executionCount: state.executionCount })
65
- * );
66
- *
67
- * // Monitor rate limit status
68
- * const handleClick = () => {
69
- * const remaining = rateLimiter.getRemainingInWindow();
70
- * if (remaining > 0) {
71
- * rateLimiter.maybeExecute(data);
72
- * } else {
73
- * showRateLimitWarning();
74
- * }
75
- * };
76
- *
77
- * // Access the selected state (will be empty object {} unless selector provided)
78
- * const { executionCount, rejectionCount } = rateLimiter.state();
79
- * ```
80
- */
81
- function injectRateLimiter(fn, options, selector = () => ({})) {
82
- const mergedOptions = {
83
- ...require_pacer_context.injectPacerOptions().rateLimiter,
84
- ...options
85
- };
86
- const rateLimiter = new _tanstack_pacer_rate_limiter.RateLimiter(fn, mergedOptions);
87
- const state = (0, _tanstack_angular_store.injectSelector)(rateLimiter.store, selector);
88
- const result = {
89
- ...rateLimiter,
90
- state
91
- };
92
- (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true })?.onDestroy(() => {
93
- if (mergedOptions.onUnmount) mergedOptions.onUnmount(result);
94
- });
95
- return result;
96
- }
97
-
98
- //#endregion
99
- exports.injectRateLimiter = injectRateLimiter;
100
- //# sourceMappingURL=injectRateLimiter.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectRateLimiter.cjs","names":["injectPacerOptions","RateLimiter","injectSelector","inject","DestroyRef"],"sources":["../../src/rate-limiter/injectRateLimiter.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { RateLimiter } from '@tanstack/pacer/rate-limiter'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyFunction } from '@tanstack/pacer/types'\nimport type {\n RateLimiterOptions,\n RateLimiterState,\n} from '@tanstack/pacer/rate-limiter'\n\nexport interface AngularRateLimiterOptions<\n TFn extends AnyFunction,\n TSelected = {},\n> extends RateLimiterOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the rate limiter instance.\n */\n onUnmount?: (rateLimiter: AngularRateLimiter<TFn, TSelected>) => void\n}\n\nexport interface AngularRateLimiter<\n TFn extends AnyFunction,\n TSelected = {},\n> extends Omit<RateLimiter<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the rate limiter state changes\n *\n * Use this instead of `rateLimiter.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `rateLimiter.state` instead of `rateLimiter.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<RateLimiterState>>\n}\n\n/**\n * An Angular function that creates and manages a RateLimiter instance.\n *\n * This is a lower-level function that provides direct access to the RateLimiter's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * Rate limiting is a simple \"hard limit\" approach that allows executions until a maximum count is reached within\n * a time window, then blocks all subsequent calls until the window resets. Unlike throttling or debouncing,\n * it does not attempt to space out or collapse executions intelligently.\n *\n * The rate limiter supports two types of windows:\n * - 'fixed': A strict window that resets after the window period. All executions within the window count\n * towards the limit, and the window resets completely after the period.\n * - 'sliding': A rolling window that allows executions as old ones expire. This provides a more\n * consistent rate of execution over time.\n *\n * For smoother execution patterns:\n * - Use throttling when you want consistent spacing between executions (e.g. UI updates)\n * - Use debouncing when you want to collapse rapid-fire events (e.g. search input)\n * - Use rate limiting only when you need to enforce hard limits (e.g. API rate limits)\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 * Available state properties:\n * - `executionCount`: Number of function executions that have been completed\n * - `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations\n * - `rejectionCount`: Number of function executions that have been rejected due to rate limiting\n *\n * ## Cleanup on Destroy\n *\n * Use the `onUnmount` option to run a callback when the component is destroyed.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const rateLimiter = injectRateLimiter(apiCall, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding',\n * });\n *\n * // Opt-in to track execution count changes\n * const rateLimiter = injectRateLimiter(\n * apiCall,\n * {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding',\n * },\n * (state) => ({ executionCount: state.executionCount })\n * );\n *\n * // Monitor rate limit status\n * const handleClick = () => {\n * const remaining = rateLimiter.getRemainingInWindow();\n * if (remaining > 0) {\n * rateLimiter.maybeExecute(data);\n * } else {\n * showRateLimitWarning();\n * }\n * };\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { executionCount, rejectionCount } = rateLimiter.state();\n * ```\n */\nexport function injectRateLimiter<TFn extends AnyFunction, TSelected = {}>(\n fn: TFn,\n options: AngularRateLimiterOptions<TFn, TSelected>,\n selector: (state: RateLimiterState) => TSelected = () => ({}) as TSelected,\n): AngularRateLimiter<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().rateLimiter,\n ...options,\n } as AngularRateLimiterOptions<TFn, TSelected>\n\n const rateLimiter = new RateLimiter<TFn>(fn, mergedOptions)\n const state = injectSelector(rateLimiter.store, selector)\n\n const result = {\n ...rateLimiter,\n state,\n } as AngularRateLimiter<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiHA,SAAgB,kBACd,IACA,SACA,kBAA0D,CAAC,IACvB;CACpC,MAAM,gBAAgB;EACpB,GAAGA,yCAAmB,CAAC,CAAC;EACxB,GAAG;CACL;CAEA,MAAM,cAAc,IAAIC,yCAAiB,IAAI,aAAa;CAC1D,MAAM,YAAQC,wCAAe,YAAY,OAAO,QAAQ;CAExD,MAAM,SAAS;EACb,GAAG;EACH;CACF;CAGA,IADmBC,sBAAOC,0BAAY,EAAE,UAAU,KAAK,CAC9C,CAAC,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,MAAM;CAElC,CAAC;CAED,OAAO;AACT"}
@@ -1,102 +0,0 @@
1
- import { Signal } from "@angular/core";
2
- import { Store } from "@tanstack/angular-store";
3
- import { AnyFunction } from "@tanstack/pacer/types";
4
- import { RateLimiter, RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
5
- //#region src/rate-limiter/injectRateLimiter.d.ts
6
- interface AngularRateLimiterOptions<TFn extends AnyFunction, TSelected = {}> extends RateLimiterOptions<TFn> {
7
- /**
8
- * Optional callback invoked when the component is destroyed. Receives the rate limiter instance.
9
- */
10
- onUnmount?: (rateLimiter: AngularRateLimiter<TFn, TSelected>) => void;
11
- }
12
- interface AngularRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit<RateLimiter<TFn>, 'store'> {
13
- /**
14
- * Reactive state signal that will be updated when the rate limiter state changes
15
- *
16
- * Use this instead of `rateLimiter.store.state`
17
- */
18
- readonly state: Signal<Readonly<TSelected>>;
19
- /**
20
- * @deprecated Use `rateLimiter.state` instead of `rateLimiter.store.state` if you want to read reactive state.
21
- * The state on the store object is not reactive in Angular signals.
22
- */
23
- readonly store: Store<Readonly<RateLimiterState>>;
24
- }
25
- /**
26
- * An Angular function that creates and manages a RateLimiter instance.
27
- *
28
- * This is a lower-level function that provides direct access to the RateLimiter's functionality.
29
- * This allows you to integrate it with any state management solution you prefer.
30
- *
31
- * Rate limiting is a simple "hard limit" approach that allows executions until a maximum count is reached within
32
- * a time window, then blocks all subsequent calls until the window resets. Unlike throttling or debouncing,
33
- * it does not attempt to space out or collapse executions intelligently.
34
- *
35
- * The rate limiter supports two types of windows:
36
- * - 'fixed': A strict window that resets after the window period. All executions within the window count
37
- * towards the limit, and the window resets completely after the period.
38
- * - 'sliding': A rolling window that allows executions as old ones expire. This provides a more
39
- * consistent rate of execution over time.
40
- *
41
- * For smoother execution patterns:
42
- * - Use throttling when you want consistent spacing between executions (e.g. UI updates)
43
- * - Use debouncing when you want to collapse rapid-fire events (e.g. search input)
44
- * - Use rate limiting only when you need to enforce hard limits (e.g. API rate limits)
45
- *
46
- * ## State Management and Selector
47
- *
48
- * The function uses TanStack Store for state management and wraps it with Angular signals.
49
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
50
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
51
- *
52
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
53
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
54
- * full control over when your component tracks state changes.
55
- *
56
- * Available state properties:
57
- * - `executionCount`: Number of function executions that have been completed
58
- * - `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations
59
- * - `rejectionCount`: Number of function executions that have been rejected due to rate limiting
60
- *
61
- * ## Cleanup on Destroy
62
- *
63
- * Use the `onUnmount` option to run a callback when the component is destroyed.
64
- *
65
- * @example
66
- * ```ts
67
- * // Default behavior - no reactive state subscriptions
68
- * const rateLimiter = injectRateLimiter(apiCall, {
69
- * limit: 5,
70
- * window: 60000,
71
- * windowType: 'sliding',
72
- * });
73
- *
74
- * // Opt-in to track execution count changes
75
- * const rateLimiter = injectRateLimiter(
76
- * apiCall,
77
- * {
78
- * limit: 5,
79
- * window: 60000,
80
- * windowType: 'sliding',
81
- * },
82
- * (state) => ({ executionCount: state.executionCount })
83
- * );
84
- *
85
- * // Monitor rate limit status
86
- * const handleClick = () => {
87
- * const remaining = rateLimiter.getRemainingInWindow();
88
- * if (remaining > 0) {
89
- * rateLimiter.maybeExecute(data);
90
- * } else {
91
- * showRateLimitWarning();
92
- * }
93
- * };
94
- *
95
- * // Access the selected state (will be empty object {} unless selector provided)
96
- * const { executionCount, rejectionCount } = rateLimiter.state();
97
- * ```
98
- */
99
- declare function injectRateLimiter<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: AngularRateLimiterOptions<TFn, TSelected>, selector?: (state: RateLimiterState) => TSelected): AngularRateLimiter<TFn, TSelected>;
100
- //#endregion
101
- export { AngularRateLimiter, AngularRateLimiterOptions, injectRateLimiter };
102
- //# sourceMappingURL=injectRateLimiter.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectRateLimiter.js","names":[],"sources":["../../src/rate-limiter/injectRateLimiter.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { RateLimiter } from '@tanstack/pacer/rate-limiter'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyFunction } from '@tanstack/pacer/types'\nimport type {\n RateLimiterOptions,\n RateLimiterState,\n} from '@tanstack/pacer/rate-limiter'\n\nexport interface AngularRateLimiterOptions<\n TFn extends AnyFunction,\n TSelected = {},\n> extends RateLimiterOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the rate limiter instance.\n */\n onUnmount?: (rateLimiter: AngularRateLimiter<TFn, TSelected>) => void\n}\n\nexport interface AngularRateLimiter<\n TFn extends AnyFunction,\n TSelected = {},\n> extends Omit<RateLimiter<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the rate limiter state changes\n *\n * Use this instead of `rateLimiter.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `rateLimiter.state` instead of `rateLimiter.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<RateLimiterState>>\n}\n\n/**\n * An Angular function that creates and manages a RateLimiter instance.\n *\n * This is a lower-level function that provides direct access to the RateLimiter's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * Rate limiting is a simple \"hard limit\" approach that allows executions until a maximum count is reached within\n * a time window, then blocks all subsequent calls until the window resets. Unlike throttling or debouncing,\n * it does not attempt to space out or collapse executions intelligently.\n *\n * The rate limiter supports two types of windows:\n * - 'fixed': A strict window that resets after the window period. All executions within the window count\n * towards the limit, and the window resets completely after the period.\n * - 'sliding': A rolling window that allows executions as old ones expire. This provides a more\n * consistent rate of execution over time.\n *\n * For smoother execution patterns:\n * - Use throttling when you want consistent spacing between executions (e.g. UI updates)\n * - Use debouncing when you want to collapse rapid-fire events (e.g. search input)\n * - Use rate limiting only when you need to enforce hard limits (e.g. API rate limits)\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 * Available state properties:\n * - `executionCount`: Number of function executions that have been completed\n * - `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations\n * - `rejectionCount`: Number of function executions that have been rejected due to rate limiting\n *\n * ## Cleanup on Destroy\n *\n * Use the `onUnmount` option to run a callback when the component is destroyed.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const rateLimiter = injectRateLimiter(apiCall, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding',\n * });\n *\n * // Opt-in to track execution count changes\n * const rateLimiter = injectRateLimiter(\n * apiCall,\n * {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding',\n * },\n * (state) => ({ executionCount: state.executionCount })\n * );\n *\n * // Monitor rate limit status\n * const handleClick = () => {\n * const remaining = rateLimiter.getRemainingInWindow();\n * if (remaining > 0) {\n * rateLimiter.maybeExecute(data);\n * } else {\n * showRateLimitWarning();\n * }\n * };\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { executionCount, rejectionCount } = rateLimiter.state();\n * ```\n */\nexport function injectRateLimiter<TFn extends AnyFunction, TSelected = {}>(\n fn: TFn,\n options: AngularRateLimiterOptions<TFn, TSelected>,\n selector: (state: RateLimiterState) => TSelected = () => ({}) as TSelected,\n): AngularRateLimiter<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().rateLimiter,\n ...options,\n } as AngularRateLimiterOptions<TFn, TSelected>\n\n const rateLimiter = new RateLimiter<TFn>(fn, mergedOptions)\n const state = injectSelector(rateLimiter.store, selector)\n\n const result = {\n ...rateLimiter,\n state,\n } as AngularRateLimiter<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiHA,SAAgB,kBACd,IACA,SACA,kBAA0D,CAAC,IACvB;CACpC,MAAM,gBAAgB;EACpB,GAAG,mBAAmB,CAAC,CAAC;EACxB,GAAG;CACL;CAEA,MAAM,cAAc,IAAI,YAAiB,IAAI,aAAa;CAC1D,MAAM,QAAQ,eAAe,YAAY,OAAO,QAAQ;CAExD,MAAM,SAAS;EACb,GAAG;EACH;CACF;CAGA,AADmB,OAAO,YAAY,EAAE,UAAU,KAAK,CAC9C,CAAC,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,MAAM;CAElC,CAAC;CAED,OAAO;AACT"}
@@ -1,17 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_injectThrottler = require('./injectThrottler.cjs');
3
- const require_injectThrottledCallback = require('./injectThrottledCallback.cjs');
4
- const require_injectThrottledSignal = require('./injectThrottledSignal.cjs');
5
- const require_injectThrottledValue = require('./injectThrottledValue.cjs');
6
-
7
- exports.injectThrottledCallback = require_injectThrottledCallback.injectThrottledCallback;
8
- exports.injectThrottledSignal = require_injectThrottledSignal.injectThrottledSignal;
9
- exports.injectThrottledValue = require_injectThrottledValue.injectThrottledValue;
10
- exports.injectThrottler = require_injectThrottler.injectThrottler;
11
- var _tanstack_pacer_throttler = require("@tanstack/pacer/throttler");
12
- Object.keys(_tanstack_pacer_throttler).forEach(function (k) {
13
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
14
- enumerable: true,
15
- get: function () { return _tanstack_pacer_throttler[k]; }
16
- });
17
- });
@@ -1,6 +0,0 @@
1
- import { injectThrottledCallback } from "./injectThrottledCallback.cjs";
2
- import { AngularThrottler, AngularThrottlerOptions, injectThrottler } from "./injectThrottler.cjs";
3
- import { ThrottledSignal, injectThrottledSignal } from "./injectThrottledSignal.cjs";
4
- import { injectThrottledValue } from "./injectThrottledValue.cjs";
5
- export * from "@tanstack/pacer/throttler";
6
- export { AngularThrottler, AngularThrottlerOptions, ThrottledSignal, injectThrottledCallback, injectThrottledSignal, injectThrottledValue, injectThrottler };
@@ -1,45 +0,0 @@
1
- const require_injectThrottler = require('./injectThrottler.cjs');
2
-
3
- //#region src/throttler/injectThrottledCallback.ts
4
- /**
5
- * An Angular function that creates a throttled version of a callback function.
6
- * This function is essentially a wrapper around `injectThrottler` that provides
7
- * a simplified API for basic throttling needs.
8
- *
9
- * The throttled function will execute at most once within the specified wait time.
10
- * If called multiple times within the wait period, only the first call (if leading is enabled)
11
- * or the last call (if trailing is enabled) will execute.
12
- *
13
- * This function provides a simpler API compared to `injectThrottler`, making it ideal for basic
14
- * throttling needs. However, it does not expose the underlying Throttler instance.
15
- *
16
- * For advanced usage requiring features like:
17
- * - Manual cancellation
18
- * - Access to execution counts
19
- * - State tracking
20
- *
21
- * Consider using the `injectThrottler` function instead.
22
- *
23
- * @example
24
- * ```ts
25
- * // Throttle a scroll handler
26
- * const handleScroll = injectThrottledCallback((scrollY: number) => {
27
- * updateScrollPosition(scrollY);
28
- * }, {
29
- * wait: 100 // Execute at most once per 100ms
30
- * });
31
- *
32
- * // Use in an event listener
33
- * window.addEventListener('scroll', () => {
34
- * handleScroll(window.scrollY);
35
- * });
36
- * ```
37
- */
38
- function injectThrottledCallback(fn, options) {
39
- const throttler = require_injectThrottler.injectThrottler(fn, options);
40
- return (...args) => throttler.maybeExecute(...args);
41
- }
42
-
43
- //#endregion
44
- exports.injectThrottledCallback = injectThrottledCallback;
45
- //# sourceMappingURL=injectThrottledCallback.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectThrottledCallback.cjs","names":["injectThrottler"],"sources":["../../src/throttler/injectThrottledCallback.ts"],"sourcesContent":["import { injectThrottler } from './injectThrottler'\nimport type { ThrottlerOptions } from '@tanstack/pacer/throttler'\nimport type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates a throttled version of a callback function.\n * This function is essentially a wrapper around `injectThrottler` that provides\n * a simplified API for basic throttling needs.\n *\n * The throttled function will execute at most once within the specified wait time.\n * If called multiple times within the wait period, only the first call (if leading is enabled)\n * or the last call (if trailing is enabled) will execute.\n *\n * This function provides a simpler API compared to `injectThrottler`, making it ideal for basic\n * throttling needs. However, it does not expose the underlying Throttler instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - State tracking\n *\n * Consider using the `injectThrottler` function instead.\n *\n * @example\n * ```ts\n * // Throttle a scroll handler\n * const handleScroll = injectThrottledCallback((scrollY: number) => {\n * updateScrollPosition(scrollY);\n * }, {\n * wait: 100 // Execute at most once per 100ms\n * });\n *\n * // Use in an event listener\n * window.addEventListener('scroll', () => {\n * handleScroll(window.scrollY);\n * });\n * ```\n */\nexport function injectThrottledCallback<TFn extends AnyFunction>(\n fn: TFn,\n options: ThrottlerOptions<TFn>,\n): (...args: Parameters<TFn>) => void {\n const throttler = injectThrottler(fn, options)\n return (...args: Parameters<TFn>) => throttler.maybeExecute(...args)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,wBACd,IACA,SACoC;CACpC,MAAM,YAAYA,wCAAgB,IAAI,OAAO;CAC7C,QAAQ,GAAG,SAA0B,UAAU,aAAa,GAAG,IAAI;AACrE"}
@@ -1,41 +0,0 @@
1
- import { AnyFunction } from "@tanstack/pacer/types";
2
- import { ThrottlerOptions } from "@tanstack/pacer/throttler";
3
- //#region src/throttler/injectThrottledCallback.d.ts
4
- /**
5
- * An Angular function that creates a throttled version of a callback function.
6
- * This function is essentially a wrapper around `injectThrottler` that provides
7
- * a simplified API for basic throttling needs.
8
- *
9
- * The throttled function will execute at most once within the specified wait time.
10
- * If called multiple times within the wait period, only the first call (if leading is enabled)
11
- * or the last call (if trailing is enabled) will execute.
12
- *
13
- * This function provides a simpler API compared to `injectThrottler`, making it ideal for basic
14
- * throttling needs. However, it does not expose the underlying Throttler instance.
15
- *
16
- * For advanced usage requiring features like:
17
- * - Manual cancellation
18
- * - Access to execution counts
19
- * - State tracking
20
- *
21
- * Consider using the `injectThrottler` function instead.
22
- *
23
- * @example
24
- * ```ts
25
- * // Throttle a scroll handler
26
- * const handleScroll = injectThrottledCallback((scrollY: number) => {
27
- * updateScrollPosition(scrollY);
28
- * }, {
29
- * wait: 100 // Execute at most once per 100ms
30
- * });
31
- *
32
- * // Use in an event listener
33
- * window.addEventListener('scroll', () => {
34
- * handleScroll(window.scrollY);
35
- * });
36
- * ```
37
- */
38
- declare function injectThrottledCallback<TFn extends AnyFunction>(fn: TFn, options: ThrottlerOptions<TFn>): (...args: Parameters<TFn>) => void;
39
- //#endregion
40
- export { injectThrottledCallback };
41
- //# sourceMappingURL=injectThrottledCallback.d.cts.map