Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Cosmetic changes and bugfix</strong></p> <p>The regular expression <strong>must</strong> read <code>\bfunction\b</code> to avoid false positives!</p> <p>Functions defined in blocks (e.g. in the bodies of loops) will be ignored if <code>nested</code> does not evaluate to <code>true</code>.</p> <pre><code>function tokenize(code) { var code = code.split(/\\./).join(''), regex = /\bfunction\b|\(|\)|\{|\}|\/\*|\*\/|\/\/|"|'|\n|\s+/mg, tokens = [], pos = 0; for(var matches; matches = regex.exec(code); pos = regex.lastIndex) { var match = matches[0], matchStart = regex.lastIndex - match.length; if(pos &lt; matchStart) tokens.push(code.substring(pos, matchStart)); tokens.push(match); } if(pos &lt; code.length) tokens.push(code.substring(pos)); return tokens; } var separators = { '/*' : '*/', '//' : '\n', '"' : '"', '\'' : '\'' }; function extractInnerFunctionNames(func, nested) { var names = [], tokens = tokenize(func.toString()), level = 0; for(var i = 0; i &lt; tokens.length; ++i) { var token = tokens[i]; switch(token) { case '{': ++level; break; case '}': --level; break; case '/*': case '//': case '"': case '\'': var sep = separators[token]; while(++i &lt; tokens.length &amp;&amp; tokens[i] !== sep); break; case 'function': if(level === 1 || (nested &amp;&amp; level)) { while(++i &lt; tokens.length) { token = tokens[i]; if(token === '(') break; if(/^\s+$/.test(token)) continue; if(token === '/*' || token === '//') { var sep = separators[token]; while(++i &lt; tokens.length &amp;&amp; tokens[i] !== sep); continue; } names.push(token); break; } } break; } } return names; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload