Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
() => {
if (transformedValue.current) transformedValue.current.destroy()
// This cast is needed because interpolate does not base it's return type on the to type (yet)
const transformer = interpolate(from, to) as Transformer
transformedValue.current = value.addChild({ transformer })
return transformedValue.current
},
[value, ...from, ...to]
export function transform(
...args:
| [number, number[], T[], TransformOptions?]
| [number[], T[], TransformOptions?]
) {
const useImmediate = !Array.isArray(args[0])
const argOffset = useImmediate ? 0 : -1
const inputValue = args[0 + argOffset] as number
const inputRange = args[1 + argOffset] as number[]
const outputRange = args[2 + argOffset] as T[]
const options = args[3 + argOffset] as TransformOptions
const interpolator = interpolate(inputRange, outputRange, {
mixer: getMixer(outputRange[0]),
...options,
})
return useImmediate ? interpolator(inputValue) : interpolator
}