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

@produck/meta-iana-media-type

v0.1.1

Published

IANA Media Types registry as static metadata for Node.js.

Readme

@produck/meta-iana-media-type

IANA Media Types registry as static metadata for Node.js.

Install

npm install @produck/meta-iana-media-type

Usage

The package root exports the snapshot provenance and the data namespace:

import { source, data } from '@produck/meta-iana-media-type';

source.url; // registry URL the snapshot was collected from
source.updated; // exact collection time, ISO 8601
source.digest; // SHA-256 of the document in docs/reference.xml

Every entry of data is keyed by its full media type, type/subtype:

data['application/json'].type; // 'application'
data['application/json'].subtype; // 'json'
data['application/ld+json'].xrefList; // [{ type: 'person', data: 'W3C' }, …]
data['text/html'].date; // registration date, or null

The package ships no aggregated list, no index and no lookup API. It only exposes the records as written in the IANA registry. Building a list, an index, or a query on top of them is the consumer's job.

Enumerating data gives every record module. Pick the fields you need while building your own table:

import { data } from '@produck/meta-iana-media-type';

const bySubtype = new Map();

for (const [mediaType, record] of Object.entries(data)) {
  if (!mediaType.startsWith('application/')) continue;

  bySubtype.set(record.subtype, {
    name: record.name,
    xrefList: record.xrefList,
    date: record.date,
  });
}

bySubtype.get('json').name; // json

Data shape

interface Source {
  url: string;
  updated: string;
  digest: string;
}

interface Xref {
  type: string; // rfc / person / uri / draft / note / rfc-errata / text
  data: string;
}

Every record exports each field by name, with no aggregate object:

| Export | Type | | ---------- | ---------------- | | type | string | | subtype | string | | name | string | | xrefList | Xref[] | | date | string \| null | | updated | string \| null |

type and subtype are split from the media type, so application/json becomes type: 'application' and subtype: 'json', while application/ld+json keeps subtype: 'ld+json'.

A few registrations are aliases of an existing one, written in IANA as <file name="image/x-emf">image/emf</file>. Those get their own file that re-exports the owner record, so data['image/x-emf'] and data['image/emf'] are the same values.

Files

  • src/index.mjs — the source snapshot provenance.
  • src/data/index.mjs — one export * as '<type>/<subtype>' per record.
  • src/data/record/<type>/<subtype>.mjs — one record each.
  • src/data/xref/<type>.mjs — cross references shared by the records.
  • docs/reference.xml — the exact IANA document the data was generated from.

docs/reference.xml is not part of the published package. source.digest is the SHA-256 of that file, so a release can be traced back to the exact upstream document it was built from.

Cross references are deduplicated: rfc, person, draft, note, rfc-errata and text entries become named constants, and uri entries are named after an 8 character MD5 prefix of the URL.

With sideEffects: false, downstream builds can import only the records they use.

Tree shaking

Field level. Each record has its own /<type>/<subtype> entry, exporting the fields separately. Only the fields you import end up in the bundle:

import { name, subtype } from '@produck/meta-iana-media-type/application/json';

Record level, statically. Import the record modules you need by path. Each import is a separate module, so the bundler keeps exactly the records you named and drops the other 2382:

import * as JSON_TYPE from '@produck/meta-iana-media-type/application/json';
import * as HTML_TYPE from '@produck/meta-iana-media-type/text/html';

JSON_TYPE.name; // json
HTML_TYPE.name; // html

Whole registry. The root entry re-exports data, which re-exports every record. It is read at runtime, so a bundler cannot tell which entries you use: any enumeration pulls every record into the bundle.

import { data } from '@produck/meta-iana-media-type';

Object.keys(data); // every type/subtype key

Prefer /<type>/<subtype> when the records are known at build time. Use the data namespace only when you genuinely have to enumerate every registration at runtime.

Notes

  • The registry has no numeric primary key, so records are identified by their type/subtype pair.
  • Subpath names follow the registry casing exactly. 223 subtypes contain upper case characters, for example /application/A2L or /text/SGML. Type and subtype are case sensitive: build the import path from the registry value instead of lowercasing it. On case insensitive file systems a wrongly cased path silently resolves to the nearest existing record instead of failing.
  • example is an empty sub-registry: any subtype may be used, none is registered, so it produces no records.

License

MIT