Moved generator loop logic into a function
Moved generator loop logic into a function

Part one of making this asynchronous-capable...

JoshuaKGoldberg/jquery-2-typescript-async-await-adapter,JoshuaKGoldberg/jquery-2-typescript-async-await-adapter,JoshuaKGoldberg/jquery-2-typescript-async-await-adapter