Releases: varna/measure-ts
Releases · varna/measure-ts
Classy
Brand new, 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²"