When you create a timer in Node, you get the following object back:
Timeout {
_called: false,
_idleTimeout: 500,
_idlePrev: [TimersList],
_idleNext: [TimersList],
_idleStart: 34,
_onTimeout: [Function],
_timerArgs: undefined,
_repeat: null,
_destroyed: false,
[Symbol(unrefed)]: false,
[Symbol(asyncId)]: 5,
[Symbol(triggerId)]: 1 }
The actual numeric id of this timeout object is contained under the [Symbol(asyncId)] field. My problem is, how can I get a reference to this symbol in a non-hackish way? The only way I currently know of that will give me this object is Object.getOwnPropertySymbols(), but using a hardcoded index seems fragile as f:
$ node -p 't=setTimeout(()=>{}, 500); triggerSym=Object.getOwnPropertySymbols(t)[2];t[asyncId]'
67
Is there a less fragile way I can get a reference to this symbol to use for lookup?