Skip to content

fix: implement missing utilities and fix edge-case bugs - #337

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2211-1789007333
Open

fix: implement missing utilities and fix edge-case bugs#337
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2211-1789007333

Conversation

@stooit

@stooit stooit commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests in the utility library (now 60/60 passing) by implementing missing functionality and correcting edge-case bugs. No test files modified, no dependencies added.

Changes

  • calculator.tsdivide now throws on division by zero (including -0) instead of returning Infinity.
  • string-utils.ts — implemented truncate (truncates at a word boundary with "..." counted toward maxLength, returns unchanged when within limit); fixed wordCount to split on any whitespace run so consecutive spaces/tabs/newlines no longer inflate the count.
  • task-manager.ts — implemented remove (true/false via Map.delete), partial update (only applies keys present in changes, guarded by !== undefined), and sortBy for priority/status/createdAt (sorts a copy, leaving Map order intact).
  • date-utils.ts — fixed off-by-one in formatRelative: Math.floorMath.round with Math.abs applied before rounding, giving symmetric past/future day counts. Removed the now-stale BUG: comment.
  • validator.tsisEmail TLD quantifier {2,4}{2,} to accept long TLDs (e.g. .museum); isUrl now accepts explicit ports while keeping the http/https protocol allowlist (still rejects ftp://).

Verification

  • bun test: 60 pass / 0 fail
  • tsc --noEmit: clean
  • Independent review performed; no blocking issues.

Assumptions / notes

  • isEmail remains a deliberately loose regex — it satisfies the tests but is not a full RFC 5322 validator. For security-relevant use, verification-by-delivery is the durable control. Left as-is since no test required tightening.
  • update treats { description: undefined } as "no change" (conventional Partial semantics); there's no path to clear a field, matching the tested contract.

- calculator: divide throws on division by zero (incl. -0) instead of returning Infinity
- string-utils: implement truncate (word-boundary, ellipsis within maxLength); fix wordCount to split on any whitespace run
- task-manager: implement remove, partial update, and sortBy (priority/status/createdAt)
- date-utils: fix off-by-one in formatRelative (round + abs for symmetric past/future)
- validator: accept long TLDs in isEmail; accept ports in isUrl while keeping http/https allowlist
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