UNPKG

askui

Version:

Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on

17 lines (16 loc) 733 B
import { ControlCommand } from '../ui-control-commands/control-command'; import { Annotation } from '../annotation/annotation'; import { InvalidModelTypeError } from './invalid-model-type-error'; export class InferenceResponse { static fromJson(json, resizeRatio = 1, image) { return this.createModels(json.type, json.data, resizeRatio, image); } static createModels(type, data, resizeRatio, image) { if (type === 'COMMANDS') return ControlCommand.fromJson(data, resizeRatio); if (type === 'DETECTED_ELEMENTS') { return Annotation.fromJson({ image, detected_elements: data.detected_elements }, resizeRatio); } throw new InvalidModelTypeError(type); } }