This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* micro event emitter | |
* @author [email protected] | |
* @gist https://gist.github.com/mikepuerto/1418a024ab93e1cb353305c9ceadfbde | |
*/ | |
class EventEmitter { | |
constructor() { | |
this._eventHandlers = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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++; |