fix: Replace custom repeatString function with repeat() - #2820
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Looks like the old function was there because at the time |
|
I didn't perform any benchmark, but I would assume that the built-in functionality should be at least as fast as the custom implementation. Actually I would expect it to be faster as a lot of the string allocation+concatenation can be done in one go in the native implementation. Update: Did a benchmark now out of curiosity. Result: It depends 😅 If you count the cost of creating the function it the old version is always slower than |
|
Should be same-or-faster unless we're repeating really small strings, in which case the implementation shouldn't matter anyway. But it's nice to use the built-in language feature. Do all marked-supported language runtimes now support |
repeatString function with repeat()repeatString function with repeat()
|
We don't have a list of supported runtimes outside of Node.js as far I know. We support Node.js 18 and newer since Marked 5.0.0 (see #2767) |
## [5.0.4](markedjs/marked@v5.0.3...v5.0.4) (2023-05-30) ### Bug Fixes * Add Unicode punctuations ([#2811](markedjs/marked#2811)) ([9c873cf](markedjs/marked@9c873cf)) * fix hr after list ([#2809](markedjs/marked#2809)) ([cbbde87](markedjs/marked@cbbde87)) * Replace custom `repeatString` function with `repeat()` ([#2820](markedjs/marked#2820)) ([2bfc3c1](markedjs/marked@2bfc3c1))
Marked version:
5.0.3
Description
While working on #2805 I noticed that there are a few
repeatStringfunctions that could trivially be replaced withString.proptotype.repeat(), which is already used in some other places in the code anyway.Contributor
Committer
In most cases, this should be a different person than the contributor.