Framework for numbers and string changes#61
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the TypeScript implementations of @tolki/str and @tolki/num with updated Laravel-style semantics: containsAll() no longer treats an empty needle list as a successful match, and numeric humanization/abbreviation no longer emits a spurious "-0" for small negative values that round to zero.
Changes:
- Update
Str.containsAll()(and thusStringable#containsAll()) to returnfalsewhen the needles iterable is empty, and add corresponding test coverage. - Update
Num.summarize()sign handling to avoid returning"-0"when the summarized magnitude equals zero at the requested precision, and add corresponding test coverage. - Add changesets for both behavior fixes; update PHP stubs / function lists and a collections docs stub in support of framework parity/reference syncing.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/str/stubs/StrTest.php | Updates Laravel stub test data provider for empty-needles containsAll case (reference parity). |
| packages/str/stubs/Str.php | Updates Laravel stub implementation of containsAll to return false on empty needles (reference parity). |
| packages/str/src/str.ts | Changes containsAll() to require at least one needle (empty iterable now returns false). |
| packages/str/fn-lists/StrTest-Function-List.txt | Regenerated function list line mappings after stub change (generated file). |
| packages/str/fn-lists/Str-Function-List.txt | Regenerated function list line mappings after stub change (generated file). |
| packages/str/tests/str.spec.ts | Updates/extends tests to cover empty-needles containsAll returning false. |
| packages/num/stubs/NumberTest.php | Adds Laravel stub tests for negative values rounding to zero not keeping the sign (reference parity). |
| packages/num/stubs/Number.php | Updates Laravel stub summarize sign logic to avoid -0 (reference parity). |
| packages/num/src/num.ts | Updates negative-branch summarize() sign handling to avoid emitting -0 when summary equals zero summary. |
| packages/num/fn-lists/NumberTest-Function-List.txt | Regenerated function list line mappings after stub change (generated file). |
| packages/num/fn-lists/Number-Function-List.txt | Regenerated function list line mappings after stub change (generated file). |
| packages/num/tests/num.spec.ts | Adds tests ensuring abbreviate()/forHumans() don’t return -0 for small negatives that round to zero. |
| docs/stubs/collections.md | Updates collections docs stub to include reduceInto reference and additional guidance (reference content). |
| .changeset/quiet-numbers-round-safely.md | Patch changeset documenting the -0 output fix for @tolki/num. |
| .changeset/empty-needles-return-false.md | Patch changeset documenting the empty-needles behavior fix for @tolki/str. |
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.
No description provided.