set version for npm release

This commit is contained in:
Brent Schroeter 2026-02-03 01:44:43 +00:00
parent 582284a36b
commit f5901f9111
3 changed files with 48 additions and 7 deletions

View file

@ -2,11 +2,24 @@
An async tiny task queue (and related utilities), with zero dependencies. Attq An async tiny task queue (and related utilities), with zero dependencies. Attq
provides a data structure that executes an asynchronous callback sequentially on provides a data structure that executes an asynchronous callback sequentially on
a flexible list. It is designed to facilitate in-order client-server message a flexible list. It is generally designed to facilitate replaying ordered events
passing with bells and whistles including batching, throttling, and configurable from a client to a server and comes with bells and whistles including batching,
retries. **Work in progress.** 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 ```typescript
import { AsyncTaskQueue } from "attq"; import { AsyncTaskQueue } from "attq";
@ -33,3 +46,30 @@ q.onError(() => {
q.drain(); 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<number>(
// 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<number>(
withRetry(
(nums) => fetch(`/refine?macrodata=${nums.join(",")}`),
{
attempts: 3,
backoffMs: (attempt) => 1000 * attempt,
},
),
);
```

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "attq", "name": "attq",
"version": "0.1.0-beta.0", "version": "0.1.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "attq", "name": "attq",
"version": "0.1.0-beta.0", "version": "0.1.0",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.39.2", "@eslint/js": "^9.39.2",

View file

@ -1,6 +1,6 @@
{ {
"name": "attq", "name": "attq",
"version": "0.1.0-beta.0", "version": "0.1.0",
"description": "Async Tiny Task Queue", "description": "Async Tiny Task Queue",
"repository": { "repository": {
"type": "git", "type": "git",
@ -8,6 +8,7 @@
}, },
"license": "MIT", "license": "MIT",
"author": "Brent Schroeter (https://brentsch.com)", "author": "Brent Schroeter (https://brentsch.com)",
"files": ["dist", "LICENSE", "README.md"],
"browser": "dist/index.min.js", "browser": "dist/index.min.js",
"main": "dist/index.js", "main": "dist/index.js",
"module": "dist/index.mjs", "module": "dist/index.mjs",