From f5901f911166e8cbd87fb8fede07d2c55c6f1a9e Mon Sep 17 00:00:00 2001 From: Brent Schroeter Date: Tue, 3 Feb 2026 01:44:43 +0000 Subject: [PATCH] set version for npm release --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++++---- package-lock.json | 4 ++-- package.json | 3 ++- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cf4ecb4..335fc1a 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,24 @@ An async tiny task queue (and related utilities), with zero dependencies. Attq provides a data structure that executes an asynchronous callback sequentially on -a flexible list. It is designed to facilitate in-order client-server message -passing with bells and whistles including batching, throttling, and configurable -retries. **Work in progress.** +a flexible list. It is generally designed to facilitate replaying ordered events +from a client to a server and comes with bells and whistles including batching, +throttling, and configurable retries. -## Example +## Installation + +```sh +npm install --save attq +``` + +## Examples + +### Basic Task Queue + +The `AsyncTaskQueue` constructor takes a task handler callback, and items are +added to the queue object with the `.push()` method. Additional options may be +configured with methods such as `.onError()`, `.batchSize()`, and +`.throttleMs()`. ```typescript import { AsyncTaskQueue } from "attq"; @@ -33,3 +46,30 @@ q.onError(() => { q.drain(); }); ``` + +### Retries + +Rather than build retry logic into the queue itself, Attq provides a +`withRetry()` higher-order function which can be wrapped around the task +handler. (If desired, `withRetry()` may be used independently of the task queue +as well!) + +```typescript +import { AsyncTaskQueue, withRetry } from "attq"; + +let q = new AsyncTaskQueue( + // Defaults to 6 attempts with binary exponential backoff. + withRetry((nums) => fetch(`/refine?macrodata=${nums.join(",")}`)), +); + +// To specify, for example, up to 3 attempts with a linear backoff: +q = new AsyncTaskQueue( + withRetry( + (nums) => fetch(`/refine?macrodata=${nums.join(",")}`), + { + attempts: 3, + backoffMs: (attempt) => 1000 * attempt, + }, + ), +); +``` diff --git a/package-lock.json b/package-lock.json index 08bc8b4..c61d57c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "attq", - "version": "0.1.0-beta.0", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "attq", - "version": "0.1.0-beta.0", + "version": "0.1.0", "license": "MIT", "devDependencies": { "@eslint/js": "^9.39.2", diff --git a/package.json b/package.json index 623ab17..ac5c36b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "attq", - "version": "0.1.0-beta.0", + "version": "0.1.0", "description": "Async Tiny Task Queue", "repository": { "type": "git", @@ -8,6 +8,7 @@ }, "license": "MIT", "author": "Brent Schroeter (https://brentsch.com)", + "files": ["dist", "LICENSE", "README.md"], "browser": "dist/index.min.js", "main": "dist/index.js", "module": "dist/index.mjs",