diff options
author | Yash Ladha <yashladhapankajladha123@gmail.com> | 2021-03-16 19:45:02 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2021-04-30 23:28:27 +0300 |
commit | 93f0b4d35bf72a1119b8a5bfea932b85faa1a4a6 (patch) | |
tree | b50d379518b06a75ddaef611d347e17a1b9fe02e /test | |
parent | 5bfb6f0564403093c03c30112763e5fa1bb24df5 (diff) |
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-tojson-perf_hooks.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/parallel/test-tojson-perf_hooks.js b/test/parallel/test-tojson-perf_hooks.js new file mode 100644 index 00000000000..2a716fc4478 --- /dev/null +++ b/test/parallel/test-tojson-perf_hooks.js @@ -0,0 +1,14 @@ +'use strict'; + +require('../common'); +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'); +} |