Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the naming convention of NodeJS?

I found that the naming conversion of node is a little strange. For instance, in the file system module, the read link function's letters are all lower cased:

fs.readlink

But the read file function's name are camelized:

fs.readFile

It confused me. After mistyping for times, I think I shoud ask. So is there a naming convention to help me memorize the api names?

like image 938
Yad Smood Avatar asked Aug 19 '13 17:08

Yad Smood


People also ask

What is the naming convention for Node JS?

File names must be all lowercase and may include underscores (_) or dashes (-), but no additional punctuation. Follow the convention that your project uses. Filenames' extension must be . js.

What is the naming style convention in JS?

There are no special naming conventions for global JavaScript variables. A global JavaScript variable is declared at the top of a project/file. A global JavaScript variable is written in camelCase if it is mutable. A global JavaScript variable is written in UPPERCASE if it is immutable.

What are naming conventions?

What Is a Naming Convention? In simple terms, a naming convention refers to a framework used for naming your files in a specific way. This should be descriptive and consistent throughout the organization. It is always best to use a naming convention to describe the contents of the files.

What is naming convention for filename?

A File Naming Convention (FNC) is a framework for naming your files in a way that describes what they contain and how they relate to other files. Developing an FNC is done through identifying the key elements of the project, the important differences and commonalities between your files.


1 Answers

Node's default convention is camelCase. But functions in file system module named according to their respective POSIX C interface functions. For example readdir, readlink. These functions names are well-known by Linux developers and therefore it's often decided to use them as is(as single word), without camelizing.

like image 129
ataman Avatar answered Oct 29 '22 10:10

ataman