Skip to content

Releases: varna/measure-ts

Classy

10 Jul 11:21
Compare
Choose a tag to compare

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²"

Started using @pika/pack

02 Jul 08:55
Compare
Choose a tag to compare

96ae945...v1.0.6