@judo/idem
Version:
A powerful and expressive query language designed for filtering and manipulating data
14 lines (13 loc) • 794 B
TypeScript
import { EvalContext } from './evaluate';
import { ASTNode } from './types/ast';
/**
* A robust rounding function for JavaScript that mimics Java's BigDecimal.ROUND_HALF_UP.
* It rounds values like x.5 away from zero (e.g., 2.5 -> 3, -2.5 -> -3).
* Note: The original spec test for `1.5!round()` was incorrect for `ROUND_HALF_UP` which would be 2.
* This implementation rounds to the nearest integer, with .5 rounding up (away from -Infinity).
* The corrected implementation below mimics Java's `RoundingMode.HALF_UP`.
* @param num The number to round.
* @param precision The number of decimal places.
*/
export declare function round(num: number, precision?: number): number;
export declare function dispatch(functionName: string, target: any, args: ASTNode[], ctx: EvalContext): any;