function* generateId() {
let index = 1;
while (true) {
yield index++;
}
}
const generateUserId = generateId();
const generateProdId = generateId();
console.log("user", generateUserId.next());
console.log("user", generateUserId.next());
console.log("user", generateUserId.next());
console.log("prod", generateProdId.next());
console.log("prod", generateProdId.next());
console.log("prod", generateProdId.next());
user { value: 1, done: false }
user { value: 2, done: false }
user { value: 3, done: false }
prod { value: 1, done: false }
prod { value: 2, done: false }
prod { value: 3, done: false }