Prototype: runWithSignal(task, signal) checks an AbortSignal before invoking task(signal), then awaits and returns its result. A pre-aborted signal rejects with its exact reason and never invokes task. In-progress cancellation is cooperative; do not pretend it can roll back an operation.

Final: mapLimit(items, limit, operation, {signal} = {}) applies operation(item,index,signal) with at most limit active calls and returns results in input order. limit must be a positive safe integer or reject with RangeError. On the first observed failure or abort, start no new items, await all started calls, then reject with that exact failure/reason. Observe later rejections. Empty input returns []; a pre-aborted signal rejects with its exact reason and dispatches nothing. On mid-flight abort, active calls may keep running cooperatively, but the batch must wait for every one to settle before rejecting; do not dispatch pending items after observing abort. Do not mutate items.

Complete the exported stubs in exercise.mjs. The prototype and final stages have separate checks.

Shell
node main.mjs --stage prototype
node main.mjs --stage final

Use Node.js 20+ locally, or the website's browser worker. Tests are standard-library only and check the documented behavior; they do not prove performance or force garbage collection.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.