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

Purpose of streaming mode? #3

Open
regular opened this issue Jun 21, 2016 · 4 comments
Open

Purpose of streaming mode? #3

regular opened this issue Jun 21, 2016 · 4 comments

Comments

@regular
Copy link

regular commented Jun 21, 2016

Hi Dominic, just a question: What is the purpose of the streaming mode here? As I understand it, if you call reader.read() without a callback, what you get is essentially a transparent through stream, right? What is the use case for this?

Thanks,
Jan

@dominictarr
Copy link
Owner

I use that when I only need to read exact bytes in the header, and then the rest of the stream is handled another way. say, you could use pull-reader to check a magic number, and then divert the rest to an appropiate handler.

in particular i needed this to implement https://github.com/auditdrivencrypto/secret-handshake/
where a header is processed, then the rest of the stream handled by another module (hmm, which incidentially, also uses pull-reader...)

@dominictarr
Copy link
Owner

maybe I could have just passed the pull reader instance to pull-box-stream, but I implemented pull-box-stream first... and so this made it self contained.

@regular
Copy link
Author

regular commented Jun 22, 2016

Interesting. I started work on a pull-stream with a readBits(n) API (pull-bits) (Need it to implement bzip2 decompression). It uses pull-reader internally, so I guess I'll just expose the switch-into-streaming-mode feature (asserting the current stream position is on a byte boundary).

Are you aware of a pre-existing module that does this, so I don't duplicate previous work?

Streaming mode in a bitstream pull-stream could be useful for implementing media de-muxers for formats with tightly packed, non-byte aligned frame header fields, or something.

@dominictarr
Copy link
Owner

I don't know about bzip2, but I know @chrisdickenson implemented zip in js for his git implementation. I don't know what came of that exactly though. the current git-js depends on https://github.com/nodeca/pako/ instead.

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

2 participants