JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 45780
  • Score
    100M100P100Q161354F
  • License MIT

Convert integer plus fraction into a decimal value

Package Exports

  • numeric-quantity
  • numeric-quantity/dist/numeric-quantity.cjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (numeric-quantity) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm version Travis (.org) downloads MIT License

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 i --save numeric-quantity

or

yarn add numeric-quantity
Browser

In the browser, available as a global function numericQuantity.

<script src="path/to/numeric-quantity.umd.js"></script>
<script>
  console.log(numericQuantity("10 1/2"));  // 10.5
</script>

Usage

import numericQuantity from 'numeric-quantity';

console.log( numericQuantity("1 1/2") );   // 1.5
console.log( numericQuantity("2 2/3") );   // 2.666