javascript generators utils