New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

measure-ts

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

measure-ts

Convert or print measurement units units: length, area, volume and weight

latest
Source
npmnpm
Version
3.3.2
Version published
Weekly downloads
7
-56.25%
Maintainers
1
Weekly downloads
 
Created
Source

measure-unit

Convert or print measurement units units: length, area, volume and weight.

Usage

Class based API:

import Measure from 'measure-ts'

const measure = new Measure(1)
Number(measure) // 1
String(measure) // "1 m"

const ha = new Measure(2, 'ha') // 2
String(ha) // "2 ha"
const ha2m2 = ha.to('m2') // 20_000
String(ha2m2) // "20_000 m²"

Pretty unit chooser:

import { measureFrom } from 'measure-ts'

const measure = measureFrom('m2', 'a', 'ha', 'km2')
measure(1) // 1 || "1 m²"
measure(100) // 100 || "1 a"
measure(10000) // 10_000 ||  "1 ha"
measure(1000000) // 1_000_000 ||  "1 km²"

Units

SI prefixes

Meters (normal, square and cubic), grams and litres are prefixable with SI prefixes. Examples:

KeyUnitValue
kmkilometre1 * 1000
cmcentimetre1 / 100
mlmililitre1 / 1000
km2square kilometre1 _ 1000 _ 1000

Length

KeyNameValue
mMeter (meter)1
MNautical MileMetre * 1852
inInchFoot / 12
ftFootYard / 3
ydYardMetre * 0.9144
chChainYard * 22
furFurlongChain * 10
miMileFurlong * 8
leaLeagueMile * 3

Area

Square length units can be used to measure area, i.e. "m2".

KeyNameValue
aAreMetre *_ 2 _ 100
haHectareAre * 100
acAcreYard *_ 2 _ 4840

Volume

Cubic length units can be used to measure volume, i.e. "m3".

I'm not sure how imperial volume units "really" work (in practise), so create an issue or PR to fix anything that is a miss.

KeyNameValue
lLitreMetre ** 3 / 1000
pintPint (Imperial)Litre * 0.568
galGallon (American)Inch ** 3 / 231
qtQuart (American)Gallon / 4
ptPint (American)Gallon / 8
giGill (American)Gallon / 32
fl ozFluid Ounce (American)Gallon / 128
peckPeckLitre * 8.809_768
buBushelLitre * 35.239_070_166_88

Mass (weight)

KeyNameValue
kgKilogram1
gGramKilogram / 1000
lbPoundGram * 453.592_37
tTonne (Metric Ton)Kilogram * 1000
tonAmerican Ton (short)Pound * 2000
longtonImperial Ton (long)Pound * 2240
cwtAmerican Hundredweight (short)Pound * 100
longcwtImperial Hundredweight (long)Pound * 112
qrQuarterPound * 25
stStonePound * 14
ozOuncePound / 16
drDrachmPound / 256
grGrainPound / 7000

Roadmap

Lincese

MIT © Farmis

Keywords

measure

FAQs

Package last updated on 04 Nov 2019

Did you know?

Socket

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.

Install

Related posts