vulgar-fractions
Simple library to convert decimals into unicode vulgar fractions.
Usage
import { toDecimal, toVulgar } from 'vulgar-fractions';
toVulgar(.25)
toVulgar(1/9)
toDecimal('⅛')
toDecimal('⅔')
If a value doesn't have a "simple" conversion, meaning there is no appropriate unicode character, either function will return the stringified input.
toVulgar(.1274859937)
toDecimal('Hello World!')
Parsing strings or multi-line text
parseVuglars('1/2 cup')
parseVuglars('It take 1/2 cup chocolate chips and 1/4 cup sugar. Additionally it takes 4.75 cups flour.')
Contribute
Feel free to open up a GitHub Issue, Discussion, or Pull Request.