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

peabind

v1.0.1

Published

**peabind** — generate JavaScript ↔ native bindings for QuickJS and WebAssembly

Readme

PEABIND(1)

NAME

peabind — generate JavaScript ↔ native bindings for QuickJS and WebAssembly

SYNOPSIS

peabind <idl> <sources...> --output <file> --target <quickjs|wasm> [--prefix <name>]

DESCRIPTION

peabind is a tool that lets you call C++ code from JavaScript.

You describe your API once (in a simple JSON IDL), and peabind generates everything needed to expose it to JavaScript — either:

  • inside an embedded engine like QuickJS
  • or as a WebAssembly module usable from standard JavaScript

The focus is on usability:

Write C++ → describe it → use it from JavaScript.

You do not need to deal with:

  • JS engine internals
  • manual binding code
  • cross-language memory handling

ARGUMENTS

<idl>

The first positional argument.

Path to the IDL JSON file describing your API.

<sources...>

All remaining positional arguments before flags.

C++ source files implementing the API.

OPTIONS

--output <file>

Output file. Its extension must match the selected target.

--target <quickjs|wasm>

Selects the output type.

  • quickjs → generates C++ bindings
  • wasm → generates JavaScript + WebAssembly module

--prefix <name>

Optional.

Used mainly for the QuickJS target:

  • prefixes generated symbols
  • defines the init function name

Has little practical effect for the WASM target.

BASIC USAGE

Example (WASM)

peabind api.json api.cpp --output module.js --target wasm

Given a api.cpp source file:

int add(int a, int b) {
  return a+b;
}

And a api.json idl description file:

{
  "functions": {
    "add": {"return": "int", "args": ["int","int"]}
  }
}

You can use it from JavaScript like a normal module:

import * as mod from "./module.js";

let result = mod.add(1, 2);

Example (QuickJS)

peabind api.json api.cpp --output bindings.cpp --target quickjs --prefix mod

Integrate in C++:

JSContext *ctx;

// Init quickjs...

mod_init(ctx);

TARGETS

QUICKJS

--target quickjs --output bindings.cpp

Generates:

  • bindings.cpp
  • bindings.h

You compile these into your application.

Entry Point

void mod_init(JSContext *ctx);

Where mod comes from --prefix.

WASM

--target wasm --output module.js

Generates:

  • module.js
  • module.wasm

In this mode:

  • compilation to WebAssembly is handled internally
  • intermediate steps are hidden

You can import the result like a normal JavaScript module.

FUNCTIONS

Functions are exposed as JavaScript functions:

mod.add(1, 2);

CLASSES

C++ classes become JavaScript classes.

IDL:

{
  "classes": {
    "Counter": {
      "methods": {
        "inc": {},
        "get": { "return": "int" }
      }
    }
  }
}

Usage:

let c = new mod.Counter();
c.inc();
console.log(c.get());

COMMON WORKFLOWS

Embedded (QuickJS)

  1. Generate bindings
  2. Compile into application
  3. Call init function
  4. Use from JS

Web / Node.js (WASM)

  1. Generate module
  2. Import in JavaScript
  3. Call functions directly

WHAT PEABIND HANDLES

  • JS ↔ C++ type conversion
  • Function dispatch
  • Object identity across calls
  • Memory safety across the boundary
  • WASM compilation pipeline

LIMITATIONS

  • Requires explicit IDL
  • Output must match target
  • Debugging may involve generated code
  • GC timing is non-deterministic

FILES

QuickJS

bindings.cpp
bindings.h

WASM

module.js
module.wasm

SUMMARY

peabind lets you expose C++ code to JavaScript with a simple interface description, targeting both embedded QuickJS environments and WebAssembly modules.

"decl": ["static", "promise", "expected","allownull"]