fix: implement missing utilities and fix edge-case bugs to pass all tests - #286
Open
stooit wants to merge 1 commit into
Open
fix: implement missing utilities and fix edge-case bugs to pass all tests#286stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…ests - calculator: divide now throws on division by zero instead of returning Infinity - date-utils: fix off-by-one in formatRelative (round hours/24, so 36h reads '2 days ago') - string-utils: implement truncate (word-boundary, ellipsis within maxLength) and fix wordCount for consecutive whitespace - task-manager: implement remove, update (partial), and sortBy (priority/status/createdAt) - validator: isEmail accepts subdomains and long TLDs; isUrl accepts URLs with ports All 60 tests pass; no test files modified.
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
Makes all 60 tests pass (was 44 pass / 16 fail) across the TypeScript utility library. Only
src/files changed — no test files modified, no dependencies added.Changes
dividenow throws on division by zero instead of returningInfinity.formatRelative: days computed asround(hours/24), so 36h correctly reads "2 days ago" while 24h stays "1 day ago".truncate(word-boundary cut, ellipsis counted withinmaxLength, result always ≤maxLength); fixedwordCountto collapse consecutive whitespace (/\s+/).remove(boolean),update(partial, only applies defined keys, false for unknown id), andsortBy(priority high→medium→low, status, createdAt oldest-first).isEmailaccepts subdomains and long TLDs (e.g.user@example.museum) while still rejecting empty labels/spaces;isUrlaccepts URLs with ports (e.g.http://localhost:3000) with the scheme allowlist retained.Verification
bun test→ 60 pass, 0 failtsc --noEmitcleanAssumptions / notes
truncatewith leading-whitespace-only input,isUrlvalidating syntax/scheme only (not SSRF destination safety), and asortByinsertion-tiebreak that assumes numeric ids. None are regressions; left as-is to keep the change minimal.