mirror of
https://github.com/swc-project/swc.git
synced 2024-12-18 11:11:30 +03:00
29 lines
503 B
JavaScript
29 lines
503 B
JavaScript
|
'use strict';
|
||
|
|
||
|
/** Generate unique IDs starting at 0. */
|
||
|
function* startsAt0() {
|
||
|
var index = 0;
|
||
|
while (true) {
|
||
|
yield index++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/** Generate unique IDs starting at 1. */
|
||
|
var startsAt1 = function* startsAt1() {
|
||
|
var index = 1;
|
||
|
while (true) {
|
||
|
yield index++;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/** Generator class. */
|
||
|
class Generator {
|
||
|
/** Generate unique IDs starting at 2. */
|
||
|
* startsAt2() {
|
||
|
var index = 2;
|
||
|
while (true) {
|
||
|
yield index++;
|
||
|
}
|
||
|
}
|
||
|
}
|