Skip to content

Commit aa9ae24

Browse files
committed
Avoid creating a new listener type array in off(), saves another 4 bytes (187b -> 183b)
1 parent 9eced2d commit aa9ae24

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ export default function mitt(all: EventHandlerMap) {
3636
* @memberOf mitt
3737
*/
3838
off(type: string, handler: EventHandler) {
39-
let e = all[type] || (all[type] = []);
40-
e.splice(e.indexOf(handler) >>> 0, 1);
39+
if (all[type]) {
40+
all[type].splice(all[type].indexOf(handler) >>> 0, 1);
41+
}
4142
},
4243

4344
/**

0 commit comments

Comments
 (0)