{"size": 761, "ext": "js", "max_stars_repo_path": "src/index.js", "max_stars_repo_name": "nikita-reshetniak/brackets", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/index.js", "max_issues_repo_name": "nikita-reshetniak/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": "nikita-reshetniak/brackets", "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": 24.5483870968, "max_line_length": 80, "alphanum_fraction": 0.5505913272}
module.exports = function check(str, bracketsConfig) {
  const opens = bracketsConfig.map(x => x[0]);
  const closes = bracketsConfig.map(x => x[1]);
  
  let equals = {};
  bracketsConfig.forEach(element => {
    if (element[0] == element[1]) {
      equals[element[0]] = 0;
    }
  });

  let stack = [];
  for (let i = 0; i < str.length; i++) {
    let char = str[i];
    if (equals.hasOwnProperty(char)) {
      equals[char] += i % 2 == 0 ?  1 : -1;
    } else if (opens.includes(char)) {
      stack.push(char);
    } else if (opens.indexOf(stack[stack.length - 1]) == closes.indexOf(char)) {
      stack.pop();
    } else {
      return false;
    }
  }
  
  for (key in equals) {
    if (equals[key] != 0) return false;
  }

  return stack.length == 0;
}