js-code-detector 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -113,8 +113,11 @@ function generateReport(jsonStr) {
113
113
  }
114
114
  async function sameCodeDetect(dirOfCwd) {
115
115
  const filesAndContent = await (0, import_readDirFiles.readSrcFiles)(dirOfCwd);
116
- const { nodeContentGroupList } = import_Core.default.investigate(filesAndContent);
117
- const md = import_Core.default.createMarkdownFile(nodeContentGroupList.slice(0, 5));
116
+ const { nodeContentGroupList, depthList } = import_Core.default.investigate(filesAndContent);
117
+ const top3DepthsSet = [...new Set(depthList)].slice(0, 3);
118
+ const validDepthList = depthList.filter((e) => top3DepthsSet.includes(e));
119
+ const validContentList = nodeContentGroupList.filter((e) => validDepthList.includes(e.depth)).sort((a, b) => b.depth - a.depth);
120
+ const md = import_Core.default.createMarkdownFile(validContentList);
118
121
  (0, import_fs2.writeFileSync)((0, import_path.join)(process.cwd(), `${(0, import_dayjs.default)().format("YYYYMDD_HHmm")}_same_code.md`), md, { encoding: "utf-8", flag: "w" });
119
122
  }
120
123
  // Annotate the CommonJS export names for ESM import in node:
@@ -69,7 +69,7 @@ ${content}
69
69
  nodeContentGroupList,
70
70
  nodeGroupList,
71
71
  countList: nodeContentGroupList.map((e) => e.nodeCount).sort((a, b) => a - b),
72
- depthList: nodeContentGroupList.map((e) => e.depth).sort((a, b) => a - b)
72
+ depthList: nodeContentGroupList.map((e) => e.depth).sort((a, b) => b - a)
73
73
  };
74
74
  }
75
75
  static getFileContentByLine(map, filePath, start, end) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-code-detector",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",