Skip to content

chore: replace deprecated String.prototype.substr()#4852

Merged
juergba merged 1 commit intomochajs:masterfrom
CommanderRoot:fix/rm-deprecated-substr
Mar 22, 2022
Merged

chore: replace deprecated String.prototype.substr()#4852
juergba merged 1 commit intomochajs:masterfrom
CommanderRoot:fix/rm-deprecated-substr

Conversation

@CommanderRoot
Copy link
Copy Markdown
Contributor

Description of the Change

String.prototype.substr() is deprecated so we replace it with String.prototype.slice() which works similarily but isn't deprecated.
.substr() probably isn't going away anytime soon but the change is trivial so it doesn't hurt to do it.

Alternate Designs

It would also be possible to use substring() instead of slice()

Why should this be in core?

Best to not use deprecated functions

Benefits

No more deprecated functions

Possible Drawbacks

None

Applicable issues

None so far

.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 94.465% when pulling 9ba2168 on CommanderRoot:fix/rm-deprecated-substr into d7f6ea5 on mochajs:master.

@juergba juergba added the run-browser-test run browser tests on forked PR if code is safe label Mar 22, 2022
@github-actions github-actions Bot removed the run-browser-test run browser tests on forked PR if code is safe label Mar 22, 2022
@juergba juergba added area: browser browser-specific area: reporters involving a specific reporter type: cleanup a refactor labels Mar 22, 2022
@juergba juergba added this to the v10.0.0 milestone Mar 22, 2022
@juergba juergba merged commit a816130 into mochajs:master Mar 22, 2022
@juergba juergba added the semver-patch implementation requires increase of "patch" version number; "bug fixes" label Mar 22, 2022
lennonnikolas pushed a commit to lennonnikolas/mocha that referenced this pull request Jan 24, 2026
'substr()' is deprecated, so we replace it with 'slice()' which works similarily.
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: browser browser-specific area: reporters involving a specific reporter semver-patch implementation requires increase of "patch" version number; "bug fixes" type: cleanup a refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants