Installation
Install Bonsai with your preferred package manager. The package is ESM-only with TypeScript types included.
bash
bun add bonsai-jsbash
npm install bonsai-jsbash
pnpm add bonsai-jsbash
yarn add bonsai-jsThen import and start evaluating:
ts
import { bonsai } from 'bonsai-js'
const expr = bonsai()
const qualifiesForFreeShipping = expr.evaluateSync(
'order.total >= freeShippingThreshold',
{ order: { total: 120 }, freeShippingThreshold: 100 }
)
console.log(qualifiesForFreeShipping) // trueMost applications start with the same pattern: create one shared instance, load only the stdlib modules you need, use evaluateSync() for sync paths, and use compile() for repeated rules.
Next: Quick Start shows the standard setup pattern.