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

convert-pro

v1.3.2

Published

convert-pro is a package to convert between units that works on browser, node & deno

Downloads

6,654

Readme

convert-pro

nest badge npm npm

GitHub issues GitHub forks GitHub stars GitHub license

convert-pro is a package to convert between units that works on browser, node & deno

covers:

  • temperature
  • length
  • area
  • volume
  • time
  • mass
  • energy
  • frequency
  • pressure
  • degrees
  • bytes

Usage

// on node (commonjs)
const { default: convert } = require("convert-pro");
// or (es6)
import convert from "convert-pro";
// on deno (replace version with current version)
import convert from "https://x.nest.land/convert-pro@version/mod.ts";
// or
import convert from "https://deno.land/x/convert_pro@version/mod.ts";

// convert from m2 to cm2
convert.area("10 m2", "cm2"); // => 100000
// convert from bit to MiB (1024 base)
convert.bytes([10 ** 15, "bit"], "MiB"); // => 119209289.55078125
// convert degrees to rad
convert.bytes(`10 d`, "r"); // => 0.17453
// convert multiple units
// 10 ft + 100 inch + 1 km + 1 ft = 3300.1732283464567 ft
convert.length([10, "FT", 100, "IN", 1, "KM", 1, "FT"], "FT"); // => 3300.1732283464567
// or
convert.length("10 ft 100 in 1 km", "ft"); // => 3299.1732283464567

Notes on convert.degrees

  1. you could write 10.2d1.2'1.3'' or 10.2°1.2'1.3'' (the numbers here could be replaced with other numbers) instead of 10.2 d 1.2 arcminute 1.3 arcsecond
  2. you could use multiple units at once
  3. convert.degrees is the ONLY function allows number and unit names to be directly added together like 10radians
// examples
convert.degrees("10.2d1.2'1.3''", "radians"); // => 0.178378952

convert.degrees("10.2d1.2'1.3'' 10r", "radians"); // => 10.178378952

options

stringify

if true returns output in string (default: false)

example:

import convert from "convert-pro";

convert.length("1 m", "cm", { stringify: true }); // => "100 cm"
convert.length("1 m", "cm"); // => 100

accuracy

this options is the accuracy of the size or how many digits are there after the dot

example:

import convert from "convert-pro";

convert.bytes("1024 byte", { accuracy: 0, stringify: true }); // => "1 KB"

shortcut

this option tels the function to use the shortcuts or the words

example:

import convert from "convert-pro";

convert.area("100 m2", "cm2", { stringify: true, shortcut: false }); // => "1000000 Square Centimeters"

lowerCase

this option tels the function to use lower case letters

import convert from "convert-pro";

convert.mass("10 kg", "g", { lowerCase: true }); // => 1 kb

License

Copyright (c) 2021 AliBasicCoder