Consider switching to ES6 Map over null object
maxnordlund opened this issue · comments
AFAIK small maps are slower then objects, but large maps are faster. See microsoft/TypeScript#12715 for a real life example with benchmarks.
Looking at kangax support seems quite good, node goes all the way back to 0.12 and Internet Explorer from 11. I'm not sure what your support requirements are, but I think these are good enough. And there's always the option of a polyfill, but I assume that's going to be slower.
Other than performance, is there any upside to this? I don't see perf as a real concern here. From the [just added] src/benchmark.js
script ...
$ npm run benchmark
mime.getType x 5,466,164 ops/sec ±1.23% (89 runs sampled)
mimeLite.getType x 5,315,061 ops/sec ±0.86% (93 runs sampled)
While I get that Map
is more elegant I'm not really in the mood to field complaints from folks still running < IE11. :-)