fix: implement missing utilities and fix edge-case bugs - #264
Open
stooit wants to merge 1 commit into
Open
Conversation
- task-manager: implement remove, update, and sortBy methods - calculator: throw on division by zero - date-utils: round to nearest day for relative formatting (off-by-one) - string-utils: implement truncate (word-boundary) and fix wordCount - validator: accept long TLDs in email and optional port in URL All 60 tests pass (was 44 pass / 16 fail).
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 previously-failing tests across the utility library (was 44 pass / 16 fail → now 60 pass / 0 fail). No test files modified, no new dependencies.
Changes by file
src/task-manager.ts— implemented three stub methods:remove(Map delete, returnsfalsefor unknown id),update(Object.assignmerge, returnsfalsefor unknown id), andsortBy(priority via{high:0, medium:1, low:2}rank map, or ascendingcreatedAt).src/calculator.ts—dividenow throws on division by zero.src/date-utils.ts— relative-time formatting off-by-one:Math.floor→Math.roundso 36h reports "2 days ago". Added a comment documenting the rounding intent to prevent regression.src/string-utils.ts— implementedtruncate(word-boundary truncation with"..."counting towardmaxLength; returns unchanged when within limit); fixedwordCountfor consecutive spaces.src/validator.ts—isEmailaccepts long TLDs (e.g..museum);isUrlaccepts an optional port (e.g.http://localhost:3000).Verification
bun test→ 60 pass / 0 fail / 70 expect() calls.Math.roundchange matches the source's own documented intent (nearest-day semantics), and the validator regex changes were checked against the reject cases the tests expect.Assumptions