
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
file-extractor
Advanced tools

Extract data from text files or log files using regular expressions.
Extractor scans file line by line. Registred callbacks are notified when a patterm matches current line.
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();
Using an accumulator :
var extractor = require('file-extractor'),
fs = require('fs');
var s = fs.createReadStream(__dirname + '/sample.csv',{});
extractor({'count': 0}).matches(/;(?!(?:[^",]|[^"],[^"])+")/,function(m, vars){
console.log(m);
vars.count ++;
}).on('end', function(vars){
console.log(vars.count + ' matches found.');
}).start(s);
Using watch mode :
var extractor = require('file-extractor');
extractor()
.matches(/regex1/, cb1)
.matches(/regex2/, cb2)
.matches(/regex3/, cb3).watch('sample.txt');
This mode supports wildcards in file names :
var extractor = require('file-extractor');
extractor()
.matches(/regex1/, cb1)
.matches(/regex2/, cb2)
.matches(/regex3/, cb3).watch('/var/log/*.log');
In this case an additionnal parameter is passed to the callback function to indicate which file triggered the pattern.
var extractor = require('file-extractor');
extractor()
.matches(/regex3/, function(match, vars, file){
console.log('pattern found in : ' + file);
}).watch('/var/log/*.log');
$ npm install file-extractor
The constructor function creates a new extractor. Optionnaly pass an accumulator as parameter.
Accumulator may be used to share data across callbacks.
Register a new matching pattern and corresponding callback. Each match is notified using callback.
Return value is this to enable method chaining.
Start scanning stream and notify callbacks. If readableStream is empty use standard input process.stdin.
Start watching file filename for modification, may contains wildcard (see minimatch by @izs). Each new lines will trigger matching callbacks.
Clean up method. Remove any watcher on file.
Sent when end of stream is reached. The current accumulator is given as first parameter to the event listener. Only emited in no-watch mode (start method).
Sent when watching files with wildcards (*) and an error occurred when selecting files. Only emited in watch mode (watch method).
FAQs
Extract data from text files or log files using regular expressions.
We found that file-extractor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.