Why are some NodeJS requires capitalized?
Why are some
requires capitalized? For example:
Take a look at this line:
Router capitalized, but
phin isn't, but
I'm scratching my head right now.
Thanks for reading,
P.S. Why am I asking? For the sake of consistency, of course!
the npm package
koa exports a default function object. you assign that to a variable called
Koa with the
const variable declaration using nodes global commonjs require method.
Koa is capitalized because the value assigned to it is a constructor function, and you can create instances of it (i.e.
app) by using the
in other words. with koa's api, you are able to do this
just like if you create a class
you can instantiate an instance of it, like you do with koa (but
app instead of
in java, you may do this (i'm a bit rusty)
Scanner, Dog, and Koa are all capitalized because they are constructors and you can create instances of it with the
so we can reason that it doesn't make much sense do this
because ejs and uid are lowercase. you probably wont find
new ejs() in their documentation simply because they are not constructors, that is not how you are supposed to use the library
firebase-admin some people would resonably infer that one way to use it is by writing a
new FieldValue() somewhere, simply because its capitalized in that way
so in short, it is a convention to capitalize in that manner. and that usually correlates with how you would use the library. of courses, sometimes there are exceptions :P
nice question btw :)