Skip to content

Rulvar API reference


Rulvar API reference / @rulvar/rulvar / sanitizeTokenCount

Function: sanitizeTokenCount()

ts
function sanitizeTokenCount(value): number;

Defined in: packages/core/dist/index.d.ts

One count, repaired in the conservative direction: non-numbers and non-finite values floor to zero (no evidence, no charge and no credit), negatives floor to zero (a negative count can only CREDIT the budget, which hostile telemetry must never do), and fractions round UP so a repaired charge is never an undercharge.

Parameters

ParameterType
valuenumber | undefined

Returns

number