Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

read-lines-riched

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-lines-riched

Easy way to read file lines on two directions: from the beginning to the end and from the end to the beginning.

  • 0.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

What is this?

Easy way to read file lines async and efficiently on two directions: from the beginning to the end and from the end to the beginning.

Installing

npm install --save read-lines-riched

Run tests

npm test

Highlights of functionality

  • readLines(file_path[,options]) - Return instance of readLineRiched configured with options to read file lines.

    • options Object (Optional)
      • bChunk Integer - Size in bytes of how many bytes are readed from file at the same time. Default is 1024.
      • dir Integer - 1 read lines from beginning to the end. -1 read lines from the end to the beginning. Default is 1.
  • readLinesStartToEnd(file_path) - Return instance of readLineRiched that read from the beginning of the file to the end reading chunks of 1kb.

  • readLinesEndToStart(file_path) - Return instance of readLineRiched that read from the end of the file to the beginning reading chunks of 1kb.

  • readLineRiched.readNextLine() - Read next line of file based on given configuration.

Usage

Reading from beginning to end using Promise

const readLinesEndToStart = require("read-lines-riched").readLinesEndToStart(file_path);

var func = function () {
    readLinesEndToStart.readNextLine().then(line => {
        if (line) {
            console.log(line);
            func()
        } else
            readLinesEndToStart.closeReader();
    });
};
func();

Reading from end to beginning using Async

const readLinesStartToEnd = require("read-lines-riched").readLinesStartToEnd(file_path);

(async function () {
    var line;
    while (line = await readLinesStartToEnd.readNextLine()) {
        console.log(line);
    }
    readLinesStartToEnd.closeReader();
})();

Reading from end to beginning on chunks of 4kb.

const readLinesRiched = require("read-lines-riched").readLines(file_path, {
        bChunk: 1024 * 4,
        dir: -1
    });

(async function () {
    var line;
    while (line = await readLinesRiched.readNextLine()) {
        console.log(line);
    }
    readLinesRiched.closeReader();
})();

Changelog

All notable changes to this project can be seen here.

Contributing

  1. Fork it on Github https://github.com/Puzzle9900/read-lines-riched
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Copyright (c) 2018 Puzzle9900

Keywords

FAQs

Package last updated on 19 Feb 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc