<commit_before>import {Component, Input, OnDestroy} from 'angular2/core';

@Component({
  selector: 'spinner',
  styleUrls: ['app/shared/spinner/spinner.component.css'],
  template: `
    <div *ngIf="isSpinning" class="spinner" [class.inverse]="inverse"></div>
    `
})

export class SpinnerComponent implements OnDestroy {

  private currentTimeout: number;
  private isSpinning: boolean = true;

  @Input() public inverse: boolean = false;
  @Input() public delay: number = 300;

  @Input() public set spinning(value: boolean) {
    if (!value) {
      this.cancelTimeout();
      this.isSpinning = false;
    }
    if (this.currentTimeout) {
      return;
    }
    this.currentTimeout = setTimeout(() => {
      this.isSpinning = value;
      this.cancelTimeout();
    }, this.delay);
  }

  private cancelTimeout(): void {
    clearTimeout(this.currentTimeout);
    this.currentTimeout = undefined;
  }

  ngOnDestroy(): any {<commit_msg>Check for current timeout before calling cancel<commit_after>import {Component, Input, OnDestroy} from 'angular2/core';

@Component({
  selector: 'spinner',
  styleUrls: ['app/shared/spinner/spinner.component.css'],
  template: `
    <div *ngIf="isSpinning" class="spinner" [class.inverse]="inverse"></div>
    `
})

export class SpinnerComponent implements OnDestroy {

  private currentTimeout: number;
  private isSpinning: boolean = true;

  @Input() public inverse: boolean = false;
  @Input() public delay: number = 300;

  @Input() public set spinning(value: boolean) {
    if (!value) {
      this.cancelTimeout();
      this.isSpinning = false;
    }
    if (this.currentTimeout) {
      return;
    }
    this.currentTimeout = setTimeout(() => {
      this.isSpinning = value;
      this.cancelTimeout();
    }, this.delay);
  }

  private cancelTimeout(): void {
    if (this.currentTimeout) {
      clearTimeout(this.currentTimeout);
      this.currentTimeout = undefined;
    }
  }

  ngOnDestroy(): any {
{'fraction_non_alphanumeric': 0.13717491075981642, 'fraction_numerical': 0.00407955124936257, 'mean_word_length': 3.52073732718894, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '359542', 'n_tokens_mistral': 614, 'n_tokens_neox': 587, 'n_words': 138}