Skip to content

Instantly share code, notes, and snippets.

View mikepuerto's full-sized avatar

Mike Puerto mikepuerto

  • ThoughtMint
  • Florida
View GitHub Profile
// 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++;
@mikepuerto
mikepuerto / micro-events.js
Last active September 11, 2018 13:05
Micro EventEmitter v2
/**
* micro event emitter
* @author [email protected]
* @gist https://gist.github.com/mikepuerto/1418a024ab93e1cb353305c9ceadfbde
*/
class EventEmitter {
constructor() {
this._eventHandlers = {};