@apexearth/egrep

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

egrep for node!

原始使用文档
文档目录5 节
  1. Installation
  2. Node.js Usage
  3. Options
  4. Command Line Usage
  5. Compatibility

egrep

Travis Status Coverage Status NPM Downloads install size License

egrep for Node.js (Extended Global Regular Expressions Print)

Installation

Use with Node.js

$ npm install @apexearth/egrep --save

Use with Command Line

$ npm install @apexearth/egrep -g

Node.js Usage

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

Output:

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

Use with callback:

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)
})

Output:

test_files/file1.txt:aaaaaaatest4aaaaaaa

Options

  • files: The files, folders, or globs to grep.
  • pattern: The pattern to grep for.
  • glob: Treat files option as a glob.
  • recursive: Recursively grep through folders.
  • ignoreCase: Perform case insensitive matching.
  • excludes: Array of RegExp exclusions.
  • objectMode: Set false to receive string data.
  • fullBinaryMatches: Set true to display the full binary match.
  • hideBinaryMatches: Set true to hide all binary matches.

Command Line Usage

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

Examples:

$ 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

Compatibility

Node.js versions 8, 10, and 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 是什么?

egrep for node!

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