在同一执行点探测多个表达式


🌐 Probing multiple expressions at the same execution point

当多个 --probe/--expr 对共享相同的 --probe 时,这些表达式将在命令行中出现的顺序在同一次暂停上进行评估。

🌐 When multiple --probe/--expr pairs share the same --probe, the expressions will be evaluated on the same pause in the order they appear on the command line.

// app.js
const x = { x: 42 };       // line 2
const y = { y: 35 };       // line 3
const z = { ...x, ...y };  // line 4 
$ node inspect --probe app.js:4 --expr 'x' --probe app.js:4 --expr 'y' -- app.js 

打印

🌐 Prints

Hit 1 at file:///path/to/app.js:4:1
  x = {x: 42}
Hit 1 at file:///path/to/app.js:4:1
  y = {y: 35}
Completed 
$ node inspect --probe app.js:4 --expr 'x' --probe app.js:4 --expr 'y' --json --preview -- app.js 

打印

🌐 Prints

{"v":2,"probes":[{"expr":"x","target":{"suffix":"app.js","line":4}},{"expr":"y","target":{"suffix":"app.js","line":4}}],"results":[{"probe":0,"event":"hit","hit":1,"location":{"url":"file:///path/to/app.js","line":4,"column":1},"result":{"type":"object","description":"Object","preview":{"type":"object","description":"Object","overflow":false,"properties":[{"name":"x","type":"number","value":"42"}]}}},{"probe":1,"event":"hit","hit":1,"location":{"url":"file:///path/to/app.js","line":4,"column":1},"result":{"type":"object","description":"Object","preview":{"type":"object","description":"Object","overflow":false,"properties":[{"name":"y","type":"number","value":"35"}]}}},{"event":"completed"}]}