{"size": 646, "ext": "js", "max_stars_repo_path": "find-formats.js", "max_stars_repo_name": "Sartaglo/challengebot", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "find-formats.js", "max_issues_repo_name": "Sartaglo/challengebot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "find-formats.js", "max_forks_repo_name": "Sartaglo/challengebot", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.3636363636, "max_line_length": 76, "alphanum_fraction": 0.5526315789}
"use strict";

const { findFormat } = require("./find-format");

exports.findFormats = async (formats, channel, division, teamSize) => {
    if (typeof division === "string" && division.length > 0) {
        if (Number.isInteger(teamSize)) {
            return [await findFormat(formats, channel, division, teamSize)];
        }

        return formats.filter(
            (format) => typeof format === "object"
                && format !== null
                && format.division.toUpperCase() === division.toUpperCase(),
        );
    }

    return formats.filter(
        (format) => typeof format === "object" && format !== null,
    );
};
