function callback(records) {
const record = records[records.length - 1];
const json = record.toJSON();
console.log(json); // A plain object
console.log(typeof json); // "object"
console.log(json.state); // Same value as record.state
}
try {
const observer = new PressureObserver(callback);
await observer.observe("cpu", {
sampleInterval: 1000, // 1000ms
});
} catch (error) {
// report error setting up the observer
}PressureRecord: toJSON() method / notebook
PressureRecord: toJSON() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
console.log(JSON.stringify(record));