<commit_before>//
//  BrowserDelegate.swift
//  SwiftNetService
//
//  Created by <NAME> on 11/2/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation
import ReactiveCocoa

public typealias ServicesType = [NSNetService]
public typealias ServicesSignalType = Signal<ServicesType, NSError>
public typealias ServicesObserverType = Event<ServicesType, NSError>.Sink

public class BrowserDelegate : NSObject, NSNetServiceBrowserDelegate {
    
    public var servicesSignal : ServicesSignalType
    public var services : ServicesType
    private var servicesObserver : ServicesObserverType
    public var isSearching : Bool = false

    internal init(servicesSignal : ServicesSignalType, servicesObserver : ServicesObserverType) {
        self.services = []
        self.servicesSignal = servicesSignal
        self.servicesObserver = servicesObserver
    }

    public override convenience init() {
        let (servicesSignal, servicesObserver) = ServicesSignalType.pipe()
        self.init(servicesSignal: servicesSignal, servicesObserver: servicesObserver)
    }
    
    public func netServiceBrowser(browser: NSNetServiceBrowser, didFindService service: NSNetService, moreComing: Bool) {
        self.services.append(service);
        if (!moreComing) {
            sendNext(self.servicesObserver, self.services)
        }
    }

    public func netServiceBrowser(browser: NSNetServiceBrowser, didRemoveService service: NSNetService, moreComing: Bool) {
        if let index = self.services.indexOf(service) {
            self.services.removeAtIndex(index);
        }
        if (!moreComing) {
            sendNext(self.servicesObserver, self.services)
        }
    }
    
    public func netServiceBrowser(browser: NSNetServiceBrowser, didNotSearch errorDict: [String : NSNumber]) {
        sendError(self.servicesObserver, errorForErrorDictionary(errorDict));
    }
    
    public func netServiceBrowserWillSearch(browser: NSNetServiceBrowser) {
        self.isSearching = true
    }

    public func netServiceBrowserDidStopSearch(browser: NSNetServiceBrowser) {
        self.isSearching = false
    }

}
<commit_msg>BrowserDelegate shouldn't need to be public.<commit_after>//
//  BrowserDelegate.swift
//  SwiftNetService
//
//  Created by <NAME> on 11/2/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation
import ReactiveCocoa

typealias ServicesType = [NSNetService]
typealias ServicesSignalType = Signal<ServicesType, NSError>
typealias ServicesObserverType = Event<ServicesType, NSError>.Sink

class BrowserDelegate : NSObject, NSNetServiceBrowserDelegate {
    
    var servicesSignal : ServicesSignalType
    var services : ServicesType
    var servicesObserver : ServicesObserverType
    var isSearching : Bool = false

    internal init(servicesSignal : ServicesSignalType, servicesObserver : ServicesObserverType) {
        self.services = []
        self.servicesSignal = servicesSignal
        self.servicesObserver = servicesObserver
    }

    override convenience init() {
        let (servicesSignal, servicesObserver) = ServicesSignalType.pipe()
        self.init(servicesSignal: servicesSignal, servicesObserver: servicesObserver)
    }
    
    func netServiceBrowser(browser: NSNetServiceBrowser, didFindService service: NSNetService, moreComing: Bool) {
        self.services.append(service);
        if (!moreComing) {
            sendNext(self.servicesObserver, self.services)
        }
    }

    func netServiceBrowser(browser: NSNetServiceBrowser, didRemoveService service: NSNetService, moreComing: Bool) {
        if let index = self.services.indexOf(service) {
            self.services.removeAtIndex(index);
        }
        if (!moreComing) {
            sendNext(self.servicesObserver, self.services)
        }
    }
    
    func netServiceBrowser(browser: NSNetServiceBrowser, didNotSearch errorDict: [String : NSNumber]) {
        sendError(self.servicesObserver, errorForErrorDictionary(errorDict));
    }
    
    func netServiceBrowserWillSearch(browser: NSNetServiceBrowser) {
        self.isSearching = true
    }

    func netServiceBrowserDidStopSearch(browser: NSNetServiceBrowser) {
        self.isSearching = false
    }

}

{'fraction_non_alphanumeric': 0.07954545454545454, 'fraction_numerical': 0.004261363636363636, 'mean_word_length': 3.452054794520548, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6629831', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1073, 'n_words': 253}