import{checkArg as r}from"./checkArg.js";export{compare}from"./array.js";export function map(i,t){return r("iterable",i).isNotMissing(),r("f",t).isNotMissing(),Array.isArray(i)?i.map(t):function*(){let r=0;for(const o of i)yield t(o,r++)}()}export function reduce(i,t,o){if(r("iterable",i).isNotMissing(),r("f",t).isNotMissing(),Array.isArray(i))return i.reduce(t,o);let e=o;for(const r of i)e=t(e,r,0);return e}export function concat(i,...t){return r("iterable",i).isNotMissing(),function*(){yield*i;for(const r of t)"object"==typeof r&&r[Symbol.iterator]?yield*r:yield r}()}export function every(i,t){if(r("iterable",i).isNotMissing(),r("p",t).isNotMissing(),Array.isArray(i))return i.every(t);let o=0;for(const r of i)if(!t(r,o++))return!1;return!0}export function filter(i,t){return r("iterable",i).isNotMissing(),r("p",t).isNotMissing(),Array.isArray(i)?i.filter(t):function*(){let r=0;for(const o of i)t(o,r++)&&(yield o)}()}export function find(i,t){if(r("iterable",i).isNotMissing(),r("p",t).isNotMissing(),Array.isArray(i))return i.find(t);let o=0;for(const r of i)if(t(r,o++))return r}export function first(i){return r("it",i).isNotMissing(),Array.isArray(i)?i.length?i[0]:void 0:i[Symbol.iterator]().next().value}export function flatten(i){return r("iterables",i).isNotMissing(),function*(){for(const r of i)yield*r}()}export function forEach(i,t){if(r("iterable",i).isNotMissing(),r("f",t).isNotMissing(),Array.isArray(i))return void i.forEach(t);let o=0;for(const r of i)t(r,o++)}export function some(i,t){if(r("iterable",i).isNotMissing(),r("p",t).isNotMissing(),Array.isArray(i))return i.some(t);let o=0;for(const r of i)if(t(r,o++))return!0;return!1}export function*fromSingleItem(r){yield r}export function length(i){if(r("iterable",i).isNotMissing(),Array.isArray(i))return i.length;let t=0;for(const r of i)t++;return t}