Hey guys,
this is kind of not an issue and more of a discussion because I'm not sure where to ask about this.
Are there any naming guidelines for APIs in the node.js world?
When doing nodeschools, I realize that many people get APIs wrong and can't remember camelcased APIs correctly. The best example is fs.readdirSync and fs.readFileSync.
Why is it not called fs.readDirSync like everything else in the node.js API? How do you decide to name an API? Are there API guidelines available for third-party package implementors and maintainers?
PS: Sorry if this is a meta discussion; but I actually think that something like a naming scheme for APIs is pretty important as it lowers the entry barriers for newcomers to the node.js world and eases up googling node.js APIs all the time.
Naming convention is fs.<unix functio name><other stuff>. In above, readdir is https://linux.die.net/man/3/readdir, Sync and FileSync are "other stuff".
Naming is consistent with expectations of people who know underlying library calls, I find it pretty easy to remember the names while understanding that others may not. The names are probably similar to other languages, since the underlying library call names have a tendency to be what language specific library developers use.
In retrospect, maybe it would have been better to be more agressively camel-case, but changing that now would hurt pretty badly.
If you have time, perhaps a PR to the fs docs that explains the naming convention would be helpful?
Most helpful comment
Naming convention is
fs.<unix functio name><other stuff>. In above, readdir is https://linux.die.net/man/3/readdir,SyncandFileSyncare "other stuff".Naming is consistent with expectations of people who know underlying library calls, I find it pretty easy to remember the names while understanding that others may not. The names are probably similar to other languages, since the underlying library call names have a tendency to be what language specific library developers use.
In retrospect, maybe it would have been better to be more agressively camel-case, but changing that now would hurt pretty badly.