diff options
| author | Jason Miller <[email protected]> | 2017-04-14 19:33:27 -0400 |
|---|---|---|
| committer | Jason Miller <[email protected]> | 2017-04-14 19:33:27 -0400 |
| commit | aa9ae241f8279ba7942e4e4eda1d4d9a56546faa (patch) | |
| tree | 617e97927ec1323c2f1ceaab1171262752d8d91b /src/index.js | |
| parent | 9eced2debd62a62669879b1ec0661259576f6215 (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.js | 5 |
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); + } }, /** |
