How to use the @truffle/debug-utils.formatValue function in @truffle/debug-utils

To help you get started, we’ve selected a few @truffle/debug-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trufflesuite / truffle / packages / core / lib / debug / printer.js View on Github external
// produces really weird output when there are errors. e.g.,
      //
      //   evalmachine.:1
      //   SAFE_EVAL_857712=a
      //   ^
      //
      //   ReferenceError: a is not defined
      //     at evalmachine.:1:1
      //     at ContextifyScript.Script.runInContext (vm.js:59:29)
      //
      // We want to hide this from the user if there's an error.
      e.stack = e.stack.replace(/SAFE_EVAL_\d+=/, "");
      if (!suppress) {
        this.config.logger.log(e);
      } else {
        this.config.logger.log(DebugUtils.formatValue(undefined, indent, true));
      }
    }
  }
}
github trufflesuite / truffle / packages / core / lib / debug / printer.js View on Github external
// converts all !<...> expressions to JS-valid selector requests
    const preprocessSelectors = expr => {
      const regex = /!<([^>]+)>/g;
      const select = "$"; // expect repl context to have this func
      const replacer = (_, selector) => `${select}("${selector}")`;

      return expr.replace(regex, replacer);
    };

    //if we're just dealing with a single variable, handle that case
    //separately (so that we can do things in a better way for that
    //case)
    let variable = raw.trim();
    if (variable in variables) {
      let formatted = DebugUtils.formatValue(variables[variable], indent);
      this.config.logger.log(formatted);
      this.config.logger.log();
      return;
    }

    //HACK
    //if we're not in the single-variable case, we'll need to do some
    //things to Javascriptify our variables so that the JS syntax for
    //using them is closer to the Solidity syntax
    variables = Codec.Format.Utils.Inspect.nativizeVariables(variables);

    let context = Object.assign(
      { $: this.select },

      variables
    );
github trufflesuite / truffle / packages / core / lib / debug / printer.js View on Github external
new RegExp("(?:1
      //   SAFE_EVAL_857712=a
      //   ^
      //
      //   ReferenceError: a is not defined
      //     at evalmachine.:1:1
      //     at ContextifyScript.Script.runInContext (vm.js:59:29)
      //
      // We want to hide this from the user if there's an error.
      e.stack = e.stack.replace(/SAFE_EVAL_\d+=/, "");
github trufflesuite / truffle / packages / core / lib / debug / printer.js View on Github external
Object.keys(variables).forEach(name => {
      let paddedName = name + ":";

      while (paddedName.length <= longestNameLength) {
        paddedName = " " + paddedName;
      }

      const value = variables[name];
      const formatted = DebugUtils.formatValue(value, longestNameLength + 5);

      this.config.logger.log("  " + paddedName, formatted);
    });