aaronhuggins / node-x12

ASC X12 parser, generator, query engine, and mapper; now with support for streams.
https://aaronhuggins.github.io/node-x12/
MIT License
49 stars 14 forks source link

Implement support for streams with `X12Parser.parseStream()` #1

Closed ahuggins-nhs closed 4 years ago

ahuggins-nhs commented 4 years ago

Library currently depends on reading in a file to memory and operating on the string there. This may have high memory cost associated with large ASC X12 EDI files. Adding a parser for streams based on the X12Parser.parse() method logic should be trivial, in theory.

Add a X12Parser.parseStream() method which accepts parameters of ediStream: ReadStream and options?: X12SerializationOptions. Method will return a stream which can be used to emit the different X12Segments which are found in the document.

Add a X12Parser.readStream() method which accepts contiguous X12Segments and returns an X12Interchange or X12FatInterchange.

ahuggins-nhs commented 4 years ago

Enhancement complete with version 1.3.0.

ahuggins-nhs commented 4 years ago

API completed is different from proposed. Please see API docs and example from README for details on the implementation.