{"size": 1668, "ext": "js", "max_stars_repo_path": "src/index.js", "max_stars_repo_name": "KSGitUser/brackets", "max_stars_repo_stars_event_min_datetime": "2021-03-15T19:08:39.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-15T19:08:39.000Z", "max_issues_repo_path": "src/index.js", "max_issues_repo_name": "KSGitUser/brackets", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/index.js", "max_forks_repo_name": "KSGitUser/brackets", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.8888888889, "max_line_length": 84, "alphanum_fraction": 0.3806954436}
module.exports = function check(str, bracketsConfig) {
    let result = [];
    const equalBrackets = [];
    if (str.length % 2 !== 0) {
        return false;
    }
    str.split('').map(char => {
        bracketsConfig.map(brArrow => {
            if (brArrow[0] === char) {
                if (brArrow[0] === brArrow[1]) {
                    if (!equalBrackets.includes(brArrow[0])) {
                        equalBrackets.push(brArrow[0]);
                    }
                    if (result.length && result[result.length - 1] === brArrow[0]) {
                        result.pop();
                        return;
                    }
                    result.push(char);
                    return;
                }
                result.push(char);
                return;
            } else {
                if (brArrow[1] === char) {
                    try {
                        if (brArrow[0] === result[result.length - 1]) {
                            result.pop();
                        }
                    } catch (e) {
                        return false;
                    }
                }
            }
        })
    });

    let finallResult = [];

    if (result.length && equalBrackets.length) {
        for (let index = 0; index < result.length; index++) {
            let item = result[index];
            if ([...result.slice(index + 1)].includes(item)) {
                return false;
            }
            if (!equalBrackets.includes(item)) {
                finallResult.push(item);
            }
        }
        result = [];
    }

    return result.length === 0 && finallResult.length === 0 ? true : false;
}
