UNPKG

veffect

Version:

powerful TypeScript validation library built on the robust foundation of Effect combining exceptional type safety, high performance, and developer experience. Taking inspiration from Effect's functional principles, VEffect delivers a balanced approach tha

53 lines 1.13 kB
/** @internal */ export function concat(that) { return self => { return { [Symbol.iterator]() { const iterA = self[Symbol.iterator](); let doneA = false; let iterB; return { next() { if (!doneA) { const r = iterA.next(); if (r.done) { doneA = true; iterB = that[Symbol.iterator](); return iterB.next(); } return r; } return iterB.next(); } }; } }; }; } /** @internal */ export function reduce(b, f) { return function (iterable) { if (Array.isArray(iterable)) { return iterable.reduce(f, b); } let result = b; for (const n of iterable) { result = f(result, n); } return result; }; } /** @internal */ export function map(f) { return function (iterable) { if (Array.isArray(iterable)) { return iterable.map(f); } return function* () { for (const n of iterable) { yield f(n); } }(); }; } //# sourceMappingURL=Iterable.js.map