0.1.1 • Published 9 years ago

lineder v0.1.1

Weekly downloads
10
License
MIT
Repository
github
Last release
9 years ago

Lineder Build Status

Finds and returns information on each line of the file that matches a regular expression.

Features

Lineder finds and returns information on each line of the file that matches your search.

  • Search with regular expressions.
  • Get the line number(s) that the matched result was found on.
  • Get the entire line(s) that the matched result was found in.

Getting Started

  • Install with NPM - npm install --save lineder

Usage

var lineder = require( "lineder" );

/* file.txt
   1. this is the text for line one.
   2. this is the text for line two.
   3. this is the text for line three.
*/

lineder( "file.txt", "line two", function( err, results ) {
  //=> [ { line: 2, value "this is the text for line two." } ]
});

API

lineder( path )

NameTypeArgumentDescription
pathstring<required>the path of the file to be searched.

lineder.find( regex, callback )

NameTypeArgumentDescription
regexstring|regex<required>a string or regular expression to search the file for.
callbackfunction<required>callback that returns the results of the search

callback( error, results )

NameTypeArgumentDescription
errorerror<required>any errors that may have occured.
resultsarray<required>an array of objects containg the line number and values from the results of the search.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

License

Copyright (c) 2015 Jason Bellamy
Licensed under the MIT license.