Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getActionCreator = (prop: any) => {
// Pattern matching would be quite lovely here
if (typeof prop === 'number') {
return createAction;
} else if (Array.isArray(prop)) {
return createArrayAction;
} else if (isUnitProp(prop)) {
return createUnitAction;
} else if (color.test(prop)) {
return createColorAction;
} else if (complex.test(prop)) {
return createComplexAction;
} else if (typeof prop === 'object') {
return createObjectAction;
} else {
return createAction;
}
};
function detectMixerFactory(v: T): MixerFactory {
if (typeof v === 'number') {
return mixNumber;
} else if (typeof v === 'string') {
if (color.test(v)) {
return mixColor;
} else {
return mixComplex;
}
} else if (Array.isArray(v)) {
return mixArray;
} else if (typeof v === 'object') {
return mixObject;
}
}
const blendValue = from.map((fromThis, i) => {
const toThis = to[i];
if (isNum(fromThis)) {
return (v: number) => mix(fromThis, toThis as number, v);
} else if (color.test(fromThis)) {
return mixColor(fromThis, toThis as HSLA | RGBA | string);
} else {
return mixComplex(fromThis as string, toThis as string);
}
});