@teakit/arith
Use this skill when writing code for @teakit/arith.
@teakit/arith exports Arith, an arbitrary-precision decimal arithmetic API
for ESM and browser environments.
Core Rules
- Import with
import { Arith } from "@teakit/arith". - Do not use default imports from
@teakit/arith. - Create values with
Arith.from(...); do not usenew Arith(...)or callArith(...). - Static methods such as
Arith.config()andArith.clone()are valid. - Use string inputs for exact decimal values, especially money-like values.
- Do not generate
BigNumber,Decimal,isBigNumber, orisDecimal. - Do not use JavaScript arithmetic or comparison operators on Arith values.
- Use
Arith.clone()when precision, rounding, or formatting config must stay local. - Use
toFixed()for fixed decimal places andtoFormat()for display strings. - Treat
Arithinstances as immutable. Do not mutatec,e,s, or_isArith.
Workflow
- Identify the operation: creation/configuration, core arithmetic, mathematical functions, rounding/precision/bounds, comparison, predicates, formatting/conversion, allocation, or static utilities.
- Load only the relevant method reference file from
references/. - In that file, read the intro, inline examples,
API Reference,Agent Contract, andAgent Notesbefore generating code. - Prefer
Arith.from(...), exact string inputs, and Arith instance methods in generated code. - If config is needed in reusable code, use a cloned constructor instead of shared
Arith.config(). - For repository changes, run the local verification commands when relevant:
bun run check,bun run typecheck,bun test, andbun run build. - For documentation site changes, also run
bun run docs:build.
Quick Example
Reference Selection
Read the smallest method file that answers the current task. Do not load every reference file unless the user asks for a full API audit.
Creation & Configuration
Core Arithmetic
Mathematical Functions
Rounding, Precision & Bounds
Comparison
Predicates
Formatting & Conversion
- toString
- toFixed
- toExponential
- toPrecision
- toNearest
- toFormat
- toFraction
- toBigInt
- toNumber
- toObject
- toJSON
- valueOf
Static Utilities
- allocate
- sum
- mean
- weightedMean
- median
- quantile
- variance
- std
- covariance
- correlation
- geometricMean
- cumulativeSum
- cumulativeMul
- min
- max
- random