UNPKG

andrade-soulseek-downloader

Version:

Simple, safe Soulseek download library with built-in rate limiting to prevent bans

74 lines 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Bitrate = void 0; /** * Value object representing audio bitrate in kbps. * Provides quality classification and scoring logic. */ class Bitrate { value; /** * @param value - Bitrate in kbps (0-9999) * @throws {Error} If value is out of range */ constructor(value) { if (value < 0 || value > 9999) { throw new Error('Invalid bitrate value'); } this.value = value; } /** @returns Bitrate value in kbps */ getValue() { return this.value; } /** * Classifies bitrate into quality tiers. * @returns Quality level based on bitrate value */ getQualityLevel() { if (this.value > 1000) return 'LOSSLESS'; // FLAC, WAV if (this.value >= 320) return 'HIGH'; if (this.value >= 256) return 'MEDIUM'; return 'LOW'; } /** * Converts bitrate to quality score points. * @returns Points from 0-50 for quality scoring */ toQualityPoints() { if (this.value > 1000) return 50; // Lossless gets max points return Math.min(50, (this.value / 320) * 50); } /** @returns True if bitrate is 320kbps or higher */ isHighQuality() { return this.value >= 320; } /** @returns True if bitrate indicates lossless audio (>1000kbps) */ isLossless() { return this.value > 1000; } /** * @param other - Bitrate to compare with * @returns True if bitrates are equal */ equals(other) { return this.value === other.value; } /** * @param other - Bitrate to compare with * @returns True if this bitrate is higher */ isHigherThan(other) { return this.value > other.value; } /** @returns Human-readable bitrate string */ toString() { return `${this.value}kbps`; } } exports.Bitrate = Bitrate; //# sourceMappingURL=bitrate.js.map