Shell scripting with Node.js

🏷️ Book, NodeJS

Available APIs in a Node.js app consist of:

Node’s functions have 3 styles:

Event loop

Node executes JS in a main thread

The main thread continuously runs the event loop

The loop executes chunks of JS

Each chunk is a scheduled task

The first task contains the code of the initial task

The loop takes the tasks out of the task queue and executes them in the main thread

Each task runs after the previous finished

Phases

Each phase will waits until its next turn before processing tasks

Except poll,

Sub-phases

Run until both queues are empty

Tasks are added and processed immediately

Path methods

path.resolve(): resolve path

path.join(): concatenate path

path.normalize(): ensure paths are normalized


https://exploringjs.com/nodejs-shell-scripting