UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

14 lines 372 B
import toIterator from './toIterator'; export function nth(...args) { if (args.length === 1) return (arg) => nth(arg, args[0]); const it = toIterator(args[0]); const index = args[1]; let i = 0; let next; while (!(next = it.next()).done && index !== i++) ; return next.value; } export default nth; //# sourceMappingURL=nth.js.map