Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

vulgar-fractions

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Issues
File Explorer

Advanced tools

vulgar-fractions

Turn integers into vulgar unicode fractions and vice-versa.

    1.4.21.4.2latest
    npm

Version published
Maintainers
1
Weekly downloads
642
decreased by-28.35%

Weekly downloads

Readme

Source

vulgar-fractions

Simple library to convert decimals into unicode vulgar fractions.

NPM Version. NPM Downloads per week TypeScript types included. Bundlephobia minified + gzipped size.

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 09 Mar 2023

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.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • 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