README
vulgar-fractions
Simple library to convert decimals into unicode vulgar fractions.
Usage
import { toDecimal, toVulgar } from 'vulgar-fractions';
// Convert decimal to unicode vulgar:
toVulgar(.25) // ΒΌ
toVulgar(1/9) // β
// Convert vulgar to decimal:
toDecimal('β
') // 0.125
toDecimal('β
') // 0.666...
If a value doesn't have a "simple" conversion, meaning there is no appropriate unicode character, either function will return undefined
.
toVulgar(.1274859937) // undefined
toDecimal('Hello World!') // undefined
Contribute
Feel free to open up a GitHub Issue, Discussion, or Pull Request.