leodutra
2/16/2017 - 5:34 PM

Curry a listener and swallows any JavaScript event (default effect and propagation).

Curry a listener and swallows any JavaScript event (default effect and propagation).

function swallowingEvents(fn) {
  return typeof fn !== 'function' ? fn : function (event) {
    event.preventDefault()
    event.stopPropagation()
    return fn(event)
  }
}