Socket
Socket
Sign inDemoInstall

vulgar-fractions

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vulgar-fractions

Turn integers into vulgar unicode fractions and vice-versa.


Version published
Weekly downloads
635
decreased by-53.95%
Maintainers
1
Install size
9.04 kB
Created
Weekly downloads
 

Readme

Source

vulgar-fractions

npm version

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 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!

Parsing strings or multi-line text

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.

Contribute

Feel free to open up a GitHub Issue, Discussion, or Pull Request.

Keywords

FAQs

Last updated on 18 Oct 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc