andrade-soulseek-downloader
Version:
Simple, safe Soulseek download library with built-in rate limiting to prevent bans
47 lines • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TrackId = void 0;
/**
* Value object representing a unique track identifier.
* Immutable and self-validating.
*/
class TrackId {
value;
/**
* @param value - The unique identifier string
* @throws {Error} If value is empty or invalid
*/
constructor(value) {
if (!value || value.trim().length === 0) {
throw new Error('TrackId cannot be empty');
}
this.value = value;
}
/**
* Factory method to generate ID from user and file path.
* @param user - Soulseek username
* @param filePath - Path to the file
* @returns New TrackId instance
*/
static generate(user, filePath) {
return new TrackId(`${user}:${filePath}`);
}
/** @returns The underlying string value */
getValue() {
return this.value;
}
/**
* Value equality comparison.
* @param other - TrackId to compare with
* @returns True if values are equal
*/
equals(other) {
return this.value === other.value;
}
/** @returns String representation of the ID */
toString() {
return this.value;
}
}
exports.TrackId = TrackId;
//# sourceMappingURL=track-id.js.map