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

jsagrum

v0.1.2

Published

aGrUM bayesian networks in the browser

Downloads

374

Readme

jsAgrum v0.1: Graphical Models in the Browser

jsAgrum v0.1.X are BETA VERSIONS and still under active development. Some features are unimplemented and there may be bugs. Please file issues if you find them and/or submit feedback using our Feedback form. Thank you for testing jsAgrum!

jsAgrum wraps the capabilities of the aGrUM C++ Bayesian reasoning library for node- and web-based environments. jsAgrum is intended to support in-browser creation and inference of Bayesian Networks, meaning that the resulting models can be manipulated on any device or browser completely independent from hardware. jsAgrum also ensures reliability and security by executing all operations within the browser, eliminating server dependencies or the transfer of confidential data over a network. Complete support for TypeScript is included.

npm install jsagrum

The aGrUM library, the backbone behind jsAgrum, can quickly perform computationally intensive work using optimized algorithms and parallelization. jsAgrum brings this capability to the JavaScript environment by compiling aGrUM to Web Assembly. Different backends are available depending on user preferences:

  • inProcessBN: runs computation directly on the main thread, sans parallelization. It is the only available backend for Node and usually the best choice for small networks.
  • workerBN: runs single-threaded computation on a web worker attached to the main process. Longer computation does not block the main thread, and there are less restrictions compared to parallelized execution.
  • parallelBN [NOT YET IMPLEMENTED]: runs multi-threaded computations on multiple web workers. It is the fastest backend for heavy computation, but has strict requirements on COEPS/COORS headers for websites and thus may present incompatabilities with other APIs.

Performance

Web Assembly is unavoidably slower than native code. The inProcessBN backend is roughly 3-4x slower than native C++ execution, while workerBN is roughly 8-10x slower. Detailed results are available by executing benchmarking in the bench folder. There are minor performance differences depending on whether the inProcessBN backend is ran on browser or in Node.

Above: Performance averaged over 20 runs of creating a Bayesian Network using FastBN syntax as a function of node count.

Above: Performance averaged over 20 runs of performing inference on a Bayesian Network as a function of node count.

Usage

To use the jsAgrum library, install the npm package and import one of the available factory methods (createInProcessBN, createWorkerBN, or the default createBayesNet). These factory functions will create a BayesNet object, which can then be manipulated using one of the many available member functions. Some select functions, such as getNode(), have a specialized return type in TypeScript.

Please note that the near entirety of available functions are asynchronous due to the nature of web workers.

import { createBayesNet } from 'jsagrum';
import type { BayesNet, BNNode } from 'jsagrum';

const bn: BayesNet = await createBayesNet();

const nodeId: number = await bn.addNode('Cloudy', 3, 200, 400)

bn.getNode(nodeId).then((n: BNNode) => {
  console.log("Retrieved node: ", n.name);
});

Documentation

Please visit our documentation for detailed information on available functions and to see examples!

Building from source

Prerequisites

  • Node.js (v18+) — includes npm [ FOR BUILD AND TEST ]

    • Download from https://nodejs.org/
    • Verify: node --version and npm --version
  • Emscripten (v4.0.21) — compiler toolchain [ FOR BUILD ONLY ]

    • Follow: https://emscripten.org/docs/getting_started/downloads.html
    • Verify: emcc --version
  • CMake (v3.15+) [ FOR BUILD ONLY ]

    • macOS: brew install cmake
    • Linux: apt-get install cmake

The jsAgrum build script will automatically search for the emsdk — to maximize success, the emsdk repo should be within or share a common parent with jsAgrum.

Build, Test, and Document

$ cd jsagrum
$ npm install
$ npm test
$ npm run pages:build
$ npm run pages:serve

Documentation will be visible locally at port 4173. The build scripts have only been verified on MacOS.

The beta version of jsAgrum is incompatible with the latest release aGrUM version (2.3.1). We thus anchor jsAgrum to the most recent commit in the dev branch with a passing pipeline for both aGrUM and jsAgrum. The current commit is here. It is possible to instead specify a ref AGRUM_REF to the desired branch or commit SHA, or provide a path AGRUM_LOCAL to compile from a local copy. This will be resolved with the next release of aGrUM.

$ AGRUM_LOCAL=/path/to/aGrUM bash ./build_libagrum_mjs.sh

To enable debug logging, after initial install, call the build script with a debug flag. This replaces the libagrum.mjs and libagrum.wasm files only. In case of a high failed test count, run npm run test:libagrum to solely execute a minimal test suite on the emscripten-compiled module and thus pinpoint bugs at the root.

$ bash ./build_libagrum_mjs.sh -debug
$ npm test
$ npm run test:libagrum

Beta Version Notes

If you have general comments or requests for the jsAgrum, please use our Feedback form. We are actively working on the formal version 1 and would be thrilled to integrate your feedback!

To-do list for jsAgrum:

  • Performance and size optimizations
  • Implementation of parallel execution backend
  • Function to permit moving between backends (i.e. move from inProcess to Worker)
  • Further documentation and examples
  • Expanded i/o support and additional file formats
  • Possible separation of package into modules:
    • jsAgrum/training: Build and train Bayesian graphical networks.
    • jsAgrum/inference: Perform probabilistic inference based on Bayesian networks.
    • jsAgrum/causality: Build and train causal models.