4 const _ = require("lodash");
5 const blurInterpolation = require("./blurInterpolation");
6 const isStandardSyntaxValue = require("./isStandardSyntaxValue");
7 const valueParser = require("postcss-value-parser");
10 * Get unit from value node
12 * Returns `null` if the unit is not found.
14 module.exports = function(node /*: Object*/) /*: ?string*/ {
15 if (!node || (node && !node.value)) {
19 const value = blurInterpolation(node.value, "")
23 // ignore decimal place
27 node.type !== "word" ||
28 !isStandardSyntaxValue(value) ||
29 !_.isFinite(parseInt(value)) ||
35 const parsedUnit = valueParser.unit(value);
41 return parsedUnit.unit;