<commit_before>import {Injectable} from '@angular/core';
import {BrowserXhr} from '@angular/http';

import {NgProgressService} from './progress.service';

@Injectable()
export class NgProgressBrowserXhr extends BrowserXhr {

  private currentRequest: number = 0;

  constructor(private service: NgProgressService) {
    super();
  }

  public build() {
    const xhr = super.build();

    xhr.onload = (evt) => this.done();
    xhr.onerror = (evt) => this.done();
    xhr.onabort = (evt) => this.done();

    xhr.onloadstart = (event) => {
      this.currentRequest++;
      if (!this.service.isStarted()) {
        this.service.start();
      }
      // TODO: do some progress magic here
      // if (event.lengthComputable) {
    };

    // TODO: use event information to compute pending
    // xhr.onprogress = (event) => {};

    return xhr;
  }

  private done() {
    this.currentRequest--;
    if (this.currentRequest === 0) {
      this.service.done();
    }
  }
}<commit_msg>cleanup<commit_after>import {Injectable} from '@angular/core';
import {BrowserXhr} from '@angular/http';

import {NgProgressService} from './progress.service';

@Injectable()
export class NgProgressBrowserXhr extends BrowserXhr {

  private currentRequest: number = 0;

  constructor(private service: NgProgressService) {
    super();
  }

  public build() {
    const xhr = super.build();

    xhr.onload = (evt) => this.done();
    xhr.onerror = (evt) => this.done();
    xhr.onabort = (evt) => this.done();

    xhr.onloadstart = (event) => {
      this.currentRequest++;
      if (!this.service.isStarted()) {
        this.service.start();
      }
    };

    return xhr;
  }

  private done() {
    this.currentRequest--;
    if (this.currentRequest === 0) {
      this.service.done();
    }
  }
}
{'fraction_non_alphanumeric': 0.15733482642777155, 'fraction_numerical': 0.0022396416573348264, 'mean_word_length': 2.876355748373102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '4722706', 'n_tokens_mistral': 583, 'n_tokens_neox': 572, 'n_words': 127}