Closed goloroden closed 8 years ago
Hey,
Thanks for the report and sorry about the confusion. Technically, it is a constructor. :smile_cat: And a factory function at the same time. One option would be to name the factory form of it as intercept
, to make it a verb, leaving the lowercase mitm
to correctly refer to an instance of Mitm
. I don't really know. What's your opinion?
Well, I just imported as getMime
, so that the questionable lines were:
const getMime = require('mime');
let mime = getMime();
What do you think about this for the documentation?
I presume you meant "mitm" where you used "mime" above? ^_^
get
is probably not the best prefix — get would refer to a getter and side effects in getters are surprising. ;-) Mitm
as a factory function however does have a side effect — it intercepts all connections (short for new Mitm().enable()
. Something named after its behavior might be more intuitive...
I'll close this until we come up with something actionable. Further conversation welcome however. :)
According to the documentation, the main entry point is
Mitm
. In JavaScript, things that start with an upper-case character are usually meant to be used as a constructor function.Hence I ran
only to find out that it doesn't work. After a while I discovered that the documentation says that one should use it as a normal function, not as a constructor:
This seems confusing, because developers may think (like me ;-)) that it is a constructor.
What do you think about either changing the name in the documentation to something with a lowercase character?