dist/exceptionless.universal.js
function findSourceByFunctionBody(func) {
        if (_isUndefined(window && window.document)) {
            return;
        }

        var urls = [window.location.href],
            scripts = window.document.getElementsByTagName('script'),
            body,
            code = '' + func,
            codeRE = /^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,
            eventRE = /^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,
            re,
            parts,
            result;

        for (var i = 0; i < scripts.length; ++i) {
            var script = scripts[i];
            if (script.src) {
                urls.push(script.src);
            }
        }

        if (!(parts = codeRE.exec(code))) {
            re = new RegExp(escapeRegExp(code).replace(/\s+/g, '\\s+'));
        }

        // not sure if this is really necessary, but I don’t have a test
        // corpus large enough to confirm that and it was in the original.
        else {
            var name = parts[1] ? '\\s+' + parts[1] : '',
                args = parts[2].split(',').join('\\s*,\\s*');

            body = escapeRegExp(parts[3]).replace(/;$/, ';?'); // semicolon is inserted if the function ends with a comment.replace(/\s+/g, '\\s+');
            re = new RegExp('function' + name + '\\s*\\(\\s*' + args + '\\s*\\)\\s*{\\s*' + body + '\\s*}');
        }

        // look for a normal function definition
        if ((result = findSourceInUrls(re, urls))) {
            return result;
        }

        // look for an old-school event handler function
        if ((parts = eventRE.exec(code))) {
            var event = parts[1];
            body = escapeCodeAsRegExpForMatchingInsideHTML(parts[2]);

            // look for a function defined in HTML as an onXXX handler
            re = new RegExp('on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]', 'i');

            if ((result = findSourceInUrls(re, urls[0]))) {
                return result;
            }

            // look for ???
            re = new RegExp(body);

            if ((result = findSourceInUrls(re, urls))) {
                return result;
            }
        }

        return null;
    }
function findSourceByFunctionBody(func) {
        if (_isUndefined(window && window.document)) {
            return;
        }

        var urls = [window.location.href],
            scripts = window.document.getElementsByTagName('script'),
            body,
            code = '' + func,
            codeRE = /^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,
            eventRE = /^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,
            re,
            parts,
            result;

        for (var i = 0; i < scripts.length; ++i) {
            var script = scripts[i];
            if (script.src) {
                urls.push(script.src);
            }
        }

        if (!(parts = codeRE.exec(code))) {
            re = new RegExp(escapeRegExp(code).replace(/\s+/g, '\\s+'));
        }

        // not sure if this is really necessary, but I don’t have a test
        // corpus large enough to confirm that and it was in the original.
        else {
            var name = parts[1] ? '\\s+' + parts[1] : '',
                args = parts[2].split(',').join('\\s*,\\s*');

            body = escapeRegExp(parts[3]).replace(/;$/, ';?'); // semicolon is inserted if the function ends with a comment.replace(/\s+/g, '\\s+');
            re = new RegExp('function' + name + '\\s*\\(\\s*' + args + '\\s*\\)\\s*{\\s*' + body + '\\s*}');
        }

        // look for a normal function definition
        if ((result = findSourceInUrls(re, urls))) {
            return result;
        }

        // look for an old-school event handler function
        if ((parts = eventRE.exec(code))) {
            var event = parts[1];
            body = escapeCodeAsRegExpForMatchingInsideHTML(parts[2]);

            // look for a function defined in HTML as an onXXX handler
            re = new RegExp('on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]', 'i');

            if ((result = findSourceInUrls(re, urls[0]))) {
                return result;
            }

            // look for ???
            re = new RegExp(body);

            if ((result = findSourceInUrls(re, urls))) {
                return result;
            }
        }

        return null;
    }
function findSourceByFunctionBody ( func ) { if ( _isUndefined ( window && window . document ) ) { return ; } var urls = [ window . location . href ] , scripts = window . document . getElementsByTagName ( 'script' ) , body , code = '' + func , codeRE = / ^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$ / , eventRE = / ^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$ / , re , parts , result ; for ( var i = 0 ; i < scripts . length ; ++ i ) { var script = scripts [ i ] ; if ( script . src ) { urls . push ( script . src ) ; } } if ( ! ( parts = codeRE . exec ( code ) ) ) { re = new RegExp ( escapeRegExp ( code ) . replace ( / \s+ / g , '\\s+' ) ) ; } // not sure if this is really necessary, but I don’t have a test // corpus large enough to confirm that and it was in the original. else { var name = parts [ 1 ] ? '\\s+' + parts [ 1 ] : '' , args = parts [ 2 ] . split ( ',' ) . join ( '\\s*,\\s*' ) ; body = escapeRegExp ( parts [ 3 ] ) . replace ( / ;$ / , ';?' ) ; // semicolon is inserted if the function ends with a comment.replace(/\s+/g, '\\s+'); re = new RegExp ( 'function' + name + '\\s*\\(\\s*' + args + '\\s*\\)\\s*{\\s*' + body + '\\s*}' ) ; } // look for a normal function definition if ( ( result = findSourceInUrls ( re , urls ) ) ) { return result ; } // look for an old-school event handler function if ( ( parts = eventRE . exec ( code ) ) ) { var event = parts [ 1 ] ; body = escapeCodeAsRegExpForMatchingInsideHTML ( parts [ 2 ] ) ; // look for a function defined in HTML as an onXXX handler re = new RegExp ( 'on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]' , 'i' ) ; if ( ( result = findSourceInUrls ( re , urls [ 0 ] ) ) ) { return result ; } // look for ??? re = new RegExp ( body ) ; if ( ( result = findSourceInUrls ( re , urls ) ) ) { return result ; } } return null ; }
Determines where a function was defined within the source code.
@param {(Function|string)} func A function reference or serialized
function definition.
@return {?Object.<string, (string|number)>} An object containing
the url, line, and column number of the defined function.
@memberof TraceKit.computeStackTrace
Determines where a function was defined within the source code .