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

bun-libclang

v0.0.1

Published

[clang C](https://clang.llvm.org/doxygen/group__CINDEX.html) binding for TypeScript using [bun FFI](https://bun.com/docs/runtime/ffi), with comprehensive TypeScript-native object wrapper

Readme

bun-libclang

clang C binding for TypeScript using bun FFI, with comprehensive TypeScript-native object wrapper

You can use it to parse C/C++/ObjC source codes and extract informations.

Background

I just want to grab some enum definitions from Xcode.app for bun-objc, why it's that hard :)

Install

You need Bun and libclang library (often bundled with llvm) to use this library. These are all dependencies.

Core facilities are in bindings.ts, which contains clang C foreign definitions, and index.ts, which builds the API from definitions.

Usage

Above everything, you should call load() before using any of API or function in bun-libclang. This function will open the libclang dynamic library and load FFI functions for you. Always call it first! You can specify the path of your libclang library, or it will try guessing it and finally fallback to DYLD_LIBRARY_PATH.

All clang C data structures have been properly wrapped into native JS objects, for example, new CXCursor() will gives you a "NULL Cursor", which essencially equal to libclang!.getNullCursor(), corresponds to clang_getNullCursor() in C.

You don't need to care about memory management when using the object wrapper. The object wrapper have integrated into JS object finalization protocol, which will dispose resource in C alongside with the garbage collection of JS object.

A typical routine is like:

import { load, CXIndex, CXTranslationUnit, CXCursor } from "./index";
import { CXChildVisitResult } from "./bindings";

load();
const idx = new CXIndex()
const tu = CXTranslationUnit.fromSource(idx, './test/hello.c');
const rootCursor = tu.cursor;
rootCursor.visitChildren((cursor, parent) => {
  // do your things here
  return CXChildVisitResult.recurse;
});

For those needs comprehensive control over FFI, You can use libclang object for raw foreign function access. makeCXCursorVisitor() can be used to create CXCursorVisitor callback function eazily from JS.

By-value structures are properly wrapped into ArrayBuffer using N-API.

See the test folder and official clang C documentation for how to use. You can also consult AI for typical routines.

Todo

This is my hobby project, thus I'm not prioritizing it. If you want any features or need any help, feel free to send an email or open a ticket, and I'll try my best to fullfill your request.

  • [ ] Object wrapper for sections below CINDEX_DEBUG of Index.c (~1000 lines) is incomplete;
  • [ ] Object wrapper for CINDEX_CPP section lacks documentation;
  • [ ] Needs more tests;