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

Converted Saxophone to transform stream. Added example to read me #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcellino-ornelas
Copy link

Hey matteoselabre,

First off I want to say that this parser is amazing. It took me a while to find a parser that was super fast and low in memory.

However, I need the parsed XML to be sent to another stream for other processing. It was very difficult to do this with your package now. I don't have too many experiences with streams but I converted your parser to be a transform stream for pipe functionality. I also added an example of how I was able to achieve data getting sent to the next stream in the readme.md file before the contributions section.

I ran your test for saxophone and passed all of them. However, I did not have a chance to write my own test.

Not officially asking to merge my work in but hope you'll review and look into it, or develop your own remedy, for people who are running into the same problem. Thanks

@matteodelabre
Copy link
Owner

Hey Marcellino!

Thank you for the kind words. Really sorry for taking so long to answer you. My understanding is that Transform streams are streams that are both Writable (as the Saxophone stream is currently) and Readable, but I’m having trouble figuring out what kind of text you would expect the readable interface to emit in this context. Could you maybe elaborate on your use case for this?

@guerrap
Copy link

guerrap commented Sep 7, 2021

Any update on this? I may be run in the same usecase as @marcellino-ornelas. I'm applying multiple transforms to a stream, using a pipeline, and parser is one of them, but since it's Writable, when I try to pipe it, it throws an error.

const { pipeline } = require("stream");
const pump = util.promisify(pipeline);

await pump(
  readableStream,
  anotherTransform,
  parser,
  fs.createWriteStream(`output-file`)
);

It throws: Cannot pipe, not readable

Making Saxophone extends Transform may be the solution, but I may be wrong since I'm still trying to figure out the whole Duplex stream thing.

@marcellino-ornelas
Copy link
Author

Hey @matteodelabre

I needed this a while ago for a project I was working on but it got put to the side now (not because of this issue). I think my use case was similar to @guerrap that I was trying to pipe the results to another process but was unable to because it wasn't readable it was only writable

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

Successfully merging this pull request may close these issues.

None yet

3 participants