JavaScriptで関数のソースから外部イテレータのソースに変換してくれるツールほしい!

たとえば

function () {
	for (var i = 0; i < 3; i ++) {
		yield i;
	}
}

って入力すると

function () {
	for (;;) {
		switch(this.pc) {
		case 0:
			this.i = 0;
			this.pc = 1;
			break;
		case 1:
			if (this.i < 3) {
				this.pc = 2;
			} else {
				this.pc = 4;
			}
			break;
		case 2:
			this.pc = 3;
			return this.i;
		case 3:
			this.i ++;
			this.pc = 1;
			break;
		case 4:
			throw StopIteration;
		}
	}
}

が返ってくる。こんなのが欲しいなー。