Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
numOrUndefined = d3Array.variance(numbersArray);
numOrUndefined = d3Array.variance(numericArray);
numOrUndefined = d3Array.variance(numbersOrUndefinedArray);
numOrUndefined = d3Array.variance(mixedObjectArray, accessorMixedObjectToNum);
numOrUndefined = d3Array.variance(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// -----------------------------------------------------------------------------
// Test Searching Arrays
// -----------------------------------------------------------------------------
// scan() ----------------------------------------------------------------------
numOrUndefined = d3Array.scan(numbersArray);
numOrUndefined = d3Array.scan(mixedObjectArray, (a, b) => {
const aElem: MixedObject = a;
const bElem: MixedObject = b;
return a.num - b.num;
});
numOrUndefined = d3Array.scan(mixedObjectOrUndefinedArray, (a, b) => {
const aElem: MixedObject | undefined = a;
const bElem: MixedObject | undefined = b;
return a && b ? a.num - b.num : NaN;
});
// bisectLeft() ----------------------------------------------------------------
num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4);
num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4, 1);
num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4, 1, 4);
// variance() ------------------------------------------------------------------
numOrUndefined = d3Array.variance(numbersArray);
numOrUndefined = d3Array.variance(numericArray);
numOrUndefined = d3Array.variance(numbersOrUndefinedArray);
numOrUndefined = d3Array.variance(mixedObjectArray, accessorMixedObjectToNum);
numOrUndefined = d3Array.variance(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// -----------------------------------------------------------------------------
// Test Searching Arrays
// -----------------------------------------------------------------------------
// scan() ----------------------------------------------------------------------
numOrUndefined = d3Array.scan(numbersArray);
numOrUndefined = d3Array.scan(mixedObjectArray, (a, b) => {
const aElem: MixedObject = a;
const bElem: MixedObject = b;
return a.num - b.num;
});
numOrUndefined = d3Array.scan(mixedObjectOrUndefinedArray, (a, b) => {
const aElem: MixedObject | undefined = a;
const bElem: MixedObject | undefined = b;
return a && b ? a.num - b.num : NaN;
});
// bisectLeft() ----------------------------------------------------------------
num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4);
function render() {
const results = _data;
// If we have no results or no range of years return early
if (
results === undefined ||
results.crews.length === 0 ||
yearRange === null
) {
return;
}
let i = scan(
_data.divisions,
(a, b) => Math.abs(a.year - year) - Math.abs(b.year - year)
);
// Too far to the right
if (i + numYearsToView > _data.divisions.length) {
i = _data.divisions.length - numYearsToView;
}
yearRange = {
start: _data.divisions[i].year,
end: _data.divisions[i + numYearsToView - 1].year,
};
const crews = results.crews;
function dragstarted() {
select(this).classed('active', true);
var pos = identityClamped(
orientation === bottom || orientation === top ? event.x : event.y
);
// Handle cases where both handles are at the same end of the slider
if (value[0] === domain[0] && value[1] === domain[0]) {
handleIndex = 1;
} else if (value[0] === domain[1] && value[1] === domain[1]) {
handleIndex = 0;
} else {
handleIndex = scan(
value.map(function(d) {
return Math.abs(d - alignedValue(scale.invert(pos)));
})
);
}
var newValue = value.map(function(d, i) {
return i === handleIndex ? alignedValue(scale.invert(pos)) : d;
});
updateHandle(newValue);
listeners.call(
'start',
sliderSelection,
newValue.length === 1 ? newValue[0] : newValue
);
export function leeRaw(lambda, phi) {
// return d3.geoGnomonicRaw(...arguments);
var w = [-1 / 2, sqrt(3) / 2],
k = [0, 0],
h = [0, 0],
i,
z = complexMul(geoStereographicRaw(lambda, phi), [sqrt(2), 0]);
// rotate to have s ~= 1
var sector = scan(
[0, 1, 2].map(function(i) {
return -complexMul(z, complexPow(w, [i, 0]))[0];
})
);
var rot = complexPow(w, [sector, 0]);
var n = complexNorm(z);
if (n > 0.3) {
// if |z| > 0.5, use the approx based on y = (1-z)
// McIlroy formula 6 p6 and table for G page 16
var y = complexSub([1, 0], complexMul(rot, z));
// w1 = gamma(1/3) * gamma(1/2) / 3 / gamma(5/6);
// https://bl.ocks.org/Fil/1aeff1cfda7188e9fbf037d8e466c95c
var w1 = 1.4021821053254548;
function sm_1(z) {
var k = [0, 0];
// rotate to have s ~= 1
var rot = complexPow(
w,
scan(
[0, 1, 2].map(function(i) {
return -complexMul(z, complexPow(w, [i, 0]))[0];
})
)
);
var y = complexMul(rot, z);
y = [1 - y[0], -y[1]];
// McIlroy formula 5 p6 and table for F3 page 16
var F0 = [
1.44224957030741,
0.240374928384568,
0.0686785509670194,
0.0178055502507087,
0.00228276285265497,
hammertime.on('panend', function(ev) {
const x = xScale.invert(-ev.deltaX + xScale(dayShift));
let i = scan(
_data.divisions,
(a, b) => Math.abs(a.startDay - x) - Math.abs(b.startDay - x)
);
// Too far to the right
if (i + numYearsToView > _data.divisions.length) {
i = _data.divisions.length - numYearsToView;
}
year = _data.divisions[i].year;
selectYear(
_data.divisions[i].year,
_data.divisions[i + numYearsToView - 1].year
);
});
function alignedValue(newValue) {
if (step) {
var valueModStep = (newValue - domain[0]) % step;
var alignValue = newValue - valueModStep;
if (valueModStep * 2 > step) {
alignValue += step;
}
return newValue instanceof Date ? new Date(alignValue) : alignValue;
}
if (marks) {
var index = scan(
marks.map(function(d) {
return Math.abs(newValue - d);
})
);
return marks[index];
}
return newValue;
}
(priceHistory = [], spotPrice) => {
const lastIndex = scan(priceHistory, (a, b) => a.time - b.time);
const oldPrice = priceHistory[lastIndex] && priceHistory[lastIndex].price;
return spotPrice - oldPrice;
},
);