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

xnl-core

v0.1.4

Published

XNL (Extensible Notation Language) parser for Node and browser with TypeScript types.

Readme

XNL Parser (TypeScript)

Node + browser-friendly parser for the XNL (Extensible Notation Language) format described in doc/ai-guide/XnlDataFormatIntroduce.md.

Install

npm install xnl-core

Usage

import { XNL, parseXnl, stringify } from "xnl-core";

// Parse many
const { nodes, warnings } = XNL.parseMany(`<item a=1 { b = 2 } [ 3 4 ]>`);

// Parse one
const { node } = XNL.parseSingle(`<text a=1 {b=2} #>hello</#>`);

// Unique children (extend-like)
const { node: unique } = XNL.parseUnique("root", `<a {x=1}> <a {x=2}> <b>`);

// Stringify (compact by default)
const compact = stringify({ nodes });

// Pretty stringify
const pretty = XNL.stringify({ nodes }, { pretty: true, indent: 2 });

API

  • parseXnl(input: string): XnlDocument – parse a full XNL string into an AST of nodes plus optional warnings.
  • parseXnlSingleNode(input: string): { node: XnlNode; warnings?: ParseWarning[] } – parse exactly one node; errors if extra content remains.
  • parseUniqueChildren(name: string, input: string, metadata?: AttributeMap, attributes?: AttributeMap): { node: XnlNode; warnings?: ParseWarning[] } – parse multiple sibling elements into a node whose extend children overwrite duplicates with a warning.
  • XNL namespace: XNL.parseMany, XNL.parseSingle, XNL.parseUnique (wrappers around the above) and XNL.stringify.
  • XNL.stringify(value: XnlDocument | XnlNode, options?) – serialize a document or node to XNL. Defaults to compact single-line; pass { pretty: true, indent: 2 } (or string indent) for pretty output.
  • AST nodes carry tag, metadata (inline key=value), optional {} attributes, optional body array ([] block), optional unique extend children (() block with warn+overwrite on duplicate tag names), and optional text/textMarker for <tag ... #>...</#...>.
  • ValueLiteral is primitive-only (String/Boolean/Null/Number). ObjectValue.entries, ArrayValue.items, metadata/attributes, and body all hold XnlNode, so object/array/attribute entries can themselves be elements, values, or comments.
  • Value literals keep numeric kind metadata (Integer vs Float) while using number values in JS/TS.
  • Multiline text blocks dedent like C# triple-quoted strings: drop a leading blank line, then strip the closing tag’s indentation prefix (spaces/tabs) from each line.

Errors

Errors are thrown as XnlParseError with code, line/column, and tag/marker context in the message:

  • UNEXPECTED_EOF – input ended before a structure closed (message names the tag/delimiter).
  • MISMATCHED_TAG – closing text marker did not match opener (message shows expected vs found).
  • DUPLICATE_CHILD – extend ( ... ) block repeated a child name (later overwrote earlier).
  • INVALID_CONTENT – disallowed content for the current body type (e.g., text with []/()), message cites parent tag.
  • INVALID_LITERAL – malformed or unsupported literal.
  • UNEXPECTED_TOKEN – unexpected character while parsing.
  • Warnings (returned, not logged): DUPLICATE_CHILD when extend children repeat names (later overwrites earlier).

Example:

import { parseXnl, XnlParseError } from "xnl-core";

try {
  parseXnl("<wrap ( <a> <a> )>");
} catch (err) {
  const e = err as XnlParseError;
  console.error(e.code, e.message); // DUPLICATE_CHILD ...
}