Native JIT Compilation
Transforms your formulas into native JavaScript functions executed at CPU speed (~2.5M+ ops/s) with zero interpretation overhead.
Evaluate and compile your mathematical & logical formulas at over 2.5 million operations per second in JavaScript and TypeScript.
import { compile } from 'smartcal';
// 1. Compile the formula once into native bytecode
const calculateTax = compile(
'income > 50000 ? (income - 50000) * 0.30 + 5000 : income * 0.10'
);
// 2. Evaluate instantly across thousands of records
console.log(calculateTax.evaluate({ income: 75000 })); // 12500
console.log(calculateTax.evaluate({ income: 30000 })); // 3000import SmartCal from 'smartcal';
// Immediate one-off evaluation
const total = SmartCal('basePrice * (1 - discountRate) + shippingTax', {
basePrice: 150,
discountRate: 0.20,
shippingTax: 12,
});
console.log(total); // 132import SmartCal, { compile } from 'smartcal';
const f_subtotal = compile('price * quantity * (1 - discount)');
const f_tax = compile('f_subtotal * 0.20');
// Automatic topological resolution without calculation duplication
const grandTotal = SmartCal('f_subtotal + f_tax', {
price: 100,
quantity: 2,
discount: 0.1,
f_subtotal,
f_tax,
});
console.log(grandTotal); // 216