add generator methods in JS and PHP