corrade-nucleus-nucleons – Blame information for rev 10
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
10 | office | 1 | import hasOwnProp from '../utils/has-own-prop'; |
2 | |||
3 | var aliases = {}; |
||
4 | |||
5 | export function addUnitAlias (unit, shorthand) { |
||
6 | var lowerCase = unit.toLowerCase(); |
||
7 | aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit; |
||
8 | } |
||
9 | |||
10 | export function normalizeUnits(units) { |
||
11 | return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined; |
||
12 | } |
||
13 | |||
14 | export function normalizeObjectUnits(inputObject) { |
||
15 | var normalizedInput = {}, |
||
16 | normalizedProp, |
||
17 | prop; |
||
18 | |||
19 | for (prop in inputObject) { |
||
20 | if (hasOwnProp(inputObject, prop)) { |
||
21 | normalizedProp = normalizeUnits(prop); |
||
22 | if (normalizedProp) { |
||
23 | normalizedInput[normalizedProp] = inputObject[prop]; |
||
24 | } |
||
25 | } |
||
26 | } |
||
27 | |||
28 | return normalizedInput; |
||
29 | } |
||
30 |