Skip to content

fix(minMax): select dates in one pass without temporary arrays - #3191

Open
OskarEichler wants to merge 1 commit into
iamkun:devfrom
OskarEichler:codex/minmax-single-pass
Open

fix(minMax): select dates in one pass without temporary arrays#3191
OskarEichler wants to merge 1 commit into
iamkun:devfrom
OskarEichler:codex/minmax-single-pass

Conversation

@OskarEichler

Copy link
Copy Markdown

Fixes and simplification

  • Select the minimum/maximum in a single pass, skipping absent values during selection instead of allocating a filtered copy.
  • Pass the existing arguments object directly, avoiding a second temporary array for variadic calls.
  • Return null consistently when every supplied value is absent. Previously dayjs.max([null, undefined]) returned undefined, while dayjs.max([]) returned null.
  • Replace overlapping empty-input conditions with the naturally empty selection result.

Valid result identity, first-winner tie handling, ignored falsy entries, and invalid-date propagation are preserved. Input arrays are not mutated. This builds on the null-skipping behavior introduced in #2330.

Compatibility

No new API, types, dependencies, or runtime requirements. The observable correction is null instead of undefined for all-absent input; callers explicitly distinguishing those values should account for it. Invalid Day.js objects are still propagated, not silently ignored.

Verification

  • 6,002 source equivalence/empty-input checks, comparing against baseline across array/variadic calls, frozen/sparse arrays, ties, null/falsy inputs, and multiple invalid dates.
  • All 794 existing tests / 93 suites and 100% line coverage on the reviewed patch set, including independent locale/calendar fixes; release 1.11.23 backport suite also passes.
  • Lint, all 40 declarations, complete builds, and size limit pass.
  • A synthetic nullable 100,000-entry array benchmark (100 selections) measured 128.93 ms before and 124.64 ms after. This is not an application-wide speedup claim; the main benefit is removing temporary arrays and a traversal.

No tests were added or changed. Legacy size checking used a process-local OpenSSL compatibility flag on Node 22, not a package change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant