{"_id":"@asdfsena/banded-queue","name":"@asdfsena/banded-queue","dist-tags":{"latest":"0.2.0"},"versions":{"0.2.0":{"name":"@asdfsena/banded-queue","version":"0.2.0","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"scripts":{"test":"vitest","build":"bun build --target=node --outdir=dist src/index.ts --external bullmq --external ioredis","build:types":"tsc --project tsconfig.build.json","release":"bun run build && bun run build:types && npx changeset publish","prepare":"husky"},"devDependencies":{"@changesets/cli":"^2.31.0","@types/bun":"latest","husky":"^9.1.7","prettier":"^3.8.3","vitest":"^4.1.7"},"peerDependencies":{"typescript":"^5"},"dependencies":{"bullmq":"^5.77.1","ioredis":"^5.10.1"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/asdfsena/banded-queue.git"},"bugs":{"url":"https://github.com/asdfsena/banded-queue/issues"},"homepage":"https://github.com/asdfsena/banded-queue#readme","_id":"@asdfsena/banded-queue@0.2.0","gitHead":"e25e5ea45a7ca1ae33e4803c44f1878489c49235","description":"[![Current Version](https://img.shields.io/github/package-json/v/asdfsena/banded-queue?logo=github&label=Current%20Version&color=181717)](https://github.com/asdfsena/banded-queue/packages) [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-kXxqjsiLdiDrZ+dawRGF+mUFicDRNWsGsDxVHGDl2pM45oes/dNufGylYAE6HpU7wouQQSZz6p/iBJxmxBaziA==","shasum":"268cc56f6ffab765990db5d39da80d1e1bbfabd4","tarball":"https://registry.npmjs.org/@asdfsena/banded-queue/-/banded-queue-0.2.0.tgz","fileCount":6,"unpackedSize":10651,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCEocrVqkHDLX/ovTVPojSav4HRTGx8Kw4ngLIC8xycHwIgfvED4Sjq73QVOhyYxajU4vPJT0D+qoFq9emHYpSkuYw="}]},"_npmUser":{"name":"asdfsena","email":"putraaryasena19@gmail.com"},"directories":{},"maintainers":[{"name":"asdfsena","email":"putraaryasena19@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/banded-queue_0.2.0_1779543250062_0.8484530608649818"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-23T13:34:09.909Z","0.2.0":"2026-05-23T13:34:10.223Z","modified":"2026-05-23T13:34:10.403Z"},"maintainers":[{"name":"asdfsena","email":"putraaryasena19@gmail.com"}],"description":"[![Current Version](https://img.shields.io/github/package-json/v/asdfsena/banded-queue?logo=github&label=Current%20Version&color=181717)](https://github.com/asdfsena/banded-queue/packages) [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo","homepage":"https://github.com/asdfsena/banded-queue#readme","repository":{"type":"git","url":"git+https://github.com/asdfsena/banded-queue.git"},"bugs":{"url":"https://github.com/asdfsena/banded-queue/issues"},"readme":"# @asdfsena/banded-queue\n\n[![Current Version](https://img.shields.io/github/package-json/v/asdfsena/banded-queue?logo=github&label=Current%20Version&color=181717)](https://github.com/asdfsena/banded-queue/packages)\n[![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=fff)](https://www.typescriptlang.org/)\n[![Bun](https://img.shields.io/badge/Bun-000?logo=bun&logoColor=fff)](https://bun.sh)\n[![BullMQ](https://img.shields.io/badge/BullMQ-FF6F00?logo=redis&logoColor=fff)](https://bullmq.io/)\n[![Vitest](https://img.shields.io/badge/Vitest-6B9F3A?logo=vitest&logoColor=fff)](https://vitest.dev/)\n[![CI](https://img.shields.io/github/actions/workflow/status/asdfsena/banded-queue/release.yml?branch=main&label=CI&logo=github)](https://github.com/asdfsena/banded-queue/actions)\n[![npm](https://img.shields.io/npm/v/@asdfsena/banded-queue?logo=npm&logoColor=fff)](https://www.npmjs.com/package/@asdfsena/banded-queue)\n[![License](https://img.shields.io/github/license/asdfsena/banded-queue)](LICENSE)\n\nTiered priority queue on BullMQ. Assigns non-overlapping priority ranges (bands) to job tiers. FIFO within tier. Redis INCR counters wrap around when bandwidth exhausted.\n\n## Install\n\n```\nbun install @asdfsena/banded-queue\n```\n\nRequires Bun runtime.\n\n## Quick start\n\n```typescript\nimport { BandedQueue } from \"@asdfsena/banded-queue\";\nimport { Queue } from \"bullmq\";\nimport Redis from \"ioredis\";\n\nconst redis = new Redis();\nconst queue = new Queue(\"render-jobs\", { connection: redis });\nconst bq = new BandedQueue(queue, {\n  bands: [\n    { name: \"vip\", bandwidth: 1000 },\n    { name: \"pro\", bandwidth: 1000 },\n    { name: \"basic\", bandwidth: 1000 },\n    { name: \"free\", bandwidth: 5000 },\n  ],\n  redis,\n});\n\nawait bq.add(\"vip\", { userId: 1 }); // priority=1\nawait bq.add(\"pro\", { userId: 2 }); // priority=1001\n```\n\nBands in array order = priority order. First = highest priority (lowest BullMQ priority number).\n\n## API\n\n| Method     | Signature                                  | Notes                                                                                                                     |\n| ---------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |\n| `add`      | `(bandName, data, opts?) => Promise<void>` | Auto-assigns priority. Throws on unknown band. Passes `opts` through (jobId, delay, etc) but always overrides `priority`. |\n| `getQueue` | `() => Queue<T>`                           | Underlying BullMQ Queue for worker/QueueEvents setup.                                                                     |\n| `getBands` | `() => BandConfig[]`                       | Computed bands with offsets (debug/logging).                                                                              |\n\n## Development\n\n| Command                        | Action                                |\n| ------------------------------ | ------------------------------------- |\n| `bun test`                     | Run vitest (no config file needed)    |\n| `bun run build`                | Build JS bundle to `dist/`            |\n| `bun run build:types`          | Generate type declarations to `dist/` |\n| `npx prettier --write <files>` | Format with Prettier (defaults)       |\n| `npx changeset`                | Add versioning entry                  |\n\nPre-commit hook: `bun test` → `prettier --write` on staged files → `git update-index --again`. Tests must pass before commit.\n\n## Runtime dependency\n\n- **Redis** (via `bullmq` + `ioredis`). Tests mock Redis — no instance needed for development.\n- BullMQ max priority: **2,097,151**. Warns if total bandwidth exceeds limit.\n\n## Publishing\n\nPublished to **npm** via [Changesets](https://github.com/changesets/changesets) CI workflow.\n\nOn merge to `main` with a changeset file present:\n\n1. Changesets bot opens/updates a version PR\n2. Merging the version PR triggers build + publish\n\nThe `release` workflow:\n\n- Checks out code\n- Sets up Bun + Node\n- Installs deps, builds JS + types\n- Runs `npx changeset publish` (npm publish)\n\n```\nbun install @asdfsena/banded-queue\n```\n","readmeFilename":"README.md","_rev":"1-482c0333dd1d2e3d423498f553ab776c"}