Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function configureScheme(type, _, count) {
var extent = _.schemeExtent,
name, scheme;
if (isArray(_.scheme)) {
scheme = interpolateColors(_.scheme, _.interpolate, _.interpolateGamma);
} else {
name = _.scheme.toLowerCase();
scheme = getScheme(name);
if (!scheme) error(`Unrecognized scheme name: ${_.scheme}`);
}
// determine size for potential discrete range
count = (type === Threshold) ? count + 1
: (type === BinOrdinal) ? count - 1
: (type === Quantile || type === Quantize) ? (+_.schemeCount || DEFAULT_COUNT)
: count;
// adjust and/or quantize scheme as appropriate
return isInterpolating(type) ? adjustScheme(scheme, extent, _.reverse)
: isFunction(scheme) ? quantizeInterpolator(adjustScheme(scheme, extent), count)
: type === Ordinal ? scheme : scheme.slice(0, count);
}