fn is expected to map (0..1) => (0..1), such as an easing function. The input to the
fn is the relative position of an element. Thus the first element will be 0, the middle 0.5 and so on.
The output of fn is then multiplied by the original value.
In the below example (which is also the default if fn is not specified), the relative position is
how values are weighted:
Applies a function
fn
to the elements of an array, weighting them based on their relative position.fn
is expected to map (0..1) => (0..1), such as an easing function. The input to thefn
is the relative position of an element. Thus the first element will be 0, the middle 0.5 and so on. The output offn
is then multiplied by the original value.In the below example (which is also the default if
fn
is not specified), the relative position is how values are weighted:Non-numbers in
data
will be silently ignored (this filtering happens first, so relative index values are sane still).