Node.js:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
无编辑摘要
 
(未显示同一用户的19个中间版本)
第57行: 第57行:
|  || [[/pipe|pipe]] || [[/Pipeline|Pipeline]]|| ||[[/cors|cors]] || [[/file|file]]
|  || [[/pipe|pipe]] || [[/Pipeline|Pipeline]]|| ||[[/cors|cors]] || [[/file|file]]
|-
|-
| [[/promise|promise]] || [[/TCP套接字|TCP套接字]] || [[/TLS堆栈|TLS堆栈]]|| [[/异步迭代器|异步迭代器]] || [[/加密解密|加密解密]]
| [[/Promise|Promise]] || [[/TCP套接字|TCP套接字]] || [[/TLS堆栈|TLS堆栈]]|| [[/异步迭代器|异步迭代器]] || [[/加密解密|加密解密]]
|-
|-
| [[/路由|路由]] || [[/错误处理|错误处理]] || [[/Unicode|Unicode]]|| [[/堆栈追踪|堆栈追踪]] || [[/随机中文字符|随机中文字符]]
| [[/路由|路由]] || [[/错误处理|错误处理]] || [[/Unicode|Unicode]]|| [[/堆栈追踪|堆栈追踪]] || [[/随机中文字符|随机中文字符]]
第75行: 第75行:
|-
|-
| [https://decoder.link/rsa_converter RSA 密钥转换器] || [https://www.myssl.cn/tools/merge-pem-cert.html PEM在线合成] || 示例
| [https://decoder.link/rsa_converter RSA 密钥转换器] || [https://www.myssl.cn/tools/merge-pem-cert.html PEM在线合成] || 示例
|}
=== 加密算法 ===
{| class="wikitable"
|-
| MD5 || SHA1 || HMAC(keyed-Hash Message Authentication Code)
|-
| 示例 || 示例 || 示例
|-
| 示例 || 示例 || 示例
|}
|}


第109行: 第119行:
{| class="wikitable"
{| class="wikitable"
|-
|-
| [[/nodemon|nodemon]] || [[/fs|fs]] || [[/profile|profile]] || [[/moment|moment]] || [[/webpack|webpack]]|| electron || [[/pm2|pm2]]
| [[/nodemon|nodemon]] || [[/fs|fs]] || [[/profile|profile]] || [[/moment|moment]] || || electron || [[/pm2|pm2]]
|-
|-
| [[/heapdump|heapdump]] || [[/Connect-Busboy|Connect-Busboy]] || [[/connect-multipart|connect-multipart]] || qs || [[/babel|babel]] || phantomjs || [[/passport|passport]]
| [[/heapdump|heapdump]] || [[/Connect-Busboy|Connect-Busboy]] || [[/connect-multipart|connect-multipart]] || qs || [[/babel|babel]] || phantomjs || [[/passport|passport]]
|-
|-
| [[/文件上传策略|文件上传策略]] || [[/string-random|string-random]] || [[/boxen|boxen]] || element-ui || [[/bcryptjs|bcryptjs]] || [[/node-sass|node-sass]] || [[/path|path]]
| [[/文件上传策略|文件上传策略]] || [[/string-random|string-random]] || [[/boxen|boxen]] || element-ui || [[/bcryptjs|bcryptjs]] || [[/node-sass|node-sass]] || [[/path|path]]
|-
| [[/decoment|decoment 删除注释]]
|}
|}
== 构建工具 ==
{| class="wikitable"
|-
|  [[/webpack|webpack]] ||  [[/rollup|rollup]] ||  [[/parcel|parcel]]
|-
|  [[/requirejs|requirejs]] ||  [[/browserify|browserify]] || 
|}
== 模块类型 ==
* [[/CJS|CJS]]: CommonJS
* [[/AMD|AMD]]: Asynchronous Module Definition
* [[/UMD|UMD]]: Universal Module Definition
* [[/ESM|ESM]]: ECMAScript modules
* [[/IIFF|IIFF]]: Immediately Invoked Function Expression
* [[/systemjs|systemjs]]:
* [[/Revealing|Revealing]]:


== 框架 ==
== 框架 ==
第131行: 第158行:
{| class="wikitable"
{| class="wikitable"
|-
|-
| [[/npm|npm]] || [[/npx|npx]] || [[/yarn|yarn]] || [[/lerna|lerna]] || [[/monorepo|monorepo]]
| [[/npm|npm]] || [[/npx|npx]] || [[/yarn|yarn]] || [[/pnpm|pnpm]]|| [[/lerna|lerna]] || [[/monorepo|monorepo]] || [[/Node-pre-gyp|node-pre-gyp]]
|}
|}


第138行: 第165行:
{| class="wikitable"
{| class="wikitable"
|-
|-
| [[/n|n]] || [[/nvm|nvm]] || 示例
| [[/n|n]] || [[/nvm|nvm]] || [[/Fnm|fnm]]
|}
|}


第146行: 第173行:
| chunk || [[/事件处理机制|事件处理机制]] || [[/ES模块删除的函数|ES模块删除的函数]]
| chunk || [[/事件处理机制|事件处理机制]] || [[/ES模块删除的函数|ES模块删除的函数]]
|-
|-
| [[/JSON文件|JSON文件]] || [[/tree-shaking|tree-shaking]] || pjax
| [[/JSON文件|JSON文件]] || || pjax
|-
|-
| mvvm || hashbang || 示例
| mvvm || hashbang || 示例
|}
== 代码解析 ==
{| class="wikitable"
|-
| [[/tree-shaking|tree-shaking]] || [[/dead-code|dead-code]] || 示例
|-
| 示例 || 示例 || 示例
|-
| 示例 || 示例 || 示例
|}
|}


第211行: 第248行:
=== 单位换算 ===
=== 单位换算 ===
==== base64 - kb ====
==== base64 - kb ====
{{leftrightflex|<syntaxhighlight lang="javascript">
{{Double-columns|<syntaxhighlight lang="javascript">
const size = (base64) => {
const size = (base64) => {
   return (base64.length/1024).toFixed(2);
   return (base64.length/1024).toFixed(2);
第246行: 第283行:
| [[/线程|线程]] || [[/事件循环线程|事件循环线程]] || [[/工作线程|工作线程]]
| [[/线程|线程]] || [[/事件循环线程|事件循环线程]] || [[/工作线程|工作线程]]
|}
|}
== 终止进程 ==
{| class="wikitable"
|-
! 标题文字 !! 标题文字 !! 标题文字
|-
| 退出,n 取值 1~255 || process.exit(1) || {{Shc_out|<syntaxhighlight lang="bash">
node -e "process.exit(10)"
echo $?</syntaxhighlight>|<syntaxhighlight lang="bash">10
</syntaxhighlight>|$|/home/kangkk}}
|-
| 捕获的异常 || throw new Error() || 示例
|-
| promise || Promise.reject() || 示例
|-
| 错误事件 || EventEmitter#emit('error') || 示例
|-
| 信号 || kill <PROCESS_ID> || 示例
|}
=== process ===
侦听 uncaughtException 事件来拦截未捕获的错误。
<syntaxhighlight lang="javascript">
process.on('uncaughtException', (error) => {
  // TODO
  process.exit(1);
});</syntaxhighlight>
unhandledRejection
<syntaxhighlight lang="javascript">
process.on('unhandledRejection', (reason, promise) => {});</syntaxhighlight>


== 思考 ==
== 思考 ==