Iterator next function for JavaScript. See docs.
⚠️ Depending on your environment, the code may requireregeneratorRuntime
to be defined, for instance by importing regenerator-runtime/runtime.
import {iter} from '@iterable-iterator/iter';
import {next, StopIteration} from '@iterable-iterator/next';
next(iter('ABC')); // A
next(iter('')); // throws StopIteration
// With default parameter
next(iter(''), 'x'); // x