Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
readable-fractions
Advanced tools
Converts decimals to human readable fractions, and fractions to decimals.
A small library to convert decimals to human readable fractions. Since the fractions are human readable, it means that they are not precise. The maximum denominator (right now) is 10. Also contains a function to convert fractions to decimals.
Formats the readable fraction object as a string.
Usage:
let fractionObject = {
denominator: 3,
error: -3.3333333332441484e-7,
numerator: 1
};
let result = formatReadableFraction(fractionObject);
console.log(result);
// '1/3'
let fractionObject = {
denominator: 5,
error: -0.012500000000000178,
numerator: 11
};
let result = formatReadableFraction(fractionObject);
console.log(result);
// '2 1/5'
let fractionObject = {
denominator: 5,
error: -0.012500000000000178,
numerator: 11
};
let result = formatReadableFraction(fractionObject);
console.log(result);
// '11/5'
Converts a fraction to a decimal. Unlike toReadableFraction, this is precise.
Usage:
let fraction = '1/4';
let result = fractionToDecimal(fraction);
console.log(result);
// 0.25
let fraction = '2 1/4';
let result = fractionToDecimal(fraction);
console.log(result);
// 2.25
Converts a decimal to a human readable fraction with a maximum denominator of 10. This means that the result is NOT precise.
Usage:
let decimal = 0.333333;
let result = toReadableFraction(decimal);
console.log(result);
// { denominator: 3, error: -3.3333333332441484e-7, numerator: 1 }
let decimal = 0.125;
let result = toReadableFraction(decimal, true);
console.log(result); // '1/8'
Add the git post-commit hook
MIT
FAQs
Converts decimals to human readable fractions, and fractions to decimals.
The npm package readable-fractions receives a total of 1,010 weekly downloads. As such, readable-fractions popularity was classified as popular.
We found that readable-fractions 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.