Security News
RubyGems.org Adds New Maintainer Role
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.
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.
Converting Number to Fraction with Node.js.
npm install num2fraction
var π = Math.PI
var n2f = require('num2fraction')
console.log(n2f(0)) // => 0
console.log(n2f(.2)) // => 1/5
console.log(n2f(1.1)) // => 11/10
console.log(n2f(1.2)) // => 6/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(2.1)) // => 21/10
console.log(n2f(3)) // => 3/1
console.log(n2f(2.555)) // => 511/200
console.log(n2f(8.36)) // => 209/25
console.log(n2f('3em')) // => 3/1
console.log(n2f('1.5px')) // => 3/2
console.log(n2f(7 / 9) // => 7/9
console.log(n2f(8 / 9) // => 8/9
console.log(n2f(512 / 999) // => 512/999
console.log(n2f((2 * π / 3) / π) // => 2/3
console.log(n2f((8 * 5) / (4 / 2)) // => 20/1
Opera old versions support the non-standard -o-min-device-pixel-ratio
or -o-max-device-pixel-ratio
in CSS media queries.
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1), /* Opera */
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi), /* fallback */
only screen and ( min-resolution: 2dppx) {
}
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
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.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.