Skip to content

Instantly share code, notes, and snippets.

View mikepuerto's full-sized avatar

Mike Puerto mikepuerto

  • ThoughtMint
  • Florida
View GitHub Profile
@mikepuerto
mikepuerto / micro-events.js
Last active September 11, 2018 13:05
Micro EventEmitter v2
/**
* micro event emitter
* @author mikepuerto@gmail.com
* @gist https://gist.github.com/mikepuerto/1418a024ab93e1cb353305c9ceadfbde
*/
class EventEmitter {
constructor() {
this._eventHandlers = {};
// example input 'aaaabbcccdaa'
// example output 'a4b2c3da2'
function compress(str) {
var input = str.split('')
, count = 1
, ret = [];
for (var i = 0, len = input.length; i < len; i++) {
if (input[i] === input[i + 1]) count++;