parseUnit

API / publicodes / parseUnit

function parseUnit(string, getUnitKey): Unit

Experimental

Parse a unit string into a Unit object

Parameters

ParameterTypeDescription
stringstringThe unit string to parse
getUnitKeygetUnitKey-

Returns

Unit

The parsed unit object

Example

parseUnit('m/s2')
// returns { numerators: ['m'], denominators: ['s', 's'] }

Defined in

packages/core/src/units.ts:21