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

maml-ast

v1.0.0

Published

AST parser for the MAML data format

Readme

maml-ast

AST parser for the MAML data format. Produces a full abstract syntax tree with node types, source positions, and comment preservation — designed for building formatters, linters, codemods, and editor tooling.

For a simpler parser that returns plain JavaScript values, see maml.js.

  • Full AST with discriminated union node types
  • Source positions (offset, line, column) on every node
  • Comments preserved and attached to nodes
  • print() reconstructs source from AST, including comments
  • Zero dependencies, ESM first
  • Works in Node.js, Deno, Bun and browsers

Installation

npm install maml-ast

Usage

Parsing

import { parse, print, toValue } from 'maml-ast'

const doc = parse(`{
  # Database config
  host: "localhost"
  port: 5432
}`)

Printing

print() reconstructs MAML source from an AST, preserving comments:

print(doc)
// {
//   # Database config
//   host: "localhost"
//   port: 5432
// }

Converting to plain values

toValue() strips AST metadata and returns plain JavaScript values:

toValue(doc)  // { host: 'localhost', port: 5432 }

AST Node Types

Every node has a type discriminant and a span with start/end positions.

| Node Type | type | value | raw | |------------|---------------|--------------------|-------| | String | 'String' | string | yes | | Raw String | 'RawString' | string | yes | | Integer | 'Integer' | number \| bigint | yes | | Float | 'Float' | number | yes | | Boolean | 'Boolean' | boolean | — | | Null | 'Null' | null | — | | Object | 'Object' | properties | — | | Array | 'Array' | elements | — |

Keys

Object keys are either IdentifierKey (type: 'Identifier') for bare keys like foo, or StringNode ( type: 'String') for quoted keys like "foo bar".

Comments

Comments are attached to the nearest node:

  • Property.leadingComments — comments on lines before the property
  • Property.trailingComment — comment on the same line after the value
  • ObjectNode.innerComments / ArrayNode.innerComments — comments inside an empty container or after the last entry
  • Document.leadingComments / Document.trailingComments — comments before/after the root value

Document

parse() returns a Document node wrapping the root value:

interface Document {
  type: 'Document'
  value: ValueNode
  leadingComments: CommentNode[]
  trailingComments: CommentNode[]
  span: Span
}

License

MIT