Switch the implementation of iterator to the official JS iterator protocol.