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

napi-stdlib-cli

v1.1.2

Published

A CLI tool to generate native addons for nodejs when provided a C file and it's header file

Readme

napi-stdlib-cli

napi-stdlib-cli is a command-line tool designed to simplify the process of generating native Node.js addons. By providing a source C file with a single function and a corresponding header file, napi-stdlib-cli generates the necessary bindings using the Node-API macros from stdlib-js.

Installation

To install napi-stdlib-cli, use the following command:

npm install -g napi-stdlib-cli@latest

This will globally install the tool, making it accessible from anywhere on your system.

To check your installation, use the following command:

napi-stdlib-cli --version

Usage

napi-stdlib-cli takes a C source file and its header file as input and generates a Node.js addon. Here's an example of how to use it:

napi-stdlib-cli my_function.c my_header.h

See the examples/ directory for detailed instructions on how to use this!

Options:

  • --help: Help command.
  • --version: Version command.

Features

  • Node-API Integration: Leverages the Node-API macros from stdlib-js for seamless addon creation.
  • Simple Workflow: Requires only a single function in the C source file, making it easy to use.

Supported parameter types

| C Type | JavaScript Equivalent | Node-API Macro | | ----------- | --------------------- | -------------------------------- | | double | number | @stdlib/napi/argv_double | | double* | Float64Array | @stdlib/napi/argv_float64array | | float | number | @stdlib/napi/argv_float | | float* | Float32Array | @stdlib/napi/argv_float32array | | int32_t | number | @stdlib/napi/argv_int32 | | int32_t* | Int32Array | @stdlib/napi/argv_int32array | | int | number | @stdlib/napi/argv_int32 | | int* | Int32Array | @stdlib/napi/argv_int32array | | int64_t | bigint | @stdlib/napi/argv_int64 | | int8_t* | Int8Array | @stdlib/napi/argv_int8array | | int16_t* | Int16Array | @stdlib/napi/argv_int16array | | uint8_t* | Uint8Array | @stdlib/napi/argv_uint8array | | uint16_t* | Uint16Array | @stdlib/napi/argv_uint16array | | uint32_t | number | @stdlib/napi/argv_uint32 | | uint32_t* | Uint32Array | @stdlib/napi/argv_uint32array |

Supported return types

| C Type | JavaScript Equivalent | Node-API Macro | | -------- | --------------------- | ---------------------------- | | void | void | - | | double | number | @stdlib/napi/create_double | | float | number | @stdlib/napi/create_double |

Limitations (IMPORTANT)

This tool is still very much under development and has some limitations:

  • Your source C file should include the header that you are providing the path to in the argument
  • Your source C file should only have that one function.
  • The supported function parameters and return types are strictly limited to those listed in the tables above.
  • The header file and the source file should be in the same directory.
  • For any parameter that is an array (e.g., int*, float*, etc.), the corresponding C function must include an additional int or int32_t parameter named N_<variable_name>. This parameter should specify the size of the array to ensure proper memory allocation.

Example

Given the following C source file (my_function.c):

#include "my_header.h"

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

And the corresponding header file (my_header.h):

#ifndef MY_FUNCTION_H
#define MY_FUNCTION_H

int add(int a, int b);

#endif

Running napi-stdlib-cli will generate a Node.js addon that allows you to call the add function directly from JavaScript:

const addon = require("./addon.node");

console.log(addon(2, 3)); // Output: 5

Happy coding with napi-stdlib-cli!