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

@zjonsson/arrsac

v0.0.2

Published

Robust line fitting for Node.js powered by a Rust implementation of ARR-SAC.

Readme

arrsac

Robust line fitting for Node.js powered by a Rust implementation of ARR-SAC.

This package exposes a single function arrsacLine(x, y, options) that estimates a best-fit line while rejecting outliers, and returns rich quality metrics.

Install

npm i arrsac
# or
yarn add arrsac

Prebuilt native binaries are provided for major platforms and architectures. No toolchains are required for installation under normal circumstances.

Quick start

import { arrsacLine } from 'arrsac'

const x = [0, 1, 2, 3, 4, 5]
const y = [0.1, 1.0, 2.0, 2.9, 4.2, 20] // 20 is a clear outlier

const result = arrsacLine(x, y, { inlierThreshold: 0.5 })

if (result) {
  console.log('slope/intercept', result.slope, result.intercept)
  console.log('numInliers', result.numInliers, 'of', result.numPoints)
  console.log('R^2 (inliers)', result.r2Inliers)
  console.log('inlier indices', result.inliers) // 0-based indices
}

API

arrsacLine(x: number[], y: number[], options?: ArrsacOptions | null): ArrsacResult | null
  • Returns null when x and y have different lengths or fewer than 2 points.
  • Inlier indices are 0-based and refer to positions in the input arrays.

ArrsacOptions

  • inlierThreshold (number, default 0.3): Residual threshold used by ARR-SAC to classify inliers.
  • minSlope (number | undefined): Reject candidate models with slope less than this value.
  • maxSlope (number | undefined): Reject candidate models with slope greater than this value.
  • minIntercept (number | undefined): Reject candidate models with intercept less than this value.
  • maxIntercept (number | undefined): Reject candidate models with intercept greater than this value.

ArrsacResult

  • slope (number): Estimated line slope.
  • intercept (number): Estimated line intercept.
  • inliers (number[]): 0-based indices of inlier points.
  • r2All (number): R² over all points. May be NaN if degenerate.
  • r2Inliers (number): R² over inliers only. NaN if fewer than 2 inliers.
  • rmseAll (number): RMSE over all points. NaN if no points.
  • rmseInliers (number): RMSE over inliers. NaN if no inliers.
  • madAll (number): Median absolute deviation of residuals over all points.
  • madInliers (number): MAD over inliers.
  • iqrAll (number): Interquartile range of residuals over all points.
  • iqrInliers (number): IQR over inliers.
  • inlierRatio (number): numInliers / numPoints.
  • numInliers (number)
  • numPoints (number)
  • maxAbsResidual (number): Maximum absolute residual across all points.
  • threshold (number): The inlier threshold actually used.

Notes and tips

  • ARR-SAC is stochastic; this binding uses a fixed RNG seed for reproducibility.
  • For nearly vertical lines, ARR-SAC returns an extremely large slope with a corresponding intercept to approximate verticality.
  • Constraining minSlope/maxSlope and/or intercept bounds can reduce false positives in noisy domains.

Platform support

Prebuilt binaries are published for:

  • macOS (x64, arm64)
  • Linux (x64 gnu/musl, arm/arm64 gnu/musl, riscv64 musl, ppc64, s390x)
  • Windows (x64, arm64)
  • FreeBSD (x64, arm64)

The loader will automatically pick the correct binary. If no suitable binary is found, loading will fail with a detailed error containing the attempted targets.

Browser / WASI (experimental)

Experimental WASI support is wired into the loader. If you provide a WASI build (arrsac-wasm32-wasi) or ./arrsac.wasi.cjs and set NAPI_RS_FORCE_WASI=1, the module will attempt to load the WASI variant. A helper worker script is included at wasi-worker-browser.mjs for integrating with @napi-rs/wasm-runtime in Web Workers.

This path is experimental and not published by default; you are expected to provide the WASI artifact yourself.

Development

Requires recent Rust and Node.js.

git clone <this repo>
cd arrsac
yarn
yarn build   # build native addon in release mode
yarn test    # run tests

Benchmark script is available via yarn bench.

License

MIT