vulgar-fractions
Advanced tools
Turn integers into vulgar unicode fractions and vice-versa.
Weekly downloads
Readme
Simple library to convert decimals into unicode vulgar fractions.
import { toDecimal, toVulgar } from 'vulgar-fractions';
// Convert decimal to unicode vulgar:
toVulgar(.25) // '¼'
toVulgar(1/9) // '⅑'
// Convert vulgar to decimal string:
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 the stringified input.
toVulgar(.1274859937) // '.1274859937'
toDecimal('Hello World!') // 'Hello World!
parseVuglars('1/2 cup') // '½ cup'
parseVuglars('It take 1/2 cup chocolate chips and 1/4 cup sugar. Additionally it takes 4.75 cups flour.') // It take ½ cup chocolate chips and ¼ cup sugar. Additionally it takes 4 ¾ cups flour.
Feel free to open up a GitHub Issue, Discussion, or Pull Request.
FAQs
Turn integers into vulgar unicode fractions and vice-versa.
The npm package vulgar-fractions receives a total of 517 weekly downloads. As such, vulgar-fractions popularity was classified as not popular.
We found that vulgar-fractions demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.