nix-evaluator-stats/packages/core
NotAShelf 2819da8e35
build: bump all pnpm dependencies
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I698d6e81aff232410c3705933b8df6f56a6a6964
2026-04-09 08:30:44 +03:00
..
src treewide: adapt for monorepo layout; initial TUI work 2026-04-09 08:28:48 +03:00
package.json build: bump all pnpm dependencies 2026-04-09 08:30:44 +03:00
README.md treewide: adapt for monorepo layout; initial TUI work 2026-04-09 08:28:48 +03:00
tsconfig.json treewide: adapt for monorepo layout; initial TUI work 2026-04-09 08:28:48 +03:00

@ns/core

Core types and parsing logic for Nix evaluator statistics. This package is framework-agnostic and can be used in any JavaScript/TypeScript environment.

Usage

import { calculateChange, parseStats, StatsData } from "@ns/core";

// Parse raw stats from Nix
const raw = JSON.parse(statsJson);
const stats: StatsData = parseStats(raw);

console.log(`CPU Time: ${stats.cpuTime}s`);
console.log(`Expressions: ${stats.nrExprs}`);

// Compare two values
const change = calculateChange(stats.nrThunks, previousStats.nrThunks);
console.log(`Thunks changed by ${change.percent.toFixed(2)}%`);

Version Compatibility

The parser handles different Nix implementations (Nix, Lix, Snix, etc.) by checking for field existence in the raw JSON, since not all implementations expose the same statistics.