@tanstack/pacer 0.8.0 → 0.9.1

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 (91) hide show
  1. package/dist/cjs/async-batcher.cjs +163 -0
  2. package/dist/cjs/async-batcher.cjs.map +1 -0
  3. package/dist/cjs/async-batcher.d.cts +273 -0
  4. package/dist/cjs/async-debouncer.cjs +149 -162
  5. package/dist/cjs/async-debouncer.cjs.map +1 -1
  6. package/dist/cjs/async-debouncer.d.cts +76 -57
  7. package/dist/cjs/async-queuer.cjs +282 -343
  8. package/dist/cjs/async-queuer.cjs.map +1 -1
  9. package/dist/cjs/async-queuer.d.cts +121 -100
  10. package/dist/cjs/async-rate-limiter.cjs +128 -185
  11. package/dist/cjs/async-rate-limiter.cjs.map +1 -1
  12. package/dist/cjs/async-rate-limiter.d.cts +72 -61
  13. package/dist/cjs/async-throttler.cjs +168 -178
  14. package/dist/cjs/async-throttler.cjs.map +1 -1
  15. package/dist/cjs/async-throttler.d.cts +97 -69
  16. package/dist/cjs/batcher.cjs +110 -119
  17. package/dist/cjs/batcher.cjs.map +1 -1
  18. package/dist/cjs/batcher.d.cts +76 -51
  19. package/dist/cjs/debouncer.cjs +97 -85
  20. package/dist/cjs/debouncer.cjs.map +1 -1
  21. package/dist/cjs/debouncer.d.cts +54 -26
  22. package/dist/cjs/index.cjs +3 -6
  23. package/dist/cjs/index.cjs.map +1 -1
  24. package/dist/cjs/index.d.cts +1 -1
  25. package/dist/cjs/queuer.cjs +247 -294
  26. package/dist/cjs/queuer.cjs.map +1 -1
  27. package/dist/cjs/queuer.d.cts +102 -81
  28. package/dist/cjs/rate-limiter.cjs +97 -130
  29. package/dist/cjs/rate-limiter.cjs.map +1 -1
  30. package/dist/cjs/rate-limiter.d.cts +50 -37
  31. package/dist/cjs/throttler.cjs +107 -123
  32. package/dist/cjs/throttler.cjs.map +1 -1
  33. package/dist/cjs/throttler.d.cts +59 -35
  34. package/dist/cjs/utils.cjs +0 -13
  35. package/dist/cjs/utils.cjs.map +1 -1
  36. package/dist/cjs/utils.d.cts +0 -1
  37. package/dist/esm/async-batcher.d.ts +273 -0
  38. package/dist/esm/async-batcher.js +163 -0
  39. package/dist/esm/async-batcher.js.map +1 -0
  40. package/dist/esm/async-debouncer.d.ts +76 -57
  41. package/dist/esm/async-debouncer.js +149 -162
  42. package/dist/esm/async-debouncer.js.map +1 -1
  43. package/dist/esm/async-queuer.d.ts +121 -100
  44. package/dist/esm/async-queuer.js +282 -343
  45. package/dist/esm/async-queuer.js.map +1 -1
  46. package/dist/esm/async-rate-limiter.d.ts +72 -61
  47. package/dist/esm/async-rate-limiter.js +128 -185
  48. package/dist/esm/async-rate-limiter.js.map +1 -1
  49. package/dist/esm/async-throttler.d.ts +97 -69
  50. package/dist/esm/async-throttler.js +168 -178
  51. package/dist/esm/async-throttler.js.map +1 -1
  52. package/dist/esm/batcher.d.ts +76 -51
  53. package/dist/esm/batcher.js +110 -119
  54. package/dist/esm/batcher.js.map +1 -1
  55. package/dist/esm/debouncer.d.ts +54 -26
  56. package/dist/esm/debouncer.js +97 -85
  57. package/dist/esm/debouncer.js.map +1 -1
  58. package/dist/esm/index.d.ts +1 -1
  59. package/dist/esm/index.js +4 -7
  60. package/dist/esm/queuer.d.ts +102 -81
  61. package/dist/esm/queuer.js +247 -294
  62. package/dist/esm/queuer.js.map +1 -1
  63. package/dist/esm/rate-limiter.d.ts +50 -37
  64. package/dist/esm/rate-limiter.js +97 -130
  65. package/dist/esm/rate-limiter.js.map +1 -1
  66. package/dist/esm/throttler.d.ts +59 -35
  67. package/dist/esm/throttler.js +107 -123
  68. package/dist/esm/throttler.js.map +1 -1
  69. package/dist/esm/utils.d.ts +0 -1
  70. package/dist/esm/utils.js +0 -13
  71. package/dist/esm/utils.js.map +1 -1
  72. package/package.json +14 -11
  73. package/src/async-batcher.ts +475 -0
  74. package/src/async-debouncer.ts +201 -121
  75. package/src/async-queuer.ts +337 -216
  76. package/src/async-rate-limiter.ts +176 -136
  77. package/src/async-throttler.ts +233 -139
  78. package/src/batcher.ts +158 -92
  79. package/src/debouncer.ts +135 -52
  80. package/src/index.ts +1 -1
  81. package/src/queuer.ts +349 -226
  82. package/src/rate-limiter.ts +125 -80
  83. package/src/throttler.ts +152 -78
  84. package/src/utils.ts +0 -15
  85. package/dist/cjs/compare.cjs +0 -72
  86. package/dist/cjs/compare.cjs.map +0 -1
  87. package/dist/cjs/compare.d.cts +0 -12
  88. package/dist/esm/compare.d.ts +0 -12
  89. package/dist/esm/compare.js +0 -72
  90. package/dist/esm/compare.js.map +0 -1
  91. package/src/compare.ts +0 -105
@@ -1,323 +1,276 @@
1
+ import { Store } from "@tanstack/store";
1
2
  import { parseFunctionOrValue } from "./utils.js";
3
+ function getDefaultQueuerState() {
4
+ return {
5
+ executionCount: 0,
6
+ expirationCount: 0,
7
+ isEmpty: true,
8
+ isFull: false,
9
+ isIdle: true,
10
+ isRunning: true,
11
+ itemTimestamps: [],
12
+ items: [],
13
+ pendingTick: false,
14
+ rejectionCount: 0,
15
+ size: 0,
16
+ status: "idle"
17
+ };
18
+ }
2
19
  const defaultOptions = {
3
20
  addItemsTo: "back",
4
21
  getItemsFrom: "front",
5
- getPriority: (item) => (item == null ? void 0 : item.priority) ?? 0,
22
+ getPriority: (item) => item?.priority ?? 0,
6
23
  getIsExpired: () => false,
7
24
  expirationDuration: Infinity,
8
25
  initialItems: [],
9
26
  maxSize: Infinity,
10
- onExecute: () => {
11
- },
12
- onIsRunningChange: () => {
13
- },
14
- onItemsChange: () => {
15
- },
16
- onReject: () => {
17
- },
18
- onExpire: () => {
19
- },
20
27
  started: true,
21
28
  wait: 0
22
29
  };
23
30
  class Queuer {
24
31
  constructor(fn, initialOptions = {}) {
25
32
  this.fn = fn;
26
- this._items = [];
27
- this._itemTimestamps = [];
28
- this._executionCount = 0;
29
- this._rejectionCount = 0;
30
- this._expirationCount = 0;
31
- this._onItemsChanges = [];
32
- this._pendingTick = false;
33
- this._options = { ...defaultOptions, ...initialOptions };
34
- this._running = this._options.started;
35
- for (let i = 0; i < this._options.initialItems.length; i++) {
36
- const item = this._options.initialItems[i];
37
- const isLast = i === this._options.initialItems.length - 1;
38
- this.addItem(item, this._options.addItemsTo, isLast);
39
- }
40
- }
41
- /**
42
- * Updates the queuer options. New options are merged with existing options.
43
- */
44
- setOptions(newOptions) {
45
- this._options = { ...this._options, ...newOptions };
46
- }
47
- /**
48
- * Returns the current queuer options, including defaults and any overrides.
49
- */
50
- getOptions() {
51
- return this._options;
52
- }
53
- /**
54
- * Returns the current wait time (in milliseconds) between processing items.
55
- * If a function is provided, it is called with the queuer instance.
56
- */
57
- getWait() {
58
- return parseFunctionOrValue(this._options.wait, this);
59
- }
60
- /**
61
- * Processes items in the queue up to the wait interval. Internal use only.
62
- */
63
- tick() {
64
- if (!this._running) {
65
- this._pendingTick = false;
66
- return;
67
- }
68
- this.checkExpiredItems();
69
- while (!this.getIsEmpty()) {
70
- const nextItem = this.execute(this._options.getItemsFrom);
71
- if (nextItem === void 0) {
72
- break;
73
- }
74
- this._onItemsChanges.forEach((cb) => cb(nextItem));
75
- const wait = this.getWait();
76
- if (wait > 0) {
77
- setTimeout(() => this.tick(), wait);
33
+ this.store = new Store(
34
+ getDefaultQueuerState()
35
+ );
36
+ this.#timeoutId = null;
37
+ this.setOptions = (newOptions) => {
38
+ this.options = { ...this.options, ...newOptions };
39
+ };
40
+ this.#setState = (newState) => {
41
+ this.store.setState((state) => {
42
+ const combinedState = {
43
+ ...state,
44
+ ...newState
45
+ };
46
+ const { items, isRunning } = combinedState;
47
+ const size = items.length;
48
+ const isFull = size >= (this.options.maxSize ?? Infinity);
49
+ const isEmpty = size === 0;
50
+ const isIdle = isRunning && isEmpty;
51
+ const status = isIdle ? "idle" : isRunning ? "running" : "stopped";
52
+ return {
53
+ ...combinedState,
54
+ isEmpty,
55
+ isFull,
56
+ isIdle,
57
+ size,
58
+ status
59
+ };
60
+ });
61
+ };
62
+ this.#getWait = () => {
63
+ return parseFunctionOrValue(this.options.wait ?? 0, this);
64
+ };
65
+ this.#tick = () => {
66
+ if (!this.store.state.isRunning) {
67
+ this.#setState({ pendingTick: false });
78
68
  return;
79
69
  }
80
- this.tick();
81
- }
82
- this._pendingTick = false;
83
- }
84
- /**
85
- * Checks for expired items in the queue and removes them. Calls onExpire for each expired item.
86
- * Internal use only.
87
- */
88
- checkExpiredItems() {
89
- if (this._options.expirationDuration === Infinity && this._options.getIsExpired === defaultOptions.getIsExpired)
90
- return;
91
- const now = Date.now();
92
- const expiredIndices = [];
93
- for (let i = 0; i < this._items.length; i++) {
94
- const timestamp = this._itemTimestamps[i];
95
- if (timestamp === void 0) continue;
96
- const item = this._items[i];
97
- if (item === void 0) continue;
98
- const isExpired = this._options.getIsExpired !== defaultOptions.getIsExpired ? this._options.getIsExpired(item, timestamp) : now - timestamp > this._options.expirationDuration;
99
- if (isExpired) {
100
- expiredIndices.push(i);
70
+ this.#setState({ pendingTick: true });
71
+ this.#checkExpiredItems();
72
+ while (this.store.state.items.length > 0) {
73
+ const nextItem = this.execute(this.options.getItemsFrom ?? "front");
74
+ if (nextItem === void 0) {
75
+ break;
76
+ }
77
+ const wait = this.#getWait();
78
+ if (wait > 0) {
79
+ this.#timeoutId = setTimeout(() => this.#tick(), wait);
80
+ return;
81
+ }
82
+ this.#tick();
101
83
  }
102
- }
103
- for (let i = expiredIndices.length - 1; i >= 0; i--) {
104
- const index = expiredIndices[i];
105
- if (index === void 0) continue;
106
- const expiredItem = this._items[index];
107
- if (expiredItem === void 0) continue;
108
- this._items.splice(index, 1);
109
- this._itemTimestamps.splice(index, 1);
110
- this._expirationCount++;
111
- this._options.onExpire(expiredItem, this);
112
- }
113
- if (expiredIndices.length > 0) {
114
- this._options.onItemsChange(this);
115
- }
116
- }
117
- /**
118
- * Stops processing items in the queue. Does not clear the queue.
119
- */
120
- stop() {
121
- this._running = false;
122
- this._pendingTick = false;
123
- this._options.onIsRunningChange(this);
124
- }
125
- /**
126
- * Starts processing items in the queue. If already running, does nothing.
127
- */
128
- start() {
129
- this._running = true;
130
- if (!this._pendingTick && !this.getIsEmpty()) {
131
- this._pendingTick = true;
132
- this.tick();
133
- }
134
- this._options.onIsRunningChange(this);
135
- }
136
- /**
137
- * Removes all pending items from the queue. Does not affect items being processed.
138
- */
139
- clear() {
140
- this._items = [];
141
- this._options.onItemsChange(this);
142
- }
143
- /**
144
- * Resets the queuer to its initial state. Optionally repopulates with initial items.
145
- * Does not affect callbacks or options.
146
- */
147
- reset(withInitialItems) {
148
- this.clear();
149
- this._executionCount = 0;
150
- if (withInitialItems) {
151
- this._items = [...this._options.initialItems];
152
- }
153
- this._running = this._options.started;
154
- }
155
- /**
156
- * Adds an item to the queue. If the queue is full, the item is rejected and onReject is called.
157
- * Items can be inserted based on priority or at the front/back depending on configuration.
158
- *
159
- * Returns true if the item was added, false if the queue is full.
160
- *
161
- * Example usage:
162
- * ```ts
163
- * queuer.addItem('task');
164
- * queuer.addItem('task2', 'front');
165
- * ```
166
- */
167
- addItem(item, position = this._options.addItemsTo, runOnUpdate = true) {
168
- if (this.getIsFull()) {
169
- this._rejectionCount++;
170
- this._options.onReject(item, this);
171
- return false;
172
- }
173
- if (this._options.getPriority !== defaultOptions.getPriority) {
174
- const priority = this._options.getPriority(item);
175
- const insertIndex = this._items.findIndex(
176
- (existing) => this._options.getPriority(existing) < priority
177
- );
178
- if (insertIndex === -1) {
179
- this._items.push(item);
180
- this._itemTimestamps.push(Date.now());
84
+ this.#setState({ pendingTick: false });
85
+ };
86
+ this.addItem = (item, position = this.options.addItemsTo ?? "back", runOnItemsChange = true) => {
87
+ if (this.store.state.items.length >= (this.options.maxSize ?? Infinity)) {
88
+ this.#setState({
89
+ rejectionCount: this.store.state.rejectionCount + 1
90
+ });
91
+ this.options.onReject?.(item, this);
92
+ return false;
93
+ }
94
+ const priority = this.options.getPriority !== defaultOptions.getPriority ? this.options.getPriority(item) : item.priority;
95
+ const items = this.store.state.items;
96
+ const itemTimestamps = this.store.state.itemTimestamps;
97
+ if (priority !== void 0) {
98
+ const insertIndex = items.findIndex((existing) => {
99
+ const existingPriority = this.options.getPriority !== defaultOptions.getPriority ? this.options.getPriority(existing) : existing.priority;
100
+ return existingPriority < priority;
101
+ });
102
+ if (insertIndex === -1) {
103
+ items.push(item);
104
+ itemTimestamps.push(Date.now());
105
+ } else {
106
+ items.splice(insertIndex, 0, item);
107
+ itemTimestamps.splice(insertIndex, 0, Date.now());
108
+ }
181
109
  } else {
182
- this._items.splice(insertIndex, 0, item);
183
- this._itemTimestamps.splice(insertIndex, 0, Date.now());
110
+ if (position === "front") {
111
+ items.unshift(item);
112
+ itemTimestamps.unshift(Date.now());
113
+ } else {
114
+ items.push(item);
115
+ itemTimestamps.push(Date.now());
116
+ }
184
117
  }
185
- } else {
118
+ this.#setState({
119
+ items,
120
+ itemTimestamps
121
+ });
122
+ if (runOnItemsChange) {
123
+ this.options.onItemsChange?.(this);
124
+ }
125
+ if (this.store.state.isRunning && !this.store.state.pendingTick) {
126
+ this.#setState({ pendingTick: true });
127
+ this.#tick();
128
+ }
129
+ return true;
130
+ };
131
+ this.getNextItem = (position = this.options.getItemsFrom ?? "front") => {
132
+ const { items, itemTimestamps } = this.store.state;
133
+ let item;
186
134
  if (position === "front") {
187
- this._items.unshift(item);
188
- this._itemTimestamps.unshift(Date.now());
135
+ item = items[0];
136
+ if (item !== void 0) {
137
+ this.#setState({
138
+ items: items.slice(1),
139
+ itemTimestamps: itemTimestamps.slice(1)
140
+ });
141
+ }
189
142
  } else {
190
- this._items.push(item);
191
- this._itemTimestamps.push(Date.now());
143
+ item = items[items.length - 1];
144
+ if (item !== void 0) {
145
+ this.#setState({
146
+ items: items.slice(0, -1),
147
+ itemTimestamps: itemTimestamps.slice(0, -1)
148
+ });
149
+ }
150
+ }
151
+ if (item !== void 0) {
152
+ this.options.onItemsChange?.(this);
153
+ }
154
+ return item;
155
+ };
156
+ this.execute = (position) => {
157
+ const item = this.getNextItem(position);
158
+ if (item !== void 0) {
159
+ this.fn(item);
160
+ this.#setState({
161
+ executionCount: this.store.state.executionCount + 1
162
+ });
163
+ this.options.onExecute?.(item, this);
164
+ }
165
+ return item;
166
+ };
167
+ this.flush = (numberOfItems = this.store.state.items.length, position) => {
168
+ this.#clearTimeout();
169
+ for (let i = 0; i < numberOfItems; i++) {
170
+ this.execute(position);
171
+ }
172
+ this.#tick();
173
+ };
174
+ this.#checkExpiredItems = () => {
175
+ if ((this.options.expirationDuration ?? Infinity) === Infinity && this.options.getIsExpired === defaultOptions.getIsExpired) {
176
+ return;
177
+ }
178
+ const now = Date.now();
179
+ const expiredIndices = [];
180
+ for (let i = 0; i < this.store.state.items.length; i++) {
181
+ const timestamp = this.store.state.itemTimestamps[i];
182
+ if (timestamp === void 0) continue;
183
+ const item = this.store.state.items[i];
184
+ if (item === void 0) continue;
185
+ const isExpired = this.options.getIsExpired !== defaultOptions.getIsExpired ? this.options.getIsExpired(item, timestamp) : now - timestamp > (this.options.expirationDuration ?? Infinity);
186
+ if (isExpired) {
187
+ expiredIndices.push(i);
188
+ }
189
+ }
190
+ for (let i = expiredIndices.length - 1; i >= 0; i--) {
191
+ const index = expiredIndices[i];
192
+ if (index === void 0) continue;
193
+ const expiredItem = this.store.state.items[index];
194
+ if (expiredItem === void 0) continue;
195
+ const newItems = [...this.store.state.items];
196
+ const newTimestamps = [...this.store.state.itemTimestamps];
197
+ newItems.splice(index, 1);
198
+ newTimestamps.splice(index, 1);
199
+ this.#setState({
200
+ items: newItems,
201
+ itemTimestamps: newTimestamps,
202
+ expirationCount: this.store.state.expirationCount + 1
203
+ });
204
+ this.options.onExpire?.(expiredItem, this);
205
+ }
206
+ if (expiredIndices.length > 0) {
207
+ this.options.onItemsChange?.(this);
208
+ }
209
+ };
210
+ this.peekNextItem = (position = "front") => {
211
+ if (position === "front") {
212
+ return this.store.state.items[0];
213
+ }
214
+ return this.store.state.items[this.store.state.items.length - 1];
215
+ };
216
+ this.peekAllItems = () => {
217
+ return [...this.store.state.items];
218
+ };
219
+ this.start = () => {
220
+ this.#setState({ isRunning: true });
221
+ if (!this.store.state.pendingTick && this.store.state.items.length > 0) {
222
+ this.#tick();
223
+ }
224
+ };
225
+ this.stop = () => {
226
+ this.#clearTimeout();
227
+ this.#setState({ isRunning: false, pendingTick: false });
228
+ };
229
+ this.#clearTimeout = () => {
230
+ if (this.#timeoutId) {
231
+ clearTimeout(this.#timeoutId);
232
+ this.#timeoutId = null;
233
+ }
234
+ };
235
+ this.clear = () => {
236
+ this.#setState({ items: [], itemTimestamps: [] });
237
+ this.options.onItemsChange?.(this);
238
+ };
239
+ this.reset = () => {
240
+ this.#setState(getDefaultQueuerState());
241
+ this.options.onItemsChange?.(this);
242
+ };
243
+ this.options = {
244
+ ...defaultOptions,
245
+ ...initialOptions
246
+ };
247
+ const isInitiallyRunning = this.options.initialState?.isRunning ?? this.options.started ?? true;
248
+ this.#setState({
249
+ ...this.options.initialState,
250
+ isRunning: isInitiallyRunning
251
+ });
252
+ if (this.options.initialState?.items) {
253
+ if (this.store.state.isRunning) {
254
+ this.#tick();
192
255
  }
193
- }
194
- if (this._running && !this._pendingTick) {
195
- this._pendingTick = true;
196
- this.tick();
197
- }
198
- if (runOnUpdate) {
199
- this._options.onItemsChange(this);
200
- }
201
- return true;
202
- }
203
- /**
204
- * Removes and returns the next item from the queue without executing the function.
205
- * Use for manual queue management. Normally, use execute() to process items.
206
- *
207
- * Example usage:
208
- * ```ts
209
- * // FIFO
210
- * queuer.getNextItem();
211
- * // LIFO
212
- * queuer.getNextItem('back');
213
- * ```
214
- */
215
- getNextItem(position = this._options.getItemsFrom) {
216
- let item;
217
- if (position === "front") {
218
- item = this._items.shift();
219
- this._itemTimestamps.shift();
220
256
  } else {
221
- item = this._items.pop();
222
- this._itemTimestamps.pop();
223
- }
224
- if (item !== void 0) {
225
- this._options.onItemsChange(this);
226
- }
227
- return item;
228
- }
229
- /**
230
- * Removes and returns the next item from the queue and processes it using the provided function.
231
- *
232
- * Example usage:
233
- * ```ts
234
- * queuer.execute();
235
- * // LIFO
236
- * queuer.execute('back');
237
- * ```
238
- */
239
- execute(position) {
240
- const item = this.getNextItem(position);
241
- if (item !== void 0) {
242
- this.fn(item);
243
- this._executionCount++;
244
- this._options.onExecute(item, this);
245
- }
246
- return item;
247
- }
248
- /**
249
- * Returns the next item in the queue without removing it.
250
- *
251
- * Example usage:
252
- * ```ts
253
- * queuer.peekNextItem(); // front
254
- * queuer.peekNextItem('back'); // back
255
- * ```
256
- */
257
- peekNextItem(position = this._options.getItemsFrom) {
258
- if (position === "front") {
259
- return this._items[0];
257
+ for (let i = 0; i < (this.options.initialItems?.length ?? 0); i++) {
258
+ const item = this.options.initialItems[i];
259
+ const isLast = i === (this.options.initialItems?.length ?? 0) - 1;
260
+ this.addItem(item, this.options.addItemsTo ?? "back", isLast);
261
+ }
260
262
  }
261
- return this._items[this._items.length - 1];
262
- }
263
- /**
264
- * Returns true if the queue is empty (no pending items).
265
- */
266
- getIsEmpty() {
267
- return this._items.length === 0;
268
- }
269
- /**
270
- * Returns true if the queue is full (reached maxSize).
271
- */
272
- getIsFull() {
273
- return this._items.length >= this._options.maxSize;
274
- }
275
- /**
276
- * Returns the number of pending items in the queue.
277
- */
278
- getSize() {
279
- return this._items.length;
280
- }
281
- /**
282
- * Returns a copy of all items in the queue.
283
- */
284
- peekAllItems() {
285
- return [...this._items];
286
- }
287
- /**
288
- * Returns the number of items that have been processed and removed from the queue.
289
- */
290
- getExecutionCount() {
291
- return this._executionCount;
292
- }
293
- /**
294
- * Returns the number of items that have been rejected from being added to the queue.
295
- */
296
- getRejectionCount() {
297
- return this._rejectionCount;
298
- }
299
- /**
300
- * Returns the number of items that have expired and been removed from the queue.
301
- */
302
- getExpirationCount() {
303
- return this._expirationCount;
304
- }
305
- /**
306
- * Returns true if the queuer is currently running (processing items).
307
- */
308
- getIsRunning() {
309
- return this._running;
310
- }
311
- /**
312
- * Returns true if the queuer is running but has no items to process.
313
- */
314
- getIsIdle() {
315
- return this._running && this.getIsEmpty();
316
263
  }
264
+ #timeoutId;
265
+ #setState;
266
+ #getWait;
267
+ #tick;
268
+ #checkExpiredItems;
269
+ #clearTimeout;
317
270
  }
318
- function queue(fn, options) {
319
- const queuer = new Queuer(fn, options);
320
- return queuer.addItem.bind(queuer);
271
+ function queue(fn, initialOptions) {
272
+ const queuer = new Queuer(fn, initialOptions);
273
+ return queuer.addItem;
321
274
  }
322
275
  export {
323
276
  Queuer,