mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
perf_hooks: add toJSON to performance class
Added toJSON method to the InternalPerformance class as per the convention followed in other performance classes and per the spec: https://www.w3.org/TR/hr-time/#tojson-method Fixes: https://github.com/nodejs/node/issues/37623 PR-URL: https://github.com/nodejs/node/pull/37771 Fixes: https://github.com/nodejs/node/issues/37623 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
5bfb6f0564
commit
93f0b4d35b
3 changed files with 37 additions and 0 deletions
|
@ -59,6 +59,15 @@ class Performance extends EventTarget {
|
|||
timeOrigin: this.timeOrigin,
|
||||
}, opts)}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function toJSON() {
|
||||
return {
|
||||
nodeTiming: this.nodeTiming,
|
||||
timeOrigin: this.timeOrigin,
|
||||
eventLoopUtilization: this.eventLoopUtilization()
|
||||
};
|
||||
}
|
||||
|
||||
class InternalPerformance extends EventTarget {}
|
||||
|
@ -105,6 +114,11 @@ ObjectDefineProperties(Performance.prototype, {
|
|||
configurable: true,
|
||||
enumerable: true,
|
||||
value: timeOriginTimestamp,
|
||||
},
|
||||
toJSON: {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
value: toJSON,
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue