feat: add nextTick support, add arrConcat and fnBindArgs helpers#573
Conversation
Codecov Report❌ Patch coverage is 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
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
scheduleNextTickwith Nodeprocess.nextTicksupport 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. |
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
There was a problem hiding this comment.
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
_runMicroTasknow silently ignores falsy callbacks. Since the type isMicrotaskFn, 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);
}
}
- 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
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
Uh oh!
There was an error while loading. Please reload this page.