Merged
Conversation
`String.prototype.repeat` has existed since ES2015 / Node 4. The custom repeat() used new Array(n).join(s) which produces n-1 copies — the replacement preserves this semantic with .repeat(n-1). Also updates a misleading IE7/IE8 comment on boxed String handling. Ref: #5357 (v12 Release Plan)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes lib/utils.js by removing a local repeat() helper in favor of String.prototype.repeat(), aligning with Mocha’s modern runtime targets, and clarifies a comment related to boxed String handling during stringification.
Changes:
- Remove the internal
.repeat()polyfill helper (new Array(n).join(s)) fromjsonStringify(). - Replace indentation building with
" ".repeat(...)while preserving the previous off-by-one semantics. - Update the boxed
Stringcomment inexports.stringify()to describe the behavior more accurately.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5837 +/- ##
==========================================
+ Coverage 89.70% 89.74% +0.03%
==========================================
Files 64 64
Lines 4691 4689 -2
Branches 976 976
==========================================
Hits 4208 4208
+ Misses 483 481 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
String.prototype.repeathas existed since ES2015 / Node 4.The custom
repeat()usednew Array(n).join(s)which produces n-1 copies — the replacement preserves this semantic with.repeat(n-1).Also updates a misleading IE7/IE8 comment on boxed String handling.
PR Checklist
status: accepting prs