Record-21-06


6 月

  • chrome HSTS 策略导致部分域名下的资源或者接口跨域 , 打开 chrome://net-internals/#hsts 底部 delete 相关域名即可

  • vue备注与学习相关已经移动到vue_post中,参考资料 0040-script-setup.md

  • vue-next dev 默认不开启 sourcemap 启动时加上--s 或者 --sourcemap即可

  • String.prototype.match()

    const router = `<router>  group: "one" ; title : "list"    </router>`;
    const regex = /<router>(.+)<\/router>/;
    const result = router.match(regex); // Array
    // 0: "<router>  group: "one" ; title : "list"    </router>"
    // 1: " group: "one" ; title : "list" "
    // groups: undefined
    // index: 0
    // input: "<router>  group: "one" ; title : "list"    </router>"
    
    const str = "Nothing will come of nothing.";
    str.match(); // returns [""]

webpack plugin

  • vite plugin 基于 rollup 工作流定制

  • plugin

    class myPugin {
      apply(compiler) {}
    }
  • Compiler Hooks

  • Compilation Hooks

  • 轮子太多了 babel + chokidar + fs + ast > ⚪

  • 调试技巧见后

v8 https://github.com/v8/v8

  • 快慢数组

  • hash 表

  • 想到了之前看过一个问题 v8 array.prototype.sort 的排序原理 , 查了一下 ,大多数回复就一个链接地址指向一个 n 年前的 v8 分支的 js 文件上 , 撸代码发现 小于 10 就使用插入排序, 10 以上就快速排序

  • 实际上 v8 早就更新为 ArrayTimSort 排序方法

  • third_party > v8 >builtins > array-sort.tq ,一种语法类似 ts 的语言

  • // TODO 整理解析
    function ArrayTimSort(context: Context, sortState: SortState, length: Smi) {
      if (length < 2) return;
      let remaining: Smi = length;
    
      // March over the array once, left to right, finding natural runs,
      // and extending short natural runs to minrun elements.
      let low: Smi = 0;
      const minRunLength: Smi = ComputeMinRunLength(remaining);
      while (remaining != 0) {
        let currentRunLength: Smi = CountAndMakeRun(low, low + remaining);
    
        // If the run is short, extend it to min(minRunLength, remaining).
        if (currentRunLength < minRunLength) {
          const forcedRunLength: Smi = SmiMin(minRunLength, remaining);
          BinaryInsertionSort(low, low + currentRunLength, low + forcedRunLength);
          currentRunLength = forcedRunLength;
        }
    
        // Push run onto pending-runs stack, and maybe merge.
        PushRun(sortState, low, currentRunLength);
    
        MergeCollapse(context, sortState);
    
        // Advance to find next run.
        low = low + currentRunLength;
        remaining = remaining - currentRunLength;
      }
    
      MergeForceCollapse(context, sortState);
      assert(GetPendingRunsSize(sortState) == 1);
      assert(GetPendingRunLength(sortState.pendingRuns, 0) == length);
    }
    

调试 node 程序

  • vscode 断点调试 node 程序 ,比如开发 webpack vite 插件 , electron 桌面应用 ,egg web 应用等
  • 进程守护工具 pm2 或者 modemon // 终端日志输出
  • pm2-dev 启动 // pm2 终端日志输出
  • egg-dev // egg 终端日志输出
  • vscode 断点
  • pm2 start --inspect 启动, 然后 vscode 使用 debug attach 自动附加到带--inspect 标识的进程, 即可使用 vscode 断点调试功能,修改代码后, pm2 会自动重启应用,debug 也会自动重新附加到目标程序。

win11 开发预览版体验

  • 设置中加入预览体验计划
  • 设置中打开相关推送 -收到受到 win11 升级推送
  • 选择 dev 版本 -升级安装即可

其他

  • 6 月事情有点多 不太顺心

Author: yanstars
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source yanstars !
  TOC