x12-parser is a robust and efficient Node.js library designed for parsing X12 Electronic Data Interchange (EDI) files. Leveraging the native Node.js stream API, it specializes in handling exceptionally large multi-gigabyte files by processing them in chunks, significantly reducing RAM usage compared to in-memory parsers. The library is fully typed with TypeScript, boasts 100% code coverage, and has zero production dependencies, making it a lightweight and reliable choice for EDI processing workflows. The current stable version is 1.3.0, with recent updates focusing on TypeScript and ESM conversion, indicating an active development cadence. It exports both CommonJS and ES Modules, easing integration into modern Node.js environments. Key differentiators include its stream-first approach for performance and memory efficiency, complete type definitions, and minimal external footprint, ideal for scenarios requiring high-throughput EDI parsing.
npm install x12-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to parse an X12 EDI file using `X12parser` as a Node.js Transform stream, handling data and errors for each parsed segment.
Migrate your project to use ES module `import { X12parser } from 'x12-parser';` statements. Ensure your `package.json` specifies `"type": "module"` or use `.mjs` file extensions.When providing options to the parser, always pass an object: `new X12parser({ defaultEncoding: 'utf8' })`.Adapt your logic that consumes the parsed segment objects to account for the normalized (zero-stripped) numerical keys instead of expecting original X12 format keys.
Design your grouping schemas to break down X12 files into smaller, manageable chunks or logical envelopes, rather than attempting to group entire multi-gigabyte files into a single object.
Ensure your project is configured for ES Modules and use `import { X12parser } from 'x12-parser';` then `new X12parser();`.Add the import statement `import { createReadStream } from 'node:fs';` at the top of your file.Inspect the X12 file for data integrity, correct encoding, and adherence to the X12 standard. You may need to sanitize or pre-process the input file.
Ensure that the input stream (e.g., `fs.createReadStream`) properly signals its end and no further data is piped into the parser once the source is exhausted or destroyed. Implement proper error handling and 'end' event listeners.
No dependency data recorded yet.