npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ediflow/edifact

v0.2.1

Published

EDIFACT EDI Parser - Format-specific infrastructure for UN/EDIFACT standard

Readme

@ediflow/edifact

EDIFACT EDI Parser - Format-specific infrastructure for UN/EDIFACT standard

Part of the EdiFlow ecosystem - Modern, type-safe EDI parsing for TypeScript/JavaScript.


🆕 Updated in v0.2.0!

This package has been restructured in v0.2.0 for Clean Architecture!

What changed:

  • Clean Architecture - Infrastructure separated from domain
  • Same functionality - All parsers/builders still work
  • Better organized - Clearer code structure

Migration: If you used @ediflow/core parsers before, now use @ediflow/edifact:

// Before (v0.1.x)
import { EdifactMessageParser } from '@ediflow/core';

// After (v0.2.0) - Recommended
import { EdifactMessageParser } from '@ediflow/edifact';

This package provides EDIFACT-specific parsers for the UN/EDIFACT EDI standard. It works with @ediflow/core to parse EDIFACT messages (ORDERS, INVOIC, DESADV, etc.).

import { EdifactMessageParser } from '@ediflow/edifact';
import { ParseEDIUseCase } from '@ediflow/core';

// Parse EDIFACT message
const parser = new EdifactMessageParser(/* ... */);
const parseUseCase = new ParseEDIUseCase(parser, definitionLoader);
const message = parseUseCase.execute(edifactData);

🔄 Migration from @ediflow/core

⚠️ Important: EDIFACT parsers in @ediflow/core are deprecated and will be removed in v1.0.0.

Before (Deprecated):

import { EdifactMessageParser } from '@ediflow/core/infrastructure';

After (Recommended):

import { EdifactMessageParser } from '@ediflow/edifact';

Installation:

# Old way (still works but deprecated):
npm install @ediflow/core

# New way (recommended):
npm install @ediflow/core @ediflow/edifact

🎯 Why a Separate Package?

Clean Architecture:

  • @ediflow/core = Format-agnostic domain & application logic
  • @ediflow/edifact = EDIFACT-specific parsing infrastructure
  • @ediflow/x12 = X12-specific parsing infrastructure

This allows you to:

  • ✅ Only install parsers you need (tree-shaking)
  • ✅ Keep core small and format-agnostic
  • ✅ Add new formats without bloating core

📥 Installation

npm install @ediflow/core @ediflow/edifact

🚀 Quick Start

import { 
  EdifactMessageParser,
  EdifactDelimiterDetector,
  EdifactTokenizer,
  EdifactSegmentParser 
} from '@ediflow/edifact';
import { ParseEDIUseCase, RepositoryManager } from '@ediflow/core';

// EDIFACT ORDERS D96A message
const edifactData = `UNB+UNOC:3+SENDER+RECEIVER+240204:1200+1++ORDERS'UNH+1+ORDERS:D:96A:UN'BGM+220+ORDER123+9'DTM+137:20240204:102'UNT+4+1'UNZ+1+1'`;

// Setup parsers
const delimiterDetector = new EdifactDelimiterDetector();
const tokenizer = new EdifactTokenizer();
const segmentParser = new EdifactSegmentParser();
const messageParser = new EdifactMessageParser(
  delimiterDetector,
  tokenizer,
  segmentParser
);

// Setup use case
const repositoryManager = new RepositoryManager();
const definitionLoader = createDefinitionLoader(repositoryManager);
const useCase = new ParseEDIUseCase(messageParser, definitionLoader);

// Parse
const message = useCase.execute(edifactData);

console.log(message.getSegments());
// [UNB, UNH, BGM, DTM, UNT, UNZ]

🏗️ Architecture

@ediflow/edifact/
└── infrastructure/
    └── parsers/
        ├── EdifactTokenizer.ts           # Splits EDIFACT into tokens
        ├── EdifactSegmentParser.ts       # Parses segments
        ├── EdifactDelimiterDetector.ts   # Detects delimiters from UNA
        └── EdifactMessageParser.ts       # Full message parsing

🎓 EDIFACT Delimiters

| Delimiter | Default | Purpose | Example | |-----------|---------|---------|---------| | Component | : | Separates composite elements | UNOC:3 | | Data Element | + | Separates data elements | UNB+UNOC:3+... | | Decimal | . | Decimal point | 123.45 | | Escape | ? | Escapes special characters | TEST?+DATA | | Segment | ' | Terminates segments | UNH+1+ORDERS:D:96A:UN' |

UNA Segment (optional): UNA:+.? ' - Defines custom delimiters

📚 Supported Message Types

Works with all EDIFACT versions through data packages:

Common message types: ORDERS, INVOIC, DESADV, ORDRSP, PRICAT, etc.

🧪 Testing

# Run tests
npm test

# Watch mode
npm run test:watch

# Coverage
npm run test:coverage

🔗 Related Packages

📖 Documentation

🤝 Contributing

See CONTRIBUTING.md

📄 License

MIT - See LICENSE


Part of EdiFlow - Modern, type-safe EDI parsing for TypeScript/JavaScript