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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ricsam/formula-engine

v0.2.1

Published

A TypeScript-based spreadsheet formula evaluation library designed for high-performance calculation of formulas across sparse datasets.

Readme

FormulaEngine

A TypeScript-based spreadsheet formula evaluation library designed for high-performance calculation of formulas across sparse datasets.

Features

  • Sparse-aware architecture - Only populated cells consume memory
  • Map-based storage - O(1) cell access with automatic sparse handling
  • Excel-compatible addressing (A1 notation)
  • Multi-sheet support with sheet management
  • Named expressions with global and sheet-level scoping
  • Undo/redo system with command pattern
  • Copy/paste operations with clipboard support
  • TypeScript-first design with comprehensive type safety

Installation

bun install

Quick Start

import { FormulaEngine } from 'formula-engine';

// Create a new engine
const engine = FormulaEngine.buildEmpty();

// Add a sheet
const sheetName = engine.addSheet('Sheet1');
const sheetId = engine.getSheetId(sheetName);

// Set cell values
engine.setCellContent({ sheet: sheetId, col: 0, row: 0 }, 42);
engine.setCellContent({ sheet: sheetId, col: 1, row: 0 }, 58);

// Set a formula (evaluation not yet implemented)
engine.setCellContent({ sheet: sheetId, col: 2, row: 0 }, '=A1+B1');

// Get cell value
const value = engine.getCellValue({ sheet: sheetId, col: 0, row: 0 }); // 42

// Set multiple values at once
engine.setCellContent({ sheet: sheetId, col: 0, row: 2 }, [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
]);

// Get range values
const range = {
  start: { sheet: sheetId, col: 0, row: 2 },
  end: { sheet: sheetId, col: 2, row: 4 }
};
const values = engine.getRangeValues(range); // [[1,2,3],[4,5,6],[7,8,9]]

Development Status

✅ Completed

  • Core type system and interfaces
  • Basic engine structure with sheet management
  • Cell addressing system (A1 notation)
  • Sparse data storage with Map-based implementation
  • Copy/paste operations
  • Named expressions (storage only)
  • Undo/redo infrastructure

🚧 In Progress

  • Formula parser and lexer
  • Formula evaluation engine
  • Dependency tracking system
  • Array formula support

📋 Planned

  • Function library (SUM, AVERAGE, etc.)
  • Array formulas with broadcasting
  • Comprehensive error handling
  • React hooks for integration
  • Performance optimizations

Running Tests

bun test

Architecture

FormulaEngine uses a sparse-aware architecture optimized for spreadsheets where most cells are empty:

  • Sheets store cells in a Map<string, Cell> structure
  • Addresses use zero-based indexing internally, A1 notation externally
  • Formulas will be parsed into ASTs for efficient evaluation
  • Dependencies will be tracked in a directed acyclic graph

License

MIT