From 943433d486755c5fa74e9af2bc8d88ad8699ca31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Thu, 11 Apr 2024 11:47:11 +0200 Subject: [PATCH] remove unused exports > npx ts-unused-exports tsconfig.json src/**/*.js src/**/*ts test/**/*.js test/**/*.ts --- src/format.js | 4 ++-- src/options.js | 9 +-------- src/scales/index.js | 2 +- src/stats.js | 8 ++++---- src/style.js | 12 ++++++------ src/time.js | 2 +- 6 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/format.js b/src/format.js index f65fb16901..db9269ef4d 100644 --- a/src/format.js +++ b/src/format.js @@ -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) { const format = numberFormat(locale); return (i) => (i != null && !isNaN(i) ? format.format(i) : undefined); } @@ -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); } diff --git a/src/options.js b/src/options.js index 387daa94fb..15dff988e6 100644 --- a/src/options.js +++ b/src/options.js @@ -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; 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); export const first = (x) => (x ? x[0] : undefined); export const second = (x) => (x ? x[1] : undefined); export const third = (x) => (x ? x[2] : undefined); @@ -225,11 +223,6 @@ export function range(data) { return r; } -// Returns a filtered range of data given the test function. -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); @@ -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( diff --git a/src/scales/index.js b/src/scales/index.js index ee2f2b2688..fd08c77bb3 100644 --- a/src/scales/index.js +++ b/src/scales/index.js @@ -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 diff --git a/src/stats.js b/src/stats.js index e4fee82f05..91b5889e8c 100644 --- a/src/stats.js +++ b/src/stats.js @@ -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) { var EPS = 1e-8; var a1 = a - 1; var b1 = b - 1; @@ -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)); @@ -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; @@ -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, diff --git a/src/style.js b/src/style.js index a1af100fcd..98ae865130 100644 --- a/src/style.js +++ b/src/style.js @@ -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])) @@ -156,7 +156,7 @@ 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])) @@ -164,11 +164,11 @@ export function applyTitleGroup(selection, L) { .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])); } @@ -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); } @@ -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; } diff --git a/src/time.js b/src/time.js index 63722f587c..630260552b 100644 --- a/src/time.js +++ b/src/time.js @@ -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".