Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
shorthandParts.forEach(part => {
if (!(set & TIMING_FUNCTION) && easingRegExp.test(part)) {
accum.timingFunction = part as any;
set &= TIMING_FUNCTION;
} else if (!(set & DURATION) && durationRegExp.test(part)) {
accum.duration = getDurationInMs(part);
set &= DURATION;
} else if (!(set & DELAY) && durationRegExp.test(part)) {
accum.delay = getDurationInMs(part);
set &= DELAY;
} else if (!(set & PROPERTY)) {
accum.property = getPropertyName(part);
set &= PROPERTY;
} else {
throw new Error("Failed to parse shorthand");
}
});
const getInterpolationType = (
substitutionMap: SubstitutionMap,
[prop, value]: StyleTuple
) => {
if (!containsSubstitution(substitutionMap, value)) {
return InterpolationType.NoOrSimple;
} else if (getPropertyName(prop) in unitTypes && !calcRe.test(value)) {
return InterpolationType.NoOrSimple;
}
return InterpolationType.Template;
};
([prop, value]): ViewportMode => {
if (!viewportUnitRegExp.test(value)) {
return ViewportMode.None;
} else if (
unitTypes[getPropertyName(prop)] === UnitType.Length &&
!calcRe.test(value)
) {
return ViewportMode.SimpleLengthUnits;
} else {
return ViewportMode.ComplexUnits;
}
}
)
const getInterpolationType = (substitutionMap, [prop, value]) => {
if (!containsSubstitution(substitutionMap, value)) {
return SIMPLE_OR_NO_INTERPOLATION;
} else if (getPropertyName(prop) in simpleInterpolation) {
return SIMPLE_OR_NO_INTERPOLATION;
}
return TEMPLATE_INTERPOLATION;
};
([prop, value]) =>
babel.types.arrayExpression([
babel.types.stringLiteral(getPropertyName(prop)),
getStringWithSubstitutedValues(babel, substitutionMap, value)
]),
styleTuples
styleTuplesGroup.forEach(([prop, value]) => {
const propertyName = getPropertyName(prop);
const substitutionMatches = substitutionRegExp
? value.match(substitutionRegExp)
: null;
if (substitutionMatches == null) {
const styles = transformStyleTuples([[propertyName, value]]);
Object.entries(styles).forEach(([key, value]) => {
styleMap[key] = jsonToNode(babel, value);
});
} else if (substitutionMatches.length === 1) {
const substitution =
substitutionMatches[0] === value.trim()
? t.cloneDeep(substitutionMap[value])
: getStringWithSubstitutedValues(babel, substitutionMap, value);
const bodyPairs = t.arrayExpression(_.map(([prop, value]) => t.arrayExpression([
t.stringLiteral(getPropertyName(prop)),
getStringWithSubstitutedValues(substitutionMap, value),
]), styleTuplesGroup));
) => t.arrayExpression(_.map(([prop, value]) => (
t.arrayExpression([
t.stringLiteral(getPropertyName(prop)),
getStringWithSubstitutedValues(substitutionMap, value),
])
), styleTuples));
const styleMap = _.reduce((accum, [prop, value]) => {
const propertyName = getPropertyName(prop);
const substitutionMatches = substitutionRegExp
? value.match(substitutionRegExp)
: null;
if (!substitutionMatches) {
const styles = transformStyleTuples([[propertyName, value]]);
const styleToValue = _.mapValues(jsonToNode, styles);
return _.assign(accum, styleToValue);
} else if (substitutionMatches.length === 1) {
const substitutionNode = substitutionMatches[0] === value.trim()
? substitutionMap[value]
: getStringWithSubstitutedValues(substitutionMap, value);
return _.set(
propertyName,
simpleInterpolation[propertyName](path, substitutionNode),