simplifyNodeUnit
API / publicodes / simplifyNodeUnit
function simplifyNodeUnit<Node>(node): Node
Simplify if possible the unit of a node
If not used, the result of the evaluation of a node will have the most precise unit possible, in order to prevent rounding errors.
Type Parameters
Type Parameter | Default type |
---|---|
Node extends EvaluatedNode | EvaluatedNode |
Parameters
Parameter | Type | Description |
---|---|---|
node | Node | The node to simplify |
Returns
Node
The node its unit simplified
Example
simplifyNodeUnit(engine.evaluate('42 €/mois * 1 an'))
// returns { nodeValue: 504, unit: { numerators: ['€'], denominators: [] } }