Skip to content

util: add inspectTag template literal tag

Rodrigo Muino Tomonari requested to merge github/fork/jasnell/inspect-tag into master

Introduces a simple template literal tag that ensures that each constituent part of the template literal passes through util.inspect() using the default options.

This is inspired by recent changes in tests that have tried to convert console.log('message', a, b) to something like:

`message ${a} ${b}`
const inspectTag = require('util').inspectTag;
const m = {a: 1};

console.log(`${m}`);
// Prints: '[object Object]'

console.log(inspectTag`${m}`);
// Prints: '{ a : 1 }'
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

util

Merge request reports

Loading