Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2325-1785624453
Open

fix: implement missing utilities and fix edge-case bugs#274
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2325-1785624453

Conversation

@stooit

@stooit stooit commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

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

Changes

  • src/calculator.tsdivide now throws on division by zero instead of returning a poisoned Infinity/NaN.
  • src/string-utils.ts — implemented truncate (truncates at a word boundary with "..." counting toward maxLength; returns unchanged when within limit; guards short/negative maxLength). Fixed wordCount to split on /\s+/ so consecutive spaces/tabs/newlines are handled.
  • src/task-manager.ts — implemented remove and update (both return false for an unknown id; update applies only fields explicitly present) and sortBy (priority high > medium > low; createdAt oldest first).
  • src/date-utils.ts — fixed off-by-one in formatRelative day rounding. Rounding now takes the absolute value before Math.round, so 36h resolves to "2 days" for both past and future dates (a review pass caught that rounding the signed value regressed future dates at .5-day boundaries).
  • src/validator.tsisEmail now supports arbitrary subdomain depth and long TLDs with anchored labels (still rejects a@-b.com, a@b..com). isUrl accepts URLs with a port (e.g. http://localhost:3000) while retaining the http/https scheme allow-list.

Verification

  • bun test60 pass, 0 fail
  • bunx tsc --noEmit → clean
  • Changes reviewed by a review subagent; the one blocking regression it identified (future-date rounding) was fixed before commit.

Assumptions

  • Email domain charset: the implementation validates ASCII alphanumeric + hyphen domain labels. Non-ASCII/IDN domains (e.g. user@münchen.de) that the old permissive regex accepted are now rejected. This matches the test contract; IDN support was never a requirement. Flagged here in case a consumer relies on it.
  • sortBy ties on createdAt fall back to insertion order via stable sort, which equals creation order given createdAt is assigned in add.

- calculator: divide throws on division by zero
- string-utils: implement truncate (word-boundary, ellipsis in maxLength); wordCount handles consecutive whitespace
- task-manager: implement remove/update (false for unknown id) and sortBy (priority high>medium>low, createdAt oldest first)
- date-utils: fix off-by-one in formatRelative day rounding (abs before round, both past and future)
- validator: isEmail supports subdomains/long TLDs with anchored labels; isUrl accepts URLs with a port
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