@tanstack/solid-pacer 0.2.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 (184) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/async-debouncer/createAsyncDebouncer.cjs +32 -0
  3. package/dist/cjs/async-debouncer/createAsyncDebouncer.cjs.map +1 -0
  4. package/dist/cjs/async-debouncer/createAsyncDebouncer.d.cts +42 -0
  5. package/dist/cjs/async-debouncer/index.cjs +12 -0
  6. package/dist/cjs/async-debouncer/index.cjs.map +1 -0
  7. package/dist/cjs/async-debouncer/index.d.cts +2 -0
  8. package/dist/cjs/async-queuer/createAsyncQueuer.cjs +69 -0
  9. package/dist/cjs/async-queuer/createAsyncQueuer.cjs.map +1 -0
  10. package/dist/cjs/async-queuer/createAsyncQueuer.d.cts +90 -0
  11. package/dist/cjs/async-queuer/index.cjs +12 -0
  12. package/dist/cjs/async-queuer/index.cjs.map +1 -0
  13. package/dist/cjs/async-queuer/index.d.cts +2 -0
  14. package/dist/cjs/async-rate-limiter/createAsyncRateLimiter.cjs +50 -0
  15. package/dist/cjs/async-rate-limiter/createAsyncRateLimiter.cjs.map +1 -0
  16. package/dist/cjs/async-rate-limiter/createAsyncRateLimiter.d.cts +46 -0
  17. package/dist/cjs/async-rate-limiter/index.cjs +12 -0
  18. package/dist/cjs/async-rate-limiter/index.cjs.map +1 -0
  19. package/dist/cjs/async-rate-limiter/index.d.cts +2 -0
  20. package/dist/cjs/async-throttler/createAsyncThrottler.cjs +42 -0
  21. package/dist/cjs/async-throttler/createAsyncThrottler.cjs.map +1 -0
  22. package/dist/cjs/async-throttler/createAsyncThrottler.d.cts +46 -0
  23. package/dist/cjs/async-throttler/index.cjs +12 -0
  24. package/dist/cjs/async-throttler/index.cjs.map +1 -0
  25. package/dist/cjs/async-throttler/index.d.cts +2 -0
  26. package/dist/cjs/compare/index.cjs +10 -0
  27. package/dist/cjs/compare/index.cjs.map +1 -0
  28. package/dist/cjs/compare/index.d.cts +1 -0
  29. package/dist/cjs/debouncer/createDebouncedSignal.cjs +11 -0
  30. package/dist/cjs/debouncer/createDebouncedSignal.cjs.map +1 -0
  31. package/dist/cjs/debouncer/createDebouncedSignal.d.cts +47 -0
  32. package/dist/cjs/debouncer/createDebouncedValue.cjs +19 -0
  33. package/dist/cjs/debouncer/createDebouncedValue.cjs.map +1 -0
  34. package/dist/cjs/debouncer/createDebouncedValue.d.cts +44 -0
  35. package/dist/cjs/debouncer/createDebouncer.cjs +32 -0
  36. package/dist/cjs/debouncer/createDebouncer.cjs.map +1 -0
  37. package/dist/cjs/debouncer/createDebouncer.d.cts +47 -0
  38. package/dist/cjs/debouncer/index.cjs +16 -0
  39. package/dist/cjs/debouncer/index.cjs.map +1 -0
  40. package/dist/cjs/debouncer/index.d.cts +4 -0
  41. package/dist/cjs/index.cjs +38 -0
  42. package/dist/cjs/index.cjs.map +1 -0
  43. package/dist/cjs/index.d.cts +18 -0
  44. package/dist/cjs/queuer/createQueuer.cjs +66 -0
  45. package/dist/cjs/queuer/createQueuer.cjs.map +1 -0
  46. package/dist/cjs/queuer/createQueuer.d.cts +82 -0
  47. package/dist/cjs/queuer/index.cjs +12 -0
  48. package/dist/cjs/queuer/index.cjs.map +1 -0
  49. package/dist/cjs/queuer/index.d.cts +2 -0
  50. package/dist/cjs/rate-limiter/createRateLimitedSignal.cjs +15 -0
  51. package/dist/cjs/rate-limiter/createRateLimitedSignal.cjs.map +1 -0
  52. package/dist/cjs/rate-limiter/createRateLimitedSignal.d.cts +58 -0
  53. package/dist/cjs/rate-limiter/createRateLimitedValue.cjs +13 -0
  54. package/dist/cjs/rate-limiter/createRateLimitedValue.cjs.map +1 -0
  55. package/dist/cjs/rate-limiter/createRateLimitedValue.d.cts +51 -0
  56. package/dist/cjs/rate-limiter/createRateLimiter.cjs +50 -0
  57. package/dist/cjs/rate-limiter/createRateLimiter.cjs.map +1 -0
  58. package/dist/cjs/rate-limiter/createRateLimiter.d.cts +49 -0
  59. package/dist/cjs/rate-limiter/index.cjs +16 -0
  60. package/dist/cjs/rate-limiter/index.cjs.map +1 -0
  61. package/dist/cjs/rate-limiter/index.d.cts +4 -0
  62. package/dist/cjs/throttler/createThrottledSignal.cjs +11 -0
  63. package/dist/cjs/throttler/createThrottledSignal.cjs.map +1 -0
  64. package/dist/cjs/throttler/createThrottledSignal.d.cts +42 -0
  65. package/dist/cjs/throttler/createThrottledValue.cjs +19 -0
  66. package/dist/cjs/throttler/createThrottledValue.cjs.map +1 -0
  67. package/dist/cjs/throttler/createThrottledValue.d.cts +36 -0
  68. package/dist/cjs/throttler/createThrottler.cjs +42 -0
  69. package/dist/cjs/throttler/createThrottler.cjs.map +1 -0
  70. package/dist/cjs/throttler/createThrottler.d.cts +47 -0
  71. package/dist/cjs/throttler/index.cjs +16 -0
  72. package/dist/cjs/throttler/index.cjs.map +1 -0
  73. package/dist/cjs/throttler/index.d.cts +4 -0
  74. package/dist/cjs/types/index.cjs +10 -0
  75. package/dist/cjs/types/index.cjs.map +1 -0
  76. package/dist/cjs/types/index.d.cts +1 -0
  77. package/dist/cjs/utils/index.cjs +10 -0
  78. package/dist/cjs/utils/index.cjs.map +1 -0
  79. package/dist/cjs/utils/index.d.cts +1 -0
  80. package/dist/esm/async-debouncer/createAsyncDebouncer.d.ts +42 -0
  81. package/dist/esm/async-debouncer/createAsyncDebouncer.js +32 -0
  82. package/dist/esm/async-debouncer/createAsyncDebouncer.js.map +1 -0
  83. package/dist/esm/async-debouncer/index.d.ts +2 -0
  84. package/dist/esm/async-debouncer/index.js +6 -0
  85. package/dist/esm/async-debouncer/index.js.map +1 -0
  86. package/dist/esm/async-queuer/createAsyncQueuer.d.ts +90 -0
  87. package/dist/esm/async-queuer/createAsyncQueuer.js +69 -0
  88. package/dist/esm/async-queuer/createAsyncQueuer.js.map +1 -0
  89. package/dist/esm/async-queuer/index.d.ts +2 -0
  90. package/dist/esm/async-queuer/index.js +6 -0
  91. package/dist/esm/async-queuer/index.js.map +1 -0
  92. package/dist/esm/async-rate-limiter/createAsyncRateLimiter.d.ts +46 -0
  93. package/dist/esm/async-rate-limiter/createAsyncRateLimiter.js +50 -0
  94. package/dist/esm/async-rate-limiter/createAsyncRateLimiter.js.map +1 -0
  95. package/dist/esm/async-rate-limiter/index.d.ts +2 -0
  96. package/dist/esm/async-rate-limiter/index.js +6 -0
  97. package/dist/esm/async-rate-limiter/index.js.map +1 -0
  98. package/dist/esm/async-throttler/createAsyncThrottler.d.ts +46 -0
  99. package/dist/esm/async-throttler/createAsyncThrottler.js +42 -0
  100. package/dist/esm/async-throttler/createAsyncThrottler.js.map +1 -0
  101. package/dist/esm/async-throttler/index.d.ts +2 -0
  102. package/dist/esm/async-throttler/index.js +6 -0
  103. package/dist/esm/async-throttler/index.js.map +1 -0
  104. package/dist/esm/compare/index.d.ts +1 -0
  105. package/dist/esm/compare/index.js +2 -0
  106. package/dist/esm/compare/index.js.map +1 -0
  107. package/dist/esm/debouncer/createDebouncedSignal.d.ts +47 -0
  108. package/dist/esm/debouncer/createDebouncedSignal.js +11 -0
  109. package/dist/esm/debouncer/createDebouncedSignal.js.map +1 -0
  110. package/dist/esm/debouncer/createDebouncedValue.d.ts +44 -0
  111. package/dist/esm/debouncer/createDebouncedValue.js +19 -0
  112. package/dist/esm/debouncer/createDebouncedValue.js.map +1 -0
  113. package/dist/esm/debouncer/createDebouncer.d.ts +47 -0
  114. package/dist/esm/debouncer/createDebouncer.js +32 -0
  115. package/dist/esm/debouncer/createDebouncer.js.map +1 -0
  116. package/dist/esm/debouncer/index.d.ts +4 -0
  117. package/dist/esm/debouncer/index.js +10 -0
  118. package/dist/esm/debouncer/index.js.map +1 -0
  119. package/dist/esm/index.d.ts +18 -0
  120. package/dist/esm/index.js +32 -0
  121. package/dist/esm/index.js.map +1 -0
  122. package/dist/esm/queuer/createQueuer.d.ts +82 -0
  123. package/dist/esm/queuer/createQueuer.js +66 -0
  124. package/dist/esm/queuer/createQueuer.js.map +1 -0
  125. package/dist/esm/queuer/index.d.ts +2 -0
  126. package/dist/esm/queuer/index.js +6 -0
  127. package/dist/esm/queuer/index.js.map +1 -0
  128. package/dist/esm/rate-limiter/createRateLimitedSignal.d.ts +58 -0
  129. package/dist/esm/rate-limiter/createRateLimitedSignal.js +15 -0
  130. package/dist/esm/rate-limiter/createRateLimitedSignal.js.map +1 -0
  131. package/dist/esm/rate-limiter/createRateLimitedValue.d.ts +51 -0
  132. package/dist/esm/rate-limiter/createRateLimitedValue.js +13 -0
  133. package/dist/esm/rate-limiter/createRateLimitedValue.js.map +1 -0
  134. package/dist/esm/rate-limiter/createRateLimiter.d.ts +49 -0
  135. package/dist/esm/rate-limiter/createRateLimiter.js +50 -0
  136. package/dist/esm/rate-limiter/createRateLimiter.js.map +1 -0
  137. package/dist/esm/rate-limiter/index.d.ts +4 -0
  138. package/dist/esm/rate-limiter/index.js +10 -0
  139. package/dist/esm/rate-limiter/index.js.map +1 -0
  140. package/dist/esm/throttler/createThrottledSignal.d.ts +42 -0
  141. package/dist/esm/throttler/createThrottledSignal.js +11 -0
  142. package/dist/esm/throttler/createThrottledSignal.js.map +1 -0
  143. package/dist/esm/throttler/createThrottledValue.d.ts +36 -0
  144. package/dist/esm/throttler/createThrottledValue.js +19 -0
  145. package/dist/esm/throttler/createThrottledValue.js.map +1 -0
  146. package/dist/esm/throttler/createThrottler.d.ts +47 -0
  147. package/dist/esm/throttler/createThrottler.js +42 -0
  148. package/dist/esm/throttler/createThrottler.js.map +1 -0
  149. package/dist/esm/throttler/index.d.ts +4 -0
  150. package/dist/esm/throttler/index.js +10 -0
  151. package/dist/esm/throttler/index.js.map +1 -0
  152. package/dist/esm/types/index.d.ts +1 -0
  153. package/dist/esm/types/index.js +2 -0
  154. package/dist/esm/types/index.js.map +1 -0
  155. package/dist/esm/utils/index.d.ts +1 -0
  156. package/dist/esm/utils/index.js +2 -0
  157. package/dist/esm/utils/index.js.map +1 -0
  158. package/package.json +163 -0
  159. package/src/async-debouncer/createAsyncDebouncer.ts +89 -0
  160. package/src/async-debouncer/index.ts +4 -0
  161. package/src/async-queuer/createAsyncQueuer.ts +175 -0
  162. package/src/async-queuer/index.ts +3 -0
  163. package/src/async-rate-limiter/createAsyncRateLimiter.ts +116 -0
  164. package/src/async-rate-limiter/index.ts +4 -0
  165. package/src/async-throttler/createAsyncThrottler.ts +106 -0
  166. package/src/async-throttler/index.ts +4 -0
  167. package/src/compare/index.ts +1 -0
  168. package/src/debouncer/createDebouncedSignal.ts +59 -0
  169. package/src/debouncer/createDebouncedValue.ts +64 -0
  170. package/src/debouncer/createDebouncer.ts +90 -0
  171. package/src/debouncer/index.ts +6 -0
  172. package/src/index.ts +36 -0
  173. package/src/queuer/createQueuer.ts +167 -0
  174. package/src/queuer/index.ts +3 -0
  175. package/src/rate-limiter/createRateLimitedSignal.ts +74 -0
  176. package/src/rate-limiter/createRateLimitedValue.ts +66 -0
  177. package/src/rate-limiter/createRateLimiter.ts +115 -0
  178. package/src/rate-limiter/index.ts +5 -0
  179. package/src/throttler/createThrottledSignal.ts +52 -0
  180. package/src/throttler/createThrottledValue.ts +56 -0
  181. package/src/throttler/createThrottler.ts +106 -0
  182. package/src/throttler/index.ts +6 -0
  183. package/src/types/index.ts +1 -0
  184. package/src/utils/index.ts +1 -0
@@ -0,0 +1,90 @@
1
+ import { AsyncQueuer, AsyncQueuerOptions } from '@tanstack/pacer/async-queuer';
2
+ import { Accessor } from 'solid-js';
3
+ export interface SolidAsyncQueuer<TValue> extends Omit<AsyncQueuer<TValue>, 'getActiveItems' | 'getAllItems' | 'getExecutionCount' | 'getIsEmpty' | 'getIsFull' | 'getIsIdle' | 'getIsRunning' | 'getPeek' | 'getPendingItems' | 'getSize'> {
4
+ /**
5
+ * Signal version of `getActiveItems`
6
+ */
7
+ activeItems: Accessor<Array<() => Promise<TValue>>>;
8
+ /**
9
+ * Signal version of `getAllItems`
10
+ */
11
+ allItems: Accessor<Array<() => Promise<TValue>>>;
12
+ /**
13
+ * Signal version of `getExecutionCount`
14
+ */
15
+ executionCount: Accessor<number>;
16
+ /**
17
+ * Signal version of `getIsEmpty`
18
+ */
19
+ isEmpty: Accessor<boolean>;
20
+ /**
21
+ * Signal version of `getIsFull`
22
+ */
23
+ isFull: Accessor<boolean>;
24
+ /**
25
+ * Signal version of `getIsIdle`
26
+ */
27
+ isIdle: Accessor<boolean>;
28
+ /**
29
+ * Signal version of `getIsRunning`
30
+ */
31
+ isRunning: Accessor<boolean>;
32
+ /**
33
+ * Signal version of `getPeek`
34
+ */
35
+ peek: Accessor<TValue | undefined>;
36
+ /**
37
+ * Signal version of `getPendingItems`
38
+ */
39
+ pendingItems: Accessor<Array<() => Promise<TValue>>>;
40
+ /**
41
+ * Signal version of `getSize`
42
+ */
43
+ size: Accessor<number>;
44
+ }
45
+ /**
46
+ * A lower-level React hook that creates an `AsyncQueuer` instance for managing an async queue of items.
47
+ *
48
+ * This hook provides a flexible, state-management agnostic way to handle queued async operations.
49
+ * It returns a queuer instance with methods to add items, control queue execution, and monitor queue state.
50
+ *
51
+ * The queue can be configured with:
52
+ * - Maximum concurrent operations
53
+ * - Maximum queue size
54
+ * - Processing function for queue items
55
+ * - Various lifecycle callbacks
56
+ *
57
+ * The hook returns an object containing methods to:
58
+ * - Add/remove items from the queue
59
+ * - Start/stop queue processing
60
+ * - Get queue status and items
61
+ * - Register event handlers
62
+ * - Control execution throttling
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * // Basic async queuer for API requests
67
+ * const asyncQueuer = createAsyncQueuer({
68
+ * initialItems: [],
69
+ * concurrency: 2,
70
+ * maxSize: 100,
71
+ * started: false,
72
+ * });
73
+ *
74
+ * // Add items to queue
75
+ * asyncQueuer.addItem(newItem);
76
+ *
77
+ * // Start processing
78
+ * asyncQueuer.start();
79
+ *
80
+ * // Handle results
81
+ * asyncQueuer.onSuccess((result) => {
82
+ * console.log('Item processed:', result);
83
+ * });
84
+ *
85
+ * asyncQueuer.onError((error) => {
86
+ * console.error('Processing failed:', error);
87
+ * });
88
+ * ```
89
+ */
90
+ export declare function createAsyncQueuer<TValue>(initialOptions?: AsyncQueuerOptions<TValue>): SolidAsyncQueuer<TValue>;
@@ -0,0 +1,69 @@
1
+ import { AsyncQueuer } from "@tanstack/pacer/async-queuer";
2
+ import { createSignal } from "solid-js";
3
+ import { bindInstanceMethods } from "@tanstack/pacer/utils";
4
+ function createAsyncQueuer(initialOptions = {}) {
5
+ const asyncQueuer = new AsyncQueuer(initialOptions);
6
+ const [executionCount, setExecutionCount] = createSignal(
7
+ asyncQueuer.getExecutionCount()
8
+ );
9
+ const [rejectionCount, setRejectionCount] = createSignal(
10
+ asyncQueuer.getRejectionCount()
11
+ );
12
+ const [isEmpty, setIsEmpty] = createSignal(asyncQueuer.getIsEmpty());
13
+ const [isFull, setIsFull] = createSignal(asyncQueuer.getIsFull());
14
+ const [isIdle, setIsIdle] = createSignal(asyncQueuer.getIsIdle());
15
+ const [isRunning, setIsRunning] = createSignal(asyncQueuer.getIsRunning());
16
+ const [allItems, setAllItems] = createSignal(
17
+ asyncQueuer.getAllItems()
18
+ );
19
+ const [activeItems, setActiveItems] = createSignal(asyncQueuer.getActiveItems());
20
+ const [pendingItems, setPendingItems] = createSignal(asyncQueuer.getPendingItems());
21
+ const [peek, setPeek] = createSignal(
22
+ asyncQueuer.getPeek()
23
+ );
24
+ const [size, setSize] = createSignal(asyncQueuer.getSize());
25
+ asyncQueuer.setOptions({
26
+ onItemsChange: (queuer) => {
27
+ var _a;
28
+ setExecutionCount(queuer.getExecutionCount());
29
+ setIsEmpty(queuer.getIsEmpty());
30
+ setIsFull(queuer.getIsFull());
31
+ setIsIdle(queuer.getIsIdle());
32
+ setAllItems(queuer.getAllItems());
33
+ setActiveItems(queuer.getActiveItems());
34
+ setPendingItems(queuer.getPendingItems());
35
+ setPeek(() => queuer.getPeek());
36
+ setSize(queuer.getSize());
37
+ (_a = initialOptions.onItemsChange) == null ? void 0 : _a.call(initialOptions, queuer);
38
+ },
39
+ onIsRunningChange: (queuer) => {
40
+ var _a;
41
+ setIsRunning(queuer.getIsRunning());
42
+ setIsIdle(queuer.getIsIdle());
43
+ (_a = initialOptions.onIsRunningChange) == null ? void 0 : _a.call(initialOptions, queuer);
44
+ },
45
+ onReject: (item, queuer) => {
46
+ var _a;
47
+ setRejectionCount(queuer.getRejectionCount());
48
+ (_a = initialOptions.onReject) == null ? void 0 : _a.call(initialOptions, item, queuer);
49
+ }
50
+ });
51
+ return {
52
+ ...bindInstanceMethods(asyncQueuer),
53
+ activeItems,
54
+ executionCount,
55
+ isEmpty,
56
+ isFull,
57
+ isIdle,
58
+ isRunning,
59
+ allItems,
60
+ peek,
61
+ pendingItems,
62
+ rejectionCount,
63
+ size
64
+ };
65
+ }
66
+ export {
67
+ createAsyncQueuer
68
+ };
69
+ //# sourceMappingURL=createAsyncQueuer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAsyncQueuer.js","sources":["../../../src/async-queuer/createAsyncQueuer.ts"],"sourcesContent":["import { AsyncQueuer } from '@tanstack/pacer/async-queuer'\nimport { createSignal } from 'solid-js'\nimport { bindInstanceMethods } from '@tanstack/pacer/utils'\nimport type { Accessor } from 'solid-js'\nimport type { AsyncQueuerOptions } from '@tanstack/pacer/async-queuer'\n\nexport interface SolidAsyncQueuer<TValue>\n extends Omit<\n AsyncQueuer<TValue>,\n | 'getActiveItems'\n | 'getAllItems'\n | 'getExecutionCount'\n | 'getIsEmpty'\n | 'getIsFull'\n | 'getIsIdle'\n | 'getIsRunning'\n | 'getPeek'\n | 'getPendingItems'\n | 'getSize'\n > {\n /**\n * Signal version of `getActiveItems`\n */\n activeItems: Accessor<Array<() => Promise<TValue>>>\n /**\n * Signal version of `getAllItems`\n */\n allItems: Accessor<Array<() => Promise<TValue>>>\n /**\n * Signal version of `getExecutionCount`\n */\n executionCount: Accessor<number>\n /**\n * Signal version of `getIsEmpty`\n */\n isEmpty: Accessor<boolean>\n /**\n * Signal version of `getIsFull`\n */\n isFull: Accessor<boolean>\n /**\n * Signal version of `getIsIdle`\n */\n isIdle: Accessor<boolean>\n /**\n * Signal version of `getIsRunning`\n */\n isRunning: Accessor<boolean>\n /**\n * Signal version of `getPeek`\n */\n peek: Accessor<TValue | undefined>\n /**\n * Signal version of `getPendingItems`\n */\n pendingItems: Accessor<Array<() => Promise<TValue>>>\n /**\n * Signal version of `getSize`\n */\n size: Accessor<number>\n}\n\n/**\n * A lower-level React hook that creates an `AsyncQueuer` instance for managing an async queue of items.\n *\n * This hook provides a flexible, state-management agnostic way to handle queued async operations.\n * It returns a queuer instance with methods to add items, control queue execution, and monitor queue state.\n *\n * The queue can be configured with:\n * - Maximum concurrent operations\n * - Maximum queue size\n * - Processing function for queue items\n * - Various lifecycle callbacks\n *\n * The hook returns an object containing methods to:\n * - Add/remove items from the queue\n * - Start/stop queue processing\n * - Get queue status and items\n * - Register event handlers\n * - Control execution throttling\n *\n * @example\n * ```tsx\n * // Basic async queuer for API requests\n * const asyncQueuer = createAsyncQueuer({\n * initialItems: [],\n * concurrency: 2,\n * maxSize: 100,\n * started: false,\n * });\n *\n * // Add items to queue\n * asyncQueuer.addItem(newItem);\n *\n * // Start processing\n * asyncQueuer.start();\n *\n * // Handle results\n * asyncQueuer.onSuccess((result) => {\n * console.log('Item processed:', result);\n * });\n *\n * asyncQueuer.onError((error) => {\n * console.error('Processing failed:', error);\n * });\n * ```\n */\nexport function createAsyncQueuer<TValue>(\n initialOptions: AsyncQueuerOptions<TValue> = {},\n): SolidAsyncQueuer<TValue> {\n const asyncQueuer = new AsyncQueuer<TValue>(initialOptions)\n\n const [executionCount, setExecutionCount] = createSignal(\n asyncQueuer.getExecutionCount(),\n )\n const [rejectionCount, setRejectionCount] = createSignal(\n asyncQueuer.getRejectionCount(),\n )\n const [isEmpty, setIsEmpty] = createSignal(asyncQueuer.getIsEmpty())\n const [isFull, setIsFull] = createSignal(asyncQueuer.getIsFull())\n const [isIdle, setIsIdle] = createSignal(asyncQueuer.getIsIdle())\n const [isRunning, setIsRunning] = createSignal(asyncQueuer.getIsRunning())\n const [allItems, setAllItems] = createSignal<Array<() => Promise<TValue>>>(\n asyncQueuer.getAllItems(),\n )\n const [activeItems, setActiveItems] = createSignal<\n Array<() => Promise<TValue>>\n >(asyncQueuer.getActiveItems())\n const [pendingItems, setPendingItems] = createSignal<\n Array<() => Promise<TValue>>\n >(asyncQueuer.getPendingItems())\n const [peek, setPeek] = createSignal<(() => Promise<TValue>) | undefined>(\n asyncQueuer.getPeek(),\n )\n const [size, setSize] = createSignal(asyncQueuer.getSize())\n\n asyncQueuer.setOptions({\n onItemsChange: (queuer) => {\n setExecutionCount(queuer.getExecutionCount())\n setIsEmpty(queuer.getIsEmpty())\n setIsFull(queuer.getIsFull())\n setIsIdle(queuer.getIsIdle())\n setAllItems(queuer.getAllItems())\n setActiveItems(queuer.getActiveItems())\n setPendingItems(queuer.getPendingItems())\n setPeek(() => queuer.getPeek())\n setSize(queuer.getSize())\n initialOptions.onItemsChange?.(queuer)\n },\n onIsRunningChange: (queuer) => {\n setIsRunning(queuer.getIsRunning())\n setIsIdle(queuer.getIsIdle())\n initialOptions.onIsRunningChange?.(queuer)\n },\n onReject: (item, queuer) => {\n setRejectionCount(queuer.getRejectionCount())\n initialOptions.onReject?.(item, queuer)\n },\n })\n\n return {\n ...bindInstanceMethods(asyncQueuer),\n activeItems,\n executionCount,\n isEmpty,\n isFull,\n isIdle,\n isRunning,\n allItems,\n peek,\n pendingItems,\n rejectionCount,\n size,\n }\n}\n"],"names":[],"mappings":";;;AA2GgB,SAAA,kBACd,iBAA6C,IACnB;AACpB,QAAA,cAAc,IAAI,YAAoB,cAAc;AAEpD,QAAA,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,IAC1C,YAAY,kBAAkB;AAAA,EAChC;AACM,QAAA,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,IAC1C,YAAY,kBAAkB;AAAA,EAChC;AACA,QAAM,CAAC,SAAS,UAAU,IAAI,aAAa,YAAY,YAAY;AACnE,QAAM,CAAC,QAAQ,SAAS,IAAI,aAAa,YAAY,WAAW;AAChE,QAAM,CAAC,QAAQ,SAAS,IAAI,aAAa,YAAY,WAAW;AAChE,QAAM,CAAC,WAAW,YAAY,IAAI,aAAa,YAAY,cAAc;AACnE,QAAA,CAAC,UAAU,WAAW,IAAI;AAAA,IAC9B,YAAY,YAAY;AAAA,EAC1B;AACA,QAAM,CAAC,aAAa,cAAc,IAAI,aAEpC,YAAY,gBAAgB;AAC9B,QAAM,CAAC,cAAc,eAAe,IAAI,aAEtC,YAAY,iBAAiB;AACzB,QAAA,CAAC,MAAM,OAAO,IAAI;AAAA,IACtB,YAAY,QAAQ;AAAA,EACtB;AACA,QAAM,CAAC,MAAM,OAAO,IAAI,aAAa,YAAY,SAAS;AAE1D,cAAY,WAAW;AAAA,IACrB,eAAe,CAAC,WAAW;;AACP,wBAAA,OAAO,mBAAmB;AACjC,iBAAA,OAAO,YAAY;AACpB,gBAAA,OAAO,WAAW;AAClB,gBAAA,OAAO,WAAW;AAChB,kBAAA,OAAO,aAAa;AACjB,qBAAA,OAAO,gBAAgB;AACtB,sBAAA,OAAO,iBAAiB;AAChC,cAAA,MAAM,OAAO,SAAS;AACtB,cAAA,OAAO,SAAS;AACxB,2BAAe,kBAAf,wCAA+B;AAAA,IACjC;AAAA,IACA,mBAAmB,CAAC,WAAW;;AAChB,mBAAA,OAAO,cAAc;AACxB,gBAAA,OAAO,WAAW;AAC5B,2BAAe,sBAAf,wCAAmC;AAAA,IACrC;AAAA,IACA,UAAU,CAAC,MAAM,WAAW;;AACR,wBAAA,OAAO,mBAAmB;AAC7B,2BAAA,aAAA,wCAAW,MAAM;AAAA,IAAM;AAAA,EACxC,CACD;AAEM,SAAA;AAAA,IACL,GAAG,oBAAoB,WAAW;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;"}
@@ -0,0 +1,2 @@
1
+ export * from '@tanstack/pacer/async-queuer';
2
+ export * from './createAsyncQueuer.js';
@@ -0,0 +1,6 @@
1
+ export * from "@tanstack/pacer/async-queuer";
2
+ import { createAsyncQueuer } from "./createAsyncQueuer.js";
3
+ export {
4
+ createAsyncQueuer
5
+ };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,46 @@
1
+ import { AsyncRateLimiter, AsyncRateLimiterOptions } from '@tanstack/pacer/async-rate-limiter';
2
+ import { Accessor } from 'solid-js';
3
+ import { AnyAsyncFunction } from '@tanstack/pacer/types';
4
+ export interface SolidAsyncRateLimiter<TFn extends AnyAsyncFunction, TArgs extends Parameters<TFn>> extends Omit<AsyncRateLimiter<TFn, TArgs>, 'getExecutionCount' | 'getRejectionCount' | 'getRemainingInWindow' | 'getMsUntilNextWindow'> {
5
+ executionCount: Accessor<number>;
6
+ rejectionCount: Accessor<number>;
7
+ remainingInWindow: Accessor<number>;
8
+ msUntilNextWindow: Accessor<number>;
9
+ }
10
+ /**
11
+ * A low-level Solid hook that creates an `AsyncRateLimiter` instance to limit how many times an async function can execute within a time window.
12
+ *
13
+ * This hook is designed to be flexible and state-management agnostic - it simply returns a rate limiter instance that
14
+ * you can integrate with any state management solution (createSignal, etc).
15
+ *
16
+ * Rate limiting allows an async function to execute up to a specified limit within a time window,
17
+ * then blocks subsequent calls until the window passes. This is useful for respecting API rate limits,
18
+ * managing resource constraints, or controlling bursts of async operations.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * // Basic API call rate limiting
23
+ * const { maybeExecute } = createAsyncRateLimiter(
24
+ * async (id: string) => {
25
+ * const data = await api.fetchData(id);
26
+ * return data;
27
+ * },
28
+ * { limit: 5, window: 1000 } // 5 calls per second
29
+ * );
30
+ *
31
+ * // With state management
32
+ * const [data, setData] = createSignal(null);
33
+ * const { maybeExecute } = createAsyncRateLimiter(
34
+ * async (query) => {
35
+ * const result = await searchAPI(query);
36
+ * setData(result);
37
+ * },
38
+ * {
39
+ * limit: 10,
40
+ * window: 60000, // 10 calls per minute
41
+ * onReject: (info) => console.log(`Rate limit exceeded: ${info.nextValidTime - Date.now()}ms until next window`)
42
+ * }
43
+ * );
44
+ * ```
45
+ */
46
+ export declare function createAsyncRateLimiter<TFn extends AnyAsyncFunction, TArgs extends Parameters<TFn>>(fn: TFn, initialOptions: AsyncRateLimiterOptions<TFn, TArgs>): SolidAsyncRateLimiter<TFn, TArgs>;
@@ -0,0 +1,50 @@
1
+ import { AsyncRateLimiter } from "@tanstack/pacer/async-rate-limiter";
2
+ import { createSignal } from "solid-js";
3
+ import { bindInstanceMethods } from "@tanstack/pacer/utils";
4
+ function createAsyncRateLimiter(fn, initialOptions) {
5
+ const asyncRateLimiter = new AsyncRateLimiter(fn, initialOptions);
6
+ const [executionCount, setExecutionCount] = createSignal(
7
+ asyncRateLimiter.getExecutionCount()
8
+ );
9
+ const [rejectionCount, setRejectionCount] = createSignal(
10
+ asyncRateLimiter.getRejectionCount()
11
+ );
12
+ const [remainingInWindow, setRemainingInWindow] = createSignal(
13
+ asyncRateLimiter.getRemainingInWindow()
14
+ );
15
+ const [msUntilNextWindow, setMsUntilNextWindow] = createSignal(
16
+ asyncRateLimiter.getMsUntilNextWindow()
17
+ );
18
+ function setOptions(newOptions) {
19
+ asyncRateLimiter.setOptions({
20
+ ...newOptions,
21
+ onExecute: (rateLimiter) => {
22
+ setExecutionCount(rateLimiter.getExecutionCount());
23
+ setRemainingInWindow(rateLimiter.getRemainingInWindow());
24
+ setMsUntilNextWindow(rateLimiter.getMsUntilNextWindow());
25
+ const onExecute = newOptions.onExecute ?? initialOptions.onExecute;
26
+ onExecute == null ? void 0 : onExecute(rateLimiter);
27
+ },
28
+ onReject: (rateLimiter) => {
29
+ setRejectionCount(rateLimiter.getRejectionCount());
30
+ setRemainingInWindow(rateLimiter.getRemainingInWindow());
31
+ setMsUntilNextWindow(rateLimiter.getMsUntilNextWindow());
32
+ const onReject = newOptions.onReject ?? initialOptions.onReject;
33
+ onReject == null ? void 0 : onReject(rateLimiter);
34
+ }
35
+ });
36
+ }
37
+ setOptions(initialOptions);
38
+ return {
39
+ ...bindInstanceMethods(asyncRateLimiter),
40
+ executionCount,
41
+ rejectionCount,
42
+ remainingInWindow,
43
+ msUntilNextWindow,
44
+ setOptions
45
+ };
46
+ }
47
+ export {
48
+ createAsyncRateLimiter
49
+ };
50
+ //# sourceMappingURL=createAsyncRateLimiter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAsyncRateLimiter.js","sources":["../../../src/async-rate-limiter/createAsyncRateLimiter.ts"],"sourcesContent":["import { AsyncRateLimiter } from '@tanstack/pacer/async-rate-limiter'\nimport { createSignal } from 'solid-js'\nimport { bindInstanceMethods } from '@tanstack/pacer/utils'\nimport type { Accessor } from 'solid-js'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\nimport type { AsyncRateLimiterOptions } from '@tanstack/pacer/async-rate-limiter'\n\nexport interface SolidAsyncRateLimiter<\n TFn extends AnyAsyncFunction,\n TArgs extends Parameters<TFn>,\n> extends Omit<\n AsyncRateLimiter<TFn, TArgs>,\n | 'getExecutionCount'\n | 'getRejectionCount'\n | 'getRemainingInWindow'\n | 'getMsUntilNextWindow'\n > {\n executionCount: Accessor<number>\n rejectionCount: Accessor<number>\n remainingInWindow: Accessor<number>\n msUntilNextWindow: Accessor<number>\n}\n\n/**\n * A low-level Solid hook that creates an `AsyncRateLimiter` instance to limit how many times an async function can execute within a time window.\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 allows an async function to execute up to a specified limit within a time window,\n * then blocks subsequent calls until the window passes. This is useful for respecting API rate limits,\n * managing resource constraints, or controlling bursts of async operations.\n *\n * @example\n * ```tsx\n * // Basic API call rate limiting\n * const { maybeExecute } = createAsyncRateLimiter(\n * async (id: string) => {\n * const data = await api.fetchData(id);\n * return data;\n * },\n * { limit: 5, window: 1000 } // 5 calls per second\n * );\n *\n * // With state management\n * const [data, setData] = createSignal(null);\n * const { maybeExecute } = createAsyncRateLimiter(\n * async (query) => {\n * const result = await searchAPI(query);\n * setData(result);\n * },\n * {\n * limit: 10,\n * window: 60000, // 10 calls per minute\n * onReject: (info) => console.log(`Rate limit exceeded: ${info.nextValidTime - Date.now()}ms until next window`)\n * }\n * );\n * ```\n */\nexport function createAsyncRateLimiter<\n TFn extends AnyAsyncFunction,\n TArgs extends Parameters<TFn>,\n>(\n fn: TFn,\n initialOptions: AsyncRateLimiterOptions<TFn, TArgs>,\n): SolidAsyncRateLimiter<TFn, TArgs> {\n const asyncRateLimiter = new AsyncRateLimiter<TFn, TArgs>(fn, initialOptions)\n\n const [executionCount, setExecutionCount] = createSignal(\n asyncRateLimiter.getExecutionCount(),\n )\n const [rejectionCount, setRejectionCount] = createSignal(\n asyncRateLimiter.getRejectionCount(),\n )\n const [remainingInWindow, setRemainingInWindow] = createSignal(\n asyncRateLimiter.getRemainingInWindow(),\n )\n const [msUntilNextWindow, setMsUntilNextWindow] = createSignal(\n asyncRateLimiter.getMsUntilNextWindow(),\n )\n\n function setOptions(\n newOptions: Partial<AsyncRateLimiterOptions<TFn, TArgs>>,\n ) {\n asyncRateLimiter.setOptions({\n ...newOptions,\n onExecute: (rateLimiter) => {\n setExecutionCount(rateLimiter.getExecutionCount())\n setRemainingInWindow(rateLimiter.getRemainingInWindow())\n setMsUntilNextWindow(rateLimiter.getMsUntilNextWindow())\n\n const onExecute = newOptions.onExecute ?? initialOptions.onExecute\n onExecute?.(rateLimiter)\n },\n onReject: (rateLimiter) => {\n setRejectionCount(rateLimiter.getRejectionCount())\n setRemainingInWindow(rateLimiter.getRemainingInWindow())\n setMsUntilNextWindow(rateLimiter.getMsUntilNextWindow())\n\n const onReject = newOptions.onReject ?? initialOptions.onReject\n onReject?.(rateLimiter)\n },\n })\n }\n\n setOptions(initialOptions)\n\n return {\n ...bindInstanceMethods(asyncRateLimiter),\n executionCount,\n rejectionCount,\n remainingInWindow,\n msUntilNextWindow,\n setOptions,\n }\n}\n"],"names":[],"mappings":";;;AA2DgB,SAAA,uBAId,IACA,gBACmC;AACnC,QAAM,mBAAmB,IAAI,iBAA6B,IAAI,cAAc;AAEtE,QAAA,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,IAC1C,iBAAiB,kBAAkB;AAAA,EACrC;AACM,QAAA,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,IAC1C,iBAAiB,kBAAkB;AAAA,EACrC;AACM,QAAA,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD,iBAAiB,qBAAqB;AAAA,EACxC;AACM,QAAA,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD,iBAAiB,qBAAqB;AAAA,EACxC;AAEA,WAAS,WACP,YACA;AACA,qBAAiB,WAAW;AAAA,MAC1B,GAAG;AAAA,MACH,WAAW,CAAC,gBAAgB;AACR,0BAAA,YAAY,mBAAmB;AAC5B,6BAAA,YAAY,sBAAsB;AAClC,6BAAA,YAAY,sBAAsB;AAEjD,cAAA,YAAY,WAAW,aAAa,eAAe;AACzD,+CAAY;AAAA,MACd;AAAA,MACA,UAAU,CAAC,gBAAgB;AACP,0BAAA,YAAY,mBAAmB;AAC5B,6BAAA,YAAY,sBAAsB;AAClC,6BAAA,YAAY,sBAAsB;AAEjD,cAAA,WAAW,WAAW,YAAY,eAAe;AACvD,6CAAW;AAAA,MAAW;AAAA,IACxB,CACD;AAAA,EAAA;AAGH,aAAW,cAAc;AAElB,SAAA;AAAA,IACL,GAAG,oBAAoB,gBAAgB;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;"}
@@ -0,0 +1,2 @@
1
+ export * from '@tanstack/pacer/async-rate-limiter';
2
+ export * from './createAsyncRateLimiter.js';
@@ -0,0 +1,6 @@
1
+ export * from "@tanstack/pacer/async-rate-limiter";
2
+ import { createAsyncRateLimiter } from "./createAsyncRateLimiter.js";
3
+ export {
4
+ createAsyncRateLimiter
5
+ };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,46 @@
1
+ import { AsyncThrottler, AsyncThrottlerOptions } from '@tanstack/pacer/async-throttler';
2
+ import { Accessor } from 'solid-js';
3
+ import { AnyAsyncFunction } from '@tanstack/pacer/types';
4
+ export interface SolidAsyncThrottler<TFn extends AnyAsyncFunction, TArgs extends Parameters<TFn>> extends Omit<AsyncThrottler<TFn, TArgs>, 'getExecutionCount' | 'getIsPending' | 'getLastExecutionTime' | 'getNextExecutionTime'> {
5
+ executionCount: Accessor<number>;
6
+ isPending: Accessor<boolean>;
7
+ lastExecutionTime: Accessor<number>;
8
+ nextExecutionTime: Accessor<number>;
9
+ }
10
+ /**
11
+ * A low-level Solid hook that creates an `AsyncThrottler` instance to limit how often an async function can execute.
12
+ *
13
+ * This hook is designed to be flexible and state-management agnostic - it simply returns a throttler instance that
14
+ * you can integrate with any state management solution (createSignal, etc).
15
+ *
16
+ * Async throttling ensures an async function executes at most once within a specified time window,
17
+ * regardless of how many times it is called. This is useful for rate-limiting expensive API calls,
18
+ * database operations, or other async tasks.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * // Basic API call throttling
23
+ * const { maybeExecute } = createAsyncThrottler(
24
+ * async (id: string) => {
25
+ * const data = await api.fetchData(id);
26
+ * return data;
27
+ * },
28
+ * { wait: 1000 }
29
+ * );
30
+ *
31
+ * // With state management
32
+ * const [data, setData] = createSignal(null);
33
+ * const { maybeExecute } = createAsyncThrottler(
34
+ * async (query) => {
35
+ * const result = await searchAPI(query);
36
+ * setData(result);
37
+ * },
38
+ * {
39
+ * wait: 2000,
40
+ * leading: true, // Execute immediately on first call
41
+ * trailing: false // Skip trailing edge updates
42
+ * }
43
+ * );
44
+ * ```
45
+ */
46
+ export declare function createAsyncThrottler<TFn extends AnyAsyncFunction, TArgs extends Parameters<TFn>>(fn: TFn, initialOptions: AsyncThrottlerOptions<TFn, TArgs>): SolidAsyncThrottler<TFn, TArgs>;
@@ -0,0 +1,42 @@
1
+ import { AsyncThrottler } from "@tanstack/pacer/async-throttler";
2
+ import { createSignal } from "solid-js";
3
+ import { bindInstanceMethods } from "@tanstack/pacer/utils";
4
+ function createAsyncThrottler(fn, initialOptions) {
5
+ const asyncThrottler = new AsyncThrottler(fn, initialOptions);
6
+ const [executionCount, setExecutionCount] = createSignal(
7
+ asyncThrottler.getExecutionCount()
8
+ );
9
+ const [isPending, setIsPending] = createSignal(asyncThrottler.getIsPending());
10
+ const [lastExecutionTime, setLastExecutionTime] = createSignal(
11
+ asyncThrottler.getLastExecutionTime()
12
+ );
13
+ const [nextExecutionTime, setNextExecutionTime] = createSignal(
14
+ asyncThrottler.getNextExecutionTime()
15
+ );
16
+ function setOptions(newOptions) {
17
+ asyncThrottler.setOptions({
18
+ ...newOptions,
19
+ onExecute: (throttler) => {
20
+ setExecutionCount(throttler.getExecutionCount());
21
+ setIsPending(throttler.getIsPending());
22
+ setLastExecutionTime(throttler.getLastExecutionTime());
23
+ setNextExecutionTime(throttler.getNextExecutionTime());
24
+ const onExecute = newOptions.onExecute ?? initialOptions.onExecute;
25
+ onExecute == null ? void 0 : onExecute(throttler);
26
+ }
27
+ });
28
+ }
29
+ setOptions(initialOptions);
30
+ return {
31
+ ...bindInstanceMethods(asyncThrottler),
32
+ executionCount,
33
+ isPending,
34
+ lastExecutionTime,
35
+ nextExecutionTime,
36
+ setOptions
37
+ };
38
+ }
39
+ export {
40
+ createAsyncThrottler
41
+ };
42
+ //# sourceMappingURL=createAsyncThrottler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAsyncThrottler.js","sources":["../../../src/async-throttler/createAsyncThrottler.ts"],"sourcesContent":["import { AsyncThrottler } from '@tanstack/pacer/async-throttler'\nimport { createSignal } from 'solid-js'\nimport { bindInstanceMethods } from '@tanstack/pacer/utils'\nimport type { Accessor } from 'solid-js'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\nimport type { AsyncThrottlerOptions } from '@tanstack/pacer/async-throttler'\n\nexport interface SolidAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TArgs extends Parameters<TFn>,\n> extends Omit<\n AsyncThrottler<TFn, TArgs>,\n | 'getExecutionCount'\n | 'getIsPending'\n | 'getLastExecutionTime'\n | 'getNextExecutionTime'\n > {\n executionCount: Accessor<number>\n isPending: Accessor<boolean>\n lastExecutionTime: Accessor<number>\n nextExecutionTime: Accessor<number>\n}\n\n/**\n * A low-level Solid hook that creates an `AsyncThrottler` instance to limit how often an async function can execute.\n *\n * This hook is designed to be flexible and state-management agnostic - it simply returns a throttler instance that\n * you can integrate with any state management solution (createSignal, etc).\n *\n * Async throttling ensures an async function executes at most once within a specified time window,\n * regardless of how many times it is called. This is useful for rate-limiting expensive API calls,\n * database operations, or other async tasks.\n *\n * @example\n * ```tsx\n * // Basic API call throttling\n * const { maybeExecute } = createAsyncThrottler(\n * async (id: string) => {\n * const data = await api.fetchData(id);\n * return data;\n * },\n * { wait: 1000 }\n * );\n *\n * // With state management\n * const [data, setData] = createSignal(null);\n * const { maybeExecute } = createAsyncThrottler(\n * async (query) => {\n * const result = await searchAPI(query);\n * setData(result);\n * },\n * {\n * wait: 2000,\n * leading: true, // Execute immediately on first call\n * trailing: false // Skip trailing edge updates\n * }\n * );\n * ```\n */\n\nexport function createAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TArgs extends Parameters<TFn>,\n>(\n fn: TFn,\n initialOptions: AsyncThrottlerOptions<TFn, TArgs>,\n): SolidAsyncThrottler<TFn, TArgs> {\n const asyncThrottler = new AsyncThrottler<TFn, TArgs>(fn, initialOptions)\n\n const [executionCount, setExecutionCount] = createSignal(\n asyncThrottler.getExecutionCount(),\n )\n const [isPending, setIsPending] = createSignal(asyncThrottler.getIsPending())\n const [lastExecutionTime, setLastExecutionTime] = createSignal(\n asyncThrottler.getLastExecutionTime(),\n )\n const [nextExecutionTime, setNextExecutionTime] = createSignal(\n asyncThrottler.getNextExecutionTime(),\n )\n\n function setOptions(newOptions: Partial<AsyncThrottlerOptions<TFn, TArgs>>) {\n asyncThrottler.setOptions({\n ...newOptions,\n onExecute: (throttler) => {\n setExecutionCount(throttler.getExecutionCount())\n setIsPending(throttler.getIsPending())\n setLastExecutionTime(throttler.getLastExecutionTime())\n setNextExecutionTime(throttler.getNextExecutionTime())\n\n const onExecute = newOptions.onExecute ?? initialOptions.onExecute\n onExecute?.(throttler)\n },\n })\n }\n\n setOptions(initialOptions)\n\n return {\n ...bindInstanceMethods(asyncThrottler),\n executionCount,\n isPending,\n lastExecutionTime,\n nextExecutionTime,\n setOptions,\n }\n}\n"],"names":[],"mappings":";;;AA4DgB,SAAA,qBAId,IACA,gBACiC;AACjC,QAAM,iBAAiB,IAAI,eAA2B,IAAI,cAAc;AAElE,QAAA,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,IAC1C,eAAe,kBAAkB;AAAA,EACnC;AACA,QAAM,CAAC,WAAW,YAAY,IAAI,aAAa,eAAe,cAAc;AACtE,QAAA,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD,eAAe,qBAAqB;AAAA,EACtC;AACM,QAAA,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD,eAAe,qBAAqB;AAAA,EACtC;AAEA,WAAS,WAAW,YAAwD;AAC1E,mBAAe,WAAW;AAAA,MACxB,GAAG;AAAA,MACH,WAAW,CAAC,cAAc;AACN,0BAAA,UAAU,mBAAmB;AAClC,qBAAA,UAAU,cAAc;AAChB,6BAAA,UAAU,sBAAsB;AAChC,6BAAA,UAAU,sBAAsB;AAE/C,cAAA,YAAY,WAAW,aAAa,eAAe;AACzD,+CAAY;AAAA,MAAS;AAAA,IACvB,CACD;AAAA,EAAA;AAGH,aAAW,cAAc;AAElB,SAAA;AAAA,IACL,GAAG,oBAAoB,cAAc;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;"}
@@ -0,0 +1,2 @@
1
+ export * from '@tanstack/pacer/async-throttler';
2
+ export * from './createAsyncThrottler.js';
@@ -0,0 +1,6 @@
1
+ export * from "@tanstack/pacer/async-throttler";
2
+ import { createAsyncThrottler } from "./createAsyncThrottler.js";
3
+ export {
4
+ createAsyncThrottler
5
+ };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1 @@
1
+ export * from '@tanstack/pacer/compare';
@@ -0,0 +1,2 @@
1
+ export * from "@tanstack/pacer/compare";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,47 @@
1
+ import { SolidDebouncer } from './createDebouncer.js';
2
+ import { Accessor, Setter } from 'solid-js';
3
+ import { DebouncerOptions } from '@tanstack/pacer/debouncer';
4
+ /**
5
+ * A Solid hook that creates a debounced state value, combining Solid's createSignal with debouncing functionality.
6
+ * This hook provides both the current debounced value and methods to update it.
7
+ *
8
+ * The state value is only updated after the specified wait time has elapsed since the last update attempt.
9
+ * If another update is attempted before the wait time expires, the timer resets and starts waiting again.
10
+ * This is useful for handling frequent state updates that should be throttled, like search input values
11
+ * or window resize dimensions.
12
+ *
13
+ * The hook returns a tuple containing:
14
+ * - The current debounced value accessor
15
+ * - A function to update the debounced value
16
+ * - The debouncer instance with additional control methods and state signals
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * // Debounced search input
21
+ * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {
22
+ * wait: 500 // Wait 500ms after last keystroke
23
+ * });
24
+ *
25
+ * // Update value - will be debounced
26
+ * const handleChange = (e) => {
27
+ * setSearchTerm(e.target.value);
28
+ * };
29
+ *
30
+ * // Access debouncer state via signals
31
+ * console.log('Executions:', debouncer.executionCount());
32
+ * console.log('Is pending:', debouncer.isPending());
33
+ *
34
+ * // In onExecute callback, use get* methods
35
+ * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {
36
+ * wait: 500,
37
+ * onExecute: (debouncer) => {
38
+ * console.log('Total executions:', debouncer.getExecutionCount());
39
+ * }
40
+ * });
41
+ * ```
42
+ */
43
+ export declare function createDebouncedSignal<TValue>(value: TValue, initialOptions: DebouncerOptions<Setter<TValue>, [Accessor<TValue>]>): [
44
+ Accessor<TValue>,
45
+ Setter<TValue>,
46
+ SolidDebouncer<Setter<TValue>, [Accessor<TValue>]>
47
+ ];
@@ -0,0 +1,11 @@
1
+ import { createSignal } from "solid-js";
2
+ import { createDebouncer } from "./createDebouncer.js";
3
+ function createDebouncedSignal(value, initialOptions) {
4
+ const [debouncedValue, setDebouncedValue] = createSignal(value);
5
+ const debouncer = createDebouncer(setDebouncedValue, initialOptions);
6
+ return [debouncedValue, debouncer.maybeExecute, debouncer];
7
+ }
8
+ export {
9
+ createDebouncedSignal
10
+ };
11
+ //# sourceMappingURL=createDebouncedSignal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDebouncedSignal.js","sources":["../../../src/debouncer/createDebouncedSignal.ts"],"sourcesContent":["import { createSignal } from 'solid-js'\nimport { createDebouncer } from './createDebouncer'\nimport type { SolidDebouncer } from './createDebouncer'\nimport type { Accessor, Setter } from 'solid-js'\nimport type { DebouncerOptions } from '@tanstack/pacer/debouncer'\n\n/**\n * A Solid hook that creates a debounced state value, combining Solid's createSignal with debouncing functionality.\n * This hook provides both the current debounced value and methods to update it.\n *\n * The state value is only updated after the specified wait time has elapsed since the last update attempt.\n * If another update is attempted before the wait time expires, the timer resets and starts waiting again.\n * This is useful for handling frequent state updates that should be throttled, like search input values\n * or window resize dimensions.\n *\n * The hook returns a tuple containing:\n * - The current debounced value accessor\n * - A function to update the debounced value\n * - The debouncer instance with additional control methods and state signals\n *\n * @example\n * ```tsx\n * // Debounced search input\n * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {\n * wait: 500 // Wait 500ms after last keystroke\n * });\n *\n * // Update value - will be debounced\n * const handleChange = (e) => {\n * setSearchTerm(e.target.value);\n * };\n *\n * // Access debouncer state via signals\n * console.log('Executions:', debouncer.executionCount());\n * console.log('Is pending:', debouncer.isPending());\n *\n * // In onExecute callback, use get* methods\n * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {\n * wait: 500,\n * onExecute: (debouncer) => {\n * console.log('Total executions:', debouncer.getExecutionCount());\n * }\n * });\n * ```\n */\nexport function createDebouncedSignal<TValue>(\n value: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>, [Accessor<TValue>]>,\n): [\n Accessor<TValue>,\n Setter<TValue>,\n SolidDebouncer<Setter<TValue>, [Accessor<TValue>]>,\n] {\n const [debouncedValue, setDebouncedValue] = createSignal<TValue>(value)\n\n const debouncer = createDebouncer(setDebouncedValue, initialOptions)\n\n return [debouncedValue, debouncer.maybeExecute as Setter<TValue>, debouncer]\n}\n"],"names":[],"mappings":";;AA6CgB,SAAA,sBACd,OACA,gBAKA;AACA,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,aAAqB,KAAK;AAEhE,QAAA,YAAY,gBAAgB,mBAAmB,cAAc;AAEnE,SAAO,CAAC,gBAAgB,UAAU,cAAgC,SAAS;AAC7E;"}
@@ -0,0 +1,44 @@
1
+ import { SolidDebouncer } from './createDebouncer.js';
2
+ import { Accessor, Setter } from 'solid-js';
3
+ import { DebouncerOptions } from '@tanstack/pacer/debouncer';
4
+ /**
5
+ * A Solid hook that creates a debounced value that updates only after a specified delay.
6
+ * Unlike createDebouncedSignal, this hook automatically tracks changes to the input value
7
+ * and updates the debounced value accordingly.
8
+ *
9
+ * The debounced value will only update after the specified wait time has elapsed since
10
+ * the last change to the input value. If the input value changes again before the wait
11
+ * time expires, the timer resets and starts waiting again.
12
+ *
13
+ * This is useful for deriving debounced values from props or state that change frequently,
14
+ * like search queries or form inputs, where you want to limit how often downstream effects
15
+ * or calculations occur.
16
+ *
17
+ * The hook returns a tuple containing:
18
+ * - The current debounced value (as an Accessor)
19
+ * - The debouncer instance with control methods and state signals
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * // Debounce a search query
24
+ * const [searchQuery, setSearchQuery] = createSignal('');
25
+ * const [debouncedQuery, debouncer] = createDebouncedValue(searchQuery, {
26
+ * wait: 500 // Wait 500ms after last change
27
+ * });
28
+ *
29
+ * // debouncedQuery will update 500ms after searchQuery stops changing
30
+ * createEffect(() => {
31
+ * fetchSearchResults(debouncedQuery());
32
+ * });
33
+ *
34
+ * // Access debouncer state via signals
35
+ * console.log('Executions:', debouncer.executionCount());
36
+ * console.log('Is pending:', debouncer.isPending());
37
+ *
38
+ * // Handle input changes
39
+ * const handleChange = (e) => {
40
+ * setSearchQuery(e.target.value);
41
+ * };
42
+ * ```
43
+ */
44
+ export declare function createDebouncedValue<TValue>(value: Accessor<TValue>, initialOptions: DebouncerOptions<Setter<TValue>, [Accessor<TValue>]>): [Accessor<TValue>, SolidDebouncer<Setter<TValue>, [Accessor<TValue>]>];
@@ -0,0 +1,19 @@
1
+ import { createEffect, onCleanup } from "solid-js";
2
+ import { createDebouncedSignal } from "./createDebouncedSignal.js";
3
+ function createDebouncedValue(value, initialOptions) {
4
+ const [debouncedValue, setDebouncedValue, debouncer] = createDebouncedSignal(
5
+ value(),
6
+ initialOptions
7
+ );
8
+ createEffect(() => {
9
+ setDebouncedValue(value());
10
+ onCleanup(() => {
11
+ debouncer.cancel();
12
+ });
13
+ });
14
+ return [debouncedValue, debouncer];
15
+ }
16
+ export {
17
+ createDebouncedValue
18
+ };
19
+ //# sourceMappingURL=createDebouncedValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDebouncedValue.js","sources":["../../../src/debouncer/createDebouncedValue.ts"],"sourcesContent":["import { createEffect, onCleanup } from 'solid-js'\nimport { createDebouncedSignal } from './createDebouncedSignal'\nimport type { SolidDebouncer } from './createDebouncer'\nimport type { Accessor, Setter } from 'solid-js'\nimport type { DebouncerOptions } from '@tanstack/pacer/debouncer'\n\n/**\n * A Solid hook that creates a debounced value that updates only after a specified delay.\n * Unlike createDebouncedSignal, this hook automatically tracks changes to the input value\n * and updates the debounced value accordingly.\n *\n * The debounced value will only update after the specified wait time has elapsed since\n * the last change to the input value. If the input value changes again before the wait\n * time expires, the timer resets and starts waiting again.\n *\n * This is useful for deriving debounced values from props or state that change frequently,\n * like search queries or form inputs, where you want to limit how often downstream effects\n * or calculations occur.\n *\n * The hook returns a tuple containing:\n * - The current debounced value (as an Accessor)\n * - The debouncer instance with control methods and state signals\n *\n * @example\n * ```tsx\n * // Debounce a search query\n * const [searchQuery, setSearchQuery] = createSignal('');\n * const [debouncedQuery, debouncer] = createDebouncedValue(searchQuery, {\n * wait: 500 // Wait 500ms after last change\n * });\n *\n * // debouncedQuery will update 500ms after searchQuery stops changing\n * createEffect(() => {\n * fetchSearchResults(debouncedQuery());\n * });\n *\n * // Access debouncer state via signals\n * console.log('Executions:', debouncer.executionCount());\n * console.log('Is pending:', debouncer.isPending());\n *\n * // Handle input changes\n * const handleChange = (e) => {\n * setSearchQuery(e.target.value);\n * };\n * ```\n */\nexport function createDebouncedValue<TValue>(\n value: Accessor<TValue>,\n initialOptions: DebouncerOptions<Setter<TValue>, [Accessor<TValue>]>,\n): [Accessor<TValue>, SolidDebouncer<Setter<TValue>, [Accessor<TValue>]>] {\n const [debouncedValue, setDebouncedValue, debouncer] = createDebouncedSignal(\n value(),\n initialOptions,\n )\n\n createEffect(() => {\n setDebouncedValue(value() as any)\n onCleanup(() => {\n debouncer.cancel()\n })\n })\n\n return [debouncedValue, debouncer]\n}\n"],"names":[],"mappings":";;AA8CgB,SAAA,qBACd,OACA,gBACwE;AACxE,QAAM,CAAC,gBAAgB,mBAAmB,SAAS,IAAI;AAAA,IACrD,MAAM;AAAA,IACN;AAAA,EACF;AAEA,eAAa,MAAM;AACjB,sBAAkB,OAAc;AAChC,cAAU,MAAM;AACd,gBAAU,OAAO;AAAA,IAAA,CAClB;AAAA,EAAA,CACF;AAEM,SAAA,CAAC,gBAAgB,SAAS;AACnC;"}
@@ -0,0 +1,47 @@
1
+ import { Debouncer, DebouncerOptions } from '@tanstack/pacer/debouncer';
2
+ import { Accessor } from 'solid-js';
3
+ import { AnyFunction } from '@tanstack/pacer/types';
4
+ /**
5
+ * An extension of the Debouncer class that adds Solid signals to access the internal state of the debouncer
6
+ */
7
+ export interface SolidDebouncer<TFn extends AnyFunction, TArgs extends Parameters<TFn>> extends Omit<Debouncer<TFn, TArgs>, 'getExecutionCount' | 'getIsPending'> {
8
+ executionCount: Accessor<number>;
9
+ isPending: Accessor<boolean>;
10
+ }
11
+ /**
12
+ * A Solid hook that creates and manages a Debouncer instance.
13
+ *
14
+ * This is a lower-level hook that provides direct access to the Debouncer's functionality without
15
+ * any built-in state management. This allows you to integrate it with any state management solution
16
+ * you prefer (createSignal, Redux, Zustand, etc.).
17
+ *
18
+ * This hook provides debouncing functionality to limit how often a function can be called,
19
+ * waiting for a specified delay before executing the latest call. This is useful for handling
20
+ * frequent events like window resizing, scroll events, or real-time search inputs.
21
+ *
22
+ * The debouncer will only execute the function after the specified wait time has elapsed
23
+ * since the last call. If the function is called again before the wait time expires, the
24
+ * timer resets and starts waiting again.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * // Debounce a search function to limit API calls
29
+ * const debouncer = createDebouncer(
30
+ * (query: string) => fetchSearchResults(query),
31
+ * { wait: 500 } // Wait 500ms after last keystroke
32
+ * );
33
+ *
34
+ * // In an event handler
35
+ * const handleChange = (e) => {
36
+ * debouncer.maybeExecute(e.target.value);
37
+ * };
38
+ *
39
+ * // Access debouncer state via signals
40
+ * console.log('Executions:', debouncer.executionCount());
41
+ * console.log('Is pending:', debouncer.isPending());
42
+ *
43
+ * // Update options
44
+ * debouncer.setOptions({ wait: 1000 });
45
+ * ```
46
+ */
47
+ export declare function createDebouncer<TFn extends AnyFunction, TArgs extends Parameters<TFn>>(fn: TFn, initialOptions: DebouncerOptions<TFn, TArgs>): SolidDebouncer<TFn, TArgs>;