
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
lab-rounder
Advanced tools
lab-rounder is a rounding tool. You can see the definition in wikipedia about Rounding.
Rounding means replacing a number with an approximate value that has a shorter, simpler, or more explicit representation.
"Rounding half to even" method is a special way to round numbers. It is often used in laboratory and Statistics.
This variant of the round-to-nearest method is also called convergent rounding, statistician's rounding, Dutch rounding, Gaussian rounding, odd–even rounding, or bankers' rounding.
lab-rounder is a implementation of the "Rounding half to even" using JS language. And it alse has some statistical calculate methods.
npm i lab-rounder
import Rounder from 'lab-rounder'
Rounder.roundHalfToEven('23.5', 0) // 24
Rounder.roundHalfToEven('24.5', 0) // 24
Rounder.roundHalfToEven('25.5', 0) // 26
import Rounder from 'lab-rounder'
Rounder.roundDown('23.5', 0) // 23
import Rounder from 'lab-rounder'
Rounder.roundNormal('23.5', 0) // 23.4
Rounder.roundNormal('23.49', 0) // 23
import Rounder from 'lab-rounder'
Rounder.roundHalfToEven('23.5', 0) // 24
Rounder.roundHalfToEven('24.5', 0) // 24
Rounder.roundHalfToEven('25.5', 0) // 26
Round a number to a certain position of significant digit. You can see the the definition in wikipedia about Significant_figures.
Rounder.roundSignificantDigit(number, digit) method use roundHalfToEven to round numbers. If number's significant digits bigger than digit, Rounder will transfer your number to scientific string.
import Rounder from 'lab-rounder'
Rounder.roundSignificantDigit('1000', 2) // 1.0×10³
Rounder.roundSignificantDigit('999', 2); // 1.0×10³
Rounder.roundSignificantDigit('9999', 5); // 9.9990×10³
Transfer a number to scientific string depend on the follow charactor.
Rounder.numToScientificStr(number, digit) method use roundHalfToEven to round numbers.
// baseNumberMap = { "º": 0, "¹": 1, "²": 2, "³": 3, "⁴": 4, "⁵": 5, "⁶": 6, "⁷": 7, "⁸": 8, "⁹": 9, "⁻¹": "-1", "⁻²": "-2", "⁻³": "-3", "⁻⁴": "-4", "⁻⁵": "-5", "⁻⁶": "-6", "⁻⁷": "-7", "⁻⁸": "-8", "⁻⁹": "-9" };
// supNumberMap = { 0: "º", 1: "¹", 2: "²", 3: "³", 4: "⁴", 5: "⁵", 6: "⁶", 7: "⁷", 8: "⁸", 9: "⁹", "-1": "⁻¹", "-2": "⁻²", "-3": "⁻³", "-4": "⁻⁴", "-5": "⁻⁵", "-6": "⁻⁶", "-7": "⁻⁷", "-8": "⁻⁸", "-9": "⁻⁹" }
import Rounder from 'lab-rounder'
Rounder.numToScientificStr(1000.123, 2) // 1.0×10³
Transfer a scientific string to a number.
import Rounder from 'lab-rounder'
Rounder.numToScientificStr('1.0×10³') // 1000
Calculate average of a list of numbers.
const nums = [1, 2, 3, 4]
Rounder.calcAvg(...nums) // 2.5
Calculate relative standard deviation (RSD).
const numList = [10.1, 10.2, 10.3, 10.4, 10.5];
Rounder.calcRSD(numList) // 1.5
Calculate one-dimensional linear regression curve's slope
const listx = [1, 2, 3, 4];
const listy = [1, 2, 3, 4];
Rounder.calcSlope(listx, listy, precision = 2) // 1.00
FAQs
Laboratory round and some statistics calculation methods.
We found that lab-rounder 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.