Skip to content

feat: add nextTick support, add arrConcat and fnBindArgs helpers#573

Merged
nev21 merged 1 commit into
mainfrom
nev21/nextTick
May 29, 2026
Merged

feat: add nextTick support, add arrConcat and fnBindArgs helpers#573
nev21 merged 1 commit into
mainfrom
nev21/nextTick

Conversation

@nev21
Copy link
Copy Markdown
Contributor

@nev21 nev21 commented May 25, 2026

  • Add a separate scheduleNextTick API with Node-native resolution and browser/worker fallback behavior.
  • Preserve existing scheduleMicrotask semantics while sharing cancellable queue and timer-backed queue logic.
  • Hook nextTick ordering into the timeout path so nextTick runs before microtasks and normal timers.
  • update scheduleMicrotask and scheduleNextTick to support callback arguments consistently
  • add arrConcat as a new array helper with tests
  • add fnBindArgs as a dedicated helper for binding pre-supplied arguments
  • improve fnBind typing with BoundFunction so bound argument prefixes narrow the returned signature

@nev21 nev21 added this to the 0.15.0 milestone May 25, 2026
Copilot AI review requested due to automatic review settings May 25, 2026 07:29
@nev21 nev21 requested review from a team as code owners May 25, 2026 07:29
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

❌ Patch coverage is 98.67374% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.35%. Comparing base (34178c1) to head (5e239fb).

Files with missing lines Patch % Lines
lib/src/timer/microtasks/promiseQueue.ts 95.45% 3 Missing ⚠️
lib/src/timer/microtasks/cancellableTask.ts 96.42% 1 Missing ⚠️
lib/src/timer/nextTick.ts 98.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #573      +/-   ##
==========================================
- Coverage   99.42%   99.35%   -0.07%     
==========================================
  Files         158      165       +7     
  Lines        4830     5089     +259     
  Branches     1039     1116      +77     
==========================================
+ Hits         4802     5056     +254     
- Misses         28       33       +5     
Files with missing lines Coverage Δ
lib/src/array/concat.ts 100.00% <100.00%> (ø)
lib/src/funcs/fnBindArgs.ts 100.00% <100.00%> (ø)
lib/src/funcs/funcs.ts 100.00% <100.00%> (ø)
lib/src/funcs/types.ts 100.00% <ø> (ø)
lib/src/helpers/environment.ts 98.79% <100.00%> (+0.01%) ⬆️
lib/src/timer/microtask.ts 100.00% <100.00%> (ø)
lib/src/timer/microtasks/processNextTick.ts 100.00% <100.00%> (ø)
lib/src/timer/microtasks/resolveScheduleFn.ts 100.00% <100.00%> (ø)
lib/src/timer/microtasks/runMicrotask.ts 100.00% <100.00%> (ø)
lib/src/timer/microtasks/taskQueue.ts 100.00% <100.00%> (ø)
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new scheduleNextTick API to the timer utilities, integrating it into the existing timeout/microtask scheduling so “next tick” work can be ordered ahead of microtasks and normal timers across environments.

Changes:

  • Introduces scheduleNextTick with Node process.nextTick support and a timer-backed fallback queue.
  • Refactors microtask/nextTick queuing into shared, timer-backed queue helpers and a shared cancellable-task helper.
  • Updates tests and bundle size limits to account for the new API and refactor.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/src/timer/nextTick.ts Adds the new scheduleNextTick API and process.nextTick detection/getter.
lib/src/timer/timeout.ts Hooks pre-microtask flushing into the timeout callback path to preserve ordering.
lib/src/timer/microtask.ts Switches microtask scheduling to the shared cancellable-task helper and enables pre-hook support.
lib/src/timer/microtasks/cancellableTask.ts Introduces shared cancellable scheduling and the pre-microtask hook plumbing.
lib/src/timer/microtasks/timerBackedQueue.ts Adds shared timer-backed queue logic used by microtasks/nextTick fallbacks.
lib/src/timer/microtasks/timerMicrotask.ts Refactors the timer-backed microtask queue to use the shared queue helper.
lib/src/timer/microtasks/timerNextTick.ts Adds timer-backed queue state and operations for nextTick fallback behavior.
lib/src/timer/microtasks/processNextTick.ts Adds cached resolution of a process.nextTick-backed scheduler.
lib/src/helpers/environment.ts Updates isNode() detection to use getInst("process") instead of direct process access.
lib/src/index.ts Exports the new nextTick APIs from the package entrypoint.
lib/test/src/common/timer/nextTick.test.ts Adds behavioral coverage for nextTick presence/ordering and fallback behavior.
lib/test/src/common/timer/timeout.test.ts Adjusts refresh-behavior expectations using feature detection rather than isNode().
lib/test/bundle-size-check.js Raises bundle thresholds slightly to accommodate the new functionality.
.size-limit.json Updates size limits and adds size-limit checks for scheduleNextTick imports.

Comment thread lib/src/timer/nextTick.ts Outdated
Comment thread lib/test/src/common/timer/nextTick.test.ts
Comment thread lib/src/timer/microtasks/cancellableTask.ts Outdated
nevware21-bot
nevware21-bot previously approved these changes May 25, 2026
Copy link
Copy Markdown
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by nevware21-bot

nevware21-bot
nevware21-bot previously approved these changes May 26, 2026
Copy link
Copy Markdown
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by nevware21-bot

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.

Comment thread lib/src/timer/microtasks/timerQueue.ts
Comment thread lib/src/timer/microtasks/timerQueue.ts
Comment thread lib/src/timer/microtasks/runMicrotask.ts
Comment thread lib/src/timer/nextTick.ts
Comment thread lib/src/timer/nextTick.ts Outdated
Comment thread lib/test/src/common/timer/nextTick.test.ts
Comment thread lib/src/timer/nextTick.ts Outdated
nevware21-bot
nevware21-bot previously approved these changes May 27, 2026
Copy link
Copy Markdown
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by nevware21-bot

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Comment thread lib/test/src/common/timer/nextTick.test.ts
Comment thread lib/src/timer/nextTick.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Comment thread lib/src/timer/nextTick.ts
Comment thread lib/src/timer/nextTick.ts
Comment thread lib/src/timer/microtasks/runMicrotask.ts
nevware21-bot
nevware21-bot previously approved these changes May 27, 2026
Copy link
Copy Markdown
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by nevware21-bot

@nev21 nev21 force-pushed the nev21/nextTick branch from e25cf68 to 8a58a0b Compare May 28, 2026 06:48
@nev21 nev21 changed the title Add nextTick support with shared timer queue helpers feat: add nextTick support, add arrConcat and fnBindArgs helpers May 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 6 comments.

Comment thread README.md Outdated
Comment thread lib/src/timer/microtasks/promiseQueue.ts
Comment thread lib/src/timer/microtasks/promiseQueue.ts
Comment thread lib/src/timer/nextTick.ts
Comment thread lib/src/timer/nextTick.ts
Comment thread lib/test/src/common/array/append.test.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Comment thread README.md
Comment thread CHANGELOG.md
Comment thread lib/src/timer/microtasks/timerQueue.ts
nevware21-bot
nevware21-bot previously approved these changes May 28, 2026
Copy link
Copy Markdown
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by nevware21-bot

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.

Comment thread lib/src/timer/microtasks/timerQueue.ts Outdated
Comment thread lib/src/timer/nextTick.ts Outdated
nevware21-bot
nevware21-bot previously approved these changes May 29, 2026
Copy link
Copy Markdown
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by nevware21-bot

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 17 comments.

Comments suppressed due to low confidence (1)

lib/src/timer/microtasks/runMicrotask.ts:31

  • _runMicroTask now silently ignores falsy callbacks. Since the type is MicrotaskFn, this should always be callable; skipping invocation can hide programming errors and changes behavior (previously an invalid callback would be surfaced via the async rethrow path).
export function _runMicroTask(callback: MicrotaskFn): void {
    try {
        if (callback) {
            callback();
        }
    } catch (e) {
        scheduleTimeout(() => {
            throw e;
        }, 0);
    }
}

Comment thread lib/src/timer/microtask.ts
Comment thread lib/src/timer/microtask.ts Outdated
Comment thread lib/src/timer/nextTick.ts
Comment thread lib/src/timer/nextTick.ts Outdated
Comment thread lib/src/timer/microtasks/taskQueue.ts Outdated
Comment thread lib/src/timer/microtask.ts
Comment thread lib/src/timer/microtask.ts Outdated
Comment thread lib/src/timer/nextTick.ts
Comment thread lib/src/timer/nextTick.ts Outdated
Comment thread lib/src/timer/microtasks/taskQueue.ts Outdated
@nev21 nev21 force-pushed the nev21/nextTick branch from 7a58079 to 5e239fb Compare May 29, 2026 05:57
- Add a separate scheduleNextTick API with Node-native resolution and browser/worker fallback behavior.
- Preserve existing scheduleMicrotask semantics while sharing cancellable queue and timer-backed queue logic.
- Hook nextTick ordering into the timeout path so nextTick runs before microtasks and normal timers.
- update scheduleMicrotask and scheduleNextTick to support callback arguments consistently
- add arrConcat as a new array helper with tests
- add fnBindArgs as a dedicated helper for binding pre-supplied arguments
- improve fnBind typing with BoundFunction so bound argument prefixes narrow the returned signature
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.

Comment thread lib/src/timer/microtasks/runMicrotask.ts
@nev21 nev21 enabled auto-merge (squash) May 29, 2026 06:06
Copy link
Copy Markdown
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by nevware21-bot

@nev21 nev21 merged commit 124d67f into main May 29, 2026
11 checks passed
@nev21 nev21 deleted the nev21/nextTick branch May 29, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants