/** * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal */ /** * "Idiomatic" usage: * * const it = ...; * while (it.hasNext) { const v = it.move(); ... } */ interface Iterator { readonly hasNext: boolean; move(): T; } declare namespace Iterator { const Empty: Iterator; function Array(xs: ArrayLike): Iterator; function Value(value: T): Iterator; function Range(min: number, max: number): Iterator; function map(base: Iterator, f: (v: T) => R): Iterator; function filter(base: Iterator, p: (v: T) => boolean): Iterator; function forEach(it: Iterator, f: (v: T, ctx: Ctx) => any, ctx: Ctx): Ctx; } export { Iterator };