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-units.js

v1.0.7

Published

A package to convert time, length, and speed units easily.

Downloads

10

Readme

convert-units.js

Convert beetween units with ease!

Installation

npm install convert-units.js

Table of Contents

Classes

Length

Converting Inches

import { Length } from "convert-units.js";
const ic = new Length(150); //150 inches

ic.inchesToFeet(); //12.5
ic.inchesToYards(); //4.166666666666667
ic.inchesToMiles(); //0.0023674242424242425

Converting Feet

import { Length } from "convert-units.js";
const ft = new Length(100); //100 feet

ft.feetToInches(); //1200
ft.feetToYards(); //300
ft.feetToMiles(); //0.01893939393939394

Converting Yards

import { Length } from "convert-units.js";
const yd = new Length(100); //100 yards

yd.yardsToInches(); //3600
yd.yardsToFeet(); //300
yd.yardsToMiles(); //0.056818181818181816

Converting Miles

import { Length } from "convert-units.js";
const mi = new Length(100); //100 miles

mi.milesToInches(); //6336000
mi.milesToFeet(); //528000
mi.milesToYards(); //176000

Time

Converting Milliseconds

import { Time } from "convert-units.js";
const ms = new Time(100000000000000);

ms.millisecondsToSeconds(); //100000000000
ms.millisecondsToMinutes(); //1666666666.6666667
ms.millisecondsToHours(); //27777777.777777776
ms.millisecondsToDays(); //1157407.4074074074
ms.millisecondsToWeeks(); //165343.91534391535
ms.millisecondsToMonths(); //38051.75038051751
ms.millisecondsToYears(); //3170.577045022194

Converting Seconds

import { Time } from "convert-units.js";
const s = new Time(10000); //10,0000 seconds

s.secondsToMilliseconds(); //10000000
s.secondsToMinutes(); //166.66666666666666
s.secondsToHours(); //2.7777777777777777
s.secondsToDays(); //0.11574074074074074
s.secondsToWeeks(); //0.016534391534391533
s.secondsToMonths(); //0.00380517503805175
s.secondsToYears(); //0.0003170577045022194

Converting Minutes

import { Time } from "convert-units.js";
const m = new Time(12345); //12,345 minutes

m.minutesToMilliseconds(); //740700000
m.minutesToSeconds(); //740700
m.minutesToHours(); //205.75
m.minutesToDays(); //8.572916666666666
m.minutesToWeeks(); //1.224702380952381
m.minutesToMonths(); //0.28184931506849314
m.minutesToYears(); //0.023487442922374428

Converting Hours

import { Time } from "convert-units.js";
const h = new Time(24); //24 hours

h.hoursToMilliseconds(); //86400000
h.hoursToSeconds(); //86400
h.hoursToMinutes(); //1440
h.hoursToDays(); //1
h.hoursToWeeks(); //0.14285714285714285
h.hoursToMonths(); //0.03287671232876712
h.hoursToYears(); //0.0027397260273972603

Converting Days

import { Time } from "convert-units.js";
const d = new Time(100); //100 days

d.daysToMilliseconds(); //8640000000
d.daysToSeconds(); //8640000
d.daysToMinutes(); //144000
d.daysToHours(); //2400
d.daysToWeeks(); //14.285714285714286
d.daysToMonths(); //3.2876352039977643
d.daysToYears(); //0.273972602739726

Converting Weeks

import { Time } from "convert-units.js";
const w = new Time(3); //3 weeks

w.weeksToMilliseconds(); //1814400000
w.weeksToSeconds(); //1814400
w.weeksToMinutes(); //30240
w.weeksToHours(); //504
w.weeksToDays(); //21
w.weeksToMonths(); //0.6904487917146145
w.weeksToYears(); //0.05753408894770151

Converting Months

import { Time } from "convert-units.js";
const m = new Time(3); //3 months

m.monthsToMilliseconds(); //7884000000
m.monthsToSeconds(); //7884000
m.monthsToMinutes(); //131400
m.monthsToHours(); //2190
m.monthsToDays(); //91.251
m.monthsToWeeks(); //13.035
m.monthsToYears(); //0.25

Converting Years

import { Time } from "convert-units.js";
const y = new Time(1); //1 year

y.yearsToMilliseconds(); //31540000000
y.yearsToSeconds(); //31540000
y.yearsToMinutes(); //525600
y.yearsToDays(); //365
y.yearsToWeeks(); //52.143
y.yearsToMonths(); //12

MetricLength

Converting Millimeters

import { MetricLength } from "convert-units.js";
const mm = new MetricLength(100); //100 millimeters

mm.millimetersToCentimeters(); //10
mm.millimetersToMeters(); //0.1
mm.millimetersToKilometers(); //0.0001

Converting Centimeters

import { MetricLength } from "convert-units.js";
const cm = new MetricLength(50) //50 centimeters

cm.centimetersToMillimeters(); //500
cm.centimetersToMeters(); //0.5
cm.centimetersToKilometers(); //0.0005

Converting Meters

import { MetricLength } from "convert-units.js";
const m = new MetricLength(10); //10 meters

m.metersToMillimeters(); //10000
m.metersToCentimeters(); //1000
m.metersToKilometers(); //0.01

Converting Kilometers

import { MetricLength } from "convert-units.js";
const km = new MetricLength(5); //5 kilometers

km.kilometersToMillimeters(); //5000000
km.kilometersToCentimeters(); //500000
km.kilometersToMeters(); //5000

Speed

Converting MPH

import { Speed } from "convert-units.js";
const speed = new Speed(50); //50 mph

speed.mphToKnots(); //43.440486533449175
speed.mphToKpm(); //80.45

Converting KPH

import { Speed } from "convert-units.js";
const speed = new Speed(50); //50 kph

speed.kphToMph(); //31.07520198881293
speed.kphToKnots(); //26.997840172786177

Converting Knots

import { Speed } from "convert-units.js";
const speed = new Speed(50); //50 knots

speed.knotsToMph(); //57.550000000000004
speed.knotsToKpm(); //92.60000000000001

RelativeTime

import { RelativeTime, Time } from "convert-units.js"; //Class is static

RelativeTime.timeIn(100); //the current ms + 100 ms

const year = new Time(1).yearsToMilliseconds();
RelativeTime.timeIn(year); //the current ms + 1 year