Structuring core libraries
Over the years, Node.js has grown a lot, and the core libraries too. There are many libraries available for us to use, and it is important to know how they are structured to be able to use them properly.
Most of the core libraries are quite simple and are structured in a similar way so you know what to expect in practical terms. Once you know how to use one of them, you will be able to use the rest of them without any problem.
Furthermore, you will be able to create your own libraries and publish them in npm, and other developers will be able to use them easily, but we will talk about this in the next chapter.
The library structure
Let’s look at the fs
library as an example. The fs
library is used to work with the file system, and it is one of the most used libraries in Node.js.
Any library that performs I/O operations is asynchronous. Historically, Node.js has offered two ways to handle I/O operations: callbacks or synchronous functions...