saxophone icon indicating copy to clipboard operation
saxophone copied to clipboard

Converted Saxophone to transform stream. Added example to read me

Open marcellino-ornelas opened this issue 6 years ago • 3 comments

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

marcellino-ornelas avatar Nov 15 '18 18:11 marcellino-ornelas

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?

matteodelabre avatar Nov 22 '19 19:11 matteodelabre

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.

guerrap avatar Sep 07 '21 16:09 guerrap

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

marcellino-ornelas avatar Jan 19 '22 20:01 marcellino-ornelas