<commit_before>import { NativeModules, DeviceEventEmitter } from 'react-native'
import { EventEmitter } from 'events'

const RNZeroconf = NativeModules.RNZeroconf

export default class Zeroconf extends EventEmitter {

  constructor (props) {
    super(props)

    this._services = {}

    DeviceEventEmitter.addListener('RNZeroconfStart', () => {
      this.emit('start')
    })

    DeviceEventEmitter.addListener('RNZeroconfStop', () => {
      this.emit('stop')
    })

    DeviceEventEmitter.addListener('RNZeroconfError', err => {
      this.emit('error', err)
    })

    DeviceEventEmitter.addListener('RNZeroconfFound', service => {
      if (!service || !service.name) { return }
      const { name } = service

      this._services[name] = service
      this.emit('found', name)
      this.emit('update')
    })

    DeviceEventEmitter.addListener('RNZeroconfRemove', service => {
      if (!service || !service.name) { return }
      const { name } = service

      delete this._services[name]

      this.emit('remove', name)
      this.emit('update')
    })

    DeviceEventEmitter.addListener('RNZeroconfResolved', service => {
      if (!service || !service.name) { return }

      this._services[service.name] = service
      this.emit('resolved', service)
      this.emit('update')
    })

  }

  /**
   * Get all the services already resolved
   */
  getServices () {
    return this._services
  }

  /**
   * Scan for Zeroconf services,
   * Defaults to _http._tcp. on local domain
   */
  scan (type = 'http', protocol = 'tcp', domain = 'local.') {
    this._services = {}
    this.emit('update')
    RNZeroconf.scan(type, protocol, domain)
  }

  /**
   * Stop current scan if any
   */
  stop () {
    RNZeroconf.stop()
  }

}
<commit_msg>chore(core): minor refactor<commit_after>import { NativeModules, DeviceEventEmitter } from 'react-native'
import { EventEmitter } from 'events'

const RNZeroconf = NativeModules.RNZeroconf

export default class Zeroconf extends EventEmitter {

  constructor (props) {
    super(props)

    this._services = {}

    DeviceEventEmitter.addListener('RNZeroconfStart', () => this.emit('start'))
    DeviceEventEmitter.addListener('RNZeroconfStop', () => this.emit('stop'))
    DeviceEventEmitter.addListener('RNZeroconfError', err => this.emit('error', err))

    DeviceEventEmitter.addListener('RNZeroconfFound', service => {
      if (!service || !service.name) { return }
      const { name } = service

      this._services[name] = service
      this.emit('found', name)
      this.emit('update')
    })

    DeviceEventEmitter.addListener('RNZeroconfRemove', service => {
      if (!service || !service.name) { return }
      const { name } = service

      delete this._services[name]

      this.emit('remove', name)
      this.emit('update')
    })

    DeviceEventEmitter.addListener('RNZeroconfResolved', service => {
      if (!service || !service.name) { return }

      this._services[service.name] = service
      this.emit('resolved', service)
      this.emit('update')
    })

  }

  /**
   * Get all the services already resolved
   */
  getServices () {
    return this._services
  }

  /**
   * Scan for Zeroconf services,
   * Defaults to _http._tcp. on local domain
   */
  scan (type = 'http', protocol = 'tcp', domain = 'local.') {
    this._services = {}
    this.emit('update')
    RNZeroconf.scan(type, protocol, domain)
  }

  /**
   * Stop current scan if any
   */
  stop () {
    RNZeroconf.stop()
  }

}

{'fraction_non_alphanumeric': 0.14175257731958762, 'fraction_numerical': 0.0, 'mean_word_length': 2.973833902161547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3540846', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1091, 'n_words': 216}