fix: implement missing utilities and fix edge-case bugs - #282
Open
stooit wants to merge 1 commit into
Open
Conversation
- calculator: divide throws on division by zero instead of returning Infinity - string-utils: wordCount collapses consecutive whitespace; implement truncate with word-boundary + ellipsis, guarding against leading-whitespace content loss - task-manager: implement remove, update, and sortBy (with exhaustive default) - date-utils: formatRelative uses Math.round so 36h rounds to '2 days ago' - validator: isEmail accepts long TLDs/subdomains; isUrl accepts URLs with port All 60 tests pass; typecheck clean.
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 the full
bun testsuite pass (60/60, up from 44 pass / 16 fail) by implementing missing functions and fixing edge-case bugs across five source files. No test files were modified and no dependencies were added.Changes
src/calculator.ts—dividenow throws on division by zero instead of returningInfinity.src/string-utils.ts—wordCountcollapses consecutive whitespace;truncateimplemented with word-boundary truncation + ellipsis, guarding against leading-whitespace content loss and never exceedingmaxLength.src/task-manager.ts— implementedremove,update, andsortBy(priority high>medium>low, status ordering, createdAt oldest-first).sortByhas a throwingdefaultso an unknown field fails at the boundary rather than returningundefined.src/date-utils.ts—formatRelativeusesMath.roundso 36h reads "2 days ago".src/validator.ts—isEmailaccepts long TLDs and subdomains;isUrlaccepts URLs with a port.Verification
bun test: 60 pass / 0 fail (70 expect() calls)tsc --noEmit: clean (exit 0)Review notes / assumptions
update(id, { description: undefined })is intentionally a no-op; explicit""still clears.isEmailis a pragmatic regex, not RFC 5322-compliant — use a confirmation-link round-trip as the trust boundary if gating account creation.🤖 Generated autonomously.