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

@mapeo/legacy-export-format

v0.3.0

Published

reading and writing legacy Mapeo data archives

Readme

Mapeo Legacy Export Format

The Mapeo Legacy Export Format is a format for reading and writing legacy Mapeo data. It can be used to export data from Mapeo to be transformed for import into CoMapeo, or for some other purpose.

The file format

.mlef files are just ZIP files with a different extension.

They contain two folders:

  • docs/, which contains all documents and their versions.
  • media/, which contains all media, such as photos.

Documents and media are identified by a hex-encoded ID, such as 74cb70988a17b6e4. They're nested in prefixed folders to help avoid extremely large directories. For example, 74cb70988a17b6e4 is placed in 74/74cb70988a17b6e4/.

All of a document's versions are in the same folder. The first version will be called _.json and subsequent versions will be named with their version number.

Here's an example directory structure:

docs/
├─ d2/
│  └─ d2b6e3d72200c082/
│     └─ _.json
└─ 74/
   └─ 74cb70988a17b6e4/
      ├─ _.json
      ├─ 54aef99c451b09d15f9a3e8f0059fe8d5a97ee2b2f0cb605e3f04153c5723012@0.json
      └─ 54aef99c451b09d15f9a3e8f0059fe8d5a97ee2b2f0cb605e3f04153c5723012@4.json

media/
├─ original/
│  ├─ 4b/
│  │  └─ 4b04270213860542d3fb2d56275fe12f.jpg
│  └─ 9e/
│     └─ 9e657b791646d5c8e1214c4b020a9dd3.jpg
├─ preview/
│  ├─ 4b/
│  │  └─ 4b04270213860542d3fb2d56275fe12f.jpg
│  └─ 9e/
│     └─ 9e657b791646d5c8e1214c4b020a9dd3.jpg
└─ thumbnail/
   ├─ 4b/
   │  └─ 4b04270213860542d3fb2d56275fe12f.jpg
   └─ 9e/
      └─ 9e657b791646d5c8e1214c4b020a9dd3.jpg

Writing data

The write function takes a kappa.db folder as input, and the path of the output MLEF file. For example:

import { write } from 'mapeo-legacy-export-format'

const input = '/path/to/kappa.db'
const output = '/path/to/exported.mlef'
await write(input, output)

Refer to the tests for a detailed example.

Reading data

The reader function returns a Promise that resolves with a Reader instance. This instance lets you iterate over all documents and their versions. It also lets you fetch media. It should be closed when you're finished.

import { reader } from 'mapeo-legacy-export-format'

const mlefPath = '/path/to/exported.mlef'

const r = await reader(mlefPath)

for await (const document of r.documents()) {
  console.log('Document ID:', document.id)
  for (const documentVersion of document.versions) {
    console.log(
      'Document version (null if first version):',
      documentVersion.version
    )
    console.log('Raw document:', documentVersion.document)
    console.log('Hypercore metadata:', documentVersion.hypercoreMetadata)
  }
}

for await (const mediaVariant of r.getMediaById('abc.jpg')) {
  console.log(
    'Media variant (such as "original" or "preview"):',
    mediaVariant.variant
  )
  console.log('Bytes:', mediaVariant.data)
}

await r.close()

Refer to the tests for a detailed example.