line-reader-regex

1.0.1 • Public • Published

line-reader-regex

A Node.js package to read a file line by line and extract lines based on a regex match. By default, It returns every line.

Installation

Install my-project with npm

  npm install line-reader-regex

Usage/Examples

const readLinesWithRegex = require('line-reader-regex');

const filePath = 'path/to/your/large/file.txt';
const regex = /your-regex/;

// Without async-await (.then() chaining)
readLinesWithRegex(filePath, regex)
  .then((lines) => {
    console.log("Matching lines:", lines);
  })
  .catch((err) => {
    console.error("Error reading file:", err);
  });

// With async-await
const readFileAsync = async () => {
  const data = await readLinesWithRegex(filePath, regex);
  console.log("🚀 data:", data);
};

Feedback

If you have any feedback, please reach out to me at jarvisfranklinthaker@gmail.com

Authors

Package Sidebar

Install

npm i line-reader-regex

Weekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

3.68 kB

Total Files

5

Last publish

Collaborators

  • franklin_thaker