jscheiny / safe-units

Type-safe TypeScript units of measure 👷📏
https://jscheiny.github.io/safe-units
MIT License
261 stars 14 forks source link

value in an unit #163

Closed raoz closed 4 months ago

raoz commented 3 years ago

Hello!

Would appreciate an escape-hatch to get the value in a particular unit, e.g.

Measure.of(8, furlongs).valueIn(miles) returns numeric 1.

jscheiny commented 3 years ago

Hi @raoz,

This is possible right now via:

Measure.of(8, furlongs).over(miles).value

Does this solve your use case?

raoz commented 3 years ago

Hi @jscheiny,

Thanks, this does solve it for now, might make a pull request soon to add the valueIn sugar for clarity, if you don't mind.