wrap a generator to make it a promise returning function