dist/lib/browser.js
/**
     * Scans for AppleTVs on the local network.
     * @param uniqueIdentifier  An optional identifier for the AppleTV to scan for. The AppleTV advertises this via Bonjour.
     * @param timeout  An optional timeout value (in seconds) to give up the search after.
     * @returns A promise that resolves to an array of AppleTV objects. If you provide a `uniqueIdentifier` the array is guaranteed to only contain one object.
     */
Scans for AppleTVs on the local network.
@param uniqueIdentifier  An optional identifier for the AppleTV to scan for. The AppleTV advertises this via Bonjour.
@param timeout  An optional timeout value (in seconds) to give up the search after.
@returns A promise that resolves to an array of AppleTV objects. If you provide a `uniqueIdentifier` the array is guaranteed to only contain one object.
Scans for AppleTVs on the local network . @param uniqueIdentifier An optional identifier for the AppleTV to scan for . The AppleTV advertises this via Bonjour . @param timeout An optional timeout value ( in seconds ) to give up the search after . @returns A promise that resolves to an array of AppleTV objects . If you provide a ` uniqueIdentifier ` the array is guaranteed to only contain one object .
scan(uniqueIdentifier, timeout) {
        this.services = [];
        this.uniqueIdentifier = uniqueIdentifier;
        this.browser.start();
        let that = this;
        let to = timeout == null ? 5 : timeout;
        return new Promise((resolve, reject) => {
            that.onComplete = resolve;
            that.onFailure = reject;
            setTimeout(() => {
                that.browser.stop();
                if (that.uniqueIdentifier) {
                    reject(new Error("Failed to locate specified AppleTV on the network"));
                } else {
                    resolve(that.services
                        .sort((a, b) => {
                            return a > b ? 1 : -1;
                        }));
                }
            }, to * 1000);
        });
    }
scan ( uniqueIdentifier , timeout ) { this . services = [ ] ; this . uniqueIdentifier = uniqueIdentifier ; this . browser . start ( ) ; let that = this ; let to = timeout == null ? 5 : timeout ; return new Promise ( ( resolve , reject ) => { that . onComplete = resolve ; that . onFailure = reject ; setTimeout ( ( ) => { that . browser . stop ( ) ; if ( that . uniqueIdentifier ) { reject ( new Error ( "Failed to locate specified AppleTV on the network" ) ) ; } else { resolve ( that . services . sort ( ( a , b ) => { return a > b ? 1 : - 1 ; } ) ) ; } } , to * 1000 ) ; } ) ; }
Scans for AppleTVs on the local network.
Scans for AppleTVs on the local network .