author : Austin Ruby
 *  function changelog changelog module . exports = function parseQuery ( input ) { let queryString = '' ; let passedQueryString = '' ; let closer = false ; let openParensCount = 0 ; let closeParensCount = 0 ; let index = 0 ; const stack = [ ] ; while ( index < input . length ) { if ( input [ index ] === '(' ) { openParensCount += 1 ; stack . push ( input [ index ] ) ; } else if ( input [ index ] === ')' ) { if ( stack . length === 0 ) { return 'unbalanced parens by closed' ; } closeParensCount += 1 ; stack . pop ( ) ; } queryString += input [ index ] ; if ( stack . length === 0 && closer === false ) { passedQueryString = queryString ; closer = true ; } index += 1 ; } return openParensCount === closeParensCount ? passedQueryString : 'unbalanced parens' ; } ;