{
 "schemaVersion": 1,
 "pathSlug": "javascript-async-ordering",
 "items": [
  {
   "questionId": "nodejs.event_loop__532",
   "topic": "nodejs",
   "subSkill": "event_loop",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How does Node.js handle multiple expired timers in the timers phase?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It batches the expired timers into a single callback"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "It runs each timer already due in that phase, one by one"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It processes just the oldest expired timer per phase"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It distributes expired timers across multiple event loop iterations"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.event_loop__1987363",
   "topic": "javascript",
   "subSkill": "event_loop",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "In "
      },
      {
       "t": "code",
       "v": "setTimeout(callback, 500)"
      },
      {
       "t": "text",
       "v": ", what does the "
      },
      {
       "t": "code",
       "v": "500"
      },
      {
       "t": "text",
       "v": " mean?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The maximum seconds the callback may run for"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The number of times the callback should repeat"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The priority level the callback is queued at"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The delay in milliseconds before the callback runs"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.event_loop__511",
   "topic": "javascript",
   "subSkill": "event_loop",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does this code log?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "Promise.resolve().then(() => console.log('A'));\nPromise.resolve().then(() => console.log('B'));",
    "label": "event-loop.js"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "B, A, B"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A, B"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "B, A"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.event_loop__214512",
   "topic": "nodejs",
   "subSkill": "event_loop",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the output?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "console.log(1);\nsetTimeout(() => console.log(2), 0);\nPromise.resolve().then(() => console.log(3));\nprocess.nextTick(() => console.log(4));",
    "label": "event-loop.js"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "1 4 3 2"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "1 2 3 4"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "1 3 4 2"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "1 4 2 3"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.event_loop__4085492",
   "topic": "nodejs",
   "subSkill": "event_loop",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "In simple terms, what is the Node.js event loop?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The mechanism that lets Node handle work with one main thread"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A tool that copies your program across every CPU core there is"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A counter that tracks how many files your program has opened"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A cache that stores the results of every function you call"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.event_loop__741930",
   "topic": "javascript",
   "subSkill": "event_loop",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What prints?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "async function run() {\n  console.log('s1');\n  await Promise.resolve();\n  console.log('p');\n}\nsetTimeout(() => console.log('t'), 0);\nrun();\nconsole.log('s2');",
    "label": "event-loop.js"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "s1 s2 p t"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "s1 s2 t p"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "s1 p s2 t"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "p s1 s2 t"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.event_loop__502",
   "topic": "javascript",
   "subSkill": "event_loop",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which of these is a microtask in JavaScript?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "setInterval callback"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Promise.then callback"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "setTimeout callback"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "requestAnimationFrame callback"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.event_loop__530",
   "topic": "javascript",
   "subSkill": "event_loop",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Per the HTML standard, what minimum delay do browsers clamp setTimeout to once the nesting level exceeds five?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "4ms: once nesting depth passes five, the timer task source clamps further calls"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "16ms: the floor tracks the display refresh interval at a common 60Hz cadence"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "0ms: the HTML spec imposes no floor on setTimeout, whatever the nesting depth is"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "1ms: clamping matches the High Resolution Time API's reported timer precision"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.event_loop__202045",
   "topic": "nodejs",
   "subSkill": "event_loop",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which statement best describes when the microtask queue is drained?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "After the poll phase completes, provided that no setImmediate callbacks remain queued for the following check step"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Between every phase and after each individual callback in a phase, draining nextTick then resolved promise reactions"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Once per full turn of the loop, immediately before the timers phase runs so that promise reactions observe new timers"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Only when the JavaScript call stack becomes empty after all I/O callbacks have finished for the current iteration step"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "javascript.event_loop__1987366",
   "topic": "javascript",
   "subSkill": "event_loop",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "clearInterval(id)"
      },
      {
       "t": "text",
       "v": " do?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Stops a repeating interval from firing again"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Empties the queue of all pending intervals"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Runs the interval's callback one final time"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Speeds up a repeating interval's next firing"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.promises_async__524",
   "topic": "javascript",
   "subSkill": "promises_async",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does this code log?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "Promise.allSettled([\n  Promise.resolve(1),\n  Promise.reject('err'),\n  Promise.resolve(3)\n]).then(results => results.forEach(r =>\n  console.log(r.status + ': ' + (r.value ?? r.reason))\n));",
    "label": "promises-async.js"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "TypeError because mixed settlement is not allowed by spec"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "fulfilled: 1, rejected: err, fulfilled: 3"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "An array [1, err, 3] of the raw values and rejection reasons"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Only the first rejection: rejected: err (short-circuit)"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "javascript.promises_async__915026",
   "topic": "javascript",
   "subSkill": "promises_async",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A game loop schedules work with Promise.resolve().then(...) to yield. On a 144Hz monitor the render thread starves because the microtask keeps re-queuing itself before the browser can paint. The team wants to yield to paint without losing scheduling weight for upcoming input. Best mitigation?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Insert a zero-delay setTimeout between microtasks to let the rendering pipeline observe each frame cleanly"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Switch the self-chain to scheduler.postTask with a user-blocking priority tag or fall back to requestIdleCallback"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Batch the continuations into Promise.all groups of 16 so the browser yields after each settled group runs"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Wrap the continuation in queueMicrotask directly so the engine coalesces with existing paint ticks per step"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "javascript.promises_async__861904",
   "topic": "javascript",
   "subSkill": "promises_async",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What status pair is logged?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const p1 = Promise.resolve(1);\nconst p2 = Promise.reject('x');\nPromise.allSettled([p1,p2]).then(arr => {\n  console.log(arr[0].status, arr[1].status);\n});",
    "label": "promises-async.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "fulfilled rejected"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "resolved unsettled"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "fulfilled fulfilled"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "cancelled rejected"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.promises_async__502",
   "topic": "javascript",
   "subSkill": "promises_async",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which method runs a callback when a promise settles regardless of whether it resolved or rejected?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": ".then()"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": ".finally()"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": ".done()"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": ".catch()"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "javascript.promises_async__503",
   "topic": "javascript",
   "subSkill": "promises_async",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does this code log?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const p1 = Promise.resolve(1);\nconst p2 = Promise.resolve(2);\nconst p3 = Promise.resolve(3);\nPromise.all([p1, p2, p3]).then(console.log);",
    "label": "promises-async.js"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "[Promise, Promise, Promise]"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "1"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "[1, 2, 3]"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "TypeError"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.promises_async__469571",
   "topic": "javascript",
   "subSkill": "promises_async",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A service-worker install step does "
      },
      {
       "t": "code",
       "v": "await caches.open('v3')"
      },
      {
       "t": "text",
       "v": " at the script's outermost scope. On older Safari the page hangs on first load but works after hard refresh. Your bundler supports the syntax. Most likely root cause?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The bundler lowers the await wrapper into setTimeout frames that conflict with Safari's install timeout"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Top-level await delays module evaluation and blocks dependent modules importing it synchronously"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Cache API rejects during install until a controlling client claims the scope via clients.claim handshake"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Safari evaluates service-worker source files without microtask support so awaits never resume cleanly"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "javascript.promises_async__248359",
   "topic": "javascript",
   "subSkill": "promises_async",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Your Node service's error reporter fires on every unhandled failure. Since upgrading a library, you see hundreds of reports even though every caller has a catch. The library does "
      },
      {
       "t": "code",
       "v": "Promise.all([a, b, c])"
      },
      {
       "t": "text",
       "v": " then awaits the result with its own catch. Why do the siblings leak?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The library's catch only observes synchronous throws, so async failures inside all slip past it silently"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Promise.all rejects with the first reason and leaves sibling rejections unobserved by any handler"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Node emits a diagnostic event per sibling outcome even when the aggregate promise is fully handled"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Promise.all requires every input to have its own catch handler before the aggregate starts processing"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "javascript.promises_async__40455",
   "topic": "javascript",
   "subSkill": "promises_async",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the correct way to run multiple async operations in parallel with async/await?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "// Sequential (slow)\nconst a = await fetchA();\nconst b = await fetchB();\n\n// Parallel (fast)\nconst [a, b] = await Promise.all([fetchA(), fetchB()]);",
    "label": "promises-async.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Use multiple sequential await calls: async/await automatically parallelizes them"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Wrap each operation in a separate async function and call them in order"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Start all operations before awaiting any of them, or use Promise.all()"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Use a for...of loop with await inside: the loop handles parallelism"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.promises_async__40481",
   "topic": "javascript",
   "subSkill": "promises_async",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "Promise.any()"
      },
      {
       "t": "text",
       "v": " do when ALL of its input promises reject?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It resolves with undefined, treated as a fallback value"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "It stays pending indefinitely until at least one promise resolves"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It rejects with an AggregateError carrying each rejection reason"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It rejects with the first rejection reason, ignoring the rest"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.promises_async__682793",
   "topic": "javascript",
   "subSkill": "promises_async",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A team debugging a deadlock finds two async functions each awaiting a mutex the other holds. Today the gate is a plain Promise stored in a Map. One engineer suggests 'Promise.cancel' to break the wait; another says 'just race with a timeout'. What is the most defensible architectural stance?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Model the latch with an AbortSignal-aware acquire so waiters observe cancellation as a rejection they expect"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Spawn a watchdog worker that terminates the slower of the two async functions once the impasse is detected"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Use Promise.race against a timeout per acquire and release the Map entry from the rejected branch's catch"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Add a reentrant counter on the mutex so the second caller sees it as acquired and proceeds without waiting"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "javascript.functions_closures__100233",
   "topic": "javascript",
   "subSkill": "functions_closures",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Given a simple counter created by a factory that increments an inner variable, what concept best describes the mechanism that lets the returned function keep reading and writing that variable across calls?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "function makeCounter() {\n  let n = 0;\n  return () => ++n;\n}\nconst c = makeCounter();\nc(); c();",
    "label": "functions-closures.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Prototype chain lookup resolving the variable on the parent object"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Implicit hoisting of the variable to the surrounding module scope"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Garbage collection pinning the variable in a runtime global cache"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Lexical closure over the enclosing scope captured at creation time"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.functions_closures__500",
   "topic": "javascript",
   "subSkill": "functions_closures",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does this code log?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "function counter() {\n  let count = 0;\n  return () => ++count;\n}\nconst inc = counter();\nconsole.log(inc(), inc(), inc());",
    "label": "functions-closures.js"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "1, 2, 3"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "3, 3, 3"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "undefined, undefined, undefined"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "1, 1, 1"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.functions_closures__4820371",
   "topic": "javascript",
   "subSkill": "functions_closures",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What value does the final expression evaluate to?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const add = (x) => (y) => x + y;\nconst plus5 = add(5);\nconsole.log(plus5(10));",
    "label": "functions-closures.js"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "an undefined"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "the number 23"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "the number 15"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "value is NaN"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.functions_closures__100232",
   "topic": "javascript",
   "subSkill": "functions_closures",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A developer wants a one-line callback that just returns the doubled value of its argument, with the shortest syntax available in modern JS. Which form omits both the braces and an explicit return keyword?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A named function declaration with a block body wrapping the return line"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "An anonymous function expression with a block body and a return statement"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "An arrow function with a single parameter and a concise expression body"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "An arrow function with parenthesised params and a block body returning it"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.functions_closures__89117",
   "topic": "javascript",
   "subSkill": "functions_closures",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "When do class "
      },
      {
       "t": "code",
       "v": "static {}"
      },
      {
       "t": "text",
       "v": " blocks execute?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "let getPrivate;\nclass MyClass {\n  static #secret = 42;\n  static {\n    // Can access private fields here!\n    getPrivate = (obj) => obj.#secret;\n    console.log('Class evaluated');\n  }\n}",
    "label": "functions-closures.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "During class evaluation, in source order, and can read private fields"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Lazily, the first time a static property of the class is accessed"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "At module load time, before other code in the module runs"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "When the first instance of the class is created, before the constructor runs"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.functions_closures__40425",
   "topic": "javascript",
   "subSkill": "functions_closures",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does the "
      },
      {
       "t": "code",
       "v": "arguments"
      },
      {
       "t": "text",
       "v": " object contain inside a regular function?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "function sum() {\n  return Array.from(arguments).reduce((a, b) => a + b, 0);\n}\nconsole.log(sum(1, 2, 3)); // 6",
    "label": "functions-closures.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "An actual Array instance of the passed arguments"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "An array-like object of the arguments actually passed"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The default parameter values defined in the function signature"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Just the named parameters defined in the function signature"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.functions_closures__4610293",
   "topic": "javascript",
   "subSkill": "functions_closures",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the outcome of the final call?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "'use strict';\nfunction show() {\n  return this.toUpperCase();\n}\nconst b = show.bind(42);\nconsole.log(b.call('abc'));",
    "label": "functions-closures.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "prints 'ABC' upper"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "raises TypeError"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "raises RangeError"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "prints 123 as str"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.functions_closures__520",
   "topic": "javascript",
   "subSkill": "functions_closures",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does this code log?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const name = 'Alice';\nconst greet = () => 'hi ' + name;\nconsole.log(greet());",
    "label": "functions-closures.js"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "hi undefined"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "TypeError"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "undefined"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "hi Alice"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.functions_closures__6281974",
   "topic": "javascript",
   "subSkill": "functions_closures",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is printed when the detached reference runs in strict mode?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "'use strict';\nconst obj = { val: 99, get() { return this?.val; } };\nconst m = obj.get;\nconsole.log(m());",
    "label": "functions-closures.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "raises TypeError"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "prints undefined"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "prints a 99 int"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "prints null value"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.functions_closures__100231",
   "topic": "javascript",
   "subSkill": "functions_closures",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A team is choosing between two forms to define a small helper at the top of a module file. They want the helper to be callable from anywhere in the file, including lines written above the definition. Which form supports being invoked from above its own source line?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A plain function declaration using the function keyword at statement position"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A function expression assigned to a const with a descriptive variable name"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "An arrow function assigned to a let binding at module top-level scope"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A named function expression assigned to a const with an inner name"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.error_handling__500",
   "topic": "nodejs",
   "subSkill": "error_handling",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the Node.js convention for error-first callbacks?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const fs = require('node:fs');\n\nfs.readFile('config.json', 'utf8', (err, data) => {\n  if (err) {\n    console.error('Failed to read:', err.message);\n    return;\n  }\n  console.log('Config:', JSON.parse(data));\n});",
    "label": "error-handling.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The failure is raised via throw inside the body and surfaces through try/catch"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The callback returns an object whose error and data fields the caller inspects"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The failure is delivered through a separate 'error' event on the host emitter"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The first parameter is the failure (null when none), with result data following it"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "javascript.error_handling__530",
   "topic": "javascript",
   "subSkill": "error_handling",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does this code log?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const resource = {\n  data: 'hello',\n  [Symbol.dispose]() {\n    console.log('cleanup');\n  }\n};\nconsole.log(resource.data);\nresource[Symbol.dispose]();",
    "label": "error-handling.js"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "TypeError thrown"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "hello (no cleanup)"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "cleanup only"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "hello, cleanup"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.error_handling__100231",
   "topic": "nodejs",
   "subSkill": "error_handling",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Running this script with Node 20+, what is printed to stdout?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "async function run() {\n  try {\n    await (async () => { throw new Error('boom'); })();\n  } catch (e) {\n    console.log('caught:', e.message);\n  }\n}\nrun();",
    "label": "error-handling.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "caught: boom"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "rejected: boom"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "uncaught: boom"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "error: boom"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.error_handling__40482",
   "topic": "javascript",
   "subSkill": "error_handling",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the "
      },
      {
       "t": "code",
       "v": "cause"
      },
      {
       "t": "text",
       "v": " option in the Error constructor and what is it used for?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "try {\n  JSON.parse('bad json');\n} catch (e) {\n  throw new Error('Config parsing failed', { cause: e });\n}",
    "label": "error-handling.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A numeric code identifying the error category for logging systems"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The source file and line number where the error originated"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A way to chain errors, wrapping a low-level one and keeping it"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A string describing which browser or runtime caused the error"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.error_handling__526",
   "topic": "javascript",
   "subSkill": "error_handling",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "An Error is constructed in module A and thrown later from module B. Where does the top frame of "
      },
      {
       "t": "code",
       "v": "err.stack"
      },
      {
       "t": "text",
       "v": " point?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Module B: V8 rewrites the stack to the throw site when the error escapes a try"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Both A and B: V8 appends the throw frame to the constructed stack on rethrow"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Module A: the stack is captured at construction, not at the throw site"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Module B: the stack is captured the moment "
       },
       {
        "t": "code",
        "v": "throw"
       },
       {
        "t": "text",
        "v": " executes"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.error_handling__41522",
   "topic": "nodejs",
   "subSkill": "error_handling",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is "
      },
      {
       "t": "code",
       "v": "AggregateError"
      },
      {
       "t": "text",
       "v": " and when does Node.js throw it?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "An error thrown when a batch database insert partially fails"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "An error wrapping multiple errors at once; thrown by "
       },
       {
        "t": "code",
        "v": "Promise.any()"
       },
       {
        "t": "text",
        "v": " when all promises reject"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "An error thrown by "
       },
       {
        "t": "code",
        "v": "Promise.all()"
       },
       {
        "t": "text",
        "v": " when more than one promise rejects"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "An error that aggregates all uncaughtException events into one report"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.error_handling__522",
   "topic": "nodejs",
   "subSkill": "error_handling",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is AggregateError and when is it thrown?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "try {\n  await Promise.any([\n    fetch('https://mirror1.com/data'),\n    fetch('https://mirror2.com/data'),\n  ]);\n} catch (err) {\n  if (err instanceof AggregateError) {\n    console.log('All mirrors failed:');\n    err.errors.forEach(e => console.log(` - ${e.message}`));\n  }\n}",
    "label": "error-handling.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A combined linting error from multiple files"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "An error from aggregating HTTP responses"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "An error that wraps multiple errors into one"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "An error from aggregating database results"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.error_handling__40527",
   "topic": "javascript",
   "subSkill": "error_handling",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the correct way to create a custom error class in modern JavaScript?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "class ValidationError extends Error {\n  constructor(message) {\n    super(message);\n    this.name = 'ValidationError';\n  }\n}",
    "label": "error-handling.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Set "
       },
       {
        "t": "code",
        "v": "Error.prototype.name = 'MyError'"
       },
       {
        "t": "text",
        "v": " before throwing"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Use "
       },
       {
        "t": "code",
        "v": "Object.create(Error.prototype)"
       },
       {
        "t": "text",
        "v": " and manually set properties"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Call "
       },
       {
        "t": "code",
        "v": "Error.create('MyError')"
       },
       {
        "t": "text",
        "v": " with a name argument"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Write "
       },
       {
        "t": "code",
        "v": "class MyError extends Error"
       },
       {
        "t": "text",
        "v": " and call "
       },
       {
        "t": "code",
        "v": "super(message)"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.error_handling__517",
   "topic": "nodejs",
   "subSkill": "error_handling",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What was the node:domain module and why is it deprecated?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A grouping API that aimed to capture errors across emitters and callbacks; it was unreliable and leaked memory"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A deployment naming convention for multi-tenant servers; it was retired in favor of HTTP host headers"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "An access-control sandbox for untrusted modules; it was superseded by VM context and worker isolation"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A DNS resolution helper sharing the name; it was replaced by node:dns and removed on the LTS branch"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.error_handling__1108674",
   "topic": "nodejs",
   "subSkill": "error_handling",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A thrown error that no try/catch anywhere handles is described as what?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A deferred warning event"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "An uncaught exception"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A silent runtime notice"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A resolved promise value"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.iterators_generators__9564738",
   "topic": "javascript",
   "subSkill": "iterators_generators",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Each time you call "
      },
      {
       "t": "code",
       "v": "next()"
      },
      {
       "t": "text",
       "v": " on an iterator, how many values does it produce?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "none, only a flag"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "exactly one value"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "two values at once"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "all remaining values"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.iterators_generators__205991",
   "topic": "javascript",
   "subSkill": "iterators_generators",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Why does for-of over { a:1, b:2 } throw, but for-in does not?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "for-of needs enumerable symbol keys which plain object literals never define"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "for-of throws at the engine level when the target has any non-string keys"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Plain objects lack a Symbol.iterator method required by the for-of protocol"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "for-of only accepts array-like inputs whose numeric length field is present"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.iterators_generators__40502",
   "topic": "javascript",
   "subSkill": "iterators_generators",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does the spread operator do when applied to a generator?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "function* range(n) {\n  for (let i = 0; i < n; i++) yield i;\n}\nconsole.log([...range(4)]); // [0, 1, 2, 3]",
    "label": "iterators-generators.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Pauses the generator at the first yield and returns that value"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Drains the iterator and collects each yielded value into an array"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Converts the generator into a Promise that resolves when exhausted"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Creates a shallow copy of the generator object itself"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.iterators_generators__40543",
   "topic": "javascript",
   "subSkill": "iterators_generators",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the difference between an iterator and an iterable?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "An iterable has "
       },
       {
        "t": "code",
        "v": "[Symbol.iterator]()"
       },
       {
        "t": "text",
        "v": " returning an iterator; an iterator has "
       },
       {
        "t": "code",
        "v": ".next()"
       },
       {
        "t": "text",
        "v": " returning "
       },
       {
        "t": "code",
        "v": "{ value, done }"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "An iterable produces values eagerly into a buffer; an iterator pulls them lazily from the buffer one at a time"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "An iterable has "
       },
       {
        "t": "code",
        "v": ".next()"
       },
       {
        "t": "text",
        "v": " returning "
       },
       {
        "t": "code",
        "v": "{ value, done }"
       },
       {
        "t": "text",
        "v": "; an iterator has "
       },
       {
        "t": "code",
        "v": "[Symbol.iterator]()"
       },
       {
        "t": "text",
        "v": " returning the iterable back"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "An iterable is any object with a length property; an iterator is any function that increments a cursor through it"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "javascript.iterators_generators__521",
   "topic": "javascript",
   "subSkill": "iterators_generators",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does this code log?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "function* gen() {\n  yield 1;\n  return 'hello';\n}\nconst g = gen();\ng.next();\nconsole.log(g.next().value);",
    "label": "iterators-generators.js"
   },
   "widget": {
    "kind": "predict_output",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "hello"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "undefined"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "{ value: 'hello', done: true }"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "TypeError"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.iterators_generators__40538",
   "topic": "javascript",
   "subSkill": "iterators_generators",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does a generator function's "
      },
      {
       "t": "code",
       "v": ".next()"
      },
      {
       "t": "text",
       "v": " call return?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "function* gen() { yield 1; yield 2; }\nconst it = gen();\nconsole.log(it.next()); // { value: 1, done: false }\nconsole.log(it.next()); // { value: 2, done: false }\nconsole.log(it.next()); // { value: undefined, done: true }",
    "label": "iterators-generators.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "An object with "
       },
       {
        "t": "code",
        "v": "value"
       },
       {
        "t": "text",
        "v": " and "
       },
       {
        "t": "code",
        "v": "done"
       },
       {
        "t": "text",
        "v": " properties"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A two-element array holding value and done"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The value that was just yielded, directly"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A Promise resolving to the next yielded value"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.iterators_generators__9564728",
   "topic": "javascript",
   "subSkill": "iterators_generators",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "While a generator still has more values to produce, the completion flag on each result is set to what?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "true"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "empty"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "false"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "null"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "javascript.iterators_generators__9564721",
   "topic": "javascript",
   "subSkill": "iterators_generators",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which method do you call on an iterator to advance it and read the following result object?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "step()"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "pull()"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "next()"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "read()"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "javascript.iterators_generators__9564718",
   "topic": "javascript",
   "subSkill": "iterators_generators",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Building a streaming pipeline from a ReadableStream, you need to apply stage-by-stage transforms with fair backpressure. Which composition best preserves per-chunk backpressure without buffering whole windows?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Promise.all on each chunk map"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "for-await with async generators"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Array.from stream then transforms"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "ReadableStream.tee().splitMap()"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "javascript.iterators_generators__525",
   "topic": "javascript",
   "subSkill": "iterators_generators",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the difference between an iterable and an iterator?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "An iterable has next() and the iterator has [Symbol.iterator](): the protocols hang off opposite roles"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "An iterable returns Promises from next() while an iterator returns plain { value, done } objects synchronously"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "An iterable has [Symbol.iterator]() returning an iterator; the iterator has next() returning { value, done }"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "An iterable is the lazy form and an iterator is its eagerly-materialised array equivalent for fast access"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.async_patterns__815218",
   "topic": "nodejs",
   "subSkill": "async_patterns",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "A Node-style callback hands you a possible failure plus a result. What should you do first inside it?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Invoke the callback again to confirm the result holds"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Check whether an error was given before using the result"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Print the result and forward it to the next callback"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Return the result at once and check for trouble later"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.async_patterns__500864",
   "topic": "nodejs",
   "subSkill": "async_patterns",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the correct characterization of "
      },
      {
       "t": "code",
       "v": "await using resource = acquire()"
      },
      {
       "t": "text",
       "v": " declarations (TC39 explicit resource management)?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The binding captures a snapshot of every live promise in scope so exit handlers can re-await them in order."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The binding runs the acquire expression in a detached microtask and resolves the handle lazily upon first read."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The binding is promoted to the outer function scope and cleaned up by a finalization registry on garbage pass."
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The binding is disposed via its "
       },
       {
        "t": "code",
        "v": "Symbol.asyncDispose"
       },
       {
        "t": "text",
        "v": " method when the enclosing block exits, awaiting the cleanup to finish."
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.async_patterns__41588",
   "topic": "nodejs",
   "subSkill": "async_patterns",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "node --experimental-vm-modules"
      },
      {
       "t": "text",
       "v": " enable and why is it relevant to testing?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "// package.json\n{ \"scripts\": { \"test\": \"node --experimental-vm-modules node_modules/.bin/jest\" } }",
    "label": "async-patterns.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It activates V8's speculative optimization for dynamically evaluated code"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "It allows vm.runInContext to import npm packages from node_modules"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It enables multi-threading inside the vm module for parallel test execution"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "ESM inside the vm module, so test runners can transform and run it"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.async_patterns__41507",
   "topic": "nodejs",
   "subSkill": "async_patterns",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you implement a concurrency limit when processing an array of items asynchronously?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "import pLimit from 'p-limit';\nconst limit = pLimit(5);\nconst results = await Promise.all(\n  items.map(item => limit(() => processItem(item)))\n);",
    "label": "async-patterns.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Set "
       },
       {
        "t": "code",
        "v": "process.maxListeners"
       },
       {
        "t": "text",
        "v": " to the desired concurrency limit"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Use setImmediate() between each item to allow other I/O to proceed"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Use a semaphore or a pool pattern: process N items at a time using Promise.all on batches"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Use Promise.race() with the full array to naturally throttle to one at a time"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.async_patterns__41552",
   "topic": "nodejs",
   "subSkill": "async_patterns",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "AbortController"
      },
      {
       "t": "text",
       "v": " allow you to do with async operations in Node.js?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const ac = new AbortController();\nsetTimeout(() => ac.abort(), 5000);\nawait fetch(url, { signal: ac.signal });",
    "label": "async-patterns.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Set a hard timeout that kills the entire process if exceeded"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Roll back database transactions on error"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Cancel work in flight by signalling an AbortSignal"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Pause and resume a Promise chain mid-execution"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.async_patterns__41580",
   "topic": "nodejs",
   "subSkill": "async_patterns",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the 'callback hell' anti-pattern, and what is the idiomatic modern solution?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Callbacks run in parallel by default causing race conditions; use Promises to serialize them"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Each callback creates a new event loop phase increasing latency; use synchronous equivalents"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Callbacks are deprecated in Node.js 18+; migrate to EventEmitter"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Deeply nested callbacks make error handling unmanageable; use async/await with try/catch"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.async_patterns__815225",
   "topic": "nodejs",
   "subSkill": "async_patterns",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "When does the callback passed to a promise's "
      },
      {
       "t": "code",
       "v": ".then(cb)"
      },
      {
       "t": "text",
       "v": " run?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Immediately and synchronously, ignoring the promise state"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "After the promise fulfills, receiving the resolved value"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Only if the promise rejects, receiving the thrown error"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Before the promise starts, to set up its initial value"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.async_patterns__41587",
   "topic": "nodejs",
   "subSkill": "async_patterns",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Why is it problematic to mix "
      },
      {
       "t": "code",
       "v": "async/await"
      },
      {
       "t": "text",
       "v": " with "
      },
      {
       "t": "code",
       "v": ".then()"
      },
      {
       "t": "text",
       "v": " chains on the same Promise?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "await cannot unwrap a Promise that already has .then() handlers attached"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Mixing them causes the Promise to resolve twice, corrupting the value"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It creates confusing control flow and ambiguous error boundaries, though it is technically valid"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It causes a memory leak because the Promise is retained by both the async frame and the .then() closure"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.async_patterns__41529",
   "topic": "nodejs",
   "subSkill": "async_patterns",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the purpose of "
      },
      {
       "t": "code",
       "v": "node:worker_threads"
      },
      {
       "t": "text",
       "v": " in Node.js?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Handling multiple HTTP requests concurrently on separate event loops"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Offloading file I/O to separate threads for higher disk throughput"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Running CPU-heavy JavaScript on separate threads, unblocked"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Sharing memory between Node.js processes started with cluster.fork()"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.async_patterns__524",
   "topic": "nodejs",
   "subSkill": "async_patterns",
   "difficulty": 2,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you create a promise-based sleep or delay function?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "// Custom sleep\nconst sleep = (ms) => new Promise(r => setTimeout(r, ms));\n\nawait sleep(2000); // pause for 2 seconds\n\n// Built-in (Node 16+)\nimport { setTimeout as delay } from 'node:timers/promises';\nawait delay(2000);",
    "label": "async-patterns.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Use process.sleep(ms) which is built into Node.js"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Wrap setTimeout in a Promise that resolves"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Use Atomics.wait() for synchronous sleeping"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Call await setTimeout(ms) directly"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.child_processes__513",
   "topic": "nodejs",
   "subSkill": "child_processes",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you pass environment variables to a child process?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const child = spawn('node', ['worker.js'], {\n  env: {\n    ...process.env,\n    NODE_ENV: 'production',\n    WORKER_ID: '1'\n  }\n});",
    "label": "child-processes.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Write them to a .env file next to the child script"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Pass variables as command-line arguments"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Use child.setEnv('MY_VAR', 'value') after spawning"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Set the env option when calling spawn or exec"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.child_processes__530",
   "topic": "nodejs",
   "subSkill": "child_processes",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the purpose of the serialization option 'advanced' in fork()?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It swaps JSON for V8 structured clone, so Map and cycles survive"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "It encrypts the messages passing between the parent and the child"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It compresses the messages for faster IPC transfer between them"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It serializes messages to a binary format for cross-platform compatibility"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.child_processes__507",
   "topic": "nodejs",
   "subSkill": "child_processes",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does execFile() do differently from exec()?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const { execFile } = require('node:child_process');\n\n// Safe: no shell injection possible\nexecFile('git', ['log', '--oneline', '-5'], (err, stdout) => {\n  console.log(stdout);\n});\n\n// Unsafe with exec: userInput could contain ; rm -rf /\n// exec(`git log ${userInput}`, callback);",
    "label": "child-processes.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "execFile() runs JavaScript files while exec() runs whichever command"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "execFile() is asynchronous while exec() is synchronous"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "execFile() streams output while exec() buffers it up"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It skips the shell, so injection is out and it runs faster"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.child_processes__200005",
   "topic": "nodejs",
   "subSkill": "child_processes",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which statement best describes the behavior of subprocess.kill() when called with no arguments?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Detaches the child from the parent session and leaves it running in the background only"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Closes the IPC channel and lets the child terminate on its own once queued work finishes"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Sends SIGKILL immediately, bypassing any handler the child may have registered at boot"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Sends SIGTERM to the child, giving it a chance to perform graceful shutdown cleanup"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.child_processes__8471080",
   "topic": "nodejs",
   "subSkill": "child_processes",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "On a process created with spawn(), child.stdin is what kind of stream?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "a writable stream"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "a duplex socket"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "a readable stream"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "a plain buffer"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.child_processes__500003",
   "topic": "nodejs",
   "subSkill": "child_processes",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which characterization best describes the killSignal option on exec()/execFile()?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Signal sent when timeout expires or maxBuffer is exceeded, defaulting to SIGTERM normally"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Signal the runtime raises when the argv list exceeds the platform-dependent maximum byte count"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Signal forwarded from the parent on SIGINT so Ctrl-C propagates down into the child correctly"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Signal used by the shell to reap zombie descendants left behind after any pipeline finishes up"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.child_processes__8471076",
   "topic": "nodejs",
   "subSkill": "child_processes",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "When you call spawn(command, args), how are the command-line arguments supplied?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "as a key-value object"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "as separate parameters"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "as one joined string"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "as an array of strings"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.child_processes__502",
   "topic": "nodejs",
   "subSkill": "child_processes",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does fork() provide that spawn() does not?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "// parent.js\nconst { fork } = require('node:child_process');\nconst child = fork('./worker.js');\n\nchild.send({ task: 'compute', data: [1, 2, 3] });\nchild.on('message', (result) => {\n  console.log('Result:', result);\n});\n\n// worker.js\nprocess.on('message', (msg) => {\n  const sum = msg.data.reduce((a, b) => a + b, 0);\n  process.send({ sum });\n});",
    "label": "child-processes.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "An automatic IPC channel back to the child"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A shared memory space between parent and child"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The ability to run non-JavaScript executables"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Automatic load balancing across CPU cores"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.child_processes__525",
   "topic": "nodejs",
   "subSkill": "child_processes",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you pipe data between multiple child processes in Node.js?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const { spawn } = require('node:child_process');\n\nconst grep = spawn('grep', ['error']);\nconst wc = spawn('wc', ['-l']);\n\n// Pipe: grep stdout -> wc stdin\ngrep.stdout.pipe(wc.stdin);\n\n// Feed data to grep\nfs.createReadStream('app.log').pipe(grep.stdin);\n\nwc.stdout.on('data', (count) => {\n  console.log(`Error count: ${count.toString().trim()}`);\n});",
    "label": "child-processes.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Use spawn with { pipe: true } option"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Use exec with shell pipe syntax: exec('cmd1 | cmd2')"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Pipe the first stdout into the second's stdin"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Pass the child processes to stream.pipeline()"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.child_processes__9406",
   "topic": "nodejs",
   "subSkill": "child_processes",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "You need to launch a separate OS process to run an external command (e.g. "
      },
      {
       "t": "code",
       "v": "ffmpeg"
      },
      {
       "t": "text",
       "v": ") from a Node.js server. Which API is purpose-built for this?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "import { spawn } from 'node:child_process';",
    "label": "child-processes.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "worker_threads.Worker"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "vm.runInContext()"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "cluster.fork()"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "child_process.spawn()"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.streams__200007",
   "topic": "nodejs",
   "subSkill": "streams",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which statement best characterizes the default highWaterMark for a byte-mode Readable?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A compile-time constant wired into V8 and inaccessible from user JavaScript code"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A soft buffering hint expressed in bytes rather than a hard capacity limit"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A strict ceiling in kilobytes that the implementation refuses to exceed at runtime"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "An OS-level mmap region whose size changes based on the current NUMA topology"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.streams__514",
   "topic": "nodejs",
   "subSkill": "streams",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What happens if you call this.push() after already pushing null in a Readable stream?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It throws an ERR_STREAM_PUSH_AFTER_EOF error"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The pushed data is silently ignored here"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The data is buffered for the next stream.read() call"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The stream reopens and continues from the new data"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.streams__200001",
   "topic": "nodejs",
   "subSkill": "streams",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which option best characterizes a Transform stream relative to its parent class?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A Writable whose drain event triggers automatic resend of prior payloads"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A purely synchronous pipe helper that cannot be composed with async work"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A Duplex where output is computed as a function of the incoming chunks"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A Readable with an extra .write() method grafted onto the prototype chain"
       }
      ],
      "shape": "code"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.streams__1789431",
   "topic": "nodejs",
   "subSkill": "streams",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What does "
      },
      {
       "t": "code",
       "v": "readable.pipe(writable)"
      },
      {
       "t": "text",
       "v": " return, which makes chaining "
      },
      {
       "t": "code",
       "v": ".pipe()"
      },
      {
       "t": "text",
       "v": " calls possible?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "readable.pipe(a).pipe(b);",
    "label": "streams.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "A brand new duplex wrapper stream"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A promise that resolves on finish"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The destination writable stream"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The original source readable stream"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.streams__504",
   "topic": "nodejs",
   "subSkill": "streams",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "What is the canonical way to build a Transform stream that uppercases each text chunk passing through it?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "import { Transform } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\n\nconst upper = new Transform({\n  transform(chunk, enc, cb) {\n    cb(null, chunk.toString().toUpperCase());\n  }\n});\n\nawait pipeline(process.stdin, upper, process.stdout);",
    "label": "streams.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "Construct a "
       },
       {
        "t": "code",
        "v": "Transform"
       },
       {
        "t": "text",
        "v": " and implement "
       },
       {
        "t": "code",
        "v": "transform(chunk, enc, cb)"
       },
       {
        "t": "text",
        "v": ", calling "
       },
       {
        "t": "code",
        "v": "cb(null, chunk.toString().toUpperCase())"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "Subclass "
       },
       {
        "t": "code",
        "v": "Writable"
       },
       {
        "t": "text",
        "v": " and override "
       },
       {
        "t": "code",
        "v": "_write"
       },
       {
        "t": "text",
        "v": " to forward the uppercased payload to the next stream in the chain"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "Wrap the source in a "
       },
       {
        "t": "code",
        "v": "PassThrough"
       },
       {
        "t": "text",
        "v": " and replace its prototype "
       },
       {
        "t": "code",
        "v": "_transform"
       },
       {
        "t": "text",
        "v": " with the uppercase routine inline"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Call "
       },
       {
        "t": "code",
        "v": "readable.setEncoding('utf8')"
       },
       {
        "t": "text",
        "v": " and then "
       },
       {
        "t": "code",
        "v": "readable.map(chunk => chunk.toUpperCase())"
       },
       {
        "t": "text",
        "v": " before piping anywhere"
       }
      ],
      "shape": "long"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.streams__1789430",
   "topic": "nodejs",
   "subSkill": "streams",
   "difficulty": 1,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which event does a Node.js stream emit to report that something went wrong?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "The 'reject' event"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "The 'fail' event"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "The 'abort' event"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "The 'error' event"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.streams__41571",
   "topic": "nodejs",
   "subSkill": "streams",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How does "
      },
      {
       "t": "code",
       "v": "objectMode: true"
      },
      {
       "t": "text",
       "v": " change stream behavior?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const readable = new Readable({ objectMode: true, read() {} });\nreadable.push({ id: 1 });\nreadable.push({ id: 2 });\nreadable.push(null);",
    "label": "streams.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It enables automatic JSON serialization/deserialization of each chunk"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "It disables backpressure since object size is unpredictable"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It forces the stream into paused mode to avoid type coercion issues"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It carries arbitrary objects, and the watermark counts them"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.streams__300009",
   "topic": "nodejs",
   "subSkill": "streams",
   "difficulty": 3,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Which option best describes the role of _transform(chunk, enc, cb) on a Transform subclass?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "An internal routine invoked only when the stream switches from paused to flowing"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A framework-managed hook automatically emitting the chunk verbatim downstream"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "User-defined method that processes each input and pushes zero or more outputs"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "A protected callback whose purpose is solely to rate-limit the upstream producer"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.streams__515",
   "topic": "nodejs",
   "subSkill": "streams",
   "difficulty": 4,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "How do you properly implement the _writev method on a custom Writable stream?"
      }
     ]
    }
   ],
   "code": {
    "lang": "js",
    "code": "const { Writable } = require('node:stream');\n\nclass BatchWriter extends Writable {\n  _writev(chunks, callback) {\n    const batch = chunks.map(c => c.chunk.toString());\n    db.bulkInsert(batch)\n      .then(() => callback())\n      .catch(callback);\n  }\n}",
    "label": "streams.js"
   },
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "It takes an array of chunks, so the writes batch up"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "It writes data to multiple destinations simultaneously"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "It validates multiple chunks before writing the first one"
       }
      ],
      "shape": "short"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "It splits a single large chunk into multiple smaller writes"
       }
      ],
      "shape": "short"
     }
    ]
   }
  },
  {
   "questionId": "nodejs.streams__500723",
   "topic": "nodejs",
   "subSkill": "streams",
   "difficulty": 5,
   "stem": [
    {
     "type": "p",
     "runs": [
      {
       "t": "text",
       "v": "Comparing pipeline() error handling to manual pipe() + error listeners on every stream, which subtle failure mode does pipeline() still NOT protect against, requiring explicit handling?"
      }
     ]
    }
   ],
   "widget": {
    "kind": "mcq",
    "options": [
     {
      "id": "o1",
      "label": [
       {
        "t": "text",
        "v": "An upstream source that destroys itself silently without emitting error or close events"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o2",
      "label": [
       {
        "t": "text",
        "v": "A Readable whose _read() throws synchronously before the first chunk is pushed to sink"
       }
      ],
      "shape": "code"
     },
     {
      "id": "o3",
      "label": [
       {
        "t": "text",
        "v": "A Transform that calls callback(err) instead of emitting an error event on its readable side"
       }
      ],
      "shape": "long"
     },
     {
      "id": "o4",
      "label": [
       {
        "t": "text",
        "v": "Errors thrown synchronously from a Writable's 'finish' listener after all streams closed"
       }
      ],
      "shape": "long"
     }
    ]
   }
  }
 ]
}
