lib: don't use emitter.listeners(type).length

Reviewed-by: Trevor Norris <trev.norris@gmail.com>