Making node callback style functions work with generators