"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.partitionParN_ = exports.partitionParN = exports.partitionPar_ = exports.partitionPar = exports.partition_ = exports.partition = void 0;
// ets_tracing: off
const Function_1 = require("../Function");
const I = __importStar(require("../Iterable"));
const either_1 = require("./either");
const excl_forEach_1 = require("./excl-forEach");
const map_1 = require("./map");
/**
 * Feeds elements of type `A` to a function `f` that returns an effect.
 * Collects all successes and failures in a separated fashion.
 *
 * @ets_data_first partition_
 */
function partition(f, __trace) {
    return (as) => partition_(as, f, __trace);
}
exports.partition = partition;
/**
 * Feeds elements of type `A` to a function `f` that returns an effect.
 * Collects all successes and failures in a separated fashion.
 */
function partition_(as, f, __trace) {
    return (0, map_1.map_)((0, excl_forEach_1.forEach_)(as, (a) => (0, either_1.either)(f(a)), __trace), I.partitionMap(Function_1.identity));
}
exports.partition_ = partition_;
/**
 * Feeds elements of type `A` to a function `f` that returns an effect.
 * Collects all successes and failures in parallel and returns the result as
 * a tuple.
 *
 * @ets_data_first partitionPar_
 */
function partitionPar(f, __trace) {
    return (as) => partitionPar_(as, f, __trace);
}
exports.partitionPar = partitionPar;
/**
 * Feeds elements of type `A` to a function `f` that returns an effect.
 * Collects all successes and failures in parallel and returns the result as
 * a tuple.
 */
function partitionPar_(as, f, __trace) {
    return (0, map_1.map_)((0, excl_forEach_1.forEachPar_)(as, (a) => (0, either_1.either)(f(a)), __trace), I.partitionMap(Function_1.identity));
}
exports.partitionPar_ = partitionPar_;
/**
 * Feeds elements of type `A` to a function `f` that returns an effect.
 * Collects all successes and failures in parallel and returns the result as
 * a tuple.
 *
 * Unlike `partitionPar`, this method will use at most up to `n` fibers.
 *
 * @ets_data_first partitionParN_
 */
function partitionParN(n, f, __trace) {
    return (as) => partitionParN_(as, n, f, __trace);
}
exports.partitionParN = partitionParN;
/**
 * Feeds elements of type `A` to a function `f` that returns an effect.
 * Collects all successes and failures in parallel and returns the result as
 * a tuple.
 *
 * Unlike `partitionPar`, this method will use at most up to `n` fibers.
 */
function partitionParN_(as, n, f, __trace) {
    return (0, map_1.map_)((0, excl_forEach_1.forEachParN_)(as, n, (a) => (0, either_1.either)(f(a)), __trace), I.partitionMap(Function_1.identity));
}
exports.partitionParN_ = partitionParN_;
//# sourceMappingURL=partition.js.map