Skip to content
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

Remove more common lodash patterns that have native JavaScript equivalents #2517

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

jake-low
Copy link
Contributor

@jake-low jake-low commented Jan 9, 2025

Continuing on the theme from #2515, this PR replaces a few more common lodash-isms in the codebase with native JavaScript equivalents.

  • _first(arr) and _last(arr) become arr[0] and arr[arr.length - 1]
  • _indexOf(arr, elem) becomes arr.indexOf(elem)
  • _isFinite(val) becomes Number.isFinite(val)
  • _isBoolean(val) becomes typeof val === "boolean"
  • _isFunction(val) becomes typeof val === "function" (or in cases where it was being used to check if an optional function was present before calling it, I've replaced it with the optional-chaining operator val?.())
  • _isUndefined(val) becomes val === undefined
  • _isArray(val) becomes Array.isArray(val)

Each type of change was made in a separate commit, so you can review them one by one if you prefer.

Base automatically changed from jlow/autoformat to main January 15, 2025 18:59
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.

1 participant