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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@openfn/describe-package

v0.0.19

Published

Utilities to inspect an npm package.

Downloads

3,435

Readme

@openfn/describe-package

Utility for inspecting and describing an arbitrary npm package.

Usage

There is a demo project available in examples/compiler-worker.

Inspecting a module

import { Pack, Project, describeDts } from "@openfn/describe-package";

const project = new Project();

// Load a module from Unpkg
const pack = await Pack.fromUnpkg("@openfn/[email protected]");

const packageOrDts = /(?:package.json)|(?:\.d\.ts$)/i;

if (!pack.types) {
  throw new Error(
    `No 'types' field found for ${pack.specifier}`
  );
}

// Download the `package.json` and `.d.ts` files.
const files = await pack.getFiles(
  pack.fileListing.filter((path) => packageOrDts.test(path))
);

// Add the files to the Project filesystem.
project.addToFS(files);

// Add the types entrypoint (e.g. `index.d.ts`) as a 'project file'.
project.createFile(files.get(pack.types), pack.types);

// And finally get a list of exported members from a module.
const operations = describeDts(project, pack.types);

Project

The Project object is a wrapper around the Typescript compiler, providing the necessary hooks to interact with code and module type definitions.

Workers

⛔ Not working currently.

const { startWorker } = await import("@openfn/describe-package/worker");
const worker = await startWorker();
const results = await worker.describeAdaptor("a .d.ts as a string");

Building

There are three scripts:

  • pnpm test
    Runs the tests
  • pnpm run build
    Cleans up dist and builds for packaging for npm.
  • pnpm run watch
    Rebuilds on changes.

The Worker is built in two phases:

  1. Bundle up the worker which includes the TypeScript compiler.
  2. Compile the entrypoint, which injects the worker as a string.

By splitting this up we can produce a single file that can be used in the browser.