Message from JavaScript discussions
September 2017
— Also look at util.promisify
const fs =
require('fs');
const { promisify } =
require('util');
const mkdir =
promisify(fs.mkdir);
const readFile =
promisify(fs.readFile);
const writeFile =
promisify(fs.writeFile);
mkdir('stuff')
.then(() =>
readFile('read.txt'))
.then(data =>
writeFile('stuff/write.txt', data));
— Okay const means constant and that variable fs can't be changed or reassigned
— Yep
— Always use const unless you plan to reassign
— Okay thank u i will note that down now
— Not really, all it is, is an event loop and cooperative scheduler, things that can be used for any purpose
— It basically lets seperate things get processing time without returning
— Single-threaded
— Applications will use system calls to the kernel for specific things. Stuff like yield DISPATCHER_WAIT(pid);
which tells the scheduler to not run the program's main thread again, only running the event loop, until the dispatcher gets an IPC message from the specified pid
— There will be messaging between running programs, so you might want to wait for a message sometimes.
— I will also be disabling Node automatic GC via C++