UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

24 lines 681 B
/** * getSumableNumber will take any value and convert it to a number that can be sumable like: * x += numb; * x += getSumableNumber( numb, 'parseFloat', 0 ); * * @param numb * @param forStrings * @param forNAN * @returns */ export function getSumableNumber(numb, forStrings = 'zero', forNAN = 0) { let result = forNAN; if (typeof numb === 'number') { result = numb; } else if (typeof numb === 'bigint') { result = Number(numb); } else if (typeof numb === 'string') { result = forStrings === 'parseFloat' ? parseFloat(numb) : 0; } return result; } //# sourceMappingURL=getNumber.js.map