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

node-addon-helper

v0.1.1

Published

Some tool functions simplify the development of node addon

Readme

node-addon-helper

Some tool functions simplify the development of node addon.

Setup

CMake.js

Add include directories to your CMakeLists.txt

execute_process(COMMAND node -p "require('node-addon-helper').include"
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
        OUTPUT_VARIABLE NODE_ADDON_HELPER_DIR
        )

string(REPLACE "\n" "" NODE_ADDON_HELPER_DIR ${NODE_ADDON_HELPER_DIR})
string(REPLACE "\"" "" NODE_ADDON_HELPER_DIR ${NODE_ADDON_HELPER_DIR})

target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_HELPER_DIR})

Usage

Look ./test/ for all usage.

TypeConveter

// test/type_converter.cpp

#include <nhelper/type_conveter.h>

template <typename T>
Napi::Value ExportConvertToT(const Napi::CallbackInfo& info) {
    return Nhelper::TypeConverter<T>::ToJSValue(
            info.Env(), Nhelper::TypeConverter<T>::ToNativeValue(info[0]));
}

Napi::Object InitAll(Napi::Env env, Napi::Object exports) {
    exports.Set("convertBool",
                Napi::Function::New(env, ExportConvertToT<bool>));
}
// test/type_converter.test.js
assert.equal(typeConverter.convertBool(true), true);
assert.equal(typeConverter.convertBool(false), false);

| c++ | js | predicate | |--------------------------------|-------------------------------------|-------------------------------------| | bool | Boolean | true/false | | int8_t | Number | INT8_MIN - INT8_MAX | | uint8_t | Number | UINT8_MIN - UINT8_MAX | | int16_t | Number | INT16_MIN - INT16_MAX | | uint16_t | Number | UINT16_MIN - UINT16_MAX | | int32_t | Number | INT32_MIN - INT32_MAX | | uint32_t | Number | UINT32_MIN - UINT32_MAX | | int64_t | Number | INT64_MIN - INT64_MAX | | float | Number | | | double | Number | | | std::string | Number | | | std::vector | Array/ArrayBuffer/Buffer/TypedArray | T is integral and float_point | | std::vector | Array | T not is integral and float_point | | std::pair<const char*, size_t> | ArrayBuffer/Buffer/TypedArray | pointer of buffer's data and length |

ArgsCheck

check info length

// test/args_check.cpp
#include "nhelper/args_check.h"
Napi::Value ExportCheckInfoLength(const Napi::CallbackInfo& info) {
    constexpr size_t length = 4;
    Nhelper::CheckInfoLength(info, length);
    return info.Env().Null();
}

check info's args type

// test/args_check.cpp
template <typename T>
Napi::Value ExportCheckInfoType(const Napi::CallbackInfo& info) {
    Nhelper::CheckInfoType<T>(info, 0);
    return info.Env().Null();
}

CreateAsyncWorker

Create an async api