<commit_before>import { Directive, Input, HostListener } from '@angular/core';
@Directive({
  selector: '[brmasker]' // Attribute selector
})
export class BrMaskerDirective {
  @Input('brmasker') brmaskere: any;
  @HostListener('keyup', ['$event'])
  inputChanged(event: any): void {
    if (event.target.value) {
      event.target.value = this.onInput(event.target.value);
    }
  }
  constructor() {
  }
  private onInput(value: any): void {
    const ret = this.formataCampo(value, this.brmaskere.mask, this.brmaskere.len);
    return ret;
    // if (ret) {
    //   this.element.nativeElement.value = ret;
    // }
  }
  private formataCampo(campo: string, Mascara: string, tamanho: number): any {
    let boleanoMascara;
    const exp = /\-|\.|\/|\(|\)|\,|\*|\+|\@|\#|\$|\&|\%| /g;
    const campoSoNumeros = campo.toString().replace( exp, '' );
    let posicaoCampo = 0;
    let NovoValorCampo = '';
    let TamanhoMascara = campoSoNumeros.length;
    for (let i = 0; i < TamanhoMascara; i++) {
      if (i < tamanho) {
        boleanoMascara  = ((Mascara.charAt(i) === '-') || (Mascara.charAt(i) === '.') || (Mascara.charAt(i) === '/'));
        boleanoMascara  = boleanoMascara || ((Mascara.charAt(i) === '(') || (Mascara.charAt(i) === ')') || (Mascara.charAt(i) === ' '));
        boleanoMascara  = boleanoMascara || ((Mascara.charAt(i) === ',') || (Mascara.charAt(i) === '*') || (Mascara.charAt(i) === '+'));
        boleanoMascara  = boleanoMascara || ((Mascara.charAt(i) === '@') || (Mascara.charAt(i) === '#') );
        boleanoMascara  = boleanoMascara || ((Mascara.charAt(i) === '$') || (Mascara.charAt(i) === '&') || (Mascara.charAt(i) === '%'));
        if (boleanoMascara) {
          NovoValorCampo += Mascara.charAt(i);
          TamanhoMascara++;
        } else {
          NovoValorCampo += campoSoNumeros.charAt(posicaoCampo);
          posicaoCampo++;
        }
      }
    }
    return NovoValorCampo;
  }

}
<commit_msg>new mask [money], [phone], [person]<commit_after>import { Directive, Input, HostListener } from '@angular/core';
@Directive({
  selector: '[brmasker]' // Attribute selector
})
export class BrMaskerDirective {
  @Input('brmasker') brmaskere: any;
  @Input() money: boolean = false;
  @Input() phone: boolean = false;
  @Input() person: boolean = false;
  @HostListener('keyup', ['$event'])
  inputChanged(event: any): void {
    if (event.target.value) {
      if (this.money) {
        event.target.value = this.moneyMask(this.onInput(event.target.value));
        return;
      }
      if (this.phone) {
        event.target.value = this.phoneMask(event.target.value);
        return;
      }
      if (this.person) {
        event.target.value = this.peapollMask(event.target.value);
        return;
      }
      event.target.value = this.onInput(event.target.value);
    }
  }
  constructor() {
  }
  private phoneMask(v: any): void {
    if (v.length > 14) {
      this.brmaskere.mask = '(99) 99999-9999';
    } else {
      this.brmaskere.mask = '(99) 9999-9999';
    }
    return this.onInput(v);
  }
  private peapollMask(v: any): void {
    if (v.length > 14) {
      this.brmaskere.mask = '99.999.999/9999-99';
    } else {
      this.brmaskere.mask = '999.999.999-99';
    }
    return this.onInput(v);
  }
  private moneyMask(v: any): string {
    let tmp = v;
    tmp = tmp.replace(/([0-9]{2})$/g, ',$1');
    if ( tmp.length > 6 ) {
      tmp = tmp.replace(/([0-9]{3}),([0-9]{2}$)/g, '.$1,$2');
    }
    return tmp;
  }
  private onInput(value: any): void {
    const ret = this.formataCampo(value, this.brmaskere.mask, this.brmaskere.len);
    return ret;
    // if (ret) {
    //   this.element.nativeElement.value = ret;
    // }
  }
  private formataCampo(campo: string, Mascara: string, tamanho: number): any {
    let boleanoMascara;
    const exp = /\-|\.|\/|\(|\)|\,|\*|\+|\@|\#|\$|\&|\%| /g;
    const campoSoNumeros = campo.toString().replace(exp, '');
    let posicaoCampo = 0;
    let NovoValorCampo = '';
    let TamanhoMascara = campoSoNumeros.length;
    for (let i = 0; i < TamanhoMascara; i++) {
      if (i < tamanho) {
        boleanoMascara = ((Mascara.charAt(i) === '-') || (Mascara.charAt(i) === '.') || (Mascara.charAt(i) === '/'));
        boleanoMascara = boleanoMascara || ((Mascara.charAt(i) === '(') || (Mascara.charAt(i) === ')') || (Mascara.charAt(i) === ' '));
        boleanoMascara = boleanoMascara || ((Mascara.charAt(i) === ',') || (Mascara.charAt(i) === '*') || (Mascara.charAt(i) === '+'));
        boleanoMascara = boleanoMascara || ((Mascara.charAt(i) === '@') || (Mascara.charAt(i) === '#'));
        boleanoMascara = boleanoMascara || ((Mascara.charAt(i) === '$') || (Mascara.charAt(i) === '&') || (Mascara.charAt(i) === '%'));
        if (boleanoMascara) {
          NovoValorCampo += Mascara.charAt(i);
          TamanhoMascara++;
        } else {
          NovoValorCampo += campoSoNumeros.charAt(posicaoCampo);
          posicaoCampo++;
        }
      }
    }
    return NovoValorCampo;
  }

}

{'fraction_non_alphanumeric': 0.20831667333066772, 'fraction_numerical': 0.013394642143142742, 'mean_word_length': 2.7987851176917236, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '4597335', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1938, 'n_words': 300}