Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to add a method qty.getUnit() ? #109

Open
lpatiny opened this issue Aug 5, 2020 · 1 comment
Open

Possibility to add a method qty.getUnit() ? #109

lpatiny opened this issue Aug 5, 2020 · 1 comment

Comments

@lpatiny
Copy link

lpatiny commented Aug 5, 2020

In order to 'normalize' the user entered quantities in a database I create a JSON that contains 2 properties:

  • SI: the value in SI
  • unit: the unit in which the enduser would like to see the value

I would like to have a code like:

 const qty = Qty.parse('100 cm^2');
  return {
    SI: qty.baseScalar,
    unit: qty.getUnit(), // this would contain 'cm^2'
  };

I could not find a way to achieve this getUnit with js-quantities. Is this possible ?

@adrfantini
Copy link

Isn't Qty(123, 'cm2').units() enough?

Otherwise you can play around with toBase() maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants