Skip to content

ref: Replace string.substr with string.slice #6760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2023
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 12, 2023

substr is actually deprecated (see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr).

For our cases, slice() should work just as well - see this very informative answer: https://stackoverflow.com/a/31910656

I noticed this while playing around with typescript update, which complains about this being deprecated.

As far as I see, slice and substr would only perform differently when start !== 0, which we don't have anywhere.

`substr` is actually deprecated (see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr). 

For our cases, `slice()` should work just as well - see this very informative answer: https://stackoverflow.com/a/31910656
@mydea mydea requested review from lforst, Lms24 and AbhiPrasad January 12, 2023 16:37
@mydea mydea self-assigned this Jan 12, 2023
@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.84 KB (-0.03% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 61.46 KB (-0.01% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.61 KB (-0.02% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 55 KB (-0.01% 🔽)
@sentry/browser - Webpack (gzipped + minified) 20.37 KB (-0.03% 🔽)
@sentry/browser - Webpack (minified) 66.54 KB (-0.01% 🔽)
@sentry/react - Webpack (gzipped + minified) 20.4 KB (-0.02% 🔽)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.63 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.82 KB (+0.01% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.25 KB (-0.03% 🔽)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.26 KB (-0.01% 🔽)
@sentry/replay - Webpack (gzipped + minified) 38.5 KB (0%)

@mydea mydea merged commit 2662401 into master Jan 13, 2023
@mydea mydea deleted the fn/replace-substr-slice branch January 13, 2023 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants