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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@openpkg-ts/sdk

v0.1.0

Published

TypeScript package specification SDK

Readme

OpenPkg SDK

npm version

TypeScript SDK for generating and post-processing OpenPkg specs directly from your tooling.

Installation

# npm
npm install @openpkg-ts/sdk

# bun
bun add @openpkg-ts/sdk

# yarn
yarn add @openpkg-ts/sdk

# pnpm
pnpm add @openpkg-ts/sdk

Quick Start

import { OpenPkg } from '@openpkg-ts/sdk';

const openpkg = new OpenPkg({
  resolveExternalTypes: true,
});

const spec = await openpkg.analyzeFile('./src/index.ts', {
  filters: {
    include: ['createUser', 'deleteUser'],
  },
});

console.log(`exports: ${spec.exports.length}`);
console.log(`types: ${spec.types?.length ?? 0}`);

OpenPkg automatically resolves local sources, merges in declaration files, and keeps type references intact. Use filters.include / filters.exclude to narrow the surface area that lands in the final spec.

Filtering Exports

import { analyzeFile } from '@openpkg-ts/sdk';

const spec = await analyzeFile('./src/index.ts', {
  filters: {
    include: ['publicFunction'],
    exclude: ['internalHelper'],
  },
});

Filtering trims both the exports array and orphaned items under types. The SDK will surface informational diagnostics whenever an identifier cannot be located or when filtering drops transitive types you may still need.

Diagnostics

Use the analyzeFileWithDiagnostics or analyzeWithDiagnostics helpers when you need visibility into parsing or filtering issues.

import { OpenPkg } from '@openpkg-ts/sdk';

const openpkg = new OpenPkg();
const { spec, diagnostics } = await openpkg.analyzeFileWithDiagnostics('./src/index.ts');

diagnostics.forEach((diagnostic) => {
  const location = diagnostic.location?.file
    ? `${diagnostic.location.file}:${diagnostic.location.line ?? '?'}:${diagnostic.location.column ?? '?'}`
    : '(unknown)';
  console.log(`[${diagnostic.severity}] ${location} ${diagnostic.message}`);
});

Diagnostics normalize TypeScript compiler messages into error, warning, and info severity levels so you can decide how to surface them in your own tools.

Programmatic Workflows

Analyze in-memory code

import { analyze } from '@openpkg-ts/sdk';

const spec = await analyze(
  `export const sum = (a: number, b: number) => a + b;`,
  { filters: { include: ['sum'] } },
);

Batch project analysis

import { OpenPkg } from '@openpkg-ts/sdk';
import { glob } from 'glob';

const openpkg = new OpenPkg();
const files = await glob('packages/**/src/index.ts');
const specs = await Promise.all(files.map((file) => openpkg.analyzeFile(file)));

API Surface

  • new OpenPkg(options?)
    • analyze(code, fileName?, options?)
    • analyzeFile(filePath, options?)
    • analyzeWithDiagnostics(code, fileName?, options?)
    • analyzeFileWithDiagnostics(filePath, options?)
  • analyze(code, options?) – convenience wrapper
  • analyzeFile(filePath, options?) – convenience wrapper
  • extractPackageSpec(entry, packageDir, source, options) – lower-level extractor
  • Types: OpenPkgSpec, FilterOptions, AnalyzeOptions, AnalysisResult, Diagnostic

Development

git clone https://github.com/ryanwaits/openpkg.git
cd openpkg
bun install
bun run build:sdk
bun test

License

MIT