import { head, tail } from "./combinators"; import { isEmpty, isNonEmpty } from "./guards"; import type { LazyList } from "./model"; /* * ------------------------------------------- * Destructors * ------------------------------------------- */ export const toArray = (xs: LazyList): ReadonlyArray => { if (isEmpty(xs)) return []; const r = []; let l: LazyList = xs; while (isNonEmpty(l)) { r.push(head(l)); l = tail(l); } return r; };