@zenuinebit/area-units
v0.1.0
Published
Convert and format land and floor areas: sq ft, sq m, acre, hectare, gaj, bigha, cent, ground and more.
Downloads
145
Readme
@zenuinebit/area-units
Convert, read and format land and floor areas, including the units used in Indian real estate. No dependencies.
import { convert, convertRate, parse, format } from "@zenuinebit/area-units";
convert(1, "acre", "sqft"); // 43560
convert(1000, "sqft", "sqm"); // 92.90304
convert(10, "gaj", "sqft"); // 90 (gaj is sq yd)
convertRate(5000, "sqft", "sqm"); // price per sq ft -> per sq m
parse("1,200 sq ft"); // { value: 1200, unit: "sqft" }
format(1200, "sqft"); // "1,200 sq ft"
// Regional units: define how many square metres they cover
convert(2, "bigha", "sqm", { custom: { bigha: 1618.7 } });Units: sqm, sqft, sqyd (also gaj), acre, hectare, sqkm, sqmi, cent, guntha, ground, marla, kanal. parse understands common spellings such as sq. ft., sft, m², acres, gunta.
How it works
- Every unit is stored as square metres, from exact definitions (1 ft = 0.3048 m, 1 acre = 43,560 sq ft, 1 cent = 1/100 acre, 1 guntha = 1/40 acre, 1 ground = 2,400 sq ft, 1 marla = 272.25 sq ft, 1 kanal = 20 marla).
- Results are rounded to 6 decimals (
precisionoption) so you do not get 0.30000000000000004. bigha,biswa,kathaand similar are left out on purpose: their size changes from state to state, even district to district. Pass your region's value as a custom unit.convertRatecan return decimals. Round it to the currency yourself (see@zenuinebit/money).
