Net module
This module provides an API for TCP or IPC servers and clients. IPC stands for Inter Process Communication (IPC)
. To communicate between different processes, there are two fundamental methods: Shared Memory
and Message Passing
. These concepts can be broken down and grouped. You can find more resources in the Reference section.
Reference:
Inter Process Communication (IPC)
Methods in Inter process Communication
Mutex vs Semaphore
Performance measurement APIs
Browsers provide Web Performance APIs, and Node.js also offers similar APIs. An example from the Reference section is:
performance.mark('start:app');
performance.mark('start:init');
init(); // run initialization functions
performance.mark('end:init');
performance.mark('start:funcX');
funcX(); // run another function
performance.mark('end:funcX');
performance.mark('end:app');
const mark = performance.getEntriesByType('mark');
Reference:
An Introduction to the Performance API
Performance APIs
Permissions
This is a tool to restrict access from a Node.js process to specific resources. It is not intended for security purposes. For example, when you use the --permission
flag to execute js code, you must explicitly allow access using flags like --allow-fs-read
or --allow-fs-write
.
$ node --permission index.js
Error: Access to this API has been restricted
at node:internal/main/run_main_module:23:47 {
code: 'ERR_ACCESS_DENIED',
permission: 'FileSystemRead',
resource: '/home/user/index.js'
}
Path
I often use path.join()
. It's useful, but not available in browsers. You can use an alternative library like path-browserify
. Of course, you can also implement a simple version of this function yourself.
REPL
REPL stands for READ, EVAL, PRINT, LOOP
. This is that REPL is like a JavaScript playground in your terminal.
Reference:
NodeJS REPL (READ, EVAL, PRINT, LOOP)
Diagnostic report
Delivers a JSON-formatted diagnostic summary, written to a file. The report is intended for development, test, and production use, to capture and preserve information for problem determination.
You can use this feature via the command line:
node --report-uncaught-exception --report-on-signal \
--report-on-fatalerror app.js
And through API:
process.report.writeReport('./foo.json');
process.report.writeReport(err);
process.report.writeReport(filename, err);