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

@rebarxyz/calculations

v0.0.28

Published

Calculation management framework for Rebar on-chain computations

Readme

@rebarxyz/calculations

Calculation management framework for Rebar on-chain computations.

Overview

This package provides a simple, type-safe way to define and deploy on-chain calculations that automatically update when their inputs change.

Key Features:

  • Named variable mapping (no more inline string interpolation)
  • Automatic dependency resolution
  • Separate code files (.star) for better syntax highlighting
  • Type-safe registry with TypeScript autocomplete

Installation

pnpm add @rebarxyz/calculations

Usage

1. Create Calculation Files

Create .star files with your calculation logic using friendly variable names:

# calculations/starlark/nouns/average.star
auctions = last_seven_auctions

if len(auctions) == 0:
    return 0

return sum(auctions) / len(auctions)

2. Define Registry

Create a registry that maps variable names to node addresses:

// calculations/registry.ts
import type { CalculationRegistry } from '@rebarxyz/calculations';

export const CALCULATIONS: CalculationRegistry = {
  'nouns/average': {
    name: 'Average of Last Seven Nouns Auctions',
    file: './starlark/nouns/average.star',
    language: 'starlark',
    inputs: (inv) => ({
      last_seven_auctions: inv['nouns/history'].address
    }),
    valueType: 'float',
    unit: 'wei'
  }
};

3. Deploy Calculations

import { createAllCalculations } from '@rebarxyz/calculations';
import { CALCULATIONS } from './calculations/registry';

// After pipeline creates data nodes
const inventory = await createAllCalculations(
  client,
  CALCULATIONS,
  inventory,
  owner,
  './calculations/registry.ts'
);

How It Works

  1. Load: Reads .star file
  2. Transform: Replaces variable names with actual node addresses
  3. Order: Topologically sorts calculations by dependencies
  4. Deploy: Creates calculations on Rebar in correct order

Example

// Registry
'nouns/average': {
  inputs: (inv) => ({
    last_seven: inv['nouns/history'].address  // node123abc...
  })
}

// File: average.star
return sum(last_seven) / len(last_seven)

// After transformation (sent to Rebar):
return sum(node123abc...) / len(node123abc...)

API

createAllCalculations(client, registry, inventory, owner, registryPath?)

Creates all calculations in dependency order.

Returns: Updated inventory with calculation nodes

getCreationOrder(registry, inventory)

Returns calculation keys in topological order.

Returns: string[] - Array of calculation keys

loadCalculation(filePath, def, inventory, registryPath?)

Loads a calculation file and performs variable substitution.

Returns: Promise<string> - Transformed calculation code

License

MIT