Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonathanprince/grepit
Grep Module for Node
https://github.com/jonathanprince/grepit
Last synced: 11 days ago
JSON representation
Grep Module for Node
- Host: GitHub
- URL: https://github.com/jonathanprince/grepit
- Owner: JonathanPrince
- License: mit
- Created: 2014-11-04T15:09:37.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-05T15:29:35.000Z (about 10 years ago)
- Last Synced: 2024-08-08T18:04:24.331Z (3 months ago)
- Language: JavaScript
- Size: 172 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#grepit
[![Build Status](https://travis-ci.org/JonathanPrince/grepit.svg)](https://travis-ci.org/JonathanPrince/grepit)[![NPM](https://nodei.co/npm/grepit.png?downloads=true&stars=true)](https://nodei.co/npm/grepit/)
##Description
Grep Module for Node
###Syntax
`grep(pattern, file)`
####Parameters
**pattern**
RegExp or String to be searched for. (aka. the 'needle')
**file**
String - path and filename of file to be searched. (aka. the 'haystack')
####Output
Returns an array. The elements of the array will be the lines in which the pattern appears.
###Usage
Installation
```
$ npm install grepit
```test_file.txt:
```txt
The first sentence of the text.
Now the second sentence.
Why not a third, a third that has a comma in it.
And then comes the fourth sentence.
```Example
```jsvar grepit = require('grepit');
var result = grepit(/first/, 'test_file.txt');
// result = [ 'The first sentence of the text.' ]
```