How to use the util.inspect function in util

To help you get started, we’ve selected a few util 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 googleapis / cloud-debug-nodejs / test / misc / test-leak.ts View on Github external
function test() {
  iters++;

  const bp = {id: 'fake-breakpoint', location: {path: __filename, line: 4}};
  v8debugapi.set(bp);
  v8debugapi.clear(bp);

  if (iters % 100 === 0) {
    console.log(iters + ' ' + util.inspect(process.memoryUsage()));
  }

  // infinite loop
  setImmediate(test);
}
github apigee / trireme / node12 / node12tests / trireme / test-util-inspect.js View on Github external
assert(/TypeError: FAIL/.test(util.inspect(new TypeError('FAIL'))));
assert(/SyntaxError: FAIL/.test(util.inspect(new SyntaxError('FAIL'))));
try {
  undef();
} catch (e) {
  assert(/ReferenceError.*undef/.test(util.inspect(e)));
}
var ex = util.inspect(new Error('FAIL'), true);
assert.ok(ex.indexOf('[Error: FAIL]') != -1);
// Rhino doesn't put stack on Error constructor yet
//assert.ok(ex.indexOf('[stack]') != -1);
//assert.ok(ex.indexOf('[message]') != -1);

// GH-1941
// should not throw:
assert.equal(util.inspect(Object.create(Date.prototype)), '{}');

// GH-1944
assert.doesNotThrow(function() {
  var d = new Date();
  d.toUTCString = null;
  util.inspect(d);
});

assert.doesNotThrow(function() {
  var r = /regexp/;
  r.toString = null;
  util.inspect(r);
});

// bug with user-supplied inspect function returns non-string
assert.doesNotThrow(function() {
github asgerf / tscheck / tscore.js View on Github external
return {
            file: file,
            text: fs.readFileSync(file, 'utf8')
        }
    })
    if (program.lib) {
        inputs.unshift({
            file: ">lib.d.ts",
            text: fs.readFileSync(__dirname + '/lib/lib.d.ts', 'utf8')
        })
    }
    var json = convert(inputs)
    if (program.silent)
        {}
    else if (program.pretty)
        console.log(util.inspect(json, {depth:null}))
    else
        console.log(JSON.stringify(json))
}
github ethers-io / ethers.js / packages / cli / src.ts / bin / ethers.ts View on Github external
if (output instanceof Promise) {
                repl.context._p = output;
                let promiseId = nextPromiseId++;
                output.then((result) => {
                    console.log(`\n`);
                    console.log(util.inspect(result));
                    repl.context._r = result;
                    repl.displayPrompt(true)
                }, (error) => {
                    console.log(`\n`);
                    console.log(util.inspect(error));
                    repl.displayPrompt(true)
                });
                return ``;
            }
            return util.inspect(output);
        }
github baryon / tracer / lib / utils.js View on Github external
return JSON.stringify(args[i++]);
        		    }
			} catch(e) {
				return '[Circular]';
			}
		case '%t':
			return util.inspect(args[i++], inspectOpt);
		default:
			return x;
		}
	});
	for ( var len = args.length, x = args[i]; i < len; x = args[++i]) {
		if (x === null || typeof x !== 'object') {
			str += ' ' + x;
		} else {
			str += ' ' + util.inspect(x, inspectOpt);
		}
	}
	return str;
};
github gudwin / botbuilder-unit / src / log-reporters / PlainLogReporter.js View on Github external
PlainLogReporter.prototype.normizalizeForOutput = function (message) {
  return "string" == typeof message ? message : util.inspect(message, {depth: 4, color: false, showHidden: true});
}
github daisukeArk / alexa-conversation-model-assert / src / lib / conversation / conversation-factory.ts View on Github external
.then(async (previousEnvelope: AskModel.ResponseEnvelope): Promise => {
            if (condition.isEnabledTrace) {
              Logger.trace(`\npreviousEnvelope:\n${Util.inspect(previousEnvelope, { depth: null })}`);
            }

            const request = requestBuilder.build(intentName, conditionRequest, previousEnvelope);

            if (condition.isEnabledTrace) {
              Logger.trace(`\nrequest:\n${Util.inspect(request, { depth: null })}`);
            }

            const envelope = await RunHandler.runAsync(condition.handler, request);

            if (condition.isEnabledTrace) {
              Logger.trace(`\nenvelope: \n${Util.inspect(envelope, { depth: null })}`);
            }

            Object.assign(scenarios[currentIndex], { intentName, envelope });
            return envelope;
github Lemmmy / rocketchat-irc-gateway / src / server / packets / part.packet.js View on Github external
async function onPartCommand(conn, params, prefix) {
  let channel = params[0];

  try {
    await conn.rocketchat.leaveRoom(channel);
  } catch (e) {
    log.error(e.stack || util.inspect(e, {
      colors: true,
      depth: null
    }));
  }
}