Nuclear Planning Manual

    easy-read-last-lines

    2.0.1 • Public • Published

    Easy-Read-Last-Lines

    Read the last N lines in the file. (like tail -n)

    Table of contents

    Feature

    • Support setting character encoding
    • Compatible with newlines on different platforms/format: \r, \n, \r\n
    • Support get a String or Buffer object

    Installation

    npm install easy-read-last-lines

    Usage

    // Read last lines of text (tail -n)
    
    // Asynchronous
    erll.read(filePath, 10).then(function(lines) {
        console.log(lines);
    }).catch(function(err) {
        console.log(err.message);
    });
    
    // Synchronous
    let lines = await erll.read(filePath, 10, 'utf8');
    console.log(lines);
    
    // Read last lines buffer data
    let buffer = await erll.readBuffer(filePath, 1);
    console.log(buffer.toString('base64'));

    Functions

    • read(filePath, maxLine, [encoding]): Promise

      • filePath: file path(direct or relative path to file)
      • maxLine: max number of last lines to read in.
      • encoding: When converting between Buffers and strings, a character encoding may be specified. If no character encoding is specified, UTF-8 will be used as the default. buffers-and-character-encodings
    • readBuffer(filePath, maxLine): Promise

    License

    MIT License

    End

    Email:inthinkcolor@gmail.com

    http://www.easyproject.cn

    Donation/捐助:

    
支付宝/微信/QQ/云闪付/PayPal 扫码支付
    支付宝/微信/QQ/云闪付/PayPal

    我们相信,每个人的点滴贡献,都将是推动产生更多、更好免费开源产品的一大步。

    感谢慷慨捐助,以支持服务器运行和鼓励更多社区成员。

    We believe that the contribution of each bit by bit, will be driven to produce more and better free and open source products a big step.

    Thank you donation to support the server running and encourage more community members.

    Install

    npm i easy-read-last-lines

    DownloadsWeekly Downloads

    4

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    15.2 kB

    Total Files

    10

    Last publish

    Collaborators

    • easyproject