npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lab-rounder

v1.0.2

Published

Laboratory round and some statistics calculation methods.

Downloads

2

Readme

What is lab-rounder?

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.

How to use?

  1. install lab-rounder through npm
npm i lab-rounder
  1. import lab-rounder in your project
import Rounder from 'lab-rounder'

Rounder.roundHalfToEven('23.5', 0) // 24
Rounder.roundHalfToEven('24.5', 0) // 24
Rounder.roundHalfToEven('25.5', 0) // 26

Transfer number format methods

roundDown

import Rounder from 'lab-rounder'

Rounder.roundDown('23.5', 0) // 23

roundNormal

import Rounder from 'lab-rounder'

Rounder.roundNormal('23.5', 0) // 23.4
Rounder.roundNormal('23.49', 0) // 23

roundHalfToEven

import Rounder from 'lab-rounder'

Rounder.roundHalfToEven('23.5', 0) // 24
Rounder.roundHalfToEven('24.5', 0) // 24
Rounder.roundHalfToEven('25.5', 0) // 26

roundSignificantDigit

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³

numToScientificStr

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³

scientificStrToNum

Transfer a scientific string to a number.

import Rounder from 'lab-rounder'

Rounder.numToScientificStr('1.0×10³') // 1000

statistical calculation methods

calcAvg

Calculate average of a list of numbers.

const nums = [1, 2, 3, 4]
Rounder.calcAvg(...nums) // 2.5

calcRSD

Calculate relative standard deviation (RSD).

const numList = [10.1, 10.2, 10.3, 10.4, 10.5];
Rounder.calcRSD(numList) // 1.5

calcSlope

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