core/utils.js
function countBrackets(str) {
    var lex = getLexer(str);
    var brackets = 0;
    var tok = lex.next();
    while (tok!==undefined) {
      if (tok.str=="(" || tok.str=="{" || tok.str=="[") brackets++;
      if (tok.str==")" || tok.str=="}" || tok.str=="]") brackets--;
      tok = lex.next();
    }
    return brackets;
  }
function countBrackets(str) {
    var lex = getLexer(str);
    var brackets = 0;
    var tok = lex.next();
    while (tok!==undefined) {
      if (tok.str=="(" || tok.str=="{" || tok.str=="[") brackets++;
      if (tok.str==")" || tok.str=="}" || tok.str=="]") brackets--;
      tok = lex.next();
    }
    return brackets;
  }
function countBrackets ( str ) { var lex = getLexer ( str ) ; var brackets = 0 ; var tok = lex . next ( ) ; while ( tok !== undefined ) { if ( tok . str == "(" || tok . str == "{" || tok . str == "[" ) brackets ++ ; if ( tok . str == ")" || tok . str == "}" || tok . str == "]" ) brackets -- ; tok = lex . next ( ) ; } return brackets ; }
Count brackets in a string - will be 0 if all are closed
Count brackets in a string - will be 0 if all are closed