UNPKG

@felixgeelhaar/govee-api-client

Version:

Enterprise-grade TypeScript client library for the Govee Developer REST API

48 lines 1.25 kB
export class ColorTemperature { constructor(kelvin) { this.validateKelvin(kelvin); this._kelvin = Math.round(kelvin); } validateKelvin(value) { if (!Number.isFinite(value)) { throw new Error('Color temperature must be a finite number'); } if (value < 1000 || value > 50000) { throw new Error(`Color temperature must be between 1000K and 50000K, got ${value}K`); } } get kelvin() { return this._kelvin; } equals(other) { return this._kelvin === other._kelvin; } toString() { return `${this._kelvin}K`; } toObject() { return { kelvin: this._kelvin }; } static fromObject(obj) { return new ColorTemperature(obj.kelvin); } static warmWhite() { return new ColorTemperature(2700); } static coolWhite() { return new ColorTemperature(6500); } static daylight() { return new ColorTemperature(5600); } isWarm() { return this._kelvin < 3500; } isCool() { return this._kelvin > 5000; } isNeutral() { return this._kelvin >= 3500 && this._kelvin <= 5000; } } //# sourceMappingURL=ColorTemperature.js.map