import { deepFreeze, isFiniteNumber } from "../../utils"; import { CyclingPowerCapabilities } from "./cyclingPower.js"; export class Control { constructor({ supportsERG = false, controlCharacteristic, maxPowerWatts, minPowerWatts, ergRampRateWattsPerSec, cyclingPower, } = {}) { this.supportsERG = Boolean(supportsERG); this.controlCharacteristic = controlCharacteristic; this.maxPowerWatts = isFiniteNumber(maxPowerWatts) ? Number(maxPowerWatts) : undefined; this.minPowerWatts = isFiniteNumber(minPowerWatts) ? Number(minPowerWatts) : undefined; this.ergRampRateWattsPerSec = isFiniteNumber(ergRampRateWattsPerSec) ? Number(ergRampRateWattsPerSec) : undefined; this.cyclingPower = cyclingPower instanceof CyclingPowerCapabilities ? cyclingPower : cyclingPower ? new CyclingPowerCapabilities(cyclingPower) : undefined; deepFreeze(this); } merge = (partial) => new Control(Object.assign({}, this, partial)); }