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

rust-jit

v1.0.7

Published

node.JS run Rust language Just In Time

Downloads

17

Readme

node-rust-jit

Build Status

node.JS run Rust language Just In Time

Installation

You can install with npm:

$ npm install rust-jit

Prepare

npm install -g neon-cli

You will also need to install:

On Unix

  • Rust
  • make
  • A proper C/C++ compiler toolchain, like GCC

On Mac OS X

  • Rust
  • Xcode
    • You also need to install the Command Line Tools via Xcode. You can find this under the menu Xcode -> Preferences -> Downloads
    • This step will install gcc and the related toolchain containing make

On Windows

Option 1

Install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator).

Option 2

Install tools and configuration manually:

  • Visual C++ Build Environment:

    • Option 1: Install Visual C++ Build Tools using the Default Install option.

    • Option 2: Install Visual Studio 2015 and select Common Tools for Visual C++ during setup. This also works with the free Community and Express for Desktop editions.

    • Option 3: if you already have Visual Studio 2015 installed and did not install the Common Tools for Visual C++ during setup, you can File -> New -> Project, pick any of the options under Templates -> Other Languages -> Visual C++ then Ok and Visual Studio will offer to install the Common Tools for Visual C++ with a "Install Missing Features" / "You need the Universal Windows App Development Tools to develop Windows app projects." dialog.

    :bulb: [Windows Vista / 7 only] requires .NET Framework 4.5.1

  • Install Rust

  • Launch cmd, npm config set msvs_version 2015

If the above steps didn't work for you, please visit Microsoft's Node.js Guidelines for Windows for additional tips.

How to Use

notice:The compilation is to be put in the startup file of node.js because it is time consuming

example

const RustJit = require("rust-jit");
const path = require("path");

let rustJit  = new RustJit();

let code = `
    let scope = call.scope;
    let option_num = call.arguments.get(scope,0);
    let mut num:i32 = 0;
    if let Some(x1) = option_num {
        if let neon::js::Variant::Integer(x2) = x1.variant() {
            num = x2.value() as i32;
        }
    }
    let mut fibnum:i32 = 1;
    if num>2 {
        let mut a:i32 = 1;
        let mut b:i32 = 1;
        let mut c:i32 = 0;
        for _i in 2..num {
            c=a+b;
            a=b;
            b=c;
        }
        fibnum = c;
    }
    
    Ok(neon::js::JsInteger::new(scope, fibnum))
`;
let rustFibByCode = rustJit.compileSync(code,'JsInteger');
console.log("rustJit.compileSync fib(5)=>5:"+rustFibByCode(5));

let rustFibByFile = rustJit.compileByFileSync(path.join(__dirname,"test.rs"),'JsInteger');
console.log("rustJit.compileByFileSync fib(6)=>8:"+rustFibByFile(6));

Grammar

neon grammar-example neon-github