fix(config-helpers): Guard against missing measurements
This commit is contained in:
parent
8b717197b1
commit
b714d9af1f
2 changed files with 9 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
|||
Unreleased:
|
||||
Added:
|
||||
Fixed:
|
||||
config-helpers:
|
||||
- Guard against missing measurements in toAbs()
|
||||
|
||||
2.21.1:
|
||||
date: 2022-06-28
|
||||
|
|
|
@ -44,8 +44,12 @@ export const bigsteps = {
|
|||
*/
|
||||
export function pctBasedOn(measurement) {
|
||||
return {
|
||||
toAbs: (val, { measurements }) => measurements[measurement] * val,
|
||||
fromAbs: (val, { measurements }) => Math.round((10 * val) / measurements[measurement]) / 10,
|
||||
toAbs: (val, { measurements }) => measurements?.[measurement]
|
||||
? measurements[measurement] * val
|
||||
: null,
|
||||
fromAbs: (val, { measurements }) => measurements?.[measurement]
|
||||
? Math.round((10 * val) / measurements[measurement]) / 10
|
||||
: null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue