-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: 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: #37623
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const { performance } = require('perf_hooks'); | ||
|
||
// Test toJSON for performance object | ||
{ | ||
assert.strictEqual(typeof performance.toJSON, 'function'); | ||
const jsonObject = performance.toJSON(); | ||
assert.strictEqual(typeof jsonObject, 'object'); | ||
assert.strictEqual(jsonObject.timeOrigin, performance.timeOrigin); | ||
assert.strictEqual(typeof jsonObject.nodeTiming, 'object'); | ||
} |