numeric-quantity

Converts a string to a number. The string can include mixed numbers or vulgar fractions.
For the inverse operation, converting a number to an imperial measurement, check out format-quantity.
Installation
npm
# npm
npm i numeric-quantity
# yarn
yarn add numeric-quantity
Browser
In the browser, available as a global function numericQuantity
.
<script src="https://unpkg.com/numeric-quantity"></script>
<script>
console.log(numericQuantity('10 1/2'));
</script>
Usage
import numericQuantity from 'numeric-quantity';
console.log(numericQuantity('1 1/2'));
console.log(numericQuantity('2 2/3'));
The return value will be NaN
if the provided string does not resemble a number.