Nebulous Puffy Marshmallows
Miss any of our Open RFC calls?Watch the recordings here! »

parse-fraction

1.2.1 • Public • Published

parse-fraction unstable Build Status

Parse numerator and denominator from a string.

npm install parse-fraction

const parseFract = require('parse-fraction')
 
parseFract('half') // [1, 2]
parseFract('one third') // [1, 3]
parseFract('seven eighths') // [7, 8]
parseFract('¼') // [1, 4]
parseFract('13 / 15') // [13, 15]
parseFract('19 ÷ 21') // [19, 21]
parseFract('full') // [1, 1]
parseFract('one millionth') // [1 , 1000000]
parseFract('five over six') // [5, 6]
parseFract('zero-point-one-two') // [12, 100]
parseFract('.12') // [12, 100]
parseFract('12%') // [12, 100]
parseFract('tau over phi') // [Math.PI * 2, (1 + Math.sqrt(5)) / 2]
parseFract('one hundred twenty-three thousand four hundred fifty-six one hundred twenty-three thousand four hundred fifty-sixths') // [123456, 123456]
parseFract('fifty-fifty') // [50, 50]

parseFraction(str, locale?)

Return [numerator, denominator] couple from a string. Optionally pass locale object for other than en locales, see en locale example.

License

(c) 2017 Dima Yv. MIT License

Install

npm i parse-fraction

DownloadsWeekly Downloads

1

Version

1.2.1

License

MIT

Unpacked Size

40.5 kB

Total Files

9

Last publish

Collaborators

  • avatar
  • avatar