Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read one more line then passed maxLineCount #41

Open
tjx666 opened this issue Mar 15, 2022 · 1 comment
Open

read one more line then passed maxLineCount #41

tjx666 opened this issue Mar 15, 2022 · 1 comment

Comments

@tjx666
Copy link

tjx666 commented Mar 15, 2022

Description

image

Reproduction

code:

const fs = require('fs/promises');
const readLastLines = require('read-last-lines');

async function main() {
    const testPath = '/Users/yutengjing/code/scripting-listener/package-lock.json';
    const lines = await readLastLines.read(testPath, 3, 'utf8');
    console.log(lines.split('\n').length);
}

main();

test txt file:

asaa


bb



Environment

  • Version of this library used: 1.8.0
  • node: 16.14.0
@tjx666
Copy link
Author

tjx666 commented Mar 15, 2022

I know this is caused by: https://github.com/alexbbt/read-last-lines/blob/master/src/index.js#L77

if (NEW_LINE_CHARACTERS.includes(nextCharacter) && lines.length > 1) {
	lineCount++;
}

Don't know why you skip the last line to add lineCount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant