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

mdx-choose-your-own-adventure

v1.0.4

Published

A utility for parsing an MDX file into a choose your own adventure game.

Downloads

9

Readme

MDX Choose Your Own Adventure Parser

This is a tool designed to transform MDX documents into choose your own adventure stories.

At this time the repo is just a work in progress, a partial MDX parser has been built.

Writing a Choose Your Own Adventure in MDX

See Author Instructions

Usage

$ node
Welcome to Node.js v25.0.0.
Type ".help" for more information.
> const { CYOARunner } = await import("./runner.js");
undefined
> const cyoaRunner = new CYOARunner(JSON.parse(fs.readFileSync("test_output.json", "utf8")))
undefined
> cyoaRunner.passageText
[
  'You arrive in block. A number of hot food vendors line the bedraggled streets and a few catch your eye...'
]
> cyoaRunner.inventory
{ credits: 50 }
> cyoaRunner.transitionOptions
[
  {
    transitionCriteria: 'inventory.credits > 1',
    header: '#suprise-soup',
    text: 'Buy some soup from the woman with 1 cr',
    isValid: true
  },
  {
    transitionCriteria: 'inventory.credits > 100',
    header: '#super-suprise-soup',
    text: 'Buy some really special soup from the woman for 100 cr',
    isValid: false
  },
  {
    transitionCriteria: null,
    header: '#other-thing',
    text: 'Do that other thing',
    isValid: true
  }
]
> cyoaRunner.transition('#suprise-soup')
undefined
> cyoaRunner.inventory
{ credits: 49 }
> cyoaRunner.passageText
[ 'Great soup!\nReally good' ]
> cyoaRunner.isDone
true

Run Tests

npm install
npm test

Example

The following MDX file is consumed:

---
title: Some story
author: John Doe
costToRead: 0
triggers: ["spooky soups", "the great outdoors"]
---

{inventory.credits = 50}

## Start

You arrive in block. A number of hot food vendors line the bedraggled streets and a few catch your eye...

- <If when={inventory.credits > 1}> 
    [Buy some soup from the woman with 1 cr](#suprise-soup)
  </If>
- <If when={inventory.credits > 100}> 
    [Buy some really special soup from the woman for 100 cr](#super-suprise-soup)
  </If>
- [Do that other thing](#other-thing)

## Suprise Soup

{inventory.credits = inventory.credits - 1}

Great soup!
Really good

## Super Suprising Soup

{inventory.credits = inventory.credits - 100}

WOW WOW WOW!
BEST EVER SOUP!

## Other Thing

You do the other thing

Internally, the file is converted to this representation:

{
  "passages": {
    "#start": {
      "initializationScript": [],
      "text": [
        "You arrive in block. A number of hot food vendors line the bedraggled streets and a few catch your eye..."
      ],
      "transitions": [
        {
          "transitionCriteria": "inventory.credits > 1",
          "header": "#suprise-soup",
          "text": "Buy some soup from the woman with 1 cr"
        },
        {
          "transitionCriteria": "inventory.credits > 100",
          "header": "#super-suprise-soup",
          "text": "Buy some really special soup from the woman for 100 cr"
        },
        {
          "transitionCriteria": null,
          "header": "#other-thing",
          "text": "Do that other thing"
        }
      ]
    },
    "#suprise-soup": {
      "initializationScript": [
        "inventory.credits = inventory.credits - 1"
      ],
      "text": [
        "Great soup!\nReally good"
      ],
      "transitions": []
    },
    "#super-suprising-soup": {
      "initializationScript": [
        "inventory.credits = inventory.credits - 100"
      ],
      "text": [
        "WOW WOW WOW!\nBEST EVER SOUP!"
      ],
      "transitions": []
    },
    "#other-thing": {
      "initializationScript": [],
      "text": [
        "You do the other thing"
      ],
      "transitions": []
    }
  },
  "metaData": {
    "title": "Some story",
    "author": "John Doe",
    "costToRead": 0,
    "triggers": [
      "spooky soups",
      "the great outdoors"
    ]
  },
  "initializationScript": [
    "inventory.credits = 50"
  ]
}

Finally, a runner is provided to actually navigate through the choose your own adventure

Security

Never use this package to run untrusted MDX files. Treat MDX files like source code, as any code in those files will be executed.