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

ro-crate-zip-explorer

v0.4.1

Published

A TypeScript library for browsing and extracting contents within RO-Crate zip archives.

Readme

RO-Crate Zip Explorer

RO-Crate Zip Explorer is a TypeScript library for browsing and extracting RO-Crate metadata files directly within ZIP archives. It provides a read-only interface to access and navigate RO-Crate metadata while leveraging the ro-crate-js library.

✨ Features

  • Supports both local and remote ZIP archives.
  • Browse ZIP archives contents with ease without downloading the entire archive.
  • Extract and parse RO-Crate metadata effortlessly.
  • Fetch and read files from the ZIP archive.
  • Compatible with modern browsers and Node.js environments.
  • Fully typed with TypeScript.

📦 Installation

Install via npm or yarn:

npm install ro-crate-zip-explorer
# or
yarn add ro-crate-zip-explorer

🚀 Usage

[!WARNING] The API is not yet stable and may change until a stable release is reached.

Supported Environments

  • Browser: Works with <input type="file"> for local file selection.
  • Node.js: Supports loading ZIP archives from the filesystem.
  • Remote Files: Can fetch and parse ZIP files over HTTP(S), provided proper CORS headers are configured.

Importing the Library

For ZIP files containing RO-Crate metadata:

import { ROCrateZipExplorer } from "ro-crate-zip-explorer";

or for any other kind of ZIP file:

import { ZipExplorer } from "ro-crate-zip-explorer";

Opening a Local RO-Crate ZIP Archive

import { ROCrateZipExplorer } from "ro-crate-zip-explorer";

const fileInput = document.querySelector('input[type="file"]');

fileInput.addEventListener("change", async (event) => {
  const file = event.target.files[0];

  // Create a new instance of ROCrateZipExplorer
  const explorer = new ROCrateZipExplorer(file);

  // Open the ZIP archive to read the directory structure
  await explorer.open();

  console.log("Total files and directories in the ZIP:", explorer.entries.length);

  // Check if the ZIP file contains a crate
  if (explorer.hasCrate) {
    console.log("RO-Crate metadata found in the ZIP archive.");

    // Ensure the crate metadata is loaded to access the crate
    await explorer.extractMetadata();

    console.log("RO-Crate Root Dataset:", explorer.crate.rootDataset);
  } else {
    console.log("No RO-Crate metadata found in the ZIP archive.");
  }
});

Opening a Remote RO-Crate ZIP Archive

import { ROCrateZipExplorer } from "ro-crate-zip-explorer";

const explorer = new ROCrateZipExplorer("https://example.com/archive.zip");
await explorer.open();

console.log("Total files and directories in the ZIP:", explorer.entries.length);
console.log("RO-Crate Root Dataset:", explorer.crate.rootDataset);

[!TIP] Need to explore a standard ZIP file? Use the ZipExplorer class instead:

import { ZipExplorer } from "ro-crate-zip-explorer";

const explorer = new ZipExplorer("https://example.com/archive.zip");
const zip = await explorer.open();

console.log("Total files and directories in the ZIP:", zip.entries.length);

Promoting a ZipExplorer to ROCrateZipExplorer

import { ZipExplorer, ROCrateZipExplorer } from "ro-crate-zip-explorer";

const explorer = new ZipExplorer("https://example.com/archive.zip");
await explorer.open();

// Just wrap the ZipExplorer with ROCrateZipExplorer
const roCrateExplorer = new ROCrateZipExplorer(explorer);

// Now you can use the ROCrateZipExplorer methods
// You don't need to open the ZIP again but make sure to call extractMetadata
// to load the RO-Crate metadata
await roCrateExplorer.extractMetadata();

console.log("RO-Crate Root Dataset:", roCrateExplorer.crate.rootDataset);

[!IMPORTANT] This library uses the Fetch API to load remote ZIP archives. Ensure the server provides proper CORS headers if hosting files on another domain.

Extracting File Contents

const fileEntry = zip.findFileByName("path/to/file.txt");

if (fileEntry) {
  const fileContents = await explorer.getFileContents(fileEntry);
  console.log(new TextDecoder().decode(fileContents));
} else {
  console.error("File not found in the ZIP archive.");
}

🛠 Example Projects

Explore how RO-Crate Zip Explorer integrates into other projects:

📌 Vue.js Example

A simple Vue.js demo is available in the repository:

🔗 Vue Example: RO-Crate-Zip-Vue

Example Usage in Vue:

<template>
  <input type="file" @change="handleFileUpload" />
</template>

<script setup>
import { ROCrateZipExplorer } from "ro-crate-zip-explorer";

const handleFileUpload = async (event) => {
  try {
    const file = event.target.files[0];
    const explorer = new ROCrateZipExplorer(file);
    const zip = await explorer.open();

    console.log("Total files and directories in the ZIP:", zip.entries.length);
  } catch (error) {
    console.error("Error opening ZIP archive:", error);
  }
};
</script>

📄 License

This project is licensed under the MIT License.