js-quantities icon indicating copy to clipboard operation
js-quantities copied to clipboard

Are the scalar and baseScalar properties public?

Open n-e opened this issue 10 years ago • 2 comments

Hi,

The scalar and baseScalar properties aren't documented in the README.md, though there's a mention in a toFloat exception:

> q('10km').toFloat();
Error: Can't convert to Float unless unitless.  Use Unit#scalar`

Are theses properties public? If so the documentation might need to be updated.

n-e avatar Feb 21 '15 12:02 n-e

I have the exact same question, are they public? Can I trust them to stay, or must I use q('10km').div('m').toFloat()?

nakedible-p avatar Jan 20 '16 12:01 nakedible-p

I always used the scalar member directly, so personally, I consider it part of the public api. And the error message seems to confirm this. But it may be better to have a getScalar function so that we keep the user from modifying it directly.

rage-shadowman avatar Feb 25 '16 02:02 rage-shadowman