@tanstack/solid-pacer 0.16.0 → 0.17.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 (322) hide show
  1. package/README.md +1 -1
  2. package/dist/async-batcher/createAsyncBatcher.cjs +122 -0
  3. package/dist/async-batcher/createAsyncBatcher.cjs.map +1 -0
  4. package/dist/{cjs/async-batcher → async-batcher}/createAsyncBatcher.d.cts +22 -17
  5. package/dist/{esm/async-batcher → async-batcher}/createAsyncBatcher.d.ts +22 -17
  6. package/dist/async-batcher/createAsyncBatcher.js +122 -0
  7. package/dist/async-batcher/createAsyncBatcher.js.map +1 -0
  8. package/dist/async-batcher/index.cjs +10 -0
  9. package/dist/async-batcher/index.d.cts +3 -0
  10. package/dist/async-batcher/index.d.ts +3 -0
  11. package/dist/async-batcher/index.js +5 -0
  12. package/dist/async-debouncer/createAsyncDebouncer.cjs +114 -0
  13. package/dist/async-debouncer/createAsyncDebouncer.cjs.map +1 -0
  14. package/dist/{cjs/async-debouncer → async-debouncer}/createAsyncDebouncer.d.cts +23 -18
  15. package/dist/{esm/async-debouncer → async-debouncer}/createAsyncDebouncer.d.ts +23 -18
  16. package/dist/async-debouncer/createAsyncDebouncer.js +114 -0
  17. package/dist/async-debouncer/createAsyncDebouncer.js.map +1 -0
  18. package/dist/async-debouncer/index.cjs +10 -0
  19. package/dist/async-debouncer/index.d.cts +3 -0
  20. package/dist/async-debouncer/index.d.ts +3 -0
  21. package/dist/async-debouncer/index.js +5 -0
  22. package/dist/async-queuer/createAsyncQueuer.cjs +114 -0
  23. package/dist/async-queuer/createAsyncQueuer.cjs.map +1 -0
  24. package/dist/{cjs/async-queuer → async-queuer}/createAsyncQueuer.d.cts +22 -17
  25. package/dist/{esm/async-queuer → async-queuer}/createAsyncQueuer.d.ts +22 -17
  26. package/dist/async-queuer/createAsyncQueuer.js +114 -0
  27. package/dist/async-queuer/createAsyncQueuer.js.map +1 -0
  28. package/dist/async-queuer/index.cjs +10 -0
  29. package/dist/async-queuer/index.d.cts +3 -0
  30. package/dist/async-queuer/index.d.ts +3 -0
  31. package/dist/async-queuer/index.js +5 -0
  32. package/dist/async-rate-limiter/createAsyncRateLimiter.cjs +120 -0
  33. package/dist/async-rate-limiter/createAsyncRateLimiter.cjs.map +1 -0
  34. package/dist/{cjs/async-rate-limiter → async-rate-limiter}/createAsyncRateLimiter.d.cts +23 -18
  35. package/dist/{esm/async-rate-limiter → async-rate-limiter}/createAsyncRateLimiter.d.ts +23 -18
  36. package/dist/async-rate-limiter/createAsyncRateLimiter.js +120 -0
  37. package/dist/async-rate-limiter/createAsyncRateLimiter.js.map +1 -0
  38. package/dist/async-rate-limiter/index.cjs +10 -0
  39. package/dist/async-rate-limiter/index.d.cts +3 -0
  40. package/dist/async-rate-limiter/index.d.ts +3 -0
  41. package/dist/async-rate-limiter/index.js +5 -0
  42. package/dist/async-throttler/createAsyncThrottler.cjs +108 -0
  43. package/dist/async-throttler/createAsyncThrottler.cjs.map +1 -0
  44. package/dist/{cjs/async-throttler → async-throttler}/createAsyncThrottler.d.cts +23 -18
  45. package/dist/{esm/async-throttler → async-throttler}/createAsyncThrottler.d.ts +23 -18
  46. package/dist/async-throttler/createAsyncThrottler.js +108 -0
  47. package/dist/async-throttler/createAsyncThrottler.js.map +1 -0
  48. package/dist/async-throttler/index.cjs +10 -0
  49. package/dist/async-throttler/index.d.cts +3 -0
  50. package/dist/async-throttler/index.d.ts +3 -0
  51. package/dist/async-throttler/index.js +5 -0
  52. package/dist/batcher/createBatcher.cjs +97 -0
  53. package/dist/batcher/createBatcher.cjs.map +1 -0
  54. package/dist/{cjs/batcher → batcher}/createBatcher.d.cts +22 -17
  55. package/dist/{esm/batcher → batcher}/createBatcher.d.ts +22 -17
  56. package/dist/batcher/createBatcher.js +97 -0
  57. package/dist/batcher/createBatcher.js.map +1 -0
  58. package/dist/batcher/index.cjs +10 -0
  59. package/dist/batcher/index.d.cts +3 -0
  60. package/dist/batcher/index.d.ts +3 -0
  61. package/dist/batcher/index.js +5 -0
  62. package/dist/debouncer/createDebouncedSignal.cjs +88 -0
  63. package/dist/debouncer/createDebouncedSignal.cjs.map +1 -0
  64. package/dist/{cjs/debouncer → debouncer}/createDebouncedSignal.d.cts +10 -8
  65. package/dist/{esm/debouncer → debouncer}/createDebouncedSignal.d.ts +10 -8
  66. package/dist/debouncer/createDebouncedSignal.js +88 -0
  67. package/dist/debouncer/createDebouncedSignal.js.map +1 -0
  68. package/dist/debouncer/createDebouncedValue.cjs +77 -0
  69. package/dist/debouncer/createDebouncedValue.cjs.map +1 -0
  70. package/dist/{cjs/debouncer → debouncer}/createDebouncedValue.d.cts +10 -4
  71. package/dist/{esm/debouncer → debouncer}/createDebouncedValue.d.ts +10 -4
  72. package/dist/debouncer/createDebouncedValue.js +77 -0
  73. package/dist/debouncer/createDebouncedValue.js.map +1 -0
  74. package/dist/debouncer/createDebouncer.cjs +101 -0
  75. package/dist/debouncer/createDebouncer.cjs.map +1 -0
  76. package/dist/{cjs/debouncer → debouncer}/createDebouncer.d.cts +23 -18
  77. package/dist/{esm/debouncer → debouncer}/createDebouncer.d.ts +23 -18
  78. package/dist/debouncer/createDebouncer.js +101 -0
  79. package/dist/debouncer/createDebouncer.js.map +1 -0
  80. package/dist/debouncer/index.cjs +14 -0
  81. package/dist/debouncer/index.d.cts +5 -0
  82. package/dist/debouncer/index.d.ts +5 -0
  83. package/dist/{esm/debouncer → debouncer}/index.js +5 -8
  84. package/dist/index.cjs +46 -0
  85. package/dist/index.d.cts +20 -0
  86. package/dist/index.d.ts +20 -0
  87. package/dist/{esm/index.js → index.js} +6 -26
  88. package/dist/provider/PacerProvider.cjs +27 -0
  89. package/dist/provider/PacerProvider.cjs.map +1 -0
  90. package/dist/provider/PacerProvider.d.cts +29 -0
  91. package/dist/provider/PacerProvider.d.ts +29 -0
  92. package/dist/provider/PacerProvider.js +25 -0
  93. package/dist/provider/PacerProvider.js.map +1 -0
  94. package/dist/provider/index.cjs +5 -0
  95. package/dist/provider/index.d.cts +2 -0
  96. package/dist/provider/index.d.ts +2 -0
  97. package/dist/provider/index.js +3 -0
  98. package/dist/queuer/createQueuedSignal.cjs +129 -0
  99. package/dist/queuer/createQueuedSignal.cjs.map +1 -0
  100. package/dist/{cjs/queuer → queuer}/createQueuedSignal.d.cts +9 -7
  101. package/dist/{esm/queuer → queuer}/createQueuedSignal.d.ts +9 -7
  102. package/dist/queuer/createQueuedSignal.js +129 -0
  103. package/dist/queuer/createQueuedSignal.js.map +1 -0
  104. package/dist/queuer/createQueuer.cjs +98 -0
  105. package/dist/queuer/createQueuer.cjs.map +1 -0
  106. package/dist/{cjs/queuer → queuer}/createQueuer.d.cts +22 -17
  107. package/dist/{esm/queuer → queuer}/createQueuer.d.ts +22 -17
  108. package/dist/queuer/createQueuer.js +98 -0
  109. package/dist/queuer/createQueuer.js.map +1 -0
  110. package/dist/queuer/index.cjs +12 -0
  111. package/dist/queuer/index.d.cts +4 -0
  112. package/dist/queuer/index.d.ts +4 -0
  113. package/dist/queuer/index.js +6 -0
  114. package/dist/rate-limiter/createRateLimitedSignal.cjs +102 -0
  115. package/dist/rate-limiter/createRateLimitedSignal.cjs.map +1 -0
  116. package/dist/{cjs/rate-limiter → rate-limiter}/createRateLimitedSignal.d.cts +10 -8
  117. package/dist/{esm/rate-limiter → rate-limiter}/createRateLimitedSignal.d.ts +10 -8
  118. package/dist/rate-limiter/createRateLimitedSignal.js +102 -0
  119. package/dist/rate-limiter/createRateLimitedSignal.js.map +1 -0
  120. package/dist/rate-limiter/createRateLimitedValue.cjs +102 -0
  121. package/dist/rate-limiter/createRateLimitedValue.cjs.map +1 -0
  122. package/dist/{cjs/rate-limiter → rate-limiter}/createRateLimitedValue.d.cts +10 -4
  123. package/dist/{esm/rate-limiter → rate-limiter}/createRateLimitedValue.d.ts +10 -4
  124. package/dist/rate-limiter/createRateLimitedValue.js +102 -0
  125. package/dist/rate-limiter/createRateLimitedValue.js.map +1 -0
  126. package/dist/rate-limiter/createRateLimiter.cjs +95 -0
  127. package/dist/rate-limiter/createRateLimiter.cjs.map +1 -0
  128. package/dist/{cjs/rate-limiter → rate-limiter}/createRateLimiter.d.cts +23 -18
  129. package/dist/{esm/rate-limiter → rate-limiter}/createRateLimiter.d.ts +23 -18
  130. package/dist/rate-limiter/createRateLimiter.js +95 -0
  131. package/dist/rate-limiter/createRateLimiter.js.map +1 -0
  132. package/dist/rate-limiter/index.cjs +14 -0
  133. package/dist/rate-limiter/index.d.cts +5 -0
  134. package/dist/rate-limiter/index.d.ts +5 -0
  135. package/dist/{esm/rate-limiter → rate-limiter}/index.js +4 -7
  136. package/dist/throttler/createThrottledSignal.cjs +79 -0
  137. package/dist/throttler/createThrottledSignal.cjs.map +1 -0
  138. package/dist/{cjs/throttler → throttler}/createThrottledSignal.d.cts +10 -8
  139. package/dist/{esm/throttler → throttler}/createThrottledSignal.d.ts +10 -8
  140. package/dist/throttler/createThrottledSignal.js +79 -0
  141. package/dist/throttler/createThrottledSignal.js.map +1 -0
  142. package/dist/throttler/createThrottledValue.cjs +74 -0
  143. package/dist/throttler/createThrottledValue.cjs.map +1 -0
  144. package/dist/{cjs/throttler → throttler}/createThrottledValue.d.cts +10 -4
  145. package/dist/{esm/throttler → throttler}/createThrottledValue.d.ts +10 -4
  146. package/dist/throttler/createThrottledValue.js +74 -0
  147. package/dist/throttler/createThrottledValue.js.map +1 -0
  148. package/dist/throttler/createThrottler.cjs +97 -0
  149. package/dist/throttler/createThrottler.cjs.map +1 -0
  150. package/dist/{cjs/throttler → throttler}/createThrottler.d.cts +23 -18
  151. package/dist/{esm/throttler → throttler}/createThrottler.d.ts +23 -18
  152. package/dist/throttler/createThrottler.js +97 -0
  153. package/dist/throttler/createThrottler.js.map +1 -0
  154. package/dist/throttler/index.cjs +14 -0
  155. package/dist/throttler/index.d.cts +5 -0
  156. package/dist/throttler/index.d.ts +5 -0
  157. package/dist/{esm/throttler → throttler}/index.js +5 -8
  158. package/dist/types/index.cjs +9 -0
  159. package/dist/types/index.d.cts +1 -0
  160. package/dist/types/index.d.ts +1 -0
  161. package/dist/types/index.js +3 -0
  162. package/dist/utils/index.cjs +9 -0
  163. package/dist/utils/index.d.cts +1 -0
  164. package/dist/utils/index.d.ts +1 -0
  165. package/dist/utils/index.js +3 -0
  166. package/package.json +37 -106
  167. package/src/async-batcher/createAsyncBatcher.ts +4 -2
  168. package/src/async-queuer/createAsyncQueuer.ts +4 -2
  169. package/src/batcher/createBatcher.ts +4 -2
  170. package/src/debouncer/createDebouncer.ts +4 -2
  171. package/src/provider/index.ts +1 -0
  172. package/src/queuer/createQueuer.ts +4 -2
  173. package/src/rate-limiter/createRateLimiter.ts +4 -2
  174. package/src/throttler/createThrottler.ts +4 -2
  175. package/dist/cjs/async-batcher/createAsyncBatcher.cjs +0 -19
  176. package/dist/cjs/async-batcher/createAsyncBatcher.cjs.map +0 -1
  177. package/dist/cjs/async-batcher/index.cjs +0 -12
  178. package/dist/cjs/async-batcher/index.cjs.map +0 -1
  179. package/dist/cjs/async-batcher/index.d.cts +0 -2
  180. package/dist/cjs/async-debouncer/createAsyncDebouncer.cjs +0 -25
  181. package/dist/cjs/async-debouncer/createAsyncDebouncer.cjs.map +0 -1
  182. package/dist/cjs/async-debouncer/index.cjs +0 -12
  183. package/dist/cjs/async-debouncer/index.cjs.map +0 -1
  184. package/dist/cjs/async-debouncer/index.d.cts +0 -2
  185. package/dist/cjs/async-queuer/createAsyncQueuer.cjs +0 -19
  186. package/dist/cjs/async-queuer/createAsyncQueuer.cjs.map +0 -1
  187. package/dist/cjs/async-queuer/index.cjs +0 -12
  188. package/dist/cjs/async-queuer/index.cjs.map +0 -1
  189. package/dist/cjs/async-queuer/index.d.cts +0 -2
  190. package/dist/cjs/async-rate-limiter/createAsyncRateLimiter.cjs +0 -19
  191. package/dist/cjs/async-rate-limiter/createAsyncRateLimiter.cjs.map +0 -1
  192. package/dist/cjs/async-rate-limiter/index.cjs +0 -12
  193. package/dist/cjs/async-rate-limiter/index.cjs.map +0 -1
  194. package/dist/cjs/async-rate-limiter/index.d.cts +0 -2
  195. package/dist/cjs/async-throttler/createAsyncThrottler.cjs +0 -19
  196. package/dist/cjs/async-throttler/createAsyncThrottler.cjs.map +0 -1
  197. package/dist/cjs/async-throttler/index.cjs +0 -12
  198. package/dist/cjs/async-throttler/index.cjs.map +0 -1
  199. package/dist/cjs/async-throttler/index.d.cts +0 -2
  200. package/dist/cjs/batcher/createBatcher.cjs +0 -19
  201. package/dist/cjs/batcher/createBatcher.cjs.map +0 -1
  202. package/dist/cjs/batcher/index.cjs +0 -12
  203. package/dist/cjs/batcher/index.cjs.map +0 -1
  204. package/dist/cjs/batcher/index.d.cts +0 -2
  205. package/dist/cjs/debouncer/createDebouncedSignal.cjs +0 -11
  206. package/dist/cjs/debouncer/createDebouncedSignal.cjs.map +0 -1
  207. package/dist/cjs/debouncer/createDebouncedValue.cjs +0 -17
  208. package/dist/cjs/debouncer/createDebouncedValue.cjs.map +0 -1
  209. package/dist/cjs/debouncer/createDebouncer.cjs +0 -25
  210. package/dist/cjs/debouncer/createDebouncer.cjs.map +0 -1
  211. package/dist/cjs/debouncer/index.cjs +0 -16
  212. package/dist/cjs/debouncer/index.cjs.map +0 -1
  213. package/dist/cjs/debouncer/index.d.cts +0 -4
  214. package/dist/cjs/index.cjs +0 -48
  215. package/dist/cjs/index.cjs.map +0 -1
  216. package/dist/cjs/index.d.cts +0 -22
  217. package/dist/cjs/provider/PacerProvider.cjs +0 -28
  218. package/dist/cjs/provider/PacerProvider.cjs.map +0 -1
  219. package/dist/cjs/provider/PacerProvider.d.cts +0 -25
  220. package/dist/cjs/queuer/createQueuedSignal.cjs +0 -9
  221. package/dist/cjs/queuer/createQueuedSignal.cjs.map +0 -1
  222. package/dist/cjs/queuer/createQueuer.cjs +0 -19
  223. package/dist/cjs/queuer/createQueuer.cjs.map +0 -1
  224. package/dist/cjs/queuer/index.cjs +0 -14
  225. package/dist/cjs/queuer/index.cjs.map +0 -1
  226. package/dist/cjs/queuer/index.d.cts +0 -3
  227. package/dist/cjs/rate-limiter/createRateLimitedSignal.cjs +0 -19
  228. package/dist/cjs/rate-limiter/createRateLimitedSignal.cjs.map +0 -1
  229. package/dist/cjs/rate-limiter/createRateLimitedValue.cjs +0 -13
  230. package/dist/cjs/rate-limiter/createRateLimitedValue.cjs.map +0 -1
  231. package/dist/cjs/rate-limiter/createRateLimiter.cjs +0 -19
  232. package/dist/cjs/rate-limiter/createRateLimiter.cjs.map +0 -1
  233. package/dist/cjs/rate-limiter/index.cjs +0 -16
  234. package/dist/cjs/rate-limiter/index.cjs.map +0 -1
  235. package/dist/cjs/rate-limiter/index.d.cts +0 -4
  236. package/dist/cjs/throttler/createThrottledSignal.cjs +0 -11
  237. package/dist/cjs/throttler/createThrottledSignal.cjs.map +0 -1
  238. package/dist/cjs/throttler/createThrottledValue.cjs +0 -17
  239. package/dist/cjs/throttler/createThrottledValue.cjs.map +0 -1
  240. package/dist/cjs/throttler/createThrottler.cjs +0 -25
  241. package/dist/cjs/throttler/createThrottler.cjs.map +0 -1
  242. package/dist/cjs/throttler/index.cjs +0 -16
  243. package/dist/cjs/throttler/index.cjs.map +0 -1
  244. package/dist/cjs/throttler/index.d.cts +0 -4
  245. package/dist/cjs/types/index.cjs +0 -10
  246. package/dist/cjs/types/index.cjs.map +0 -1
  247. package/dist/cjs/types/index.d.cts +0 -1
  248. package/dist/cjs/utils/index.cjs +0 -10
  249. package/dist/cjs/utils/index.cjs.map +0 -1
  250. package/dist/cjs/utils/index.d.cts +0 -1
  251. package/dist/esm/async-batcher/createAsyncBatcher.js +0 -19
  252. package/dist/esm/async-batcher/createAsyncBatcher.js.map +0 -1
  253. package/dist/esm/async-batcher/index.d.ts +0 -2
  254. package/dist/esm/async-batcher/index.js +0 -6
  255. package/dist/esm/async-batcher/index.js.map +0 -1
  256. package/dist/esm/async-debouncer/createAsyncDebouncer.js +0 -25
  257. package/dist/esm/async-debouncer/createAsyncDebouncer.js.map +0 -1
  258. package/dist/esm/async-debouncer/index.d.ts +0 -2
  259. package/dist/esm/async-debouncer/index.js +0 -6
  260. package/dist/esm/async-debouncer/index.js.map +0 -1
  261. package/dist/esm/async-queuer/createAsyncQueuer.js +0 -19
  262. package/dist/esm/async-queuer/createAsyncQueuer.js.map +0 -1
  263. package/dist/esm/async-queuer/index.d.ts +0 -2
  264. package/dist/esm/async-queuer/index.js +0 -6
  265. package/dist/esm/async-queuer/index.js.map +0 -1
  266. package/dist/esm/async-rate-limiter/createAsyncRateLimiter.js +0 -19
  267. package/dist/esm/async-rate-limiter/createAsyncRateLimiter.js.map +0 -1
  268. package/dist/esm/async-rate-limiter/index.d.ts +0 -2
  269. package/dist/esm/async-rate-limiter/index.js +0 -6
  270. package/dist/esm/async-rate-limiter/index.js.map +0 -1
  271. package/dist/esm/async-throttler/createAsyncThrottler.js +0 -19
  272. package/dist/esm/async-throttler/createAsyncThrottler.js.map +0 -1
  273. package/dist/esm/async-throttler/index.d.ts +0 -2
  274. package/dist/esm/async-throttler/index.js +0 -6
  275. package/dist/esm/async-throttler/index.js.map +0 -1
  276. package/dist/esm/batcher/createBatcher.js +0 -19
  277. package/dist/esm/batcher/createBatcher.js.map +0 -1
  278. package/dist/esm/batcher/index.d.ts +0 -2
  279. package/dist/esm/batcher/index.js +0 -6
  280. package/dist/esm/batcher/index.js.map +0 -1
  281. package/dist/esm/debouncer/createDebouncedSignal.js +0 -11
  282. package/dist/esm/debouncer/createDebouncedSignal.js.map +0 -1
  283. package/dist/esm/debouncer/createDebouncedValue.js +0 -17
  284. package/dist/esm/debouncer/createDebouncedValue.js.map +0 -1
  285. package/dist/esm/debouncer/createDebouncer.js +0 -25
  286. package/dist/esm/debouncer/createDebouncer.js.map +0 -1
  287. package/dist/esm/debouncer/index.d.ts +0 -4
  288. package/dist/esm/debouncer/index.js.map +0 -1
  289. package/dist/esm/index.d.ts +0 -22
  290. package/dist/esm/index.js.map +0 -1
  291. package/dist/esm/provider/PacerProvider.d.ts +0 -25
  292. package/dist/esm/provider/PacerProvider.js +0 -28
  293. package/dist/esm/provider/PacerProvider.js.map +0 -1
  294. package/dist/esm/queuer/createQueuedSignal.js +0 -9
  295. package/dist/esm/queuer/createQueuedSignal.js.map +0 -1
  296. package/dist/esm/queuer/createQueuer.js +0 -19
  297. package/dist/esm/queuer/createQueuer.js.map +0 -1
  298. package/dist/esm/queuer/index.d.ts +0 -3
  299. package/dist/esm/queuer/index.js +0 -8
  300. package/dist/esm/queuer/index.js.map +0 -1
  301. package/dist/esm/rate-limiter/createRateLimitedSignal.js +0 -19
  302. package/dist/esm/rate-limiter/createRateLimitedSignal.js.map +0 -1
  303. package/dist/esm/rate-limiter/createRateLimitedValue.js +0 -13
  304. package/dist/esm/rate-limiter/createRateLimitedValue.js.map +0 -1
  305. package/dist/esm/rate-limiter/createRateLimiter.js +0 -19
  306. package/dist/esm/rate-limiter/createRateLimiter.js.map +0 -1
  307. package/dist/esm/rate-limiter/index.d.ts +0 -4
  308. package/dist/esm/rate-limiter/index.js.map +0 -1
  309. package/dist/esm/throttler/createThrottledSignal.js +0 -11
  310. package/dist/esm/throttler/createThrottledSignal.js.map +0 -1
  311. package/dist/esm/throttler/createThrottledValue.js +0 -17
  312. package/dist/esm/throttler/createThrottledValue.js.map +0 -1
  313. package/dist/esm/throttler/createThrottler.js +0 -25
  314. package/dist/esm/throttler/createThrottler.js.map +0 -1
  315. package/dist/esm/throttler/index.d.ts +0 -4
  316. package/dist/esm/throttler/index.js.map +0 -1
  317. package/dist/esm/types/index.d.ts +0 -1
  318. package/dist/esm/types/index.js +0 -2
  319. package/dist/esm/types/index.js.map +0 -1
  320. package/dist/esm/utils/index.d.ts +0 -1
  321. package/dist/esm/utils/index.js +0 -2
  322. package/dist/esm/utils/index.js.map +0 -1
@@ -1,6 +1,9 @@
1
- import { SolidRateLimiter } from './createRateLimiter.cjs';
2
- import { Accessor, Setter } from 'solid-js';
3
- import { RateLimiterOptions, RateLimiterState } from '@tanstack/pacer/rate-limiter';
1
+ import { SolidRateLimiter } from "./createRateLimiter.cjs";
2
+ import { Accessor, Setter } from "solid-js";
3
+ import { RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
4
+
5
+ //#region src/rate-limiter/createRateLimitedSignal.d.ts
6
+
4
7
  /**
5
8
  * A Solid hook that creates a rate-limited state value that enforces a hard limit on state updates within a time window.
6
9
  * This hook combines Solid's createSignal with rate limiting functionality to provide controlled state updates.
@@ -86,8 +89,7 @@ import { RateLimiterOptions, RateLimiterState } from '@tanstack/pacer/rate-limit
86
89
  * };
87
90
  * ```
88
91
  */
89
- export declare function createRateLimitedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): [
90
- Accessor<TValue>,
91
- Setter<TValue>,
92
- SolidRateLimiter<Setter<TValue>, TSelected>
93
- ];
92
+ declare function createRateLimitedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>];
93
+ //#endregion
94
+ export { createRateLimitedSignal };
95
+ //# sourceMappingURL=createRateLimitedSignal.d.cts.map
@@ -1,6 +1,9 @@
1
- import { SolidRateLimiter } from './createRateLimiter.js';
2
- import { Accessor, Setter } from 'solid-js';
3
- import { RateLimiterOptions, RateLimiterState } from '@tanstack/pacer/rate-limiter';
1
+ import { SolidRateLimiter } from "./createRateLimiter.js";
2
+ import { Accessor, Setter } from "solid-js";
3
+ import { RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
4
+
5
+ //#region src/rate-limiter/createRateLimitedSignal.d.ts
6
+
4
7
  /**
5
8
  * A Solid hook that creates a rate-limited state value that enforces a hard limit on state updates within a time window.
6
9
  * This hook combines Solid's createSignal with rate limiting functionality to provide controlled state updates.
@@ -86,8 +89,7 @@ import { RateLimiterOptions, RateLimiterState } from '@tanstack/pacer/rate-limit
86
89
  * };
87
90
  * ```
88
91
  */
89
- export declare function createRateLimitedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): [
90
- Accessor<TValue>,
91
- Setter<TValue>,
92
- SolidRateLimiter<Setter<TValue>, TSelected>
93
- ];
92
+ declare function createRateLimitedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>];
93
+ //#endregion
94
+ export { createRateLimitedSignal };
95
+ //# sourceMappingURL=createRateLimitedSignal.d.ts.map
@@ -0,0 +1,102 @@
1
+ import { createRateLimiter } from "./createRateLimiter.js";
2
+ import { createSignal } from "solid-js";
3
+
4
+ //#region src/rate-limiter/createRateLimitedSignal.ts
5
+ /**
6
+ * A Solid hook that creates a rate-limited state value that enforces a hard limit on state updates within a time window.
7
+ * This hook combines Solid's createSignal with rate limiting functionality to provide controlled state updates.
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. This can lead to bursts of rapid updates followed by periods of no updates.
12
+ *
13
+ * The rate limiter supports two types of windows:
14
+ * - 'fixed': A strict window that resets after the window period. All updates within the window count
15
+ * towards the limit, and the window resets completely after the period.
16
+ * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more
17
+ * consistent rate of updates over time.
18
+ *
19
+ * For smoother update patterns, consider:
20
+ * - createThrottledSignal: When you want consistent spacing between updates (e.g. UI changes)
21
+ * - createDebouncedSignal: When you want to collapse rapid updates into a single update (e.g. search input)
22
+ *
23
+ * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.
24
+ *
25
+ * The hook returns a tuple containing:
26
+ * - The rate-limited state value accessor
27
+ * - A rate-limited setter function that respects the configured limits
28
+ * - The rateLimiter instance for additional control
29
+ *
30
+ * For more direct control over rate limiting without state management,
31
+ * consider using the lower-level createRateLimiter hook instead.
32
+ *
33
+ * ## State Management and Selector
34
+ *
35
+ * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.
36
+ * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,
37
+ * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
38
+ *
39
+ * **By default, there will be no reactive state subscriptions** and you must opt-in to state
40
+ * tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
41
+ * full control over when your component subscribes to state changes. Only when you provide a selector will
42
+ * the reactive system track the selected state values.
43
+ *
44
+ * Available rate limiter state properties:
45
+ * - `callsInWindow`: Number of calls made in the current window
46
+ * - `remainingInWindow`: Number of calls remaining in the current window
47
+ * - `windowStart`: Unix timestamp when the current window started
48
+ * - `nextWindowStart`: Unix timestamp when the next window will start
49
+ * - `msUntilNextWindow`: Milliseconds until the next window starts
50
+ * - `isAtLimit`: Whether the call limit for the current window has been reached
51
+ * - `status`: Current status ('disabled' | 'idle' | 'at-limit')
52
+ *
53
+ * @example
54
+ * ```tsx
55
+ * // Default behavior - no reactive state subscriptions
56
+ * const [value, setValue, rateLimiter] = createRateLimitedSignal(0, {
57
+ * limit: 5,
58
+ * window: 60000,
59
+ * windowType: 'sliding'
60
+ * });
61
+ *
62
+ * // Opt-in to reactive updates when limit state changes (optimized for UI feedback)
63
+ * const [value, setValue, rateLimiter] = createRateLimitedSignal(
64
+ * 0,
65
+ * { limit: 5, window: 60000 },
66
+ * (state) => ({ isAtLimit: state.isAtLimit, remainingInWindow: state.remainingInWindow })
67
+ * );
68
+ *
69
+ * // With rejection callback and fixed window
70
+ * const [value, setValue] = createRateLimitedSignal(0, {
71
+ * limit: 3,
72
+ * window: 5000,
73
+ * windowType: 'fixed',
74
+ * onReject: (rateLimiter) => {
75
+ * alert(`Rate limit reached. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);
76
+ * }
77
+ * });
78
+ *
79
+ * // Access rateLimiter state via signals
80
+ * const handleSubmit = () => {
81
+ * const remaining = rateLimiter.state().remainingInWindow;
82
+ * if (remaining > 0) {
83
+ * setValue(newValue);
84
+ * } else {
85
+ * showRateLimitWarning();
86
+ * }
87
+ * };
88
+ * ```
89
+ */
90
+ function createRateLimitedSignal(value, initialOptions, selector) {
91
+ const [rateLimitedValue, setRateLimitedValue] = createSignal(value);
92
+ const rateLimiter = createRateLimiter(setRateLimitedValue, initialOptions, selector);
93
+ return [
94
+ rateLimitedValue,
95
+ rateLimiter.maybeExecute,
96
+ rateLimiter
97
+ ];
98
+ }
99
+
100
+ //#endregion
101
+ export { createRateLimitedSignal };
102
+ //# sourceMappingURL=createRateLimitedSignal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRateLimitedSignal.js","names":[],"sources":["../../src/rate-limiter/createRateLimitedSignal.ts"],"sourcesContent":["import { createSignal } from 'solid-js'\nimport { createRateLimiter } from './createRateLimiter'\nimport type { SolidRateLimiter } from './createRateLimiter'\nimport type { Accessor, Setter } from 'solid-js'\nimport type {\n RateLimiterOptions,\n RateLimiterState,\n} from '@tanstack/pacer/rate-limiter'\n\n/**\n * A Solid hook that creates a rate-limited state value that enforces a hard limit on state updates within a time window.\n * This hook combines Solid's createSignal with rate limiting functionality to provide controlled state updates.\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. This can lead to bursts of rapid updates followed by periods of no updates.\n *\n * The rate limiter supports two types of windows:\n * - 'fixed': A strict window that resets after the window period. All updates within the window count\n * towards the limit, and the window resets completely after the period.\n * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more\n * consistent rate of updates over time.\n *\n * For smoother update patterns, consider:\n * - createThrottledSignal: When you want consistent spacing between updates (e.g. UI changes)\n * - createDebouncedSignal: When you want to collapse rapid updates into a single update (e.g. search input)\n *\n * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.\n *\n * The hook returns a tuple containing:\n * - The rate-limited state value accessor\n * - A rate-limited setter function that respects the configured limits\n * - The rateLimiter instance for additional control\n *\n * For more direct control over rate limiting without state management,\n * consider using the lower-level createRateLimiter hook instead.\n *\n * ## State Management and Selector\n *\n * The hook 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 reactive 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available rate limiter state properties:\n * - `callsInWindow`: Number of calls made in the current window\n * - `remainingInWindow`: Number of calls remaining in the current window\n * - `windowStart`: Unix timestamp when the current window started\n * - `nextWindowStart`: Unix timestamp when the next window will start\n * - `msUntilNextWindow`: Milliseconds until the next window starts\n * - `isAtLimit`: Whether the call limit for the current window has been reached\n * - `status`: Current status ('disabled' | 'idle' | 'at-limit')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [value, setValue, rateLimiter] = createRateLimitedSignal(0, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding'\n * });\n *\n * // Opt-in to reactive updates when limit state changes (optimized for UI feedback)\n * const [value, setValue, rateLimiter] = createRateLimitedSignal(\n * 0,\n * { limit: 5, window: 60000 },\n * (state) => ({ isAtLimit: state.isAtLimit, remainingInWindow: state.remainingInWindow })\n * );\n *\n * // With rejection callback and fixed window\n * const [value, setValue] = createRateLimitedSignal(0, {\n * limit: 3,\n * window: 5000,\n * windowType: 'fixed',\n * onReject: (rateLimiter) => {\n * alert(`Rate limit reached. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);\n * }\n * });\n *\n * // Access rateLimiter state via signals\n * const handleSubmit = () => {\n * const remaining = rateLimiter.state().remainingInWindow;\n * if (remaining > 0) {\n * setValue(newValue);\n * } else {\n * showRateLimitWarning();\n * }\n * };\n * ```\n */\nexport function createRateLimitedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: RateLimiterOptions<Setter<TValue>>,\n selector?: (state: RateLimiterState) => TSelected,\n): [\n Accessor<TValue>,\n Setter<TValue>,\n SolidRateLimiter<Setter<TValue>, TSelected>,\n] {\n const [rateLimitedValue, setRateLimitedValue] = createSignal<TValue>(value)\n\n const rateLimiter = createRateLimiter(\n setRateLimitedValue,\n initialOptions,\n selector,\n )\n\n return [\n rateLimitedValue,\n rateLimiter.maybeExecute as Setter<TValue>,\n rateLimiter,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8FA,SAAgB,wBACd,OACA,gBACA,UAKA;CACA,MAAM,CAAC,kBAAkB,uBAAuB,aAAqB,MAAM;CAE3E,MAAM,cAAc,kBAClB,qBACA,gBACA,SACD;AAED,QAAO;EACL;EACA,YAAY;EACZ;EACD"}
@@ -0,0 +1,102 @@
1
+ const require_createRateLimitedSignal = require('./createRateLimitedSignal.cjs');
2
+ let solid_js = require("solid-js");
3
+
4
+ //#region src/rate-limiter/createRateLimitedValue.ts
5
+ /**
6
+ * A high-level Solid hook that creates a rate-limited version of a value that updates at most a certain number of times within a time window.
7
+ * This hook uses Solid's createSignal internally to manage the rate-limited state.
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. This can lead to bursts of rapid updates followed by periods of no updates.
12
+ *
13
+ * The rate limiter supports two types of windows:
14
+ * - 'fixed': A strict window that resets after the window period. All updates within the window count
15
+ * towards the limit, and the window resets completely after the period.
16
+ * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more
17
+ * consistent rate of updates over time.
18
+ *
19
+ * For smoother update patterns, consider:
20
+ * - createThrottledValue: When you want consistent spacing between updates (e.g. UI changes)
21
+ * - createDebouncedValue: When you want to collapse rapid updates into a single update (e.g. search input)
22
+ *
23
+ * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.
24
+ *
25
+ * The hook returns a tuple containing:
26
+ * - An accessor function that provides the rate-limited value
27
+ * - The rate limiter instance with control methods
28
+ *
29
+ * For more direct control over rate limiting behavior without Solid state management,
30
+ * consider using the lower-level createRateLimiter hook instead.
31
+ *
32
+ * ## State Management and Selector
33
+ *
34
+ * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.
35
+ * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,
36
+ * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
37
+ *
38
+ * **By default, there will be no reactive state subscriptions** and you must opt-in to state
39
+ * tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
40
+ * full control over when your component subscribes to state changes. Only when you provide a selector will
41
+ * the reactive system track the selected state values.
42
+ *
43
+ * Available rate limiter state properties:
44
+ * - `executionCount`: Number of function executions that have been completed
45
+ * - `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations
46
+ * - `rejectionCount`: Number of function executions that have been rejected due to rate limiting
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * // Default behavior - no reactive state subscriptions
51
+ * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {
52
+ * limit: 5,
53
+ * window: 60000,
54
+ * windowType: 'sliding'
55
+ * });
56
+ *
57
+ * // Opt-in to reactive updates when execution count changes (optimized for tracking successful updates)
58
+ * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
59
+ * rawValue,
60
+ * { limit: 5, window: 60000, windowType: 'sliding' },
61
+ * (state) => ({ executionCount: state.executionCount })
62
+ * );
63
+ *
64
+ * // Opt-in to reactive updates when rejection count changes (optimized for tracking rate limit violations)
65
+ * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
66
+ * rawValue,
67
+ * { limit: 5, window: 60000, windowType: 'sliding' },
68
+ * (state) => ({ rejectionCount: state.rejectionCount })
69
+ * );
70
+ *
71
+ * // Opt-in to reactive updates when execution times change (optimized for window calculations)
72
+ * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
73
+ * rawValue,
74
+ * { limit: 5, window: 60000, windowType: 'sliding' },
75
+ * (state) => ({ executionTimes: state.executionTimes })
76
+ * );
77
+ *
78
+ * // With rejection callback and fixed window
79
+ * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {
80
+ * limit: 3,
81
+ * window: 5000,
82
+ * windowType: 'fixed',
83
+ * onReject: (rateLimiter) => {
84
+ * console.log(`Update rejected. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);
85
+ * }
86
+ * });
87
+ *
88
+ * // Access the selected rate limiter state (will be empty object {} unless selector provided)
89
+ * const { executionCount, rejectionCount } = rateLimiter.state;
90
+ * ```
91
+ */
92
+ function createRateLimitedValue(value, initialOptions, selector) {
93
+ const [rateLimitedValue, setRateLimitedValue, rateLimiter] = require_createRateLimitedSignal.createRateLimitedSignal(value(), initialOptions, selector);
94
+ (0, solid_js.createEffect)(() => {
95
+ setRateLimitedValue(value());
96
+ });
97
+ return [rateLimitedValue, rateLimiter];
98
+ }
99
+
100
+ //#endregion
101
+ exports.createRateLimitedValue = createRateLimitedValue;
102
+ //# sourceMappingURL=createRateLimitedValue.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRateLimitedValue.cjs","names":["createRateLimitedSignal"],"sources":["../../src/rate-limiter/createRateLimitedValue.ts"],"sourcesContent":["import { createEffect } from 'solid-js'\nimport { createRateLimitedSignal } from './createRateLimitedSignal'\nimport type { SolidRateLimiter } from './createRateLimiter'\nimport type { Accessor, Setter } from 'solid-js'\nimport type {\n RateLimiterOptions,\n RateLimiterState,\n} from '@tanstack/pacer/rate-limiter'\n\n/**\n * A high-level Solid hook that creates a rate-limited version of a value that updates at most a certain number of times within a time window.\n * This hook uses Solid's createSignal internally to manage the rate-limited state.\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. This can lead to bursts of rapid updates followed by periods of no updates.\n *\n * The rate limiter supports two types of windows:\n * - 'fixed': A strict window that resets after the window period. All updates within the window count\n * towards the limit, and the window resets completely after the period.\n * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more\n * consistent rate of updates over time.\n *\n * For smoother update patterns, consider:\n * - createThrottledValue: When you want consistent spacing between updates (e.g. UI changes)\n * - createDebouncedValue: When you want to collapse rapid updates into a single update (e.g. search input)\n *\n * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.\n *\n * The hook returns a tuple containing:\n * - An accessor function that provides the rate-limited value\n * - The rate limiter instance with control methods\n *\n * For more direct control over rate limiting behavior without Solid state management,\n * consider using the lower-level createRateLimiter hook instead.\n *\n * ## State Management and Selector\n *\n * The hook 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 reactive 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available rate limiter 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 * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding'\n * });\n *\n * // Opt-in to reactive updates when execution count changes (optimized for tracking successful updates)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ executionCount: state.executionCount })\n * );\n *\n * // Opt-in to reactive updates when rejection count changes (optimized for tracking rate limit violations)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ rejectionCount: state.rejectionCount })\n * );\n *\n * // Opt-in to reactive updates when execution times change (optimized for window calculations)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ executionTimes: state.executionTimes })\n * );\n *\n * // With rejection callback and fixed window\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {\n * limit: 3,\n * window: 5000,\n * windowType: 'fixed',\n * onReject: (rateLimiter) => {\n * console.log(`Update rejected. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);\n * }\n * });\n *\n * // Access the selected rate limiter state (will be empty object {} unless selector provided)\n * const { executionCount, rejectionCount } = rateLimiter.state;\n * ```\n */\nexport function createRateLimitedValue<TValue, TSelected = {}>(\n value: Accessor<TValue>,\n initialOptions: RateLimiterOptions<Setter<TValue>>,\n selector?: (state: RateLimiterState) => TSelected,\n): [Accessor<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>] {\n const [rateLimitedValue, setRateLimitedValue, rateLimiter] =\n createRateLimitedSignal(value(), initialOptions, selector)\n\n createEffect(() => {\n setRateLimitedValue(value() as any)\n })\n\n return [rateLimitedValue, rateLimiter]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,SAAgB,uBACd,OACA,gBACA,UACiE;CACjE,MAAM,CAAC,kBAAkB,qBAAqB,eAC5CA,wDAAwB,OAAO,EAAE,gBAAgB,SAAS;AAE5D,kCAAmB;AACjB,sBAAoB,OAAO,CAAQ;GACnC;AAEF,QAAO,CAAC,kBAAkB,YAAY"}
@@ -1,6 +1,9 @@
1
- import { SolidRateLimiter } from './createRateLimiter.cjs';
2
- import { Accessor, Setter } from 'solid-js';
3
- import { RateLimiterOptions, RateLimiterState } from '@tanstack/pacer/rate-limiter';
1
+ import { SolidRateLimiter } from "./createRateLimiter.cjs";
2
+ import { Accessor, Setter } from "solid-js";
3
+ import { RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
4
+
5
+ //#region src/rate-limiter/createRateLimitedValue.d.ts
6
+
4
7
  /**
5
8
  * A high-level Solid hook that creates a rate-limited version of a value that updates at most a certain number of times within a time window.
6
9
  * This hook uses Solid's createSignal internally to manage the rate-limited state.
@@ -88,4 +91,7 @@ import { RateLimiterOptions, RateLimiterState } from '@tanstack/pacer/rate-limit
88
91
  * const { executionCount, rejectionCount } = rateLimiter.state;
89
92
  * ```
90
93
  */
91
- export declare function createRateLimitedValue<TValue, TSelected = {}>(value: Accessor<TValue>, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): [Accessor<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>];
94
+ declare function createRateLimitedValue<TValue, TSelected = {}>(value: Accessor<TValue>, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): [Accessor<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>];
95
+ //#endregion
96
+ export { createRateLimitedValue };
97
+ //# sourceMappingURL=createRateLimitedValue.d.cts.map
@@ -1,6 +1,9 @@
1
- import { SolidRateLimiter } from './createRateLimiter.js';
2
- import { Accessor, Setter } from 'solid-js';
3
- import { RateLimiterOptions, RateLimiterState } from '@tanstack/pacer/rate-limiter';
1
+ import { SolidRateLimiter } from "./createRateLimiter.js";
2
+ import { Accessor, Setter } from "solid-js";
3
+ import { RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
4
+
5
+ //#region src/rate-limiter/createRateLimitedValue.d.ts
6
+
4
7
  /**
5
8
  * A high-level Solid hook that creates a rate-limited version of a value that updates at most a certain number of times within a time window.
6
9
  * This hook uses Solid's createSignal internally to manage the rate-limited state.
@@ -88,4 +91,7 @@ import { RateLimiterOptions, RateLimiterState } from '@tanstack/pacer/rate-limit
88
91
  * const { executionCount, rejectionCount } = rateLimiter.state;
89
92
  * ```
90
93
  */
91
- export declare function createRateLimitedValue<TValue, TSelected = {}>(value: Accessor<TValue>, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): [Accessor<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>];
94
+ declare function createRateLimitedValue<TValue, TSelected = {}>(value: Accessor<TValue>, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): [Accessor<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>];
95
+ //#endregion
96
+ export { createRateLimitedValue };
97
+ //# sourceMappingURL=createRateLimitedValue.d.ts.map
@@ -0,0 +1,102 @@
1
+ import { createRateLimitedSignal } from "./createRateLimitedSignal.js";
2
+ import { createEffect } from "solid-js";
3
+
4
+ //#region src/rate-limiter/createRateLimitedValue.ts
5
+ /**
6
+ * A high-level Solid hook that creates a rate-limited version of a value that updates at most a certain number of times within a time window.
7
+ * This hook uses Solid's createSignal internally to manage the rate-limited state.
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. This can lead to bursts of rapid updates followed by periods of no updates.
12
+ *
13
+ * The rate limiter supports two types of windows:
14
+ * - 'fixed': A strict window that resets after the window period. All updates within the window count
15
+ * towards the limit, and the window resets completely after the period.
16
+ * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more
17
+ * consistent rate of updates over time.
18
+ *
19
+ * For smoother update patterns, consider:
20
+ * - createThrottledValue: When you want consistent spacing between updates (e.g. UI changes)
21
+ * - createDebouncedValue: When you want to collapse rapid updates into a single update (e.g. search input)
22
+ *
23
+ * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.
24
+ *
25
+ * The hook returns a tuple containing:
26
+ * - An accessor function that provides the rate-limited value
27
+ * - The rate limiter instance with control methods
28
+ *
29
+ * For more direct control over rate limiting behavior without Solid state management,
30
+ * consider using the lower-level createRateLimiter hook instead.
31
+ *
32
+ * ## State Management and Selector
33
+ *
34
+ * The hook uses TanStack Store for reactive state management via the underlying rate limiter instance.
35
+ * The `selector` parameter allows you to specify which rate limiter state changes will trigger reactive updates,
36
+ * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
37
+ *
38
+ * **By default, there will be no reactive state subscriptions** and you must opt-in to state
39
+ * tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
40
+ * full control over when your component subscribes to state changes. Only when you provide a selector will
41
+ * the reactive system track the selected state values.
42
+ *
43
+ * Available rate limiter state properties:
44
+ * - `executionCount`: Number of function executions that have been completed
45
+ * - `executionTimes`: Array of timestamps when executions occurred for rate limiting calculations
46
+ * - `rejectionCount`: Number of function executions that have been rejected due to rate limiting
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * // Default behavior - no reactive state subscriptions
51
+ * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {
52
+ * limit: 5,
53
+ * window: 60000,
54
+ * windowType: 'sliding'
55
+ * });
56
+ *
57
+ * // Opt-in to reactive updates when execution count changes (optimized for tracking successful updates)
58
+ * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
59
+ * rawValue,
60
+ * { limit: 5, window: 60000, windowType: 'sliding' },
61
+ * (state) => ({ executionCount: state.executionCount })
62
+ * );
63
+ *
64
+ * // Opt-in to reactive updates when rejection count changes (optimized for tracking rate limit violations)
65
+ * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
66
+ * rawValue,
67
+ * { limit: 5, window: 60000, windowType: 'sliding' },
68
+ * (state) => ({ rejectionCount: state.rejectionCount })
69
+ * );
70
+ *
71
+ * // Opt-in to reactive updates when execution times change (optimized for window calculations)
72
+ * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(
73
+ * rawValue,
74
+ * { limit: 5, window: 60000, windowType: 'sliding' },
75
+ * (state) => ({ executionTimes: state.executionTimes })
76
+ * );
77
+ *
78
+ * // With rejection callback and fixed window
79
+ * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {
80
+ * limit: 3,
81
+ * window: 5000,
82
+ * windowType: 'fixed',
83
+ * onReject: (rateLimiter) => {
84
+ * console.log(`Update rejected. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);
85
+ * }
86
+ * });
87
+ *
88
+ * // Access the selected rate limiter state (will be empty object {} unless selector provided)
89
+ * const { executionCount, rejectionCount } = rateLimiter.state;
90
+ * ```
91
+ */
92
+ function createRateLimitedValue(value, initialOptions, selector) {
93
+ const [rateLimitedValue, setRateLimitedValue, rateLimiter] = createRateLimitedSignal(value(), initialOptions, selector);
94
+ createEffect(() => {
95
+ setRateLimitedValue(value());
96
+ });
97
+ return [rateLimitedValue, rateLimiter];
98
+ }
99
+
100
+ //#endregion
101
+ export { createRateLimitedValue };
102
+ //# sourceMappingURL=createRateLimitedValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRateLimitedValue.js","names":[],"sources":["../../src/rate-limiter/createRateLimitedValue.ts"],"sourcesContent":["import { createEffect } from 'solid-js'\nimport { createRateLimitedSignal } from './createRateLimitedSignal'\nimport type { SolidRateLimiter } from './createRateLimiter'\nimport type { Accessor, Setter } from 'solid-js'\nimport type {\n RateLimiterOptions,\n RateLimiterState,\n} from '@tanstack/pacer/rate-limiter'\n\n/**\n * A high-level Solid hook that creates a rate-limited version of a value that updates at most a certain number of times within a time window.\n * This hook uses Solid's createSignal internally to manage the rate-limited state.\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. This can lead to bursts of rapid updates followed by periods of no updates.\n *\n * The rate limiter supports two types of windows:\n * - 'fixed': A strict window that resets after the window period. All updates within the window count\n * towards the limit, and the window resets completely after the period.\n * - 'sliding': A rolling window that allows updates as old ones expire. This provides a more\n * consistent rate of updates over time.\n *\n * For smoother update patterns, consider:\n * - createThrottledValue: When you want consistent spacing between updates (e.g. UI changes)\n * - createDebouncedValue: When you want to collapse rapid updates into a single update (e.g. search input)\n *\n * Rate limiting should primarily be used when you need to enforce strict limits, like API rate limits.\n *\n * The hook returns a tuple containing:\n * - An accessor function that provides the rate-limited value\n * - The rate limiter instance with control methods\n *\n * For more direct control over rate limiting behavior without Solid state management,\n * consider using the lower-level createRateLimiter hook instead.\n *\n * ## State Management and Selector\n *\n * The hook 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 reactive 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available rate limiter 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 * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding'\n * });\n *\n * // Opt-in to reactive updates when execution count changes (optimized for tracking successful updates)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ executionCount: state.executionCount })\n * );\n *\n * // Opt-in to reactive updates when rejection count changes (optimized for tracking rate limit violations)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ rejectionCount: state.rejectionCount })\n * );\n *\n * // Opt-in to reactive updates when execution times change (optimized for window calculations)\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(\n * rawValue,\n * { limit: 5, window: 60000, windowType: 'sliding' },\n * (state) => ({ executionTimes: state.executionTimes })\n * );\n *\n * // With rejection callback and fixed window\n * const [rateLimitedValue, rateLimiter] = createRateLimitedValue(rawValue, {\n * limit: 3,\n * window: 5000,\n * windowType: 'fixed',\n * onReject: (rateLimiter) => {\n * console.log(`Update rejected. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);\n * }\n * });\n *\n * // Access the selected rate limiter state (will be empty object {} unless selector provided)\n * const { executionCount, rejectionCount } = rateLimiter.state;\n * ```\n */\nexport function createRateLimitedValue<TValue, TSelected = {}>(\n value: Accessor<TValue>,\n initialOptions: RateLimiterOptions<Setter<TValue>>,\n selector?: (state: RateLimiterState) => TSelected,\n): [Accessor<TValue>, SolidRateLimiter<Setter<TValue>, TSelected>] {\n const [rateLimitedValue, setRateLimitedValue, rateLimiter] =\n createRateLimitedSignal(value(), initialOptions, selector)\n\n createEffect(() => {\n setRateLimitedValue(value() as any)\n })\n\n return [rateLimitedValue, rateLimiter]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,SAAgB,uBACd,OACA,gBACA,UACiE;CACjE,MAAM,CAAC,kBAAkB,qBAAqB,eAC5C,wBAAwB,OAAO,EAAE,gBAAgB,SAAS;AAE5D,oBAAmB;AACjB,sBAAoB,OAAO,CAAQ;GACnC;AAEF,QAAO,CAAC,kBAAkB,YAAY"}
@@ -0,0 +1,95 @@
1
+ const require_PacerProvider = require('../provider/PacerProvider.cjs');
2
+ let __tanstack_solid_store = require("@tanstack/solid-store");
3
+ let __tanstack_pacer_rate_limiter = require("@tanstack/pacer/rate-limiter");
4
+
5
+ //#region src/rate-limiter/createRateLimiter.ts
6
+ /**
7
+ * A low-level Solid hook that creates a `RateLimiter` instance to enforce rate limits on function execution.
8
+ *
9
+ * This hook is designed to be flexible and state-management agnostic - it simply returns a rate limiter instance that
10
+ * you can integrate with any state management solution (createSignal, etc).
11
+ *
12
+ * Rate limiting is a simple "hard limit" approach that allows executions until a maximum count is reached within
13
+ * a time window, then blocks all subsequent calls until the window resets. Unlike throttling or debouncing,
14
+ * it does not attempt to space out or collapse executions intelligently.
15
+ *
16
+ * The rate limiter supports two types of windows:
17
+ * - 'fixed': A strict window that resets after the window period. All executions within the window count
18
+ * towards the limit, and the window resets completely after the period.
19
+ * - 'sliding': A rolling window that allows executions as old ones expire. This provides a more
20
+ * consistent rate of execution over time.
21
+ *
22
+ * For smoother execution patterns:
23
+ * - Use throttling when you want consistent spacing between executions (e.g. UI updates)
24
+ * - Use debouncing when you want to collapse rapid-fire events (e.g. search input)
25
+ * - Use rate limiting only when you need to enforce hard limits (e.g. API rate limits)
26
+ *
27
+ * ## State Management and Selector
28
+ *
29
+ * The hook uses TanStack Store for reactive state management. The `selector` parameter allows you
30
+ * to specify which state changes will trigger a re-render, optimizing performance by preventing
31
+ * unnecessary re-renders when irrelevant state changes occur.
32
+ *
33
+ * **By default, there will be no reactive state subscriptions** and you must opt-in to state
34
+ * tracking by providing a selector function. This prevents unnecessary re-renders and gives you
35
+ * full control over when your component updates. Only when you provide a selector will the
36
+ * component re-render when the selected state values change.
37
+ *
38
+ * Available state properties:
39
+ * - `executionCount`: Number of function executions that have been completed
40
+ * - `rejectionCount`: Number of function calls that were rejected due to rate limiting
41
+ * - `remainingInWindow`: Number of executions remaining in the current window
42
+ * - `nextWindowTime`: Timestamp when the next window begins
43
+ * - `currentWindowStart`: Timestamp when the current window started
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * // Default behavior - no reactive state subscriptions
48
+ * const rateLimiter = createRateLimiter(apiCall, {
49
+ * limit: 5,
50
+ * window: 60000,
51
+ * windowType: 'sliding',
52
+ * onReject: (rateLimiter) => {
53
+ * console.log(`Rate limit exceeded. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);
54
+ * }
55
+ * });
56
+ *
57
+ * // Opt-in to re-render when rate limit state changes (optimized for UI feedback)
58
+ * const rateLimiter = createRateLimiter(
59
+ * apiCall,
60
+ * { limit: 5, window: 60000 },
61
+ * (state) => ({
62
+ * remainingInWindow: state.remainingInWindow,
63
+ * rejectionCount: state.rejectionCount
64
+ * })
65
+ * );
66
+ *
67
+ * // Opt-in to re-render when execution metrics change (optimized for tracking progress)
68
+ * const rateLimiter = createRateLimiter(
69
+ * apiCall,
70
+ * { limit: 5, window: 60000 },
71
+ * (state) => ({
72
+ * executionCount: state.executionCount,
73
+ * nextWindowTime: state.nextWindowTime
74
+ * })
75
+ * );
76
+ *
77
+ * // Access the selected state (will be empty object {} unless selector provided)
78
+ * const { remainingInWindow, rejectionCount } = rateLimiter.state();
79
+ * ```
80
+ */
81
+ function createRateLimiter(fn, options, selector = () => ({})) {
82
+ const rateLimiter = new __tanstack_pacer_rate_limiter.RateLimiter(fn, {
83
+ ...require_PacerProvider.useDefaultPacerOptions().rateLimiter,
84
+ ...options
85
+ });
86
+ const state = (0, __tanstack_solid_store.useStore)(rateLimiter.store, selector);
87
+ return {
88
+ ...rateLimiter,
89
+ state
90
+ };
91
+ }
92
+
93
+ //#endregion
94
+ exports.createRateLimiter = createRateLimiter;
95
+ //# sourceMappingURL=createRateLimiter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRateLimiter.cjs","names":["RateLimiter","useDefaultPacerOptions"],"sources":["../../src/rate-limiter/createRateLimiter.ts"],"sourcesContent":["import { RateLimiter } from '@tanstack/pacer/rate-limiter'\nimport { useStore } from '@tanstack/solid-store'\nimport { useDefaultPacerOptions } from '../provider/PacerProvider'\nimport type { Store } from '@tanstack/solid-store'\nimport type { Accessor } from 'solid-js'\nimport type { AnyFunction } from '@tanstack/pacer/types'\nimport type {\n RateLimiterOptions,\n RateLimiterState,\n} from '@tanstack/pacer/rate-limiter'\n\nexport interface SolidRateLimiter<\n TFn extends AnyFunction,\n TSelected = {},\n> extends Omit<RateLimiter<TFn>, 'store'> {\n /**\n * Reactive state that will be updated when the rate limiter state changes\n *\n * Use this instead of `rateLimiter.store.state`\n */\n readonly state: Accessor<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, as it has not been wrapped in a `useStore` hook internally.\n * Although, you can make the state reactive by using the `useStore` in your own usage.\n */\n readonly store: Store<Readonly<RateLimiterState>>\n}\n\n/**\n * A low-level Solid hook that creates a `RateLimiter` instance to enforce rate limits on function execution.\n *\n * This hook is designed to be flexible and state-management agnostic - it simply returns a rate limiter instance that\n * you can integrate with any state management solution (createSignal, etc).\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 hook uses TanStack Store for reactive state management. The `selector` parameter allows you\n * to specify which state changes will trigger a re-render, optimizing performance by preventing\n * unnecessary re-renders 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 re-renders and gives you\n * full control over when your component updates. Only when you provide a selector will the\n * component re-render when the selected state values change.\n *\n * Available state properties:\n * - `executionCount`: Number of function executions that have been completed\n * - `rejectionCount`: Number of function calls that were rejected due to rate limiting\n * - `remainingInWindow`: Number of executions remaining in the current window\n * - `nextWindowTime`: Timestamp when the next window begins\n * - `currentWindowStart`: Timestamp when the current window started\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const rateLimiter = createRateLimiter(apiCall, {\n * limit: 5,\n * window: 60000,\n * windowType: 'sliding',\n * onReject: (rateLimiter) => {\n * console.log(`Rate limit exceeded. Try again in ${rateLimiter.getMsUntilNextWindow()}ms`);\n * }\n * });\n *\n * // Opt-in to re-render when rate limit state changes (optimized for UI feedback)\n * const rateLimiter = createRateLimiter(\n * apiCall,\n * { limit: 5, window: 60000 },\n * (state) => ({\n * remainingInWindow: state.remainingInWindow,\n * rejectionCount: state.rejectionCount\n * })\n * );\n *\n * // Opt-in to re-render when execution metrics change (optimized for tracking progress)\n * const rateLimiter = createRateLimiter(\n * apiCall,\n * { limit: 5, window: 60000 },\n * (state) => ({\n * executionCount: state.executionCount,\n * nextWindowTime: state.nextWindowTime\n * })\n * );\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { remainingInWindow, rejectionCount } = rateLimiter.state();\n * ```\n */\nexport function createRateLimiter<TFn extends AnyFunction, TSelected = {}>(\n fn: TFn,\n options: RateLimiterOptions<TFn>,\n selector: (state: RateLimiterState) => TSelected = () => ({}) as TSelected,\n): SolidRateLimiter<TFn, TSelected> {\n const mergedOptions = {\n ...useDefaultPacerOptions().rateLimiter,\n ...options,\n } as RateLimiterOptions<TFn>\n\n const rateLimiter = new RateLimiter<TFn>(fn, mergedOptions)\n\n const state = useStore(rateLimiter.store, selector)\n\n return {\n ...rateLimiter,\n state,\n } as SolidRateLimiter<TFn, TSelected> // omit `store` in favor of `state`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA,SAAgB,kBACd,IACA,SACA,kBAA0D,EAAE,GAC1B;CAMlC,MAAM,cAAc,IAAIA,0CAAiB,IALnB;EACpB,GAAGC,8CAAwB,CAAC;EAC5B,GAAG;EACJ,CAE0D;CAE3D,MAAM,6CAAiB,YAAY,OAAO,SAAS;AAEnD,QAAO;EACL,GAAG;EACH;EACD"}
@@ -1,20 +1,22 @@
1
- import { RateLimiter, RateLimiterOptions, RateLimiterState } from '@tanstack/pacer/rate-limiter';
2
- import { Store } from '@tanstack/solid-store';
3
- import { Accessor } from 'solid-js';
4
- import { AnyFunction } from '@tanstack/pacer/types';
5
- export interface SolidRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit<RateLimiter<TFn>, 'store'> {
6
- /**
7
- * Reactive state that will be updated when the rate limiter state changes
8
- *
9
- * Use this instead of `rateLimiter.store.state`
10
- */
11
- readonly state: Accessor<Readonly<TSelected>>;
12
- /**
13
- * @deprecated Use `rateLimiter.state` instead of `rateLimiter.store.state` if you want to read reactive state.
14
- * The state on the store object is not reactive, as it has not been wrapped in a `useStore` hook internally.
15
- * Although, you can make the state reactive by using the `useStore` in your own usage.
16
- */
17
- readonly store: Store<Readonly<RateLimiterState>>;
1
+ import { Store } from "@tanstack/solid-store";
2
+ import { Accessor } from "solid-js";
3
+ import { AnyFunction } from "@tanstack/pacer/types";
4
+ import { RateLimiter, RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
5
+
6
+ //#region src/rate-limiter/createRateLimiter.d.ts
7
+ interface SolidRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit<RateLimiter<TFn>, 'store'> {
8
+ /**
9
+ * Reactive state that will be updated when the rate limiter state changes
10
+ *
11
+ * Use this instead of `rateLimiter.store.state`
12
+ */
13
+ readonly state: Accessor<Readonly<TSelected>>;
14
+ /**
15
+ * @deprecated Use `rateLimiter.state` instead of `rateLimiter.store.state` if you want to read reactive state.
16
+ * The state on the store object is not reactive, as it has not been wrapped in a `useStore` hook internally.
17
+ * Although, you can make the state reactive by using the `useStore` in your own usage.
18
+ */
19
+ readonly store: Store<Readonly<RateLimiterState>>;
18
20
  }
19
21
  /**
20
22
  * A low-level Solid hook that creates a `RateLimiter` instance to enforce rate limits on function execution.
@@ -91,4 +93,7 @@ export interface SolidRateLimiter<TFn extends AnyFunction, TSelected = {}> exten
91
93
  * const { remainingInWindow, rejectionCount } = rateLimiter.state();
92
94
  * ```
93
95
  */
94
- export declare function createRateLimiter<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: RateLimiterOptions<TFn>, selector?: (state: RateLimiterState) => TSelected): SolidRateLimiter<TFn, TSelected>;
96
+ declare function createRateLimiter<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: RateLimiterOptions<TFn>, selector?: (state: RateLimiterState) => TSelected): SolidRateLimiter<TFn, TSelected>;
97
+ //#endregion
98
+ export { SolidRateLimiter, createRateLimiter };
99
+ //# sourceMappingURL=createRateLimiter.d.cts.map