@tanstack/pacer-lite 0.1.0 → 0.1.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 (62) hide show
  1. package/dist/index.cjs +16 -0
  2. package/dist/index.d.cts +6 -0
  3. package/dist/index.d.ts +6 -0
  4. package/dist/{esm/index.js → index.js} +2 -13
  5. package/dist/lite-batcher.cjs +175 -0
  6. package/dist/lite-batcher.cjs.map +1 -0
  7. package/dist/{cjs/lite-batcher.d.cts → lite-batcher.d.cts} +89 -85
  8. package/dist/{esm/lite-batcher.d.ts → lite-batcher.d.ts} +89 -85
  9. package/dist/lite-batcher.js +173 -0
  10. package/dist/lite-batcher.js.map +1 -0
  11. package/dist/lite-debouncer.cjs +125 -0
  12. package/dist/lite-debouncer.cjs.map +1 -0
  13. package/dist/{cjs/lite-debouncer.d.cts → lite-debouncer.d.cts} +53 -47
  14. package/dist/{esm/lite-debouncer.d.ts → lite-debouncer.d.ts} +53 -47
  15. package/dist/lite-debouncer.js +123 -0
  16. package/dist/lite-debouncer.js.map +1 -0
  17. package/dist/lite-queuer.cjs +208 -0
  18. package/dist/lite-queuer.cjs.map +1 -0
  19. package/dist/lite-queuer.d.cts +243 -0
  20. package/dist/lite-queuer.d.ts +243 -0
  21. package/dist/lite-queuer.js +206 -0
  22. package/dist/lite-queuer.js.map +1 -0
  23. package/dist/lite-rate-limiter.cjs +149 -0
  24. package/dist/lite-rate-limiter.cjs.map +1 -0
  25. package/dist/{cjs/lite-rate-limiter.d.cts → lite-rate-limiter.d.cts} +73 -67
  26. package/dist/{esm/lite-rate-limiter.d.ts → lite-rate-limiter.d.ts} +73 -67
  27. package/dist/lite-rate-limiter.js +147 -0
  28. package/dist/lite-rate-limiter.js.map +1 -0
  29. package/dist/lite-throttler.cjs +127 -0
  30. package/dist/lite-throttler.cjs.map +1 -0
  31. package/dist/{cjs/lite-throttler.d.cts → lite-throttler.d.cts} +60 -54
  32. package/dist/{esm/lite-throttler.d.ts → lite-throttler.d.ts} +60 -54
  33. package/dist/lite-throttler.js +125 -0
  34. package/dist/lite-throttler.js.map +1 -0
  35. package/package.json +22 -59
  36. package/dist/cjs/index.cjs +0 -18
  37. package/dist/cjs/index.cjs.map +0 -1
  38. package/dist/cjs/index.d.cts +0 -5
  39. package/dist/cjs/lite-batcher.cjs +0 -92
  40. package/dist/cjs/lite-batcher.cjs.map +0 -1
  41. package/dist/cjs/lite-debouncer.cjs +0 -59
  42. package/dist/cjs/lite-debouncer.cjs.map +0 -1
  43. package/dist/cjs/lite-queuer.cjs +0 -171
  44. package/dist/cjs/lite-queuer.cjs.map +0 -1
  45. package/dist/cjs/lite-queuer.d.cts +0 -239
  46. package/dist/cjs/lite-rate-limiter.cjs +0 -95
  47. package/dist/cjs/lite-rate-limiter.cjs.map +0 -1
  48. package/dist/cjs/lite-throttler.cjs +0 -63
  49. package/dist/cjs/lite-throttler.cjs.map +0 -1
  50. package/dist/esm/index.d.ts +0 -5
  51. package/dist/esm/index.js.map +0 -1
  52. package/dist/esm/lite-batcher.js +0 -92
  53. package/dist/esm/lite-batcher.js.map +0 -1
  54. package/dist/esm/lite-debouncer.js +0 -59
  55. package/dist/esm/lite-debouncer.js.map +0 -1
  56. package/dist/esm/lite-queuer.d.ts +0 -239
  57. package/dist/esm/lite-queuer.js +0 -171
  58. package/dist/esm/lite-queuer.js.map +0 -1
  59. package/dist/esm/lite-rate-limiter.js +0 -95
  60. package/dist/esm/lite-rate-limiter.js.map +0 -1
  61. package/dist/esm/lite-throttler.js +0 -63
  62. package/dist/esm/lite-throttler.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"lite-batcher.cjs","sources":["../../src/lite-batcher.ts"],"sourcesContent":["/**\n * Options for configuring a lite batcher instance\n */\nexport interface LiteBatcherOptions<TValue> {\n /**\n * Custom function to determine if a batch should be processed\n * Return true to process the batch immediately\n */\n getShouldExecute?: (\n items: Array<TValue>,\n batcher: LiteBatcher<TValue>,\n ) => boolean\n /**\n * Maximum number of items in a batch\n * @default Infinity\n */\n maxSize?: number\n /**\n * Callback fired after a batch is processed\n */\n onExecute?: (batch: Array<TValue>, batcher: LiteBatcher<TValue>) => void\n /**\n * Callback fired after items are added to the batcher\n */\n onItemsChange?: (batcher: LiteBatcher<TValue>) => void\n /**\n * Whether the batcher should start processing immediately\n * @default true\n */\n started?: boolean\n /**\n * Maximum time in milliseconds to wait before processing a batch.\n * If the wait duration has elapsed, the batch will be processed.\n * If not provided, the batch will not be triggered by a timeout.\n * @default Infinity\n */\n wait?: number | ((batcher: LiteBatcher<TValue>) => number)\n}\n\n/**\n * A lightweight class that collects items and processes them in batches.\n *\n * This is an alternative to the Batcher in the core @tanstack/pacer package, but is more\n * suitable for libraries and npm packages that need minimal overhead. Unlike the core Batcher,\n * this version does not use TanStack Store for state management, has no devtools integration,\n * no callbacks, and provides only essential batching functionality.\n *\n * Batching is a technique for grouping multiple operations together to be processed as a single unit.\n * This synchronous version is lighter weight and often all you need.\n *\n * The Batcher provides a flexible way to implement batching with configurable:\n * - Maximum batch size (number of items per batch)\n * - Time-based batching (process after X milliseconds)\n * - Custom batch processing logic via getShouldExecute\n *\n * Features included:\n * - Core batching functionality (addItem, flush, clear, cancel)\n * - Size-based batching (maxSize)\n * - Time-based batching (wait timeout)\n * - Custom condition batching (getShouldExecute)\n * - Manual processing controls\n * - Public mutable options\n * - Callback support for monitoring batch execution and state changes\n *\n * Features NOT included (compared to core Batcher):\n * - No TanStack Store state management\n * - No devtools integration\n * - No complex state tracking (execution counts, etc.)\n * - No reactive state management\n *\n * @example\n * ```ts\n * // Basic batching\n * const batcher = new LiteBatcher<number>(\n * (items) => console.log('Processing batch:', items),\n * {\n * maxSize: 5,\n * wait: 2000,\n * onExecute: (batch, batcher) => {\n * console.log('Batch executed with', batch.length, 'items');\n * },\n * onItemsChange: (batcher) => {\n * console.log('Batch size changed to:', batcher.size);\n * }\n * }\n * );\n *\n * batcher.addItem(1);\n * batcher.addItem(2);\n * // After 2 seconds or when 5 items are added, whichever comes first,\n * // the batch will be processed\n * ```\n *\n * @example\n * ```ts\n * // Custom condition batching\n * const batcher = new LiteBatcher<Task>(\n * (items) => processTasks(items),\n * {\n * getShouldExecute: (items) => items.some(task => task.urgent),\n * maxSize: 10,\n * }\n * );\n *\n * batcher.addItem({ name: 'normal', urgent: false });\n * batcher.addItem({ name: 'urgent', urgent: true }); // Triggers immediate processing\n * ```\n */\nexport class LiteBatcher<TValue> {\n private items: Array<TValue> = []\n private timeoutId: NodeJS.Timeout | null = null\n private _isPending = false\n\n constructor(\n public fn: (items: Array<TValue>) => void,\n public options: LiteBatcherOptions<TValue> = {},\n ) {\n // Set defaults\n this.options.maxSize = this.options.maxSize ?? Infinity\n this.options.started = this.options.started ?? true\n this.options.wait = this.options.wait ?? Infinity\n this.options.getShouldExecute =\n this.options.getShouldExecute ?? (() => false)\n }\n\n /**\n * Number of items currently in the batch\n */\n get size(): number {\n return this.items.length\n }\n\n /**\n * Whether the batch has no items to process (items array is empty)\n */\n get isEmpty(): boolean {\n return this.items.length === 0\n }\n\n /**\n * Whether the batcher is waiting for the timeout to trigger batch processing\n */\n get isPending(): boolean {\n return this._isPending\n }\n\n private getWait(): number {\n if (typeof this.options.wait === 'function') {\n return this.options.wait(this)\n }\n return this.options.wait!\n }\n\n /**\n * Adds an item to the batcher\n * If the batch size is reached, timeout occurs, or getShouldExecute returns true, the batch will be processed\n */\n addItem = (item: TValue): void => {\n this.items.push(item)\n this._isPending = this.options.wait !== Infinity\n this.options.onItemsChange?.(this)\n\n const shouldProcess =\n this.items.length >= this.options.maxSize! ||\n this.options.getShouldExecute!(this.items, this)\n\n if (shouldProcess) {\n this.execute()\n } else if (this.options.wait !== Infinity) {\n this.clearTimeout() // clear any pending timeout to replace it with a new one\n this.timeoutId = setTimeout(() => this.execute(), this.getWait())\n }\n }\n\n /**\n * Processes the current batch of items.\n * This method will automatically be triggered if the batcher is running and any of these conditions are met:\n * - The number of items reaches maxSize\n * - The wait duration has elapsed\n * - The getShouldExecute function returns true upon adding an item\n *\n * You can also call this method manually to process the current batch at any time.\n */\n private execute = (): void => {\n if (this.items.length === 0) {\n return\n }\n\n const batch = this.peekAllItems() // copy of the items to be processed (to prevent race conditions)\n this.clear() // Clear items before processing to prevent race conditions\n\n this.fn(batch) // EXECUTE\n this.options.onExecute?.(batch, this)\n }\n\n /**\n * Processes the current batch of items immediately\n */\n flush = (): void => {\n this.clearTimeout() // clear any pending timeout\n this.execute() // execute immediately\n }\n\n /**\n * Returns a copy of all items in the batcher\n */\n peekAllItems = (): Array<TValue> => {\n return [...this.items]\n }\n\n private clearTimeout = (): void => {\n if (this.timeoutId) {\n clearTimeout(this.timeoutId)\n this.timeoutId = null\n }\n }\n\n /**\n * Removes all items from the batcher\n */\n clear = (): void => {\n const hadItems = this.items.length > 0\n this.items = []\n this._isPending = false\n if (hadItems) {\n this.options.onItemsChange?.(this)\n }\n }\n\n /**\n * Cancels any pending execution that was scheduled.\n * Does NOT clear out the items.\n */\n cancel = (): void => {\n this.clearTimeout()\n this._isPending = false\n }\n}\n\n/**\n * Creates a batcher that processes items in batches.\n *\n * This is an alternative to the batch function in the core @tanstack/pacer package, but is more\n * suitable for libraries and npm packages that need minimal overhead. Unlike the core version,\n * this function creates a batcher with no external dependencies, devtools integration, or reactive state.\n *\n * @example\n * ```ts\n * const batchItems = liteBatch<number>(\n * (items) => console.log('Processing:', items),\n * {\n * maxSize: 3,\n * }\n * );\n *\n * batchItems(1);\n * batchItems(2);\n * batchItems(3); // Triggers batch processing\n * ```\n */\nexport function liteBatch<TValue>(\n fn: (items: Array<TValue>) => void,\n options: LiteBatcherOptions<TValue> = {},\n): (item: TValue) => void {\n const batcher = new LiteBatcher<TValue>(fn, options)\n return batcher.addItem\n}\n"],"names":[],"mappings":";;AA4GO,MAAM,YAAoB;AAAA,EAK/B,YACS,IACA,UAAsC,IAC7C;AAFO,SAAA,KAAA;AACA,SAAA,UAAA;AANT,SAAQ,QAAuB,CAAA;AAC/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,QAAQ,WAAW;AAC/C,SAAK,QAAQ,OAAO,KAAK,QAAQ,QAAQ;AACzC,SAAK,QAAQ,mBACX,KAAK,QAAQ,qBAAqB,MAAM;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAe;AACjB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,UAAmB;AACrB,WAAO,KAAK,MAAM,WAAW;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ,UAAkB;AACxB,QAAI,OAAO,KAAK,QAAQ,SAAS,YAAY;AAC3C,aAAO,KAAK,QAAQ,KAAK,IAAI;AAAA,IAC/B;AACA,WAAO,KAAK,QAAQ;AAAA,EACtB;AAsFF;AAuBO,SAAS,UACd,IACA,UAAsC,IACd;AACxB,QAAM,UAAU,IAAI,YAAoB,IAAI,OAAO;AACnD,SAAO,QAAQ;AACjB;;;"}
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- class LiteDebouncer {
4
- constructor(fn, options) {
5
- this.fn = fn;
6
- this.options = options;
7
- this.canLeadingExecute = true;
8
- this.maybeExecute = (...args) => {
9
- let didLeadingExecute = false;
10
- if (this.options.leading && this.canLeadingExecute) {
11
- this.canLeadingExecute = false;
12
- didLeadingExecute = true;
13
- this.fn(...args);
14
- this.options.onExecute?.(args, this);
15
- }
16
- this.lastArgs = args;
17
- if (this.timeoutId) {
18
- clearTimeout(this.timeoutId);
19
- }
20
- this.timeoutId = setTimeout(() => {
21
- this.canLeadingExecute = true;
22
- if (this.options.trailing && !didLeadingExecute && this.lastArgs) {
23
- this.fn(...this.lastArgs);
24
- this.options.onExecute?.(this.lastArgs, this);
25
- }
26
- this.lastArgs = void 0;
27
- }, this.options.wait);
28
- };
29
- this.flush = () => {
30
- if (this.timeoutId && this.lastArgs) {
31
- clearTimeout(this.timeoutId);
32
- this.timeoutId = void 0;
33
- const args = this.lastArgs;
34
- this.fn(...args);
35
- this.options.onExecute?.(args, this);
36
- this.lastArgs = void 0;
37
- this.canLeadingExecute = true;
38
- }
39
- };
40
- this.cancel = () => {
41
- if (this.timeoutId) {
42
- clearTimeout(this.timeoutId);
43
- this.timeoutId = void 0;
44
- }
45
- this.lastArgs = void 0;
46
- this.canLeadingExecute = true;
47
- };
48
- if (this.options.leading === void 0 && this.options.trailing === void 0) {
49
- this.options.trailing = true;
50
- }
51
- }
52
- }
53
- function liteDebounce(fn, options) {
54
- const debouncer = new LiteDebouncer(fn, options);
55
- return debouncer.maybeExecute;
56
- }
57
- exports.LiteDebouncer = LiteDebouncer;
58
- exports.liteDebounce = liteDebounce;
59
- //# sourceMappingURL=lite-debouncer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lite-debouncer.cjs","sources":["../../src/lite-debouncer.ts"],"sourcesContent":["import type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * Options for configuring a lite debounced function\n */\nexport interface LiteDebouncerOptions<TFn extends AnyFunction = AnyFunction> {\n /**\n * Whether to execute on the leading edge of the timeout.\n * The first call will execute immediately and the rest will wait the delay.\n * Defaults to false.\n */\n leading?: boolean\n /**\n * Callback function that is called after the function is executed\n */\n onExecute?: (args: Parameters<TFn>, debouncer: LiteDebouncer<TFn>) => void\n /**\n * Whether to execute on the trailing edge of the timeout.\n * Defaults to true.\n */\n trailing?: boolean\n /**\n * Delay in milliseconds before executing the function.\n */\n wait: number\n}\n\n/**\n * A lightweight class that creates a debounced function.\n *\n * This is an alternative to the Debouncer in the core @tanstack/pacer package, but is more\n * suitable for libraries and npm packages that need minimal overhead. Unlike the core Debouncer,\n * this version does not use TanStack Store for state management, has no devtools integration,\n * and provides only essential debouncing functionality.\n *\n * Debouncing ensures that a function is only executed after a certain amount of time has passed\n * since its last invocation. This is useful for handling frequent events like window resizing,\n * scroll events, or input changes where you want to limit the rate of execution.\n *\n * The debounced function can be configured to execute either at the start of the delay period\n * (leading edge) or at the end (trailing edge, default). Each new call during the wait period\n * will reset the timer.\n *\n * Features:\n * - Zero dependencies - no external libraries required\n * - Minimal API surface - only essential methods (maybeExecute, flush, cancel)\n * - Simple state management - uses basic private properties instead of reactive stores\n * - Callback support for monitoring execution events\n * - Lightweight - designed for use in npm packages where bundle size matters\n *\n * @example\n * ```ts\n * const debouncer = new LiteDebouncer((value: string) => {\n * saveToDatabase(value);\n * }, {\n * wait: 500,\n * onExecute: (args, debouncer) => {\n * console.log('Saved value:', args[0]);\n * }\n * });\n *\n * // Will only save after 500ms of no new input\n * inputElement.addEventListener('input', () => {\n * debouncer.maybeExecute(inputElement.value);\n * });\n * ```\n */\nexport class LiteDebouncer<TFn extends AnyFunction> {\n private timeoutId: NodeJS.Timeout | undefined\n private lastArgs: Parameters<TFn> | undefined\n private canLeadingExecute = true\n\n constructor(\n public fn: TFn,\n public options: LiteDebouncerOptions<TFn>,\n ) {\n // Default trailing to true if neither leading nor trailing is specified\n if (\n this.options.leading === undefined &&\n this.options.trailing === undefined\n ) {\n this.options.trailing = true\n }\n }\n\n /**\n * Attempts to execute the debounced function.\n * If leading is true and this is the first call, executes immediately.\n * Otherwise, queues the execution for after the wait time.\n * Each new call resets the timer.\n */\n maybeExecute = (...args: Parameters<TFn>): void => {\n let didLeadingExecute = false\n\n if (this.options.leading && this.canLeadingExecute) {\n this.canLeadingExecute = false\n didLeadingExecute = true\n this.fn(...args)\n this.options.onExecute?.(args, this)\n }\n\n this.lastArgs = args\n\n if (this.timeoutId) {\n clearTimeout(this.timeoutId)\n }\n\n this.timeoutId = setTimeout(() => {\n this.canLeadingExecute = true\n if (this.options.trailing && !didLeadingExecute && this.lastArgs) {\n this.fn(...this.lastArgs)\n this.options.onExecute?.(this.lastArgs, this)\n }\n this.lastArgs = undefined\n }, this.options.wait)\n }\n\n /**\n * Processes the current pending execution immediately.\n * If there's a pending execution, it will be executed right away\n * and the timeout will be cleared.\n */\n flush = (): void => {\n if (this.timeoutId && this.lastArgs) {\n clearTimeout(this.timeoutId)\n this.timeoutId = undefined\n const args = this.lastArgs\n this.fn(...args)\n this.options.onExecute?.(args, this)\n this.lastArgs = undefined\n this.canLeadingExecute = true\n }\n }\n\n /**\n * Cancels any pending execution.\n * Clears the timeout and resets the internal state.\n */\n cancel = (): void => {\n if (this.timeoutId) {\n clearTimeout(this.timeoutId)\n this.timeoutId = undefined\n }\n this.lastArgs = undefined\n this.canLeadingExecute = true\n }\n}\n\n/**\n * Creates a lightweight debounced function that delays invoking the provided function until after a specified wait time.\n * Multiple calls during the wait period will cancel previous pending invocations and reset the timer.\n *\n * This is an alternative to the debounce function in the core @tanstack/pacer package, but is more\n * suitable for libraries and npm packages that need minimal overhead. Unlike the core version,\n * this function creates a debouncer with no external dependencies, devtools integration, or reactive state.\n *\n * If leading option is true, the function will execute immediately on the first call, then wait the delay\n * before allowing another execution.\n *\n * @example\n * ```ts\n * const debouncedSave = liteDebounce(() => {\n * saveChanges();\n * }, { wait: 1000 });\n *\n * // Called repeatedly but executes at most once per second\n * inputElement.addEventListener('input', debouncedSave);\n * ```\n *\n * @example\n * ```ts\n * // Leading edge execution - fires immediately then waits\n * const debouncedSearch = liteDebounce((query: string) => {\n * performSearch(query);\n * }, { wait: 300, leading: true });\n * ```\n */\nexport function liteDebounce<TFn extends AnyFunction>(\n fn: TFn,\n options: LiteDebouncerOptions<TFn>,\n): (...args: Parameters<TFn>) => void {\n const debouncer = new LiteDebouncer(fn, options)\n return debouncer.maybeExecute\n}\n"],"names":[],"mappings":";;AAmEO,MAAM,cAAuC;AAAA,EAKlD,YACS,IACA,SACP;AAFO,SAAA,KAAA;AACA,SAAA,UAAA;AAJT,SAAQ,oBAAoB;AAqB5B,SAAA,eAAe,IAAI,SAAgC;AACjD,UAAI,oBAAoB;AAExB,UAAI,KAAK,QAAQ,WAAW,KAAK,mBAAmB;AAClD,aAAK,oBAAoB;AACzB,4BAAoB;AACpB,aAAK,GAAG,GAAG,IAAI;AACf,aAAK,QAAQ,YAAY,MAAM,IAAI;AAAA,MACrC;AAEA,WAAK,WAAW;AAEhB,UAAI,KAAK,WAAW;AAClB,qBAAa,KAAK,SAAS;AAAA,MAC7B;AAEA,WAAK,YAAY,WAAW,MAAM;AAChC,aAAK,oBAAoB;AACzB,YAAI,KAAK,QAAQ,YAAY,CAAC,qBAAqB,KAAK,UAAU;AAChE,eAAK,GAAG,GAAG,KAAK,QAAQ;AACxB,eAAK,QAAQ,YAAY,KAAK,UAAU,IAAI;AAAA,QAC9C;AACA,aAAK,WAAW;AAAA,MAClB,GAAG,KAAK,QAAQ,IAAI;AAAA,IACtB;AAOA,SAAA,QAAQ,MAAY;AAClB,UAAI,KAAK,aAAa,KAAK,UAAU;AACnC,qBAAa,KAAK,SAAS;AAC3B,aAAK,YAAY;AACjB,cAAM,OAAO,KAAK;AAClB,aAAK,GAAG,GAAG,IAAI;AACf,aAAK,QAAQ,YAAY,MAAM,IAAI;AACnC,aAAK,WAAW;AAChB,aAAK,oBAAoB;AAAA,MAC3B;AAAA,IACF;AAMA,SAAA,SAAS,MAAY;AACnB,UAAI,KAAK,WAAW;AAClB,qBAAa,KAAK,SAAS;AAC3B,aAAK,YAAY;AAAA,MACnB;AACA,WAAK,WAAW;AAChB,WAAK,oBAAoB;AAAA,IAC3B;AApEE,QACE,KAAK,QAAQ,YAAY,UACzB,KAAK,QAAQ,aAAa,QAC1B;AACA,WAAK,QAAQ,WAAW;AAAA,IAC1B;AAAA,EACF;AA+DF;AA+BO,SAAS,aACd,IACA,SACoC;AACpC,QAAM,YAAY,IAAI,cAAc,IAAI,OAAO;AAC/C,SAAO,UAAU;AACnB;;;"}
@@ -1,171 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- class LiteQueuer {
4
- constructor(fn, options = {}) {
5
- this.fn = fn;
6
- this.options = options;
7
- this.items = [];
8
- this.timeoutId = null;
9
- this.isRunning = true;
10
- this.pendingTick = false;
11
- this.addItem = (item, position = this.options.addItemsTo, startProcessing = true) => {
12
- if (this.items.length >= this.options.maxSize) {
13
- return false;
14
- }
15
- if (this.options.getPriority) {
16
- const priority = this.options.getPriority(item);
17
- if (priority !== void 0) {
18
- const insertIndex = this.items.findIndex((existing) => {
19
- const existingPriority = this.options.getPriority(existing);
20
- const effectivePriority = existingPriority ?? -Infinity;
21
- return effectivePriority < priority;
22
- });
23
- if (insertIndex === -1) {
24
- this.items.push(item);
25
- } else {
26
- this.items.splice(insertIndex, 0, item);
27
- }
28
- } else {
29
- this.insertAtPosition(item, position);
30
- }
31
- } else {
32
- this.insertAtPosition(item, position);
33
- }
34
- if (startProcessing && this.isRunning && !this.pendingTick) {
35
- this.tick();
36
- }
37
- return true;
38
- };
39
- this.insertAtPosition = (item, position) => {
40
- if (position === "front") {
41
- this.items.unshift(item);
42
- } else {
43
- this.items.push(item);
44
- }
45
- };
46
- this.getNextItem = (position = this.options.getItemsFrom) => {
47
- if (this.items.length === 0) {
48
- return void 0;
49
- }
50
- let item;
51
- if (this.options.getPriority || position === "front") {
52
- item = this.items.shift();
53
- } else {
54
- item = this.items.pop();
55
- }
56
- return item;
57
- };
58
- this.execute = (position) => {
59
- const item = this.getNextItem(position);
60
- if (item !== void 0) {
61
- this.fn(item);
62
- }
63
- return item;
64
- };
65
- this.tick = () => {
66
- if (!this.isRunning) {
67
- this.pendingTick = false;
68
- return;
69
- }
70
- this.pendingTick = true;
71
- while (this.items.length > 0) {
72
- const item = this.execute(this.options.getItemsFrom);
73
- if (item === void 0) {
74
- break;
75
- }
76
- const wait = this.options.wait;
77
- if (wait > 0) {
78
- this.timeoutId = setTimeout(() => this.tick(), wait);
79
- return;
80
- }
81
- }
82
- this.pendingTick = false;
83
- };
84
- this.start = () => {
85
- this.isRunning = true;
86
- if (!this.pendingTick && this.items.length > 0) {
87
- this.tick();
88
- }
89
- };
90
- this.stop = () => {
91
- this.clearTimeout();
92
- this.isRunning = false;
93
- this.pendingTick = false;
94
- };
95
- this.clearTimeout = () => {
96
- if (this.timeoutId) {
97
- clearTimeout(this.timeoutId);
98
- this.timeoutId = null;
99
- }
100
- };
101
- this.peekNextItem = (position = "front") => {
102
- if (this.items.length === 0) {
103
- return void 0;
104
- }
105
- if (this.options.getPriority || position === "front") {
106
- return this.items[0];
107
- } else {
108
- return this.items[this.items.length - 1];
109
- }
110
- };
111
- this.peekAllItems = () => {
112
- return [...this.items];
113
- };
114
- this.flush = (numberOfItems = this.items.length, position) => {
115
- this.clearTimeout();
116
- for (let i = 0; i < numberOfItems && this.items.length > 0; i++) {
117
- this.execute(position);
118
- }
119
- if (this.isRunning && this.items.length > 0 && !this.pendingTick) {
120
- this.tick();
121
- }
122
- };
123
- this.flushAsBatch = (batchFunction) => {
124
- const items = this.peekAllItems();
125
- this.clear();
126
- batchFunction(items);
127
- };
128
- this.clear = () => {
129
- this.items = [];
130
- };
131
- this.options.addItemsTo = this.options.addItemsTo ?? "back";
132
- this.options.getItemsFrom = this.options.getItemsFrom ?? "front";
133
- this.options.maxSize = this.options.maxSize ?? Infinity;
134
- this.options.started = this.options.started ?? true;
135
- this.options.wait = this.options.wait ?? 0;
136
- this.isRunning = this.options.started;
137
- if (this.options.initialItems) {
138
- for (const item of this.options.initialItems) {
139
- this.addItem(item, this.options.addItemsTo, false);
140
- }
141
- }
142
- if (this.isRunning && this.items.length > 0) {
143
- this.tick();
144
- }
145
- }
146
- /**
147
- * Number of items currently in the queue
148
- */
149
- get size() {
150
- return this.items.length;
151
- }
152
- /**
153
- * Whether the queue is empty
154
- */
155
- get isEmpty() {
156
- return this.items.length === 0;
157
- }
158
- /**
159
- * Whether the queue is currently running (auto-processing items)
160
- */
161
- get isQueueRunning() {
162
- return this.isRunning;
163
- }
164
- }
165
- function liteQueue(fn, options = {}) {
166
- const queuer = new LiteQueuer(fn, options);
167
- return (item) => queuer.addItem(item);
168
- }
169
- exports.LiteQueuer = LiteQueuer;
170
- exports.liteQueue = liteQueue;
171
- //# sourceMappingURL=lite-queuer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lite-queuer.cjs","sources":["../../src/lite-queuer.ts"],"sourcesContent":["/**\n * Position type for addItem and getNextItem operations.\n *\n * - 'front': Operate on the front of the queue (FIFO for getNextItem)\n * - 'back': Operate on the back of the queue (LIFO for getNextItem)\n */\nexport type QueuePosition = 'front' | 'back'\n\n/**\n * Options for configuring a lite queuer instance\n */\nexport interface LiteQueuerOptions<TValue> {\n /**\n * Default position to add items to the queue\n * @default 'back'\n */\n addItemsTo?: QueuePosition\n /**\n * Default position to get items from during processing\n * @default 'front'\n */\n getItemsFrom?: QueuePosition\n /**\n * Function to determine priority of items in the queue\n * Higher priority items will be processed first\n * Return undefined for items that should use positional ordering\n */\n getPriority?: (item: TValue) => number | undefined\n /**\n * Initial items to populate the queue with\n */\n initialItems?: Array<TValue>\n /**\n * Maximum number of items allowed in the queue\n */\n maxSize?: number\n /**\n * Whether the queuer should start processing items immediately\n * @default true\n */\n started?: boolean\n /**\n * Time in milliseconds to wait between processing items\n * @default 0\n */\n wait?: number\n}\n\n/**\n * A lightweight class that creates a queue for processing items.\n *\n * This is an alternative to the Queuer in the core @tanstack/pacer package, but is more\n * suitable for libraries and npm packages that need minimal overhead. Unlike the core Queuer,\n * this version does not use TanStack Store for state management, has no devtools integration,\n * no callbacks, and provides only essential queueing functionality.\n *\n * The queuer supports FIFO (First In First Out), LIFO (Last In First Out), and priority-based\n * processing of items. Items can be processed automatically with configurable wait times\n * between executions, or processed manually using the execute methods.\n *\n * Features included:\n * - Automatic or manual processing of items\n * - FIFO, LIFO, and priority-based ordering\n * - Queue size limits with item rejection\n * - Configurable wait times between processing\n * - Batch processing capabilities\n * - Start/stop processing control\n * - Callback support for monitoring execution, rejection, and state change events\n *\n * Features NOT included (compared to core Queuer):\n * - No TanStack Store state management\n * - No devtools integration\n * - No item expiration functionality (no onExpire callback)\n * - No dynamic options updates (setOptions)\n * - No detailed state tracking (execution counts, etc.)\n *\n * Queue behavior:\n * - Default: FIFO (add to back, process from front)\n * - LIFO: Configure addItemsTo: 'back', getItemsFrom: 'back'\n * - Priority: Provide getPriority function; higher values processed first\n *\n * @example\n * ```ts\n * // Basic FIFO queue\n * const queue = new LiteQueuer((item: string) => {\n * console.log('Processing:', item);\n * }, { wait: 100 });\n *\n * queue.addItem('task1');\n * queue.addItem('task2');\n * // Processes: task1, then task2 after 100ms delay\n * ```\n *\n * @example\n * ```ts\n * // Priority queue\n * const priorityQueue = new LiteQueuer((item: Task) => {\n * processTask(item);\n * }, {\n * getPriority: task => task.priority,\n * wait: 500\n * });\n *\n * priorityQueue.addItem({ name: 'low', priority: 1 });\n * priorityQueue.addItem({ name: 'high', priority: 10 });\n * // Processes high priority task first\n * ```\n */\nexport class LiteQueuer<TValue> {\n private items: Array<TValue> = []\n private timeoutId: NodeJS.Timeout | null = null\n private isRunning = true\n private pendingTick = false\n\n constructor(\n public fn: (item: TValue) => void,\n public options: LiteQueuerOptions<TValue> = {},\n ) {\n // Set defaults\n this.options.addItemsTo = this.options.addItemsTo ?? 'back'\n this.options.getItemsFrom = this.options.getItemsFrom ?? 'front'\n this.options.maxSize = this.options.maxSize ?? Infinity\n this.options.started = this.options.started ?? true\n this.options.wait = this.options.wait ?? 0\n\n this.isRunning = this.options.started\n\n // Add initial items if provided\n if (this.options.initialItems) {\n for (const item of this.options.initialItems) {\n this.addItem(item, this.options.addItemsTo, false)\n }\n }\n\n // Start processing if enabled and has items\n if (this.isRunning && this.items.length > 0) {\n this.tick()\n }\n }\n\n /**\n * Number of items currently in the queue\n */\n get size(): number {\n return this.items.length\n }\n\n /**\n * Whether the queue is empty\n */\n get isEmpty(): boolean {\n return this.items.length === 0\n }\n\n /**\n * Whether the queue is currently running (auto-processing items)\n */\n get isQueueRunning(): boolean {\n return this.isRunning\n }\n\n /**\n * Adds an item to the queue. If the queue is full, the item is rejected.\n * Items can be inserted at the front or back, and priority ordering is applied if getPriority is configured.\n *\n * Returns true if the item was added, false if the queue is full.\n *\n * @example\n * ```ts\n * queue.addItem('task1'); // Add to default position (back)\n * queue.addItem('task2', 'front'); // Add to front\n * ```\n */\n addItem = (\n item: TValue,\n position: QueuePosition = this.options.addItemsTo!,\n startProcessing: boolean = true,\n ): boolean => {\n // Check size limit\n if (this.items.length >= this.options.maxSize!) {\n return false\n }\n\n // Handle priority insertion\n if (this.options.getPriority) {\n const priority = this.options.getPriority(item)\n if (priority !== undefined) {\n // Find insertion point for priority\n const insertIndex = this.items.findIndex((existing) => {\n const existingPriority = this.options.getPriority!(existing)\n // Treat undefined priority as negative infinity for comparison\n const effectivePriority = existingPriority ?? -Infinity\n return effectivePriority < priority\n })\n\n if (insertIndex === -1) {\n this.items.push(item)\n } else {\n this.items.splice(insertIndex, 0, item)\n }\n } else {\n // No priority, use position\n this.insertAtPosition(item, position)\n }\n } else {\n // No priority function, use position\n this.insertAtPosition(item, position)\n }\n\n // Start processing if running and not already processing\n if (startProcessing && this.isRunning && !this.pendingTick) {\n this.tick()\n }\n\n return true\n }\n\n private insertAtPosition = (item: TValue, position: QueuePosition): void => {\n if (position === 'front') {\n this.items.unshift(item)\n } else {\n this.items.push(item)\n }\n }\n\n /**\n * Removes and returns the next item from the queue without executing the function.\n * Use for manual queue management. Normally, use execute() to process items.\n *\n * @example\n * ```ts\n * const nextItem = queue.getNextItem(); // Get from default position (front)\n * const lastItem = queue.getNextItem('back'); // Get from back (LIFO)\n * ```\n */\n getNextItem = (\n position: QueuePosition = this.options.getItemsFrom!,\n ): TValue | undefined => {\n if (this.items.length === 0) {\n return undefined\n }\n\n let item: TValue | undefined\n\n // When priority function is provided, always get from front (highest priority)\n if (this.options.getPriority || position === 'front') {\n item = this.items.shift()\n } else {\n item = this.items.pop()\n }\n\n return item\n }\n\n /**\n * Removes and returns the next item from the queue and processes it using the provided function.\n *\n * @example\n * ```ts\n * queue.execute(); // Execute from default position\n * queue.execute('back'); // Execute from back (LIFO)\n * ```\n */\n execute = (position?: QueuePosition): TValue | undefined => {\n const item = this.getNextItem(position)\n if (item !== undefined) {\n this.fn(item)\n }\n return item\n }\n\n /**\n * Internal method that processes items in the queue with wait intervals\n */\n private tick = (): void => {\n if (!this.isRunning) {\n this.pendingTick = false\n return\n }\n\n this.pendingTick = true\n\n // Process items while queue is not empty\n while (this.items.length > 0) {\n const item = this.execute(this.options.getItemsFrom)\n if (item === undefined) {\n break\n }\n\n const wait = this.options.wait!\n if (wait > 0) {\n // Schedule next processing after wait time\n this.timeoutId = setTimeout(() => this.tick(), wait)\n return\n }\n\n // No wait time, continue processing immediately\n }\n\n this.pendingTick = false\n }\n\n /**\n * Starts processing items in the queue. If already running, does nothing.\n */\n start = (): void => {\n this.isRunning = true\n if (!this.pendingTick && this.items.length > 0) {\n this.tick()\n }\n }\n\n /**\n * Stops processing items in the queue. Does not clear the queue.\n */\n stop = (): void => {\n this.clearTimeout()\n this.isRunning = false\n this.pendingTick = false\n }\n\n /**\n * Clears any pending timeout\n */\n private clearTimeout = (): void => {\n if (this.timeoutId) {\n clearTimeout(this.timeoutId)\n this.timeoutId = null\n }\n }\n\n /**\n * Returns the next item in the queue without removing it.\n *\n * @example\n * ```ts\n * const next = queue.peekNextItem(); // Peek at front\n * const last = queue.peekNextItem('back'); // Peek at back\n * ```\n */\n peekNextItem = (position: QueuePosition = 'front'): TValue | undefined => {\n if (this.items.length === 0) {\n return undefined\n }\n\n if (this.options.getPriority || position === 'front') {\n return this.items[0]\n } else {\n return this.items[this.items.length - 1]\n }\n }\n\n /**\n * Returns a copy of all items in the queue.\n */\n peekAllItems = (): Array<TValue> => {\n return [...this.items]\n }\n\n /**\n * Processes a specified number of items immediately with no wait time.\n * If no numberOfItems is provided, all items will be processed.\n *\n * @example\n * ```ts\n * queue.flush(); // Process all items immediately\n * queue.flush(3); // Process next 3 items immediately\n * ```\n */\n flush = (\n numberOfItems: number = this.items.length,\n position?: QueuePosition,\n ): void => {\n this.clearTimeout() // Clear any pending timeout\n for (let i = 0; i < numberOfItems && this.items.length > 0; i++) {\n this.execute(position)\n }\n // Restart normal processing if still running and has items\n if (this.isRunning && this.items.length > 0 && !this.pendingTick) {\n this.tick()\n }\n }\n\n /**\n * Processes all items in the queue as a batch using the provided function.\n * The queue is cleared after processing.\n *\n * @example\n * ```ts\n * queue.flushAsBatch((items) => {\n * console.log('Processing batch:', items);\n * // Process all items together\n * });\n * ```\n */\n flushAsBatch = (batchFunction: (items: Array<TValue>) => void): void => {\n const items = this.peekAllItems()\n this.clear()\n batchFunction(items)\n }\n\n /**\n * Removes all items from the queue. Does not affect items being processed.\n */\n clear = (): void => {\n this.items = []\n }\n}\n\n/**\n * Creates a lightweight queue that processes items using the provided function.\n *\n * This is an alternative to the queue function in the core @tanstack/pacer package, but is more\n * suitable for libraries and npm packages that need minimal overhead. Unlike the core version,\n * this function creates a queuer with no external dependencies, devtools integration, or reactive state.\n *\n * @example\n * ```ts\n * const processItem = liteQueue((item: string) => {\n * console.log('Processing:', item);\n * }, { wait: 1000 });\n *\n * processItem('task1');\n * processItem('task2');\n * // Processes each item with 1 second delay between them\n * ```\n */\nexport function liteQueue<TValue>(\n fn: (item: TValue) => void,\n options: LiteQueuerOptions<TValue> = {},\n): (item: TValue) => boolean {\n const queuer = new LiteQueuer(fn, options)\n return (item: TValue) => queuer.addItem(item)\n}\n"],"names":[],"mappings":";;AA4GO,MAAM,WAAmB;AAAA,EAM9B,YACS,IACA,UAAqC,IAC5C;AAFO,SAAA,KAAA;AACA,SAAA,UAAA;AAPT,SAAQ,QAAuB,CAAA;AAC/B,SAAQ,YAAmC;AAC3C,SAAQ,YAAY;AACpB,SAAQ,cAAc;AA6DtB,SAAA,UAAU,CACR,MACA,WAA0B,KAAK,QAAQ,YACvC,kBAA2B,SACf;AAEZ,UAAI,KAAK,MAAM,UAAU,KAAK,QAAQ,SAAU;AAC9C,eAAO;AAAA,MACT;AAGA,UAAI,KAAK,QAAQ,aAAa;AAC5B,cAAM,WAAW,KAAK,QAAQ,YAAY,IAAI;AAC9C,YAAI,aA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aAAa;AAChE,aAAK,KAAA;AAAA,MACP;AAAA,IACF;AAcA,SAAA,eAAe,CAAC,kBAAwD;AACtE,YAAM,QAAQ,KAAK,aAAA;AACnB,WAAK,MAAA;AACL,oBAAc,KAAK;AAAA,IACrB;AAKA,SAAA,QAAQ,MAAY;AAClB,WAAK,QAAQ,CAAA;AAAA,IACf;AA/RE,SAAK,QAAQ,aAAa,KAAK,QAAQ,cAAc;AACrD,SAAK,QAAQ,eAAe,KAAK,QAAQ,gBAAgB;AACzD,SAAK,QAAQ,UAAU,KAAK,QAAQ,WAAW;AAC/C,SAAK,QAAQ,UAAU,KAAK,QAAQ,WAAW;AAC/C,SAAK,QAAQ,OAAO,KAAK,QAAQ,QAAQ;AAEzC,SAAK,YAAY,KAAK,QAAQ;AAG9B,QAAI,KAAK,QAAQ,cAAc;AAC7B,iBAAW,QAAQ,KAAK,QAAQ,cAAc;AAC5C,aAAK,QAAQ,MAAM,KAAK,QAAQ,YAAY,KAAK;AAAA,MACnD;AAAA,IACF;AAGA,QAAI,KAAK,aAAa,KAAK,MAAM,SAAS,GAAG;AAC3C,WAAK,KAAA;AAAA,IACP;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OAAe;AACjB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,UAAmB;AACrB,WAAO,KAAK,MAAM,WAAW;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,iBAA0B;AAC5B,WAAO,KAAK;AAAA,EACd;AAwPF;AAoBO,SAAS,UACd,IACA,UAAqC,IACV;AAC3B,QAAM,SAAS,IAAI,WAAW,IAAI,OAAO;AACzC,SAAO,CAAC,SAAiB,OAAO,QAAQ,IAAI;AAC9C;;;"}
@@ -1,239 +0,0 @@
1
- /**
2
- * Position type for addItem and getNextItem operations.
3
- *
4
- * - 'front': Operate on the front of the queue (FIFO for getNextItem)
5
- * - 'back': Operate on the back of the queue (LIFO for getNextItem)
6
- */
7
- export type QueuePosition = 'front' | 'back';
8
- /**
9
- * Options for configuring a lite queuer instance
10
- */
11
- export interface LiteQueuerOptions<TValue> {
12
- /**
13
- * Default position to add items to the queue
14
- * @default 'back'
15
- */
16
- addItemsTo?: QueuePosition;
17
- /**
18
- * Default position to get items from during processing
19
- * @default 'front'
20
- */
21
- getItemsFrom?: QueuePosition;
22
- /**
23
- * Function to determine priority of items in the queue
24
- * Higher priority items will be processed first
25
- * Return undefined for items that should use positional ordering
26
- */
27
- getPriority?: (item: TValue) => number | undefined;
28
- /**
29
- * Initial items to populate the queue with
30
- */
31
- initialItems?: Array<TValue>;
32
- /**
33
- * Maximum number of items allowed in the queue
34
- */
35
- maxSize?: number;
36
- /**
37
- * Whether the queuer should start processing items immediately
38
- * @default true
39
- */
40
- started?: boolean;
41
- /**
42
- * Time in milliseconds to wait between processing items
43
- * @default 0
44
- */
45
- wait?: number;
46
- }
47
- /**
48
- * A lightweight class that creates a queue for processing items.
49
- *
50
- * This is an alternative to the Queuer in the core @tanstack/pacer package, but is more
51
- * suitable for libraries and npm packages that need minimal overhead. Unlike the core Queuer,
52
- * this version does not use TanStack Store for state management, has no devtools integration,
53
- * no callbacks, and provides only essential queueing functionality.
54
- *
55
- * The queuer supports FIFO (First In First Out), LIFO (Last In First Out), and priority-based
56
- * processing of items. Items can be processed automatically with configurable wait times
57
- * between executions, or processed manually using the execute methods.
58
- *
59
- * Features included:
60
- * - Automatic or manual processing of items
61
- * - FIFO, LIFO, and priority-based ordering
62
- * - Queue size limits with item rejection
63
- * - Configurable wait times between processing
64
- * - Batch processing capabilities
65
- * - Start/stop processing control
66
- * - Callback support for monitoring execution, rejection, and state change events
67
- *
68
- * Features NOT included (compared to core Queuer):
69
- * - No TanStack Store state management
70
- * - No devtools integration
71
- * - No item expiration functionality (no onExpire callback)
72
- * - No dynamic options updates (setOptions)
73
- * - No detailed state tracking (execution counts, etc.)
74
- *
75
- * Queue behavior:
76
- * - Default: FIFO (add to back, process from front)
77
- * - LIFO: Configure addItemsTo: 'back', getItemsFrom: 'back'
78
- * - Priority: Provide getPriority function; higher values processed first
79
- *
80
- * @example
81
- * ```ts
82
- * // Basic FIFO queue
83
- * const queue = new LiteQueuer((item: string) => {
84
- * console.log('Processing:', item);
85
- * }, { wait: 100 });
86
- *
87
- * queue.addItem('task1');
88
- * queue.addItem('task2');
89
- * // Processes: task1, then task2 after 100ms delay
90
- * ```
91
- *
92
- * @example
93
- * ```ts
94
- * // Priority queue
95
- * const priorityQueue = new LiteQueuer((item: Task) => {
96
- * processTask(item);
97
- * }, {
98
- * getPriority: task => task.priority,
99
- * wait: 500
100
- * });
101
- *
102
- * priorityQueue.addItem({ name: 'low', priority: 1 });
103
- * priorityQueue.addItem({ name: 'high', priority: 10 });
104
- * // Processes high priority task first
105
- * ```
106
- */
107
- export declare class LiteQueuer<TValue> {
108
- fn: (item: TValue) => void;
109
- options: LiteQueuerOptions<TValue>;
110
- private items;
111
- private timeoutId;
112
- private isRunning;
113
- private pendingTick;
114
- constructor(fn: (item: TValue) => void, options?: LiteQueuerOptions<TValue>);
115
- /**
116
- * Number of items currently in the queue
117
- */
118
- get size(): number;
119
- /**
120
- * Whether the queue is empty
121
- */
122
- get isEmpty(): boolean;
123
- /**
124
- * Whether the queue is currently running (auto-processing items)
125
- */
126
- get isQueueRunning(): boolean;
127
- /**
128
- * Adds an item to the queue. If the queue is full, the item is rejected.
129
- * Items can be inserted at the front or back, and priority ordering is applied if getPriority is configured.
130
- *
131
- * Returns true if the item was added, false if the queue is full.
132
- *
133
- * @example
134
- * ```ts
135
- * queue.addItem('task1'); // Add to default position (back)
136
- * queue.addItem('task2', 'front'); // Add to front
137
- * ```
138
- */
139
- addItem: (item: TValue, position?: QueuePosition, startProcessing?: boolean) => boolean;
140
- private insertAtPosition;
141
- /**
142
- * Removes and returns the next item from the queue without executing the function.
143
- * Use for manual queue management. Normally, use execute() to process items.
144
- *
145
- * @example
146
- * ```ts
147
- * const nextItem = queue.getNextItem(); // Get from default position (front)
148
- * const lastItem = queue.getNextItem('back'); // Get from back (LIFO)
149
- * ```
150
- */
151
- getNextItem: (position?: QueuePosition) => TValue | undefined;
152
- /**
153
- * Removes and returns the next item from the queue and processes it using the provided function.
154
- *
155
- * @example
156
- * ```ts
157
- * queue.execute(); // Execute from default position
158
- * queue.execute('back'); // Execute from back (LIFO)
159
- * ```
160
- */
161
- execute: (position?: QueuePosition) => TValue | undefined;
162
- /**
163
- * Internal method that processes items in the queue with wait intervals
164
- */
165
- private tick;
166
- /**
167
- * Starts processing items in the queue. If already running, does nothing.
168
- */
169
- start: () => void;
170
- /**
171
- * Stops processing items in the queue. Does not clear the queue.
172
- */
173
- stop: () => void;
174
- /**
175
- * Clears any pending timeout
176
- */
177
- private clearTimeout;
178
- /**
179
- * Returns the next item in the queue without removing it.
180
- *
181
- * @example
182
- * ```ts
183
- * const next = queue.peekNextItem(); // Peek at front
184
- * const last = queue.peekNextItem('back'); // Peek at back
185
- * ```
186
- */
187
- peekNextItem: (position?: QueuePosition) => TValue | undefined;
188
- /**
189
- * Returns a copy of all items in the queue.
190
- */
191
- peekAllItems: () => Array<TValue>;
192
- /**
193
- * Processes a specified number of items immediately with no wait time.
194
- * If no numberOfItems is provided, all items will be processed.
195
- *
196
- * @example
197
- * ```ts
198
- * queue.flush(); // Process all items immediately
199
- * queue.flush(3); // Process next 3 items immediately
200
- * ```
201
- */
202
- flush: (numberOfItems?: number, position?: QueuePosition) => void;
203
- /**
204
- * Processes all items in the queue as a batch using the provided function.
205
- * The queue is cleared after processing.
206
- *
207
- * @example
208
- * ```ts
209
- * queue.flushAsBatch((items) => {
210
- * console.log('Processing batch:', items);
211
- * // Process all items together
212
- * });
213
- * ```
214
- */
215
- flushAsBatch: (batchFunction: (items: Array<TValue>) => void) => void;
216
- /**
217
- * Removes all items from the queue. Does not affect items being processed.
218
- */
219
- clear: () => void;
220
- }
221
- /**
222
- * Creates a lightweight queue that processes items using the provided function.
223
- *
224
- * This is an alternative to the queue function in the core @tanstack/pacer package, but is more
225
- * suitable for libraries and npm packages that need minimal overhead. Unlike the core version,
226
- * this function creates a queuer with no external dependencies, devtools integration, or reactive state.
227
- *
228
- * @example
229
- * ```ts
230
- * const processItem = liteQueue((item: string) => {
231
- * console.log('Processing:', item);
232
- * }, { wait: 1000 });
233
- *
234
- * processItem('task1');
235
- * processItem('task2');
236
- * // Processes each item with 1 second delay between them
237
- * ```
238
- */
239
- export declare function liteQueue<TValue>(fn: (item: TValue) => void, options?: LiteQueuerOptions<TValue>): (item: TValue) => boolean;
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- class LiteRateLimiter {
4
- constructor(fn, options) {
5
- this.fn = fn;
6
- this.options = options;
7
- this.executionTimes = [];
8
- this.timeoutIds = /* @__PURE__ */ new Set();
9
- this.maybeExecute = (...args) => {
10
- this.cleanupOldExecutions();
11
- const relevantExecutionTimes = this.getExecutionTimesInWindow();
12
- if (relevantExecutionTimes.length < this.options.limit) {
13
- this.execute(...args);
14
- return true;
15
- }
16
- this.options.onReject?.(this);
17
- return false;
18
- };
19
- this.execute = (...args) => {
20
- const now = Date.now();
21
- this.fn(...args);
22
- this.options.onExecute?.(args, this);
23
- this.executionTimes.push(now);
24
- this.setCleanupTimeout(now);
25
- };
26
- this.getExecutionTimesInWindow = () => {
27
- if (this.options.windowType === "sliding") {
28
- return this.executionTimes.filter(
29
- (time) => time > Date.now() - this.options.window
30
- );
31
- } else {
32
- if (this.executionTimes.length === 0) {
33
- return [];
34
- }
35
- const oldestExecution = Math.min(...this.executionTimes);
36
- const windowStart = oldestExecution;
37
- const windowEnd = windowStart + this.options.window;
38
- const now = Date.now();
39
- if (now > windowEnd) {
40
- return [];
41
- }
42
- return this.executionTimes.filter(
43
- (time) => time >= windowStart && time <= windowEnd
44
- );
45
- }
46
- };
47
- this.setCleanupTimeout = (executionTime) => {
48
- if (this.options.windowType === "sliding" || this.timeoutIds.size === 0) {
49
- const now = Date.now();
50
- const timeUntilExpiration = executionTime - now + this.options.window + 1;
51
- const timeoutId = setTimeout(() => {
52
- this.cleanupOldExecutions();
53
- this.clearTimeout(timeoutId);
54
- }, timeUntilExpiration);
55
- this.timeoutIds.add(timeoutId);
56
- }
57
- };
58
- this.clearTimeout = (timeoutId) => {
59
- clearTimeout(timeoutId);
60
- this.timeoutIds.delete(timeoutId);
61
- };
62
- this.clearTimeouts = () => {
63
- this.timeoutIds.forEach((timeoutId) => clearTimeout(timeoutId));
64
- this.timeoutIds.clear();
65
- };
66
- this.cleanupOldExecutions = () => {
67
- this.executionTimes = this.getExecutionTimesInWindow();
68
- };
69
- this.getRemainingInWindow = () => {
70
- const relevantExecutionTimes = this.getExecutionTimesInWindow();
71
- return Math.max(0, this.options.limit - relevantExecutionTimes.length);
72
- };
73
- this.getMsUntilNextWindow = () => {
74
- if (this.getRemainingInWindow() > 0) {
75
- return 0;
76
- }
77
- const oldestExecution = this.executionTimes[0] ?? Infinity;
78
- return oldestExecution + this.options.window - Date.now();
79
- };
80
- this.reset = () => {
81
- this.executionTimes = [];
82
- this.clearTimeouts();
83
- };
84
- if (this.options.windowType === void 0) {
85
- this.options.windowType = "fixed";
86
- }
87
- }
88
- }
89
- function liteRateLimit(fn, options) {
90
- const rateLimiter = new LiteRateLimiter(fn, options);
91
- return rateLimiter.maybeExecute;
92
- }
93
- exports.LiteRateLimiter = LiteRateLimiter;
94
- exports.liteRateLimit = liteRateLimit;
95
- //# sourceMappingURL=lite-rate-limiter.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lite-rate-limiter.cjs","sources":["../../src/lite-rate-limiter.ts"],"sourcesContent":["import type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * Options for configuring a lite rate-limited function\n */\nexport interface LiteRateLimiterOptions<TFn extends AnyFunction = AnyFunction> {\n /**\n * Maximum number of executions allowed within the time window.\n */\n limit: number\n /**\n * Callback function that is called after the function is executed\n */\n onExecute?: (args: Parameters<TFn>, rateLimiter: LiteRateLimiter<TFn>) => void\n /**\n * Optional callback function that is called when an execution is rejected due to rate limiting\n */\n onReject?: (rateLimiter: LiteRateLimiter<TFn>) => void\n /**\n * Time window in milliseconds within which the limit applies.\n */\n window: number\n /**\n * Type of window to use for rate limiting\n * - 'fixed': Uses a fixed window that resets after the window period\n * - 'sliding': Uses a sliding window that allows executions as old ones expire\n * Defaults to 'fixed'\n */\n windowType?: 'fixed' | 'sliding'\n}\n\n/**\n * A lightweight class that creates a rate-limited function.\n *\n * This is an alternative to the RateLimiter in the core @tanstack/pacer package, but is more\n * suitable for libraries and npm packages that need minimal overhead. Unlike the core RateLimiter,\n * this version does not use TanStack Store for state management, has no devtools integration,\n * and provides only essential rate limiting functionality.\n *\n * Rate limiting allows a function to execute up to a limit within a time window,\n * then blocks all subsequent calls until the window passes. This can lead to \"bursty\" behavior where\n * all executions happen immediately, followed by a complete block.\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 * Features:\n * - Zero dependencies - no external libraries required\n * - Minimal API surface - only essential methods (maybeExecute, getRemainingInWindow, getMsUntilNextWindow, reset)\n * - Simple state management - uses basic private properties instead of reactive stores\n * - Lightweight - designed for use in npm packages where bundle size matters\n *\n * @example\n * ```ts\n * const rateLimiter = new LiteRateLimiter((id: string) => {\n * api.getData(id);\n * }, { limit: 5, window: 1000 });\n *\n * // First 5 calls will execute, then block until window resets\n * if (rateLimiter.maybeExecute('123')) {\n * console.log('API call made');\n * } else {\n * console.log('Rate limited - try again in', rateLimiter.getMsUntilNextWindow(), 'ms');\n * }\n * ```\n */\nexport class LiteRateLimiter<TFn extends AnyFunction> {\n private executionTimes: Array<number> = []\n private timeoutIds: Set<NodeJS.Timeout> = new Set()\n\n constructor(\n public fn: TFn,\n public options: LiteRateLimiterOptions<TFn>,\n ) {\n // Default windowType to 'fixed' if not specified\n if (this.options.windowType === undefined) {\n this.options.windowType = 'fixed'\n }\n }\n\n /**\n * Attempts to execute the rate-limited function if within the configured limits.\n * Returns true if executed, false if rejected due to rate limiting.\n *\n * @example\n * ```ts\n * const rateLimiter = new LiteRateLimiter(fn, { limit: 5, window: 1000 });\n *\n * // First 5 calls return true\n * rateLimiter.maybeExecute('arg1', 'arg2'); // true\n *\n * // Additional calls within the window return false\n * rateLimiter.maybeExecute('arg1', 'arg2'); // false\n * ```\n */\n maybeExecute = (...args: Parameters<TFn>): boolean => {\n this.cleanupOldExecutions()\n\n const relevantExecutionTimes = this.getExecutionTimesInWindow()\n\n if (relevantExecutionTimes.length < this.options.limit) {\n this.execute(...args)\n return true\n }\n\n this.options.onReject?.(this)\n return false\n }\n\n private execute = (...args: Parameters<TFn>): void => {\n const now = Date.now()\n this.fn(...args)\n this.options.onExecute?.(args, this)\n this.executionTimes.push(now)\n this.setCleanupTimeout(now)\n }\n\n private getExecutionTimesInWindow = (): Array<number> => {\n if (this.options.windowType === 'sliding') {\n // For sliding window, return all executions within the current window\n return this.executionTimes.filter(\n (time) => time > Date.now() - this.options.window,\n )\n } else {\n // For fixed window, return all executions in the current window\n if (this.executionTimes.length === 0) {\n return []\n }\n const oldestExecution = Math.min(...this.executionTimes)\n const windowStart = oldestExecution\n const windowEnd = windowStart + this.options.window\n const now = Date.now()\n\n // If the window has expired, return empty array\n if (now > windowEnd) {\n return []\n }\n\n // Otherwise, return all executions in the current window\n return this.executionTimes.filter(\n (time) => time >= windowStart && time <= windowEnd,\n )\n }\n }\n\n private setCleanupTimeout = (executionTime: number): void => {\n if (\n this.options.windowType === 'sliding' ||\n this.timeoutIds.size === 0 // new fixed window\n ) {\n const now = Date.now()\n const timeUntilExpiration = executionTime - now + this.options.window + 1\n const timeoutId = setTimeout(() => {\n this.cleanupOldExecutions()\n this.clearTimeout(timeoutId)\n }, timeUntilExpiration)\n this.timeoutIds.add(timeoutId)\n }\n }\n\n private clearTimeout = (timeoutId: NodeJS.Timeout): void => {\n clearTimeout(timeoutId)\n this.timeoutIds.delete(timeoutId)\n }\n\n private clearTimeouts = (): void => {\n this.timeoutIds.forEach((timeoutId) => clearTimeout(timeoutId))\n this.timeoutIds.clear()\n }\n\n private cleanupOldExecutions = (): void => {\n this.executionTimes = this.getExecutionTimesInWindow()\n }\n\n /**\n * Returns the number of remaining executions allowed in the current window.\n */\n getRemainingInWindow = (): number => {\n const relevantExecutionTimes = this.getExecutionTimesInWindow()\n return Math.max(0, this.options.limit - relevantExecutionTimes.length)\n }\n\n /**\n * Returns the number of milliseconds until the next execution will be possible.\n * Returns 0 if executions are currently allowed.\n */\n getMsUntilNextWindow = (): number => {\n if (this.getRemainingInWindow() > 0) {\n return 0\n }\n const oldestExecution = this.executionTimes[0] ?? Infinity\n return oldestExecution + this.options.window - Date.now()\n }\n\n /**\n * Resets the rate limiter state, clearing all execution history.\n */\n reset = (): void => {\n this.executionTimes = []\n this.clearTimeouts()\n }\n}\n\n/**\n * Creates a lightweight rate-limited function that will execute the provided function up to a maximum number of times within a time window.\n *\n * This is an alternative to the rateLimit function in the core @tanstack/pacer package, but is more\n * suitable for libraries and npm packages that need minimal overhead. Unlike the core version,\n * this function creates a rate limiter with no external dependencies, devtools integration, or reactive state.\n *\n * Rate limiting allows all executions until the limit is reached, then blocks all subsequent calls until the window resets.\n * This differs from throttling (which ensures even spacing) and debouncing (which waits for pauses).\n *\n * @example\n * ```ts\n * const rateLimitedApi = liteRateLimit(makeApiCall, {\n * limit: 5,\n * window: 60000, // 1 minute\n * windowType: 'sliding'\n * });\n *\n * // First 5 calls execute immediately\n * // Additional calls are rejected until window allows\n * rateLimitedApi();\n * ```\n *\n * @example\n * ```ts\n * // Fixed window - all 10 calls happen in first second, then 10 second wait\n * const rateLimitedFixed = liteRateLimit(logEvent, {\n * limit: 10,\n * window: 10000,\n * windowType: 'fixed'\n * });\n * ```\n */\nexport function liteRateLimit<TFn extends AnyFunction>(\n fn: TFn,\n options: LiteRateLimiterOptions<TFn>,\n): (...args: Parameters<TFn>) => boolean {\n const rateLimiter = new LiteRateLimiter(fn, options)\n return rateLimiter.maybeExecute\n}\n"],"names":[],"mappings":";;AAqEO,MAAM,gBAAyC;AAAA,EAIpD,YACS,IACA,SACP;AAFO,SAAA,KAAA;AACA,SAAA,UAAA;AALT,SAAQ,iBAAgC,CAAA;AACxC,SAAQ,iCAAsC,IAAA;AA2B9C,SAAA,eAAe,IAAI,SAAmC;AACpD,WAAK,qBAAA;AAEL,YAAM,yBAAyB,KAAK,0BAAA;AAEpC,UAAI,uBAAuB,SAAS,KAAK,QAAQ,OAAO;AACtD,aAAK,QAAQ,GAAG,IAAI;AACpB,eAAO;AAAA,MACT;AAEA,WAAK,QAAQ,WAAW,IAAI;AAC5B,aAAO;AAAA,IACT;AAEA,SAAQ,UAAU,IAAI,SAAgC;AACpD,YAAM,MAAM,KAAK,IAAA;AACjB,WAAK,GAAG,GAAG,IAAI;AACf,WAAK,QAAQ,YAAY,MAAM,IAAI;AACnC,WAAK,eAAe,KAAK,GAAG;AAC5B,WAAK,kBAAkB,GAAG;AAAA,IAC5B;AAEA,SAAQ,4BAA4B,MAAqB;AACvD,UAAI,KAAK,QAAQ,eAAe,WAAW;AAEzC,eAAO,KAAK,eAAe;AAAA,UACzB,CAAC,SAAS,OAAO,KAAK,IAAA,IAAQ,KAAK,QAAQ;AAAA,QAAA;AAAA,MAE/C,OAAO;AAEL,YAAI,KAAK,eAAe,WAAW,GAAG;AACpC,iBAAO,CAAA;AAAA,QACT;AACA,cAAM,kBAAkB,KAAK,IAAI,GAAG,KAAK,cAAc;AACvD,cAAM,cAAc;AACpB,cAAM,YAAY,cAAc,KAAK,QAAQ;AAC7C,cAAM,MAAM,KAAK,IAAA;AAGjB,YAAI,MAAM,WAAW;AACnB,iBAAO,CAAA;AAAA,QACT;AAGA,eAAO,KAAK,eAAe;AAAA,UACzB,CAAC,SAAS,QAAQ,eAAe,QAAQ;AAAA,QAAA;AAAA,M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