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

@mdgate/core

v0.6.25

Published

mdgate converter registry: create(), Converter contract, ConvertError

Readme

@mdgate/core

The mdgate converter contract.

@mdgate/core is create(), the Converter interface, and ConvertError. Format packages implement this contract. Applications compose readers with it.

Works in Node.js, Cloudflare Workers, Edge runtimes, and browsers.

npm install @mdgate/core

Why @mdgate/core

Each format package can be used alone. create() is how you build a reader from more than one of them.

Converters compete by sniff score. Content signatures outrank extension hints. Nested converters (ZIP, PDF images, OneNote packages) call back into the same registry.

  • Pure TypeScript
  • No Python runtime
  • No native addons
  • No WASM runtime
  • Zero third-party runtime dependencies

Compose a reader

import { create } from '@mdgate/core';
import { pdf } from '@mdgate/pdf';
import { docx } from '@mdgate/docx';
import { xlsx } from '@mdgate/xlsx';

const read = create([
  pdf(),
  docx(),
  xlsx(),
]);

const markdown = await read(bytes);

The optional second argument is a format hint:

const markdown = await read(bytes, {
  path: 'records.csv',
});

path is never used to read a file from disk.


Write a converter

A converter identifies its input and returns Markdown:

import type { Converter } from '@mdgate/core';
import { documentToMarkdown } from '@mdgate/document';

export function myFormat(): Converter {
  return {
    id: 'my-format',

    sniff(bytes) {
      return looksLikeMyFormat(bytes) ? 2 : 0;
    },

    convert(bytes) {
      return {
        markdown: documentToMarkdown(
          parseMyFormat(bytes),
        ),
      };
    },
  };
}

Content signatures should return 2. Extension hints should return 1.


Errors

A conversion throws when meaningful Markdown cannot be produced.

import { ConvertError, create } from '@mdgate/core';

try {
  const markdown = await read(bytes);
} catch (error) {
  if (error instanceof ConvertError) {
    console.error(error.code);
  }
}

| Code | Meaning | | --------------- | ------------------------------------------- | | unsupported | The format is unknown or unsupported | | malformed | No meaningful content could be extracted | | encrypted | The file is encrypted or password-protected | | missingPart | Required document data is missing | | io | The input could not be read | | resourceLimit | Reserved for resource-limit failures |


Need a complete reader?

npm install @mdgate/converters
import { toMarkdown } from '@mdgate/converters';

const markdown = await toMarkdown(bytes, {
  path: filename,
});

@mdgate/core is part of the open-source mdgate/converters project.

For AI agents, the same converter architecture can be used to extend read_file from text files to real-world document formats.


License

MIT