You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
499 B
15 lines
499 B
1 year ago
|
import number from "./number";
|
||
|
|
||
|
export default function(values, p, valueof) {
|
||
|
if (valueof == null) valueof = number;
|
||
|
if (!(n = values.length)) return;
|
||
|
if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values);
|
||
|
if (p >= 1) return +valueof(values[n - 1], n - 1, values);
|
||
|
var n,
|
||
|
i = (n - 1) * p,
|
||
|
i0 = Math.floor(i),
|
||
|
value0 = +valueof(values[i0], i0, values),
|
||
|
value1 = +valueof(values[i0 + 1], i0 + 1, values);
|
||
|
return value0 + (value1 - value0) * (i - i0);
|
||
|
}
|