From 8eb92073378960802a3d300349f42881abc30d69 Mon Sep 17 00:00:00 2001 From: Arseny Garelyshev Date: Wed, 9 Aug 2023 04:24:44 +0200 Subject: [PATCH] refactor: remove unused `defaultOK` parameter (#1435) `listingMode` function was being passed `defaultOK`, but this function doesn't accept any arguments since 22/12/2021 (c96b8132). --- src/impl/locale.js | 19 +++++++++---------- src/impl/tokenParser.js | 24 ++++++++++++++---------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/impl/locale.js b/src/impl/locale.js index 4a2f14bad..fe7dd57d6 100644 --- a/src/impl/locale.js +++ b/src/impl/locale.js @@ -135,8 +135,8 @@ function mapWeekdays(f) { return ms; } -function listStuff(loc, length, defaultOK, englishFn, intlFn) { - const mode = loc.listingMode(defaultOK); +function listStuff(loc, length, englishFn, intlFn) { + const mode = loc.listingMode(); if (mode === "error") { return null; @@ -388,8 +388,8 @@ export default class Locale { return this.clone({ ...alts, defaultToEN: false }); } - months(length, format = false, defaultOK = true) { - return listStuff(this, length, defaultOK, English.months, () => { + months(length, format = false) { + return listStuff(this, length, English.months, () => { const intl = format ? { month: length, day: "numeric" } : { month: length }, formatStr = format ? "format" : "standalone"; if (!this.monthsCache[formatStr][length]) { @@ -399,8 +399,8 @@ export default class Locale { }); } - weekdays(length, format = false, defaultOK = true) { - return listStuff(this, length, defaultOK, English.weekdays, () => { + weekdays(length, format = false) { + return listStuff(this, length, English.weekdays, () => { const intl = format ? { weekday: length, year: "numeric", month: "long", day: "numeric" } : { weekday: length }, @@ -414,11 +414,10 @@ export default class Locale { }); } - meridiems(defaultOK = true) { + meridiems() { return listStuff( this, undefined, - defaultOK, () => English.meridiems, () => { // In theory there could be aribitrary day periods. We're gonna assume there are exactly two @@ -435,8 +434,8 @@ export default class Locale { ); } - eras(length, defaultOK = true) { - return listStuff(this, length, defaultOK, English.eras, () => { + eras(length) { + return listStuff(this, length, English.eras, () => { const intl = { era: length }; // This is problematic. Different calendars are going to define eras totally differently. What I need is the minimum set of dates diff --git a/src/impl/tokenParser.js b/src/impl/tokenParser.js index 19008d298..8dd38f37f 100644 --- a/src/impl/tokenParser.js +++ b/src/impl/tokenParser.js @@ -53,6 +53,10 @@ function escapeToken(value) { return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"); } +/** + * @param token + * @param {Locale} loc + */ function unitForToken(token, loc) { const one = digitRegex(loc), two = digitRegex(loc, "{2}"), @@ -73,9 +77,9 @@ function unitForToken(token, loc) { switch (t.val) { // era case "G": - return oneOf(loc.eras("short", false), 0); + return oneOf(loc.eras("short"), 0); case "GG": - return oneOf(loc.eras("long", false), 0); + return oneOf(loc.eras("long"), 0); // years case "y": return intUnit(oneToSix); @@ -93,17 +97,17 @@ function unitForToken(token, loc) { case "MM": return intUnit(two); case "MMM": - return oneOf(loc.months("short", true, false), 1); + return oneOf(loc.months("short", true), 1); case "MMMM": - return oneOf(loc.months("long", true, false), 1); + return oneOf(loc.months("long", true), 1); case "L": return intUnit(oneOrTwo); case "LL": return intUnit(two); case "LLL": - return oneOf(loc.months("short", false, false), 1); + return oneOf(loc.months("short", false), 1); case "LLLL": - return oneOf(loc.months("long", false, false), 1); + return oneOf(loc.months("long", false), 1); // dates case "d": return intUnit(oneOrTwo); @@ -163,13 +167,13 @@ function unitForToken(token, loc) { case "c": return intUnit(one); case "EEE": - return oneOf(loc.weekdays("short", false, false), 1); + return oneOf(loc.weekdays("short", false), 1); case "EEEE": - return oneOf(loc.weekdays("long", false, false), 1); + return oneOf(loc.weekdays("long", false), 1); case "ccc": - return oneOf(loc.weekdays("short", true, false), 1); + return oneOf(loc.weekdays("short", true), 1); case "cccc": - return oneOf(loc.weekdays("long", true, false), 1); + return oneOf(loc.weekdays("long", true), 1); // offset/zone case "Z": case "ZZ":