src/test/traces/save-download-trace.js
/** Defines a bunch of callbacks to write a websocket to a file.
 * @param {string} filename The name of the file to save the jsonl to
 * @param {bool} verbose Whether to print debug output
 * @return {object} an object containing callback functions
 */
Defines a bunch of callbacks to write a websocket to a file.
@param {string} filename The name of the file to save the jsonl to
@param {bool} verbose Whether to print debug output
@return {object} an object containing callback functions
Defines a bunch of callbacks to write a websocket to a file . @param { string } filename The name of the file to save the jsonl to @param { bool } verbose Whether to print debug output @return { object } an object containing callback functions
function traceSaver(filename, verbose) {
  let f;
  const measurement = function(msg) {
    if (msg instanceof Buffer) {
      return;
    }
    if (verbose) {
      if (msg.length > 40) {
        console.log(msg.substring(0, 40) + '...');
      } else {
        console.log(msg);
      }
    }
    f.write(msg);
  };
  const start = function(msg) {
    f = fs.createWriteStream(filename);
  };
  const complete = function(msg) {
    f.end();
    f = undefined;
  };
  return {
    start: start,
    measurement: measurement,
    complete: complete,
  };
}
function traceSaver ( filename , verbose ) { let f ; const measurement = function ( msg ) { if ( msg instanceof Buffer ) { return ; } if ( verbose ) { if ( msg . length > 40 ) { console . log ( msg . substring ( 0 , 40 ) + '...' ) ; } else { console . log ( msg ) ; } } f . write ( msg ) ; } ; const start = function ( msg ) { f = fs . createWriteStream ( filename ) ; } ; const complete = function ( msg ) { f . end ( ) ; f = undefined ; } ; return { start : start , measurement : measurement , complete : complete , } ; }
Defines a bunch of callbacks to write a websocket to a file.
Defines a bunch of callbacks to write a websocket to a file .