'use babel'

import {Disposable} from 'atom'

export function rangeKey(range) {
  return range.start.row + ':' + range.start.column + '::' + range.end.row + ':' + range.end.column
}

export function debounce(callback, delay) {
  let timeout = null
  return function(arg) {
    if (timeout === null) {
      timeout = setTimeout(() => {
        timeout = null
        callback.call(this, arg)
      }, delay)
    }
  }
}

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

const EDITOR_CLASS = 'number-range-cursor'

export function handlePositionClass(textEditor, add) {
  const view = atom.views.getView(textEditor)
  if (add) {
    view.classList.add(EDITOR_CLASS)
  } else {
    view.classList.remove(EDITOR_CLASS)
  }
}

'use babel'

import {Disposable} from 'atom'

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

Remove unnecessary helpers