Ruby-like internal iterators written in JavaScript