Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
num2fraction
Advanced tools
The num2fraction npm package is designed to convert decimal numbers to their simplest fractional representation. This can be particularly useful in applications that require displaying numbers in a more human-readable form, such as in cooking recipes or mathematical education tools.
Decimal to Fraction Conversion
This feature allows you to convert a decimal number to its simplest fractional form. The code sample demonstrates converting the decimal numbers 0.5 and 1.75 to their fractional representations, '1/2' and '7/4' respectively.
const num2fraction = require('num2fraction');
console.log(num2fraction(0.5)); // Outputs: '1/2'
console.log(num2fraction(1.75)); // Outputs: '7/4'
Fraction.js is a package that not only converts decimals to fractions but also provides a comprehensive set of operations for fractions, such as addition, subtraction, multiplication, and division. It offers more extensive functionality compared to num2fraction, which focuses solely on conversion.
Number to fraction
npm install num2fraction
var n2f = require('num2fraction')
console.log(n2f(0)) // => 0
console.log(n2f(.2)) // => 1/5
console.log(n2f(1.3)) // => 13/10
console.log(n2f(1.4)) // => 7/5
console.log(n2f(1.5)) // => 3/2
console.log(n2f(2)) // => 2/1
console.log(n2f(3)) // => 3/1
console.log(n2f('3em')) // => 3/1
console.log(n2f('1.5px')) // => 3/2
First release.
FAQs
Convert number to fraction
The npm package num2fraction receives a total of 0 weekly downloads. As such, num2fraction popularity was classified as not popular.
We found that num2fraction demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.