UNPKG

@openactive/data-model-validator

Version:

A library to allow a developer to validate a JSON document against the OpenActive Modelling Opportunity Specification

20 lines (18 loc) 330 B
const PrecisionHelper = class { static getPrecision(a) { if (typeof a !== 'number') { return 0; } if (!Number.isFinite(a)) { return 0; } let e = 1; let p = 0; while (Math.round(a * e) / e !== a) { e *= 10; p += 1; } return p; } }; module.exports = PrecisionHelper;