<commit_before>'use babel'

import {Disposable} from 'atom'

const NUMBER_REGEXP = /\-?\d*\.?\d+/g

export function disposableEvent(element, event, callback) {
  element.addEventListener(event, callback)
  return new Disposable(function() {
    element.removeEventListener(event, callback)
  })
}

export function applyDifference(value, difference, shouldRound) {
  let newValue = + value + (difference * value)
  if (shouldRound) {
    newValue = String(Math.round(newValue))
  } else {
    newValue = newValue.toFixed(2)
    if (newValue.slice(-2) === '00') {
      newValue = newValue.slice(0, -3)
    } else if (newValue.slice(-1) === '0') {
      newValue = newValue.slice(0, -1)
    }
  }
  return newValue
}
<commit_msg>:bug: Handle zero value properly<commit_after>'use babel'

import {Disposable} from 'atom'

const NUMBER_REGEXP = /\-?\d*\.?\d+/g

export function disposableEvent(element, event, callback) {
  element.addEventListener(event, callback)
  return new Disposable(function() {
    element.removeEventListener(event, callback)
  })
}

export function applyDifference(value, difference, shouldRound) {
  value = value === '0' ? '1' : value
  let newValue = + value + (difference * value)
  if (shouldRound) {
    newValue = String(Math.round(newValue))
  } else {
    newValue = newValue.toFixed(2)
    if (newValue.slice(-2) === '00') {
      newValue = newValue.slice(0, -3)
    } else if (newValue.slice(-1) === '0') {
      newValue = newValue.slice(0, -1)
    }
  }
  return newValue
}

{'fraction_non_alphanumeric': 0.15089344804765056, 'fraction_numerical': 0.01455989410986102, 'mean_word_length': 3.6666666666666665, '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': '6109049', 'n_tokens_mistral': 519, 'n_tokens_neox': 504, 'n_words': 115}