<commit_before>import Rx from 'rx'
//let log = logger("desktop-store")
//log.setLevel("warn")

export default function makeDesktopDriver(){

  return function desktopDriver(request$){


    function read(data){
      let obs = new Rx.Subject()
      let reader = new FileReader()
      //log.debug("reading from " + data)

      function onLoad(e) {
        [e]
          .filter(e=>e!==null)
          .map(e=>e.target.result)
          .forEach(e=>( obs.onNext({response:e}) ))
      }

      function onProgress(e) {
        [e]
          .filter(e=>e.lengthComputable)
          .forEach(function(e){
            //log.debug("fetching percent", percentComplete)
            obs.onNext({progress: (e.loaded / e.total),total:e.total}) 
          })
      }

      function onError(error) {
        //log.error("error", error)
        obs.onError(error)
      }

      reader.onload = onLoad
      //reader.onloadend = onLoad
      reader.onprogress = onProgress
      reader.onerror = onError
      reader.readAsBinaryString(data)    
      return obs
    }

    function createResponse$(options){
      if(options.method === 'get'){
        return read(options.data)
      }
    }

    let response$$ = request$
      .map(reqOptions => {
        let response$ = createResponse$(reqOptions)
        response$.request = reqOptions
        return response$
      })
      .replay(null, 1)
    response$$.connect()

    return response$$

    

    /*return {
      read
    }*/
    //return request$
    //  .map(read)
    
  }

}<commit_msg>refactor(desktopStoreDriver): - overall minor cleanup<commit_after>import Rx from 'rx'
//let log = logger("desktop-store")
//log.setLevel("warn")

export default function makeDesktopDriver(){

  return function desktopDriver(request$){

    function read(data){
      let obs = new Rx.Subject()
      let reader = new FileReader()
      //log.debug("reading from " + data)

      function onLoad(e) {
        [e]
          .filter(e=>e!==null)
          .map(e=>e.target.result)
          .forEach(e=>( obs.onNext({response:e}) ))
      }

      function onProgress(e) {
        [e]
          .filter(e=>e.lengthComputable)
          .forEach(function(e){
            //log.debug("fetching percent", percentComplete)
            obs.onNext({progress: (e.loaded / e.total),total:e.total}) 
          })
      }

      function onError(error) {
        //log.error("error", error)
        obs.onError(error)
      }

      reader.onload = onLoad
      //reader.onloadend = onLoad
      reader.onprogress = onProgress
      reader.onerror = onError
      reader.readAsBinaryString(data)    
      return obs
    }

    function createResponse$(options){
      if(options.method === 'get'){
        return read(options.data)
      }
    }

    let response$$ = request$
      .map(reqOptions => {
        let response$ = createResponse$(reqOptions)
        response$.request = reqOptions
        return response$
      })
      .replay(null, 1)
    response$$.connect()

    return response$$

    /*return {
      read
    }*/    
  }

}
{'fraction_non_alphanumeric': 0.13779655508612285, 'fraction_numerical': 0.0006499837504062399, 'mean_word_length': 1.9941634241245136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3817326', 'n_tokens_mistral': 950, 'n_tokens_neox': 911, 'n_words': 178}