<commit_before>import Ember from 'ember';

export default Ember.TextField.extend({
  prefix: '',
  suffix: '',
  affixesStay: false,
  thousands: ',',
  decimal: '.',
  precision: 2,
  allowZero: true,
  allowNegative: false,

  options: function () {
    return {
      prefix: this.get('prefix'),
      suffix: this.get('suffix'),
      affixesStay: this.get('affixesStay'),
      thousands: this.get('thousands'),
      decimal: this.get('decimal'),
      precision: this.get('precision'),
      allowZero: this.get('allowZero'),
      allowNegative: this.get('allowNegative')
    };
  }.property(),

  initializeMask: function() {
    this.$().maskMoney(this.get('options'));
  }.on('didInsertElement'),

  teardownMask: function() {
    this.$().maskMoney('destroy');
  }.on('willDestroyElement'),

  setMaskedValue: function() {
    if (this.get('number') !== undefined) {
      const number = parseFloat(this.get('number')).toFixed(this.get('precision'));
      const val = number.toString().replace(".", this.get('decimal'));
      this.$().val(val);
      this.$().maskMoney('mask');
    }
  }.observes('number'),

  setUnmaskedValue: function() {
    this.set('number', this.$().maskMoney('unmasked')[0]);
  }.observes('value')
});
<commit_msg>0.00 when number is undefined<commit_after>import Ember from 'ember';

export default Ember.TextField.extend({
  prefix: '',
  suffix: '',
  affixesStay: false,
  thousands: ',',
  decimal: '.',
  precision: 2,
  allowZero: true,
  allowNegative: false,

  options: function () {
    return {
      prefix: this.get('prefix'),
      suffix: this.get('suffix'),
      affixesStay: this.get('affixesStay'),
      thousands: this.get('thousands'),
      decimal: this.get('decimal'),
      precision: this.get('precision'),
      allowZero: this.get('allowZero'),
      allowNegative: this.get('allowNegative')
    };
  }.property(),

  initializeMask: function() {
    this.$().maskMoney(this.get('options'));
    this.propertyDidChange('number');
  }.on('didInsertElement'),

  teardownMask: function() {
    this.$().maskMoney('destroy');
  }.on('willDestroyElement'),

  setMaskedValue: function() {
    const number = parseFloat(this.get('number') || 0).toFixed(this.get('precision'));
    const val = number.toString().replace(".", this.get('decimal'));
    this.$().val(val);
    this.$().maskMoney('mask');
  }.observes('number'),

  setUnmaskedValue: function() {
    this.set('number', this.$().maskMoney('unmasked')[0]);
  }.observes('value')
});

{'fraction_non_alphanumeric': 0.20127540852929454, 'fraction_numerical': 0.0031885213232363493, 'mean_word_length': 3.8549323017408126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4986230', 'n_tokens_mistral': 829, 'n_tokens_neox': 785, 'n_words': 137}