-
-
Notifications
You must be signed in to change notification settings - Fork 0
Release notes
New waitFor() — a bounded condition poller: polls a sync/async predicate until it turns truthy, with an optional timeout, a configurable interval (default: 50ms), and AbortSignal support. Test infrastructure expanded on two fronts: automated browser tests (Playwright: Chromium + Firefox + WebKit) covering the DOM-driven paths, and race-condition property tests (fast-check) for the concurrency primitives.
-
waitFor(predicate, {timeout, interval, signal})(time-queues/wait-for.js, also on the barrel): resolves with the first truthy predicate result; the predicate may return a promise; checks never overlap — the next poll is scheduled only after the previous check settles.timeoutrejects with a plainError;signalrejects withsignal.reason; predicate errors propagate. See waitFor().
-
Browser suites under
tests/browser/run viatape-six-playwright(npm run test:browser;test:browser:allfans out to Chromium + Firefox + WebKit) — PageWatcher lifecycle transitions, FrameQueue frame semantics, IdleQueue deadlines, and whenLoaded/whenDomLoaded including theremove(fn)regression case that motivated the effort. WebKit records a skip for IdleQueue (norequestIdleCallback). An advisory CI workflow runs the suite on pushes tomain. -
Race-condition properties under
tests/test-race-*.jsviatape-six-fast-check+fast-check: LimitedQueue's concurrency cap, FIFO start order, and idle detection, plusbatch()ordering and rejection propagation, verified under arbitrary task interleavings. Recipe: Testing race conditions.
- Fixed a
js-checkTS2810 regression inLimitedQueue.waitForIdlesurfaced by a dependency bump. - Fleet-conventions audit: revived the PR CI trigger (dead since the
master→maindefault-branch rename), workflow-level least-privilege permissions, retired legacy AI-assistant mirror files, wiki navigation sidebar + search index. - Dependencies updated to latest;
engines.nodedropped — the library feature-detects, so there is no technical Node floor.
Bare import 'time-queues' now works at runtime — added an index.js barrel and a "." entry in package.json#exports. New Scheduler.onError hook and MicroTask.cancelError for richer task lifecycle control. Several user-observable bug fixes. Adopted js-check (dual-tsconfig pattern) for unused-vars / undeclared-refs / control-flow checks without ESLint's transitive-dep cost.
-
Bare imports:
import * as pkg from 'time-queues';(orimport {sleep, Scheduler, ...} from 'time-queues';) now resolves at runtime. Subpath imports (time-queues/sleep.jsetc.) continue to work unchanged. -
Scheduler.onError: optional callback(error, task) => voidinvoked when a scheduledtask.fnthrows. Defaultnull; if unset, exceptions surface via unhandled rejection. Either way, the scheduler loop continues — one failing task no longer stalls the rest. -
MicroTask.cancelError: read-only getter exposing the error supplied to the firstcancel(error)call, ornull. Useful for inspecting why a non-promised task was canceled. -
MicroTaskcancel/resolve hardening:resolve()now throws if called beforemakePromise()(was a silent no-op that hung subscribers).cancel(error)stores the error and replays it on a latermakePromise()— the freshly-created promise settles immediately asCancelTaskError(cause: error).
-
whenLoaded.remove(fn)andwhenDomLoaded.remove(fn): actual list-toolkit method isgetNodeIterator, notgetNodeIterable— both functions previously crashed at runtime. -
Scheduler.repeat(0): no longer infinite-loops the scheduler. Next-delay computation clamps to ≥1ms. -
PageWatcher: can be safely imported in Node now. The module-level singleton'sgetState()previously crashed withReferenceError: document is not definedoutside DOM. -
Retainer.get()race: concurrentget()calls before the firstcreate()resolves now share the same in-flight promise —create()runs at most once per zero-counter interval. -
Retainer.release(): deferred destroy errors no longer silently swallowed; surface as standard unhandled rejection events (consistent with theimmediatelypath). -
random-dist.normal()skewness: skew-normal computation now uses two N(0,1) samples (the second from Box-Muller'ssinarm) instead of mixing the uniformv. The previous output didn't correspond to a recognized statistical distribution.
-
js-checkadopted viatsconfig.check.json+npm run js-checkscript (also wired into CI). 30 → 0 errors after fixing the typo bugs and tightening sidecars. -
Fleet alignment: HTTPS submodule URLs, CI Node matrix
[22, 24, 26],engines.node: ">=22", paired.claude/commands/workflow files, tuned.github/dependabot.yml(grouped +versioning-strategy: increase-if-necessary). -
JSDoc stripped from
.jssource files;// @ts-self-typesdirectives in place..d.tsis the sole source of truth for types + docs.
-
ListQueue.list: List<MicroTask>andScheduler.queue: MinHeap<Task>fields now declared (instance fields visible to consumers). -
Retainer.valueis nowreadonly. -
Counter.notify()method declared (called by setter / increment / decrement / advance — and by user when mutatingcountdirectly). -
processTasks()declared onFrameQueue,IdleQueue,Scheduler(the timer callbacks). - Internal handles privatized (
Throttler.#handle,Retainer.#handle,Retainer.#creating). -
LimitedQueue.wrapstatic helper → module-private function. -
MicroTaskQueue.returnArgsstatic → module-private.
- Hoisted
_drainBatch(batchMs, taskContext)helper toListQueue;FrameQueueandIdleQueueshare it (-32 lines across the two subclasses). -
MicroTaskQueue.schedule()argument shadowing cleaned up (outerscheduleArgs, innerinvocationArgs).
- 103 → 112 tests; 668 → 733 asserts cross-runtime (Node, Bun, Deno).
- New tests for: bare-import barrel surface,
Counter.notify()direct-mutation flow,Retainerconcurrent gets,Scheduler.repeat(0)clamp,ScheduleronError handling,MicroTaskresolve/cancel error paths.
- Wiki: refreshed
Scheduler,MicroTask,Retainer,Throttlerpages for the new API surface and the pacing-vs-throttle reframing onThrottler(rate-limiting / pacing semantics, not classical throttle — every call is honored, none are dropped). -
ARCHITECTURE.md: updated for new structures and helpers. -
llms.txt/llms-full.txt: regenerated against current API.
Bug fixes, improved TypeScript declarations, expanded test coverage, and documentation corrections.
-
Scheduler:
processTasks()now skips canceled tasks instead of executing them. -
Scheduler:
dequeue()guards against already-removed tasks. -
Scheduler:
repeat()stops re-enqueueing whentask.isCanceledis set. -
LimitedQueue: Constructor now validates the
limitparameter (appliesMath.max(1, limit)). -
PageWatcher:
pause()no longer calls deadsuper.pause()path; event listeners are removed correctly. -
PageWatcher:
clear()now cancels tasks likeListQueuedoes. -
Retainer:
release()wrapsdestroy()in try/catch to prevent unhandled rejections.
-
LimitedQueue.d.ts:
enqueueandschedulecallbacks now correctly include{task, queue}argument. - Various
.d.tsfiles refined for accuracy: Scheduler, FrameQueue, IdleQueue, ListQueue, MicroTask, MicroTaskQueue, PageWatcher, Throttler, Counter, index, random-dist, random-sleep.
- Added CommonJS test (
test-cjs.cjs). - Added many new unit tests for Counter, LimitedQueue, ListQueue, Retainer, Scheduler, Throttler, random-dist.
- Added TypeScript typing tests for CancelTaskError, MicroTask, LimitedQueue, and browser types.
- Fixed
ARCHITECTURE.md: correctedwhenDomLoaded/whenLoadedexport descriptions, fixed GitHub URLs. - Fixed
wiki/whenLoaded().md: corrected description (page load, not DOM load). - Fixed
wiki/Counter.md: removed incorrect LimitedQueue/Counter association. - Updated
wiki/Scheduler.md: documentedrepeat()cancellation behavior. - Updated file layout in AGENTS.md and rule files to include
.mjs/.cjstest patterns.
Queues
Utility Functions
Supporting Classes
Base Classes
Random Utilities
Page Load Helpers
Cookbook
Built on list-toolkit