parseUnit
API / publicodes / parseUnit
function parseUnit(string, getUnitKey): Unit
Defined in: packages/core/src/units.ts:23
Experimental
Parse a unit string into a Unit object
Parameters
Parameter | Type | Description |
---|---|---|
string | string | The unit string to parse |
getUnitKey | getUnitKey | (@experimental DO NOT USE): A function to normalize the unit string |
Returns
The parsed unit object
Example
parseUnit('m/s2')
// returns { numerators: ['m'], denominators: ['s', 's'] }