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

@rust-js/builtins

v0.0.1

Published

JS's language, as rust-js compiles Rust to it: promises, errors, regular expressions, JSON

Readme

js: the JS language for rust-js

The js crate declares what JS has that Rust's std doesn't, as ReScript's standard library does: its promises, errors and regular expressions, its byte buffers, its JSON, and its global functions, its timers too, as ReScript's has them. What the browser adds is the webapi crate's; what std has, rust-js maps itself. It holds declarations only, so it's never compiled to JS. See ADR 0102.

use js::{decode_uri_component, encode_uri_component, settle, spawn};

let query = encode_uri_component("a b&c");             // encodeURIComponent("a b&c")
let text = decode_uri_component("%E0%A4%A");           // Err: a URIError
spawn(Box::new(async move {                            // runs, unawaited
    match settle(webapi::window::fetch(webapi::window, &url)).await {
        Ok(response) => { .. }                         // what fetch fulfils with
        Err(error) => { .. }                           // a network error: not a throw
    }
}));
  • A promise is a Promise<T>, to .await (ADR 0029); settle(p) makes its .await a Result, and one a binding declares as Promise<Result<T, &JsError>> is one already (ADR 0035).
  • JsError is what JS threw; js_error::to_string(e) is String(e), and js_error::is_error(e) and js_error::message(e) are an Error's.
  • RegExp is there for what Rust would use regex for: reg_exp::new(r"^\d+$", ""), and reg_exp::replace(text, pattern, "$1"). A replacer closure, and matchAll, are a program's own bindings, typed for its pattern's groups.
  • json::stringify(text) is a string's JSON, which is a JS string literal too. A Rust value's JSON is serde's (ADR 0077), and so is reading JSON: what JSON.parse gives is whatever the text holds.
  • object::from_entries(entries) is a JS object of keys and values, as an API taking a dictionary wants, and object::is(a, b) is Object.is: whether two JS objects are one.
  • set_timeout(f, ms) and set_interval(f, ms) run a closure later, or every so often, and clear_timeout and clear_interval of what they gave stop it: every JS runtime has them, browsers', workers' and Node's.
  • number::to_fixed(x, digits) is x.toFixed(digits), JS's rounding: a tie away from zero, 2.5 to "3", where format!("{:.0}", 2.5) is "2".
builtins/build.sh -o "$PWD/target/libjs.rmeta"
./target/debug/rust-js app.rs -- --extern js=target/libjs.rmeta