npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

scan-zh

v0.1.3

Published

扫描目录下文件中的简体中文字符工具

Readme

扫描简体中文工具 (scan-zh)

功能特性

  • 🔍 递归扫描指定目录下的所有文件
  • 📝 支持多种文件格式 (txt, html, js, ts, md, json 等, 目前仅支持:html)
  • 🚫 自动过滤简繁体相同的字符 (可配置)
  • 📊 提供详细的统计信息
  • 💾 支持结果导出到文件
  • ⚙️ 灵活的配置选项

安装依赖

npm install scan-zh -g

使用方法

基本用法

Usage: scan-zh [options] [command] <directory>

扫描目录下文件中的简体中文字符工具

Arguments:
  directory            要扫描的目录路径

Options:
  -V, --version        output the version number
  -s, --statistics     显示统计信息 (default: true)
  -o, --output <file>  将结果保存到文件
  -v, --verbose        显示详细信息
  -c, --config <file>  指定配置文件路径
  -h, --help           显示帮助信息

Commands:
  init                 在当前目录生成默认配置文件
  config [options]     查看当前配置

用法示例:
  scan-zh <目录路径> [选项]

选项说明:
  -s, --statistics      显示统计信息(如字符频率、文件数量等), default "true"
  -o, --output <file>   将扫描结果保存到指定文件
  -v, --verbose         显示详细扫描结果
  --config <file>       指定自定义配置文件路径

子命令:
  init                  在当前目录生成默认配置文件
  config                查看当前工具的扫描配置

示例:
  scan-zh ./src
  scan-zh ./src -s -o result.txt
  scan-zh init
  scan-zh config

配置文件

工具支持 JSON 格式的配置文件,配置文件查找顺序:

  1. 用户通过 --config 参数指定的配置文件
  2. 当前工作目录下的 config.json(推荐通过 scan-zh init 生成)
  3. 工具默认配置

配置文件格式示例

{
  "sameSimplifiedTraditional": [
    "一", "二", "三", "人", "大", "小", "中", "文"
  ],
  "supportedExtensions": [
    ".html", ".htm", ".js", ".ts", ".md"
  ],
  "excludedDirs": [
    "node_modules", ".git", "dist", "build"
  ],
  "simplifiedChineseRegex": "[\\u4e00-\\u9fff]"
}

查看配置

# 查看当前配置
scan-zh config

# 查看指定配置文件
scan-zh config -f ./my-config.json

初始化配置文件

# 在当前目录生成一份默认配置文件 config.json
scan-zh init

# 之后可直接运行扫描命令,工具会优先使用当前目录下的配置
scan-zh ./src

输出格式

找到 X 个简体中文字符:

path/to/file.txt  22行  33列  包含简体字 "国"
  上下文: Hello [国] world

path/to/file.html  15行  8列  包含简体字 "语"
  上下文: 这是[语]言测试

内置排除的目录

  • node_modules
  • .git, .svn, .hg
  • dist, build, coverage
  • tmp, temp, .cache