# @apexearth/egrep 中文文档

规范地址：https://npmcn.com/package/%40apexearth/egrep/

版本：1\.0\.9
npm 元数据更新时间：2022-04-04T14:33:13.051Z
中文译文更新时间：2026-11-06T09:11:11.226Z
软件包许可：ISC

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40apexearth/egrep
原文对照：https://npmcn.com/package/%40apexearth/egrep/?lang=original
项目主页：https://github.com/apexearth/egrep#readme
源码仓库：https://github.com/apexearth/egrep

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：29.5 kB，10 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：4 个
- 首次发布：2019-02-01T08:16:36.369Z
- 最新版本发布：2020-04-14T01:31:47.254Z
- 近 30 天下载量：5703（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：8（近 12 个月 0 个）

## 中文简介

节点的信号!

## 安装

```sh
npm install @apexearth/egrep
```

也可以使用：`pnpm add @apexearth/egrep`、`yarn add @apexearth/egrep`、`bun add @apexearth/egrep`

## README

# 图像

[![Travis Status](https://travis-ci.org/apexearth/egrep.svg?branch=master)](https://npmcn.com/package/%40apexearth/egrep/\(https://coveralls.io/github/apexearth/egrep?branch=master\)) [![Coverage Status](https://coveralls.io/repos/github/apexearth/egrep/badge.svg?branch=master)](https://coveralls.io/github/apexearth/egrep?branch=master) ![NPM Downloads](https://img.shields.io/npm/dw/@apexearth/egrep.svg?style=flat) [![install size](https://packagephobia.now.sh/badge?p=@apexearth/egrep)](https://packagephobia.now.sh/result?p=@apexearth/egrep) ![License](https://img.shields.io/npm/l/@apexearth/egrep.svg?style=flat)

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

## 安装

用节点.js

```
$ npm install @apexearth/egrep --save
```

带有命令行的使用

```
$ npm install @apexearth/egrep -g
```

## 节点使用

```javascript
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')
})
```

输出 :

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

重复使用 :

```javascript
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 是什么？

节点的信号\!

### 如何安装 @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 和提交记录判断。

