Bläddra i källkod

use utils.inspect.custom Rready for node v12

d98762625 7 år sedan
förälder
incheckning
20bb104006
2 ändrade filer med 11 tillägg och 2 borttagningar
  1. 9 0
      src/node/SyncDish.mjs
  2. 2 2
      src/node/api.mjs

+ 9 - 0
src/node/SyncDish.mjs

@@ -4,6 +4,7 @@
  * @license Apache-2.0
  * @license Apache-2.0
  */
  */
 
 
+import util from "util";
 import Utils from "../core/Utils";
 import Utils from "../core/Utils";
 import Dish from "../core/Dish";
 import Dish from "../core/Dish";
 import BigNumber from "bignumber.js";
 import BigNumber from "bignumber.js";
@@ -48,6 +49,14 @@ class SyncDish extends Dish {
     }
     }
 
 
     /**
     /**
+     * What we want to log to the console.
+     */
+    [util.inspect.custom](depth, options) {
+        return this.get(Dish.typeEnum("string"));
+    }
+
+    /**
+     * Backwards compatibility for node v6
      * Log only the value to the console in node.
      * Log only the value to the console in node.
      */
      */
     inspect() {
     inspect() {

+ 2 - 2
src/node/api.mjs

@@ -94,7 +94,7 @@ function transformArgs(originalArgs, newArgs) {
  * Ensure an input is a SyncDish object.
  * Ensure an input is a SyncDish object.
  * @param input
  * @param input
  */
  */
-const ensureIsDish = function ensureIsDish(input) {
+function ensureIsDish(input) {
     if (!input) {
     if (!input) {
         return new SyncDish();
         return new SyncDish();
     }
     }
@@ -116,7 +116,7 @@ const ensureIsDish = function ensureIsDish(input) {
  * @param input - operation input
  * @param input - operation input
  * @param args - operation args
  * @param args - operation args
  */
  */
-const prepareOp = function prepareOp(opInstance, input, args) {
+function prepareOp(opInstance, input, args) {
     const dish = ensureIsDish(input);
     const dish = ensureIsDish(input);
     let transformedArgs;
     let transformedArgs;
     // Transform object-style args to original args array
     // Transform object-style args to original args array