-
Is there any constant or something similar that I can import? I just need to get the list of accepted units. |
Beta Was this translation helpful? Give feedback.
Answered by
josdejong
Mar 21, 2024
Replies: 2 comments 4 replies
-
Hi, I'm including a relevant discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can lookup const allUnits = Object.values(math.Unit.UNITS).flatMap(unit => {
return Object.values(unit.prefixes).map(prefix => prefix.name + unit.name)
})
// [ "meter", "decameter", "hectometer", ... ] This currently returns a list with 2748 items. If you just need to know if some string is a unit, you can use the following method: const isUnit = math.Unit.isValuelessUnit("millimeter") // true |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
AFZL210
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can lookup
math.Unit.UNITS
, and write out every unit with every prefix that it can have:This currently returns a list with 2748 items.
If you just need to know if some string is a unit, you can use the following method: