Skip to content

Commit

Permalink
Avoid creating a new listener type array in off(), saves another 4 …
Browse files Browse the repository at this point in the history
…bytes (187b -> 183b)
  • Loading branch information
developit committed Apr 14, 2017
1 parent 9eced2d commit aa9ae24
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ export default function mitt(all: EventHandlerMap) {
* @memberOf mitt
*/
off(type: string, handler: EventHandler) {
let e = all[type] || (all[type] = []);
e.splice(e.indexOf(handler) >>> 0, 1);
if (all[type]) {
all[type].splice(all[type].indexOf(handler) >>> 0, 1);
}
},

/**
Expand Down

0 comments on commit aa9ae24

Please sign in to comment.