"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.collect_ = exports.collect = void 0;
// ets_tracing: off
const compact_1 = require("../Collections/Immutable/Chunk/api/compact");
const core_1 = require("./core");
const excl_forEach_1 = require("./excl-forEach");
const optional_1 = require("./optional");
/**
 * Evaluate each sync in the structure from left to right, collecting the
 * the successful values and discarding the empty cases. For a parallel version, see `collectPar`.
 *
 * @ets_data_first collect_
 */
function collect(f) {
    return (self) => collect_(self, f);
}
exports.collect = collect;
/**
 * Evaluate each Sync in the structure from left to right, collecting the
 * the successful values and discarding the empty cases. For a parallel version, see `collectPar`.
 */
function collect_(self, f) {
    return (0, core_1.map_)((0, excl_forEach_1.forEach_)(self, (a) => (0, optional_1.optional)(f(a))), compact_1.compact);
}
exports.collect_ = collect_;
//# sourceMappingURL=collect.js.map