Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused exports? #2051

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const weekdayFormat = memoize1((locale, weekday) => {
return new Intl.DateTimeFormat(locale, {timeZone: "UTC", ...(weekday && {weekday})});
});

export function formatNumber(locale = "en-US") {
function formatNumber(locale) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I learned that we don't need to set the default locale (cf. #384) in this function, since it's only called from formatAuto.

const format = numberFormat(locale);
return (i) => (i != null && !isNaN(i) ? format.format(i) : undefined);
}
Expand All @@ -33,7 +33,7 @@ export function formatIsoDate(date) {
return isoFormat(date, "Invalid Date");
}

export function formatAuto(locale = "en-US") {
function formatAuto(locale = "en-US") {
const number = formatNumber(locale);
return (v) => (v instanceof Date ? formatIsoDate : typeof v === "number" ? number : string)(v);
}
Expand Down
9 changes: 1 addition & 8 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ export const singleton = [null]; // for data-less decoration marks, e.g. frame
export const field = (name) => (d) => d[name];
export const indexOf = {transform: range};
export const identity = {transform: (d) => d};
export const zero = () => 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be here for consistency only

export const one = () => 1;
export const yes = () => true;
export const string = (x) => (x == null ? x : `${x}`);
export const number = (x) => (x == null ? x : +x);
export const boolean = (x) => (x == null ? x : !!x);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be here for consistency only

export const first = (x) => (x ? x[0] : undefined);
export const second = (x) => (x ? x[1] : undefined);
export const third = (x) => (x ? x[2] : undefined);
Expand Down Expand Up @@ -225,11 +223,6 @@ export function range(data) {
return r;
}

// Returns a filtered range of data given the test function.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

export function where(data, test) {
return range(data).filter((i) => test(data[i], i, data));
}

// Returns an array [values[index[0]], values[index[1]], …].
export function take(values, index) {
return map(index, (i) => values[i], values.constructor);
Expand Down Expand Up @@ -528,7 +521,7 @@ export function inherit(options = {}, ...rest) {

// Given an iterable of named things (objects with a name property), returns a
// corresponding object with properties associated with the given name.
export function named(things) {
function named(things) {
console.warn("named iterables are deprecated; please use an object instead");
const names = new Set();
return Object.fromEntries(
Expand Down
2 changes: 1 addition & 1 deletion src/scales/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const symbol = Symbol("symbol");

// There isn’t really a projection scale; this represents x and y for geometry.
// This is used to denote channels that should be projected.
export const projection = Symbol("projection");
const projection = Symbol("projection");

// TODO Rather than hard-coding the list of known scale names, collect the names
// and categories for each plot specification, so that custom marks can register
Expand Down
8 changes: 4 additions & 4 deletions src/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

export function ibetainv(p, a, b) {
function ibetainv(p, a, b) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is an external library, we might not want to mess with it too much

var EPS = 1e-8;
var a1 = a - 1;
var b1 = b - 1;
Expand Down Expand Up @@ -60,7 +60,7 @@ export function ibetainv(p, a, b) {
return x;
}

export function ibeta(x, a, b) {
function ibeta(x, a, b) {
// Factors in front of the continued fraction.
var bt =
x === 0 || x === 1 ? 0 : Math.exp(gammaln(a + b) - gammaln(a) - gammaln(b) + a * Math.log(x) + b * Math.log(1 - x));
Expand All @@ -72,7 +72,7 @@ export function ibeta(x, a, b) {
return 1 - (bt * betacf(1 - x, b, a)) / b;
}

export function betacf(x, a, b) {
function betacf(x, a, b) {
var fpmin = 1e-30;
var m = 1;
var qab = a + b;
Expand Down Expand Up @@ -112,7 +112,7 @@ export function betacf(x, a, b) {
return h;
}

export function gammaln(x) {
function gammaln(x) {
var j = 0;
var cof = [
76.18009172947146, -86.5053203294167, 24.01409824083091, -1.231739572450155, 0.1208650973866179e-2,
Expand Down
12 changes: 6 additions & 6 deletions src/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function styles(
}

// Applies the specified titles via selection.call.
export function applyTitle(selection, L) {
function applyTitle(selection, L) {
if (L)
selection
.filter((i) => nonempty(L[i]))
Expand All @@ -156,19 +156,19 @@ export function applyTitle(selection, L) {
}

// Like applyTitle, but for grouped data (lines, areas).
export function applyTitleGroup(selection, L) {
function applyTitleGroup(selection, L) {
if (L)
selection
.filter(([i]) => nonempty(L[i]))
.append("title")
.call(applyTextGroup, L);
}

export function applyText(selection, T) {
function applyText(selection, T) {
if (T) selection.text((i) => formatDefault(T[i]));
}

export function applyTextGroup(selection, T) {
function applyTextGroup(selection, T) {
if (T) selection.text(([i]) => formatDefault(T[i]));
}

Expand Down Expand Up @@ -387,7 +387,7 @@ export function applyAttr(selection, name, value) {
if (value != null) selection.attr(name, value);
}

export function applyStyle(selection, name, value) {
function applyStyle(selection, name, value) {
if (value != null) selection.style(name, value);
}

Expand All @@ -403,7 +403,7 @@ export function impliedString(value, impliedValue) {
if ((value = string(value)) !== impliedValue) return value;
}

export function impliedNumber(value, impliedValue) {
function impliedNumber(value, impliedValue) {
if ((value = number(value)) !== impliedValue) return value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const utcIntervals = new Map([
// interval; that would allow us to move this logic to D3, and allow
// generalization even when a custom interval is provided.
export const intervalDuration = Symbol("intervalDuration");
export const intervalType = Symbol("intervalType");
const intervalType = Symbol("intervalType");

// We greedily mutate D3’s standard intervals on load so that the hidden fields
// are available even if specified as e.g. d3.utcMonth instead of "month".
Expand Down