Useful Node.js APIs
os.cpus() : returns an array of objects with information about each logical CPU core. The “Clusters” section below references os.cpus() to fork the process. On a 16-core CPU, you’d have 16 instances of your Node.js application running to improve performance.
os.tmpdir() : the full path of the operating system’s default temporary file directory.
os.homedir() : the full path of the user’s home directory.
util.format(format, [args]) : returns a string using a printf-like format.
util.inspect(object, options) : returns a string representation of an object for debugging. This is similar to using console.dir(object, { depth: null, color: true }); .
util.isDeepStrictEqual(object1, object2) : returns true when there’s a deep equality between two objects (all child properties must match).
util.types
provides type checking for common JavaScript and Node.js
values. For example:
import util from 'util';
util.types.isDate( new Date() ); // true
util.types.isMap( new Map() ); // true
util.types.isRegExp( /abc/ ); // true
util.types.isAsyncFunction( async () => {} ); // true