Conversation
- calculator: divide throws on division by zero - string-utils: wordCount handles consecutive whitespace; implement truncate with word-boundary logic and ellipsis counting toward maxLength - task-manager: implement remove/update return semantics and sortBy for priority and createdAt - date-utils: fix formatRelative off-by-one (round hours to days) - validator: isEmail accepts long TLDs; isUrl accepts URLs with ports All 60 tests pass; no test files modified, no dependencies added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all 16 failing tests in the utility library (was 44 pass / 16 fail, now 60 pass / 0 fail). Only
src/files were changed — no test files modified, no dependencies added.Changes
calculator.ts—dividenow throws on division by zero instead of returningInfinity/NaN.string-utils.ts—wordCountsplits on\s+(handles consecutive spaces/tabs/newlines);truncateimplemented with word-boundary truncation, ellipsis counting towardmaxLength, returns unchanged when within limit, and handles strings shorter than the ellipsis.task-manager.ts—removeandupdatereturnfalsefor unknown ids;updateapplies only supplied fields;sortBysupports priority (high→medium→low) andcreatedAt(oldest first), with deterministic tie-breaking on id.date-utils.ts—formatRelativeoff-by-one fixed: day count now rounds hours to days (36h → "2 days ago").validator.ts—isEmailaccepts long TLDs (relaxed{2,4}→{2,}, added RFC-5321 254-char cap);isUrlaccepts URLs with a port (dropped the erroneous empty-port requirement, protocol allowlist retained).Testing
bun test→ 60 pass, 0 fail (70 expect() calls).tsc --noEmitexits 0.Assumptions
truncatereserves 3 chars for...only whenmaxLength > 3; otherwise it hard-slices.updatetreats omitted fields as "leave unchanged" (fields cleared only when explicitly present).sortBybreaks ties on numeric id for deterministic ordering.Notes
isEmail/isUrlare format checks, not deliverability/reachability checks.