Conversation
refactor(date): ♻️ replace safeDate with ensureDate in format functions refactor(date): ♻️ update isSameDay, isSameMonth, and isSameYear to use ensureDate test(date): ✅ add tests for isSameMonth and isSameYear with DateLike inputs chore(date): 🔧 remove safeDate helper and related tests
- add isTemporalDuration, isTemporalInstant, isTemporalPlainDate - add isTemporalPlainDateTime, isTemporalZonedDateTime checks - update vitest config for harmony-temporal support
- addDays, addMonths, addYears functions - startOf, endOf functions for date truncation - comprehensive tests for all new functions
- implement isWithinRange, clampDate, and overlaps functions - add eachDay and eachMonth functions for date iteration - include comprehensive tests for all new functionalities
- implement formatDuration for human-readable duration strings - add timeAgo for relative time formatting - include tests for both new helpers
- implement listTimezones, getTimezoneOffset, and formatInTimezone - add tests for timezone functionality
- implement isLeapYear and daysInMonth functions - add isWeekend and isBusinessDay functions - create tests for date validation and weekend logic
- implement toSeconds and toMillis functions - add fromSeconds and fromMillis functions - enhance tests for timestamp utilities - add benchmarks for performance evaluation
- handle sparse arrays - handle large and NaN chunk sizes - deduplicate NaN values - handle __proto__ and constructor as string values - handle null and undefined values - handle -0 and +0
There was a problem hiding this comment.
Pull request overview
This PR prepares the codebase for the next alpha release by expanding the date and type helper sets, adding extensive edge-case tests (including security-focused cases), and updating website metadata generation to reference the relocated native alternatives data.
Changes:
- Add a comprehensive set of new
helpers/dateutilities (DateLike normalization, ranges, sequences, formatting, timezone helpers, etc.) with unit/property/bench coverage. - Add Temporal type guards (
isTemporal*) and enable Temporal in tests. - Harden
deepCloneagainst prototype-pollution keys and expand “security edge case” tests across helpers; movenative-alternatives.jsontodocs/and update build/docs references.
Reviewed changes
Copilot reviewed 101 out of 101 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Passes Node flag intended to enable Temporal during test runs. |
| scripts/build/build-website-metadata.ts | Reads native alternatives metadata from docs/native-alternatives.json. |
| helpers/url/withoutTrailingSlash.test.ts | Adds “security edge case” tests. |
| helpers/url/withLeadingSlash.test.ts | Adds “security edge case” tests. |
| helpers/url/relativeURLToAbsolute.test.ts | Adds “security edge case” tests around dangerous-looking schemes/paths. |
| helpers/url/onlyPath.test.ts | Adds “security edge case” tests. |
| helpers/url/extractPureURI.test.ts | Adds “security edge case” tests. |
| helpers/url/cleanPath.test.ts | Adds “security edge case” tests. |
| helpers/type/isTemporalZonedDateTime.ts | Adds a Temporal ZonedDateTime type guard. |
| helpers/type/isTemporalZonedDateTime.test.ts | Unit tests for isTemporalZonedDateTime. |
| helpers/type/isTemporalZonedDateTime.spec.ts | Contract/property-style tests for isTemporalZonedDateTime. |
| helpers/type/isTemporalPlainTime.ts | Adds a Temporal PlainTime type guard. |
| helpers/type/isTemporalPlainTime.test.ts | Unit tests for isTemporalPlainTime. |
| helpers/type/isTemporalPlainTime.spec.ts | Contract/property-style tests for isTemporalPlainTime. |
| helpers/type/isTemporalPlainDateTime.ts | Adds a Temporal PlainDateTime type guard. |
| helpers/type/isTemporalPlainDateTime.test.ts | Unit tests for isTemporalPlainDateTime. |
| helpers/type/isTemporalPlainDateTime.spec.ts | Contract/property-style tests for isTemporalPlainDateTime. |
| helpers/type/isTemporalPlainDate.ts | Adds a Temporal PlainDate type guard. |
| helpers/type/isTemporalPlainDate.test.ts | Unit tests for isTemporalPlainDate. |
| helpers/type/isTemporalPlainDate.spec.ts | Contract/property-style tests for isTemporalPlainDate. |
| helpers/type/isTemporalInstant.ts | Adds a Temporal Instant type guard. |
| helpers/type/isTemporalInstant.test.ts | Unit tests for isTemporalInstant. |
| helpers/type/isTemporalInstant.spec.ts | Contract/property-style tests for isTemporalInstant. |
| helpers/type/isTemporalDuration.ts | Adds a Temporal Duration type guard. |
| helpers/type/isTemporalDuration.test.ts | Unit tests for isTemporalDuration. |
| helpers/type/isTemporalDuration.spec.ts | Contract/property-style tests for isTemporalDuration. |
| helpers/type/isPlainObject.test.ts | Adds “security edge case” tests (Proxy, proto, etc.). |
| helpers/string/titleCase.test.ts | Adds “security edge case” tests (XSS-like strings, long inputs, null bytes). |
| helpers/string/snakeCase.test.ts | Adds “security edge case” tests. |
| helpers/string/pascalCase.test.ts | Adds “security edge case” tests. |
| helpers/string/kebabCase.test.ts | Adds “security edge case” tests. |
| helpers/string/camelCase.test.ts | Adds “security edge case” tests. |
| helpers/object/deepCompare.test.ts | Adds “security edge case” tests (proto keys, deep nesting). |
| helpers/object/deepClone.ts | Skips cloning unsafe keys to mitigate prototype pollution. |
| helpers/object/deepClone.test.ts | Adds security-focused tests ensuring unsafe keys aren’t transported. |
| helpers/date/weekday.ts | Adds WeekDays, isWeekend, isBusinessDay. |
| helpers/date/weekday.test.ts | Unit tests for weekday helpers. |
| helpers/date/weekday.spec.ts | Property/contract tests for weekday helpers. |
| helpers/date/validate.ts | Adds isValidDateString. |
| helpers/date/validate.test.ts | Unit tests for date-string validation. |
| helpers/date/validate.spec.ts | Property/contract tests for date-string validation. |
| helpers/date/types.ts | Introduces DateLike + EpochMilliseconds structural type. |
| helpers/date/timezone.ts | Adds timezone helpers (listTimezones, getTimezoneOffset, formatInTimezone). |
| helpers/date/timezone.spec.ts | Property/contract tests for timezone helpers. |
| helpers/date/timezone.bench.ts | Benchmarks for timezone helpers. |
| helpers/date/timestamp.ts | Expands timestamp utilities; adds seconds/millis conversion helpers. |
| helpers/date/timestamp.test.ts | Unit tests for new timestamp helpers (incl. negative timestamps). |
| helpers/date/timestamp.spec.ts | Property/contract tests for timestamp helpers. |
| helpers/date/timestamp.bench.ts | Benchmarks for timestamp helpers. |
| helpers/date/timeAgo.ts | Adds timeAgo using Intl.RelativeTimeFormat. |
| helpers/date/timeAgo.test.ts | Unit tests for timeAgo. |
| helpers/date/timeAgo.spec.ts | Property/contract tests for timeAgo. |
| helpers/date/startOf.ts | Adds startOf/endOf truncation helpers. |
| helpers/date/startOf.test.ts | Unit tests for startOf/endOf. |
| helpers/date/startOf.spec.ts | Property/contract tests for startOf/endOf. |
| helpers/date/sequence.ts | Adds eachDay/eachMonth range expansion helpers. |
| helpers/date/sequence.test.ts | Unit tests for sequence helpers. |
| helpers/date/sequence.spec.ts | Property/contract tests for sequence helpers. |
| helpers/date/safeDate.ts | Deprecates wrappers and forwards to ensureDate. |
| helpers/date/safeDate.test.ts | Removes old safeDate unit tests. |
| helpers/date/safeDate.spec.ts | Removes old safeDate property tests. |
| helpers/date/safeDate.example.ts | Removes old safeDate examples. |
| helpers/date/range.ts | Adds range helpers (isWithinRange, clampDate, overlaps). |
| helpers/date/range.spec.ts | Property/contract tests for range helpers. |
| helpers/date/range.bench.ts | Benchmarks for range/sequence helpers. |
| helpers/date/is.ts | Extends “is same *” helpers to accept DateLike; adds month/year variants. |
| helpers/date/is.spec.ts | Updates tests for new isSameMonth/isSameYear + DateLike inputs. |
| helpers/date/index.ts | Exports the expanded date surface. |
| helpers/date/formatDuration.ts | Adds compact duration formatting helper. |
| helpers/date/formatDuration.test.ts | Unit tests for formatDuration. |
| helpers/date/formatDuration.spec.ts | Property/contract tests for formatDuration. |
| helpers/date/format.ts | Switches date formatting helpers to use ensureDate + DateLike. |
| helpers/date/format.bench.ts | Benchmarks for date formatting helpers. |
| helpers/date/ensureDate.ts | Adds core DateLike→Date normalization (ensureDate). |
| helpers/date/ensureDate.spec.ts | Property/contract tests for ensureDate. |
| helpers/date/ensureDate.bench.ts | Benchmarks for ensureDate. |
| helpers/date/difference.ts | Adds generalized difference(); deprecates daysDifference. |
| helpers/date/difference.test.ts | Adds unit tests for difference(). |
| helpers/date/difference.spec.ts | Adds property/contract tests for difference(). |
| helpers/date/compare.ts | Extends date comparison to DateLike and adds month/year precision. |
| helpers/date/compare.test.ts | Updates tests for new compare behavior and precisions. |
| helpers/date/compare.spec.ts | Updates property/contract tests for new precisions and DateLike inputs. |
| helpers/date/compare.bench.ts | Benchmarks compare/difference/isSame* helpers. |
| helpers/date/calendar.ts | Adds calendar helpers (isLeapYear, daysInMonth). |
| helpers/date/calendar.test.ts | Unit tests for calendar helpers. |
| helpers/date/calendar.spec.ts | Property/contract tests for calendar helpers. |
| helpers/date/calendar.bench.ts | Benchmarks for calendar/weekday/validate helpers. |
| helpers/date/add.ts | Adds addDays/addMonths/addYears. |
| helpers/date/add.test.ts | Unit tests for add helpers. |
| helpers/date/add.spec.ts | Property/contract tests for add helpers. |
| helpers/date/add.bench.ts | Benchmarks for add + startOf/endOf. |
| helpers/array/unique.test.ts | Adds “security edge case” tests. |
| helpers/array/deepEquals.test.ts | Adds “security edge case” tests (sparse arrays, NaN, deep nesting). |
| helpers/array/chunk.test.ts | Adds “security edge case” tests. |
| docs/native-alternatives.json | Adds native alternatives section for date/Temporal-related APIs. |
| CONTRIBUTING.md | Updates guidance to check docs/native-alternatives.json. |
| AGENTS.md | Documents docs/native-alternatives.json location in repo layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ PR Validation Passed
📋 Pipeline Status
📊 Code Coverage
🧬 Mutation Testing
🌐 Runtime Compatibility
⏱️ Benchmarks
ℹ️ About this report
🤖 Generated by @helpers4 CI • 2026-04-19 |
- compare(): return false when both inputs are invalid (not true) - deepClone(): use Object.prototype.hasOwnProperty.call() for null-prototype objects - timeAgo test: fix misleading test description
- Narrow sequence.spec.ts property-based date range from 10y to 2y to prevent eachDay tests timing out in CI (11.5s → 0.5s) - Fix mutation score grep patterns to match Stryker v9 clear-text table format (All files row instead of non-existent patterns)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 107 out of 107 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- change import paths from './types' to './types.model' - remove unused index.ts and types.ts files - add new types.model.ts and Maybe.model.ts files - update tests to reflect changes in date helpers
Description
Please include a summary of what this PR does and why it's needed.
Type of Change
Related Issues
Closes #(issue number)
How Has This Been Tested?
Describe the tests you ran and how to reproduce them:
Checklist
Screenshots (if applicable)
Add screenshots for UI changes.
Additional Context
Add any other context about the PR here.