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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dtkdtk/jsnut

v1.3.0

Published

What is "JSNut"? JSNut is a NodeJS NUTive module build tool`

Downloads

77

Readme

JSNut :: Tool for building native NodeJS modules

What is "JSNut"? JSNut is a NodeJS NUTive module build tool. It is very easy to use: npx -- @dtkdtk/jsnut build -f ./src/module.cc -o ./dist/ --onlymod will compile module.cc file into a native NodeJS addon (module.node), which you can import into your JS code using require("./module.node")

API

  • command jsnut

Features

  • Auto-generation of package.json and binding.gyp files
  • Configurable output directory and output file name
  • sort_includes tool [experimental]

Usage

Type npx @dtkdtk/jsnut help to get command help.

Type npx -- @dtkdtk/jsnut build <-f filename> <-o outdir> [-n modname] [--clean|--onlymod] to compile C++ file

Example

[!IMPORTANT]
using namespace STH; in any file causes compilation errors. Please use STH::... instead.

src/module.cc

#include <nan.h>
#include <iostream>
#include "otherfile.hh"

#define MODULE_NAME some_code

void do_nothing(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
    std::cout   << "nothing and "
                << otherfile_function()
                << std::endl;
}

void MODULE_INIT(v8::Local<v8::Object> exports)
{
	auto context = exports->GetCreationContextChecked();
	exports->Set(
		context,
		Nan::New("do_nothing").ToLocalChecked(),
		Nan::New<v8::FunctionTemplate>(do_nothing)->GetFunction(context).ToLocalChecked()
	);
}

NODE_MODULE(MODULE_NAME, MODULE_INIT)

src/otherfile.hh

int otherfile_function();

src/otherfile.cc

#include "otherfile.hh"
int otherfile_function()
{
    return 7;
}

./build-native-addons.bash

#!/usr/bin/env bash
#Warning: it calculates the path to the files from package.json
npx -- @dtkdtk/jsnut build  \
    -f "./src/module.cc"    \
    -f "./src/otherfile.hh" \
    -f "./src/otherfile.cc" \
    -o "./dist"             \
    --clean;
sleep 10s

Result: (file tree)

  • src/
    • otherfile.cc
    • otherfile.hh
    • module.cc
  • dist/
    • module.node (first specified source file name)
    • module.sln
    • module.vcxproj

About the '#include's sorting

[!WARNING]
This feature is experimental and uncompleted (and so unperfect). Use at your own risk

To sort, use the jsnut sort_includes <...src_dirs> command

#include directives are sorted as follows:

  1. Your project headers ("ui/app.h")
  2. Extern libraries (must contain / or .) (<node.h>)

[!NOTE]
Standard C headers are into this category 3. Your libraries (must be in the "lib" directory) ("lib/api.h")

  1. Standart C++ headers (without .h extension) (<iostream>) There is an empty line between categories. The order was borrowed from Google, but with some changes.

[!WARNING]
The tool will remove any not-multiline comments in the '#include's block. Please put them rather (or later) than '#include' directives