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

@capsuleer/calc

v1.0.1

Published

Calculator module for capsuleer — evaluate math expressions, round numbers, and compute descriptive statistics

Downloads

126

Readme

@capsuleer/calc

Calculator module for Capsuleer agents. The world's most over-engineered calculator — but that's the point. Lets agents evaluate math expressions, round results, and crunch descriptive statistics, with every operation emitting a structured trace event so nothing gets lost in the noise.

capsuleer install calc

No dependencies. No eval(). No regrets.


API

Expressions

// Basic arithmetic
const result = await calc.evaluate("(42 * 1.5) + 8")
// → 71

// Math functions and constants
const hyp = await calc.evaluate("sqrt(pow(3, 2) + pow(4, 2))")
// → 5

const circle = await calc.evaluate("PI * pow(7, 2)")
// → 153.93804002589985

// Chaining with prior results
const raw = await calc.evaluate("1 / 3")
const clean = await calc.round(raw, 4)
// → 0.3333

Supported functions: sqrt, cbrt, abs, ceil, floor, round, log, log2, log10, sin, cos, tan, asin, acos, atan, atan2, pow, min, max

Constants: PI, E

Rounding

await calc.round(3.14159, 2)   // → 3.14
await calc.round(1234.5)       // → 1235  (nearest integer)
await calc.round(0.1 + 0.2, 10) // → 0.3  (float noise begone)

Statistics

const scores = [88, 92, 75, 100, 61, 84, 90]
const s = await calc.stats(scores)
// → {
//     count: 7,
//     sum: 590,
//     mean: 84.28...,
//     median: 88,
//     min: 61,
//     max: 100,
//     range: 39
//   }

Observability

{ "ok": true, "op": "calc.evaluate", "data": { "expr": "sqrt(144) + 3 ** 2", "result": 21 } }
{ "ok": true, "op": "calc.round", "data": { "value": 3.14159, "decimals": 2, "result": 3.14 } }
{ "ok": true, "op": "calc.stats", "data": { "count": 7, "result": { "mean": 84.28, "median": 88, ... } } }

Safety

evaluate() does not use eval(). Expressions are validated against an allowlist of characters and identifiers, then executed via new Function() with only the math environment in scope. Property access (.) and assignment (=) are explicitly blocked. Anything that doesn't look like a math expression throws immediately.


Policy

const capsule = await Capsule({
  policy: {
    calc: {
      evaluate: true,
      round: true,
      stats: true,
    }
  }
})

See the policy docs for the full rule syntax.