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

Ability to read text file line by line #495

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

omatrot
Copy link

@omatrot omatrot commented Nov 28, 2019

This PR is about reading text files line by line with an event emitted at each line.
The trick is to send -1 to bufferSize and 'utf8' to encoding in readStream.

@Traviskn
Copy link

Can you elaborate on the motivation for this feature? I'm curious what problem it will solve and how a developer would use it. Does it add new API to rn-fetch-blob? If it does add new API, can you update any relevant README/docs?

@omatrot
Copy link
Author

omatrot commented Dec 19, 2019

The motivation for me was to be able to process a .csv file line by line. Without this modification, it would have been necessary to guess the line length to be sure to allocate a buffer that would hold at least one line.

Furthermore, the ability to pace the onData callback was very usefull in my use case where timing was very important.

This is not a new API, just some parameter tricks to switch to this particular mode.

I will update the Docs later this evening.

@omatrot
Copy link
Author

omatrot commented Dec 20, 2019

I've modified the Wiki accordingly.
Please let me know if you would like something else.

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

Successfully merging this pull request may close these issues.

None yet

2 participants