Yield labels around a repeated action.

Yield Steps

yield_steps.js
const prefix = "step";
const labels = [];

function* steps(label) {
  yield label + "-start";
  yield label + "-middle";
  yield label + "-end";
}

for (const label of steps(prefix)) {
  labels.push(label);
}

console.log("prefix=" + prefix);
console.log("labels=" + labels.join("-"));
yield-steps Each `yield` can expose a named step in a longer process. The generator keeps its local state between yielded values.