(data: any)
| 569 | } |
| 570 | |
| 571 | export function checkPlotData(data: any): boolean { |
| 572 | // data must be an object and not an array |
| 573 | if (typeof data !== "object" || data === null || Array.isArray(data)) { |
| 574 | console.log("checkPlotData: Data is not an object", data); |
| 575 | return false; |
| 576 | } |
| 577 | if (!["title", "data", "type"].every((keyName) => keyName in data)) { |
| 578 | console.log("checkPlotData: Data does not have title, data and type", data); |
| 579 | return false; |
| 580 | } |
| 581 | if ( |
| 582 | !Array.isArray(data.data) || |
| 583 | data.data.some( |
| 584 | (item: any) => |
| 585 | item === null || typeof item !== "object" || Array.isArray(item), |
| 586 | ) |
| 587 | ) { |
| 588 | console.log("checkPlotData: Data.data is not an array of objects", data); |
| 589 | return false; |
| 590 | } |
| 591 | return true; |
| 592 | } |
| 593 | |
| 594 | export function formatPlotData(plotMessage: { |
| 595 | type: "plot"; |
no outgoing calls
no test coverage detected