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

@glion/annotate-delimiters

v0.16.0

Published

Unified plugin to annotate file.data with HL7v2 delimiters derived from MSH-1/MSH-2

Downloads

205

Readme

@glion/annotate-delimiters

Unified plugin to annotate file.data with HL7v2 delimiters derived from MSH-1/MSH-2.

What it does

HL7v2 messages encode their own delimiters in the first two fields of the MSH segment: MSH-1 carries the field separator and MSH-2 carries the component, repetition, escape, and subcomponent characters. This plugin reads those characters from the parsed tree once and stores the resolved Delimiters record on file.data.delimiters so downstream plugins (serializers, escape encoders, profile lints) can consult a single source of truth.

Install

npm install @glion/annotate-delimiters

Use

import { hl7v2AnnotateDelimiters } from "@glion/annotate-delimiters";
import { hl7v2Parser } from "@glion/parser";
import { unified } from "unified";

const processor = unified().use(hl7v2Parser).use(hl7v2AnnotateDelimiters);

const file = await processor.process(
  "MSH|^~\\&|SENDER||RECEIVER||20241201||ADT^A01|MSG123|P|2.5\rPID|1||12345"
);

// file.data.delimiters === {
//   field: "|", component: "^", repetition: "~",
//   escape: "\\", subcomponent: "&", segment: "\r"
// }

API

This package exports the named constant hl7v2AnnotateDelimiters. It is a unified plugin with no options:

import type { Root } from "@glion/ast";
import type { Plugin } from "unified";

export const hl7v2AnnotateDelimiters: Plugin<[], Root, Root>;

The plugin expects a parsed Root tree and a VFile. It never mutates the tree; it only writes to file.data.delimiters.

What it annotates

This plugin writes to file.data, not to AST nodes. It derives the six HL7v2 delimiter characters from the first MSH segment and falls back to the default delimiter set when MSH-1 or MSH-2 is absent.

file.data.delimiters

After this plugin runs, the vfile carries:

interface Delimiters {
  field: string; // MSH-1, e.g. "|"
  component: string; // MSH-2[0], e.g. "^"
  repetition: string; // MSH-2[1], e.g. "~"
  escape: string; // MSH-2[2], e.g. "\\"
  subcomponent: string; // MSH-2[3], e.g. "&"
  segment: string; // segment terminator, e.g. "\r"
}

// Augmented on VFile's DataMap:
// declare module "vfile" {
//   interface DataMap {
//     delimiters: Delimiters;
//   }
// }

Resolution is delegated to the delimiters() helper in @glion/util-query, which walks the tree to find MSH, reads its first two fields, and merges any missing characters with DEFAULT_DELIMITERS from @glion/utils. Messages with no MSH segment receive the full default set.

Part of Glion

@glion/annotate-delimiters is part of Glion, the application framework for HL7v2. See the Glion README for the full package catalog and architecture.