0.6.1 • Published 11 years ago

file-extractor v0.6.1

Weekly downloads
29
License
-
Repository
github
Last release
11 years ago

file-extractor

Extract data from files with regular expressions.

introduction

Extractor scans file line by line. Registred callbacks are notified when a patterm matches current line.

synopsis

Start extracting stdin :

    var extractor = require('file-extractor');

    extractor().matches(/;(?!(?:[^",]|[^"],[^"])+")/,function(m){
        console.log(m);
    }).start();

Using multiple patterns :

    var extractor = require('file-extractor');

    extractor()
        .matches(/regex1/, cb1)
        .matches(/regex2/, cb2)
        .matches(/regex3/, cb3).start();

installation

$ npm install file-extractor

API

extractor(ac={})

The constructor function creates a new extractor. Optionnaly pass an accumulator as parameters.

.matches(regex, callback)

Register a new matching pattern and corresponding callback. Each match is notified using call back.

  • First callback parameter is regex.exec result.
  • Second parameter is the accumulator object.

Return value is this to enable method chaining.

.start(readableStream=process.stdin)

Start scanning stream and notify callbacks.

Events

'end'

Sent when end of stream is reached.

0.6.1

11 years ago

0.6.0

11 years ago

0.5.0

11 years ago

0.4.0

12 years ago

0.3.0

12 years ago

0.2.1

12 years ago

0.2.0

12 years ago

0.1.0

12 years ago