nodejs 知识补充

querystring通用字符解析器:
const weirdoString = `name:Sophie;shape:fox;condition:new`;
const result = querystring.parse(weirdoString, `;`, `:`);

Path Parsing:路径解析
myFilePath = `/someDir/someFile.json`;
path.parse(myFilePath).base === `someFile.json`; // true
path.parse(myFilePath).name === `someFile`; // true
path.parse(myFilePath).ext === `.json`; // true

console.dir(obj,{colors:true})

存在 setInterval(Timeout类)的时候NodeJS并不会退出,你可以使用如下的方法让Node沉睡:
const dailyCleanup = setInterval(() => {
cleanup();
}, 1000 * 60 * 60 * 24);

process.kill(process.pid, os.constants.signals.SIGTERM);

NodeJS 中含有内置的IP地址校验工具,这一点可以免得你写额外的正则表达式:
require(`net`).isIP(`10.0.0.1`) 返回 4
require(`net`).isIP(`cats`) 返回 0
os.EOF 替换手写行结束符
NodeJS帮我们内置了HTTP状态码及其描述,也就是http.STATUS_CODES,键为状态值,值为描述
自定义console: 你可以使用new console.Console(standardOut,errorOut),然后设置自定义的输出流。你可以选择创建console将数据输出到文件或者Socket或者第三方中。
dns.lookup(),然后自己缓存DNS查询
net 模块差不多比 http 快上两倍

在REPL模式下,可以直接输入.load someFile.js然后可以载入包含自定义常量的文件。