lib/error-parsing-utils.js
function extractStructuredCallList(structuredStackTrace) {

  /**
   * A function which walks the structuredStackTrace variable of its parent
   * and produces a JSON representation of the array of CallSites.
   * @function
   * @inner
   * @returns {String} - A JSON representation of the array of CallSites
   */

  return function() {
    var structuredCallList = [];
    var index = 0;

    if (!Array.isArray(structuredStackTrace)) {

      return JSON.stringify(structuredCallList);
    }

    for (index; index < structuredStackTrace.length; index += 1) {

      structuredCallList.push({
        functionName : structuredStackTrace[index].getFunctionName(),
        methodName : structuredStackTrace[index].getMethodName(),
        fileName : structuredStackTrace[index].getFileName(),
        lineNumber : structuredStackTrace[index].getLineNumber(),
        columnNumber : structuredStackTrace[index].getColumnNumber()
      });
    }

    return JSON.stringify(structuredCallList);
  };
}
function extractStructuredCallList(structuredStackTrace) {

  /**
   * A function which walks the structuredStackTrace variable of its parent
   * and produces a JSON representation of the array of CallSites.
   * @function
   * @inner
   * @returns {String} - A JSON representation of the array of CallSites
   */

  return function() {
    var structuredCallList = [];
    var index = 0;

    if (!Array.isArray(structuredStackTrace)) {

      return JSON.stringify(structuredCallList);
    }

    for (index; index < structuredStackTrace.length; index += 1) {

      structuredCallList.push({
        functionName : structuredStackTrace[index].getFunctionName(),
        methodName : structuredStackTrace[index].getMethodName(),
        fileName : structuredStackTrace[index].getFileName(),
        lineNumber : structuredStackTrace[index].getLineNumber(),
        columnNumber : structuredStackTrace[index].getColumnNumber()
      });
    }

    return JSON.stringify(structuredCallList);
  };
}
function extractStructuredCallList ( structuredStackTrace ) { /**
   * A function which walks the structuredStackTrace variable of its parent
   * and produces a JSON representation of the array of CallSites.
   * @function
   * @inner
   * @returns {String} - A JSON representation of the array of CallSites
   */ return function ( ) { var structuredCallList = [ ] ; var index = 0 ; if ( ! Array . isArray ( structuredStackTrace ) ) { return JSON . stringify ( structuredCallList ) ; } for ( index ; index < structuredStackTrace . length ; index += 1 ) { structuredCallList . push ( { functionName : structuredStackTrace [ index ] . getFunctionName ( ) , methodName : structuredStackTrace [ index ] . getMethodName ( ) , fileName : structuredStackTrace [ index ] . getFileName ( ) , lineNumber : structuredStackTrace [ index ] . getLineNumber ( ) , columnNumber : structuredStackTrace [ index ] . getColumnNumber ( ) } ) ; } return JSON . stringify ( structuredCallList ) ; } ; }
A function which returns a closure which itself creates a JSON representation
of an array of callSites generated by an Error stack trace. Since many errors
may be created and only some requiring a string-ification of the entire
callsite list it advantageous from a performance perspective to evaluate
this string-ification when only actually necessary and not per error
generated. When calling the enclosing function an array of CallSites must
be supplied othwise an empty JSON array will be returned.
@function extractStructuredCallList
@param {Array<CallSite>} structuredStackTrace - an array of CallSite objects
@returns {Function} - a closure which produces a JSON representation of an
array of CallSites
A function which returns a closure which itself creates a JSON representation of an array of callSites generated by an Error stack trace . Since many errors may be created and only some requiring a string - ification of the entire callsite list it advantageous from a performance perspective to evaluate this string - ification when only actually necessary and not per error generated . When calling the enclosing function an array of CallSites must be supplied othwise an empty JSON array will be returned .