aboutsummaryrefslogtreecommitdiff
path: root/src/index.js
diff options
context:
space:
mode:
authorJason Miller <[email protected]>2017-04-14 19:33:27 -0400
committerJason Miller <[email protected]>2017-04-14 19:33:27 -0400
commitaa9ae241f8279ba7942e4e4eda1d4d9a56546faa (patch)
tree617e97927ec1323c2f1ceaab1171262752d8d91b /src/index.js
parent9eced2debd62a62669879b1ec0661259576f6215 (diff)
Avoid creating a new listener type array in `off()`, saves another 4 bytes (187b -> 183b)
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/index.js b/src/index.js
index 78d675d..9746b8d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -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);
+ }
},
/**