@apexearth/egrep

中文文档
1.0.9发布于 2020/04/14ISCCommonJS近 30 天下载 5703

节点的信号!

中文使用文档
文档目录5 节
  1. 安装
  2. 节点使用
  3. 选项
  4. 命令行使用量
  5. 兼容性

图像

Travis Status Coverage Status NPM Downloads install size License

节点标记 (限量全球正则表达式打印)

安装

用节点.js

$ npm install @apexearth/egrep --save

带有命令行的使用

$ npm install @apexearth/egrep -g

节点使用

let egrep = require('@apexearth/egrep')
let stream = egrep({
    pattern: /test[1-9]/,
    files: [
        'test_files/file1.txt',
        'test_files/',
    ],
    recursive: true,
})
stream.on('data', data => {
    console.log(data)
})
stream.on('error', err => {
    console.log(err)
})
stream.on('close', () => {
    console.log('closed')
})

输出 :

{ file: 'test_files/file1.txt', line: 'aaaaaaatest4aaaaaaa' }

重复使用 :

egrep({
    pattern: /test[1-9]/,
    files: [
        'test_files/file1.txt',
        'test_files/',
    ],
    recursive: true,
    objectMode: false,
}, (err, result) => {
    if (err) console.log(err)
    console.log(result)
})

输出 :

test_files/file1.txt:aaaaaaatest4aaaaaaa

选项

  • files: 文件,文件夹,或 grep 的 globs .
  • pattern: 用于grep的图案.
  • glob: 将文件选项视为 glob .
  • recursive:通过文件夹递归grep.
  • ignoreCase: 执行大小写不敏感匹配.
  • excludes: RegExp 排除序列.
  • objectMode设置 false 以接收字符串数据.
  • fullBinaryMatches设置 true 以显示完整的二进制匹配.
  • hideBinaryMatches设置 true 以隐藏所有二进制匹配.

命令行使用量

Usage: node-egrep [options] <pattern> <file...>

Options:
  -V, --version      output the version number
  -r, --recursive    Walk through directories recursively.
  -R, --recursive    Walk through directories recursively.
  -g, --glob         Treat file args as globs.
  -i, --ignore-case  Perform case insensitive matching.
  -f, --file <file>  Read one or more newline separated patterns from file. Empty pattern lines match every input line.
  --exec <cmd>       Execute a command for each match with {1}=file {2}=line
  -h, --help         output usage information

实例:

$ node-egrep 123 test_files/numbers
1234567890

$ node-egrep -r abc test_files
test_files/one/abc:abcdefg
test_files/one/two/letters:abc

$ node-egrep -g abc "test_files/**"
test_files/one/abc:abcdefg
test_files/one/two/letters:abc

兼容性

节点.js版本8,10和11.

版本与发布记录

@apexearth/egrep 共发布 8 个版本,首次发布于 2019/02/01;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.9latest2020/04/146 年前
1.0.82020/04/146 年前
1.0.72019/07/137 年前
1.0.62019/03/087 年前
1.0.52019/02/127 年前
1.0.42019/02/057 年前

关于 @apexearth/egrep 的常见问题

@apexearth/egrep 是什么?

节点的信号!

如何安装 @apexearth/egrep?

在项目目录运行 npm install @apexearth/egrep,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 node-egrep,可以用 npx node-egrep 直接运行。

@apexearth/egrep 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/apexearth__egrep 是否存在。

@apexearth/egrep 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@apexearth/egrep 可以商用吗?

@apexearth/egrep 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@apexearth/egrep 的下载量有多少?

根据 npm 官方下载统计,@apexearth/egrep 在 2026/10/06 – 2026/11/04 这 30 天内被下载 5,703 次,日均约 190 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@apexearth/egrep 还在维护吗?

最新版本 1.0.9 发布于 2020/04/14(6 年前);至今共发布 8 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/02/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。