refactor(core): fix eslint warning #5382
Merged
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.
Which problem is this PR solving?
Fixes the following eslint warning in the
core
pacakge:Ref #5365
Short description of the changes
This could have been addressed in various ways with no change to the code, but upon further inspection, we can probably shed some weight here.
This code was inherited from lodash, which defines:
overArg
allows each argument of the passed in function to be transformed by a mapper function, in this case, effective it amounts to:So at minimum, we can just inline that and get rid of
overArg
, since that's the only place we use that function.The intent here appears to be making a "safe" version of
Object.getPrototypeOf
that can be called with primitive values.For example,
Object.getPrototypeOf(null)
would throw, butObject.getPrototypeOf(Object(null))
wouldn't, and same for1
,true
, etc.Essentially,
Object(value)
will box the primitive value and the function will return the prototype of the boxed primitive object.I suppose this is useful in the rest of the lodash codebase. However, it's unclear that it is necessary in our stripped down version.
getPrototype
is only used inisPlainObject
. The first thing that function does is reject any non-object values which would necessarily exclude all primitive values.So I am pretty sure the
Object()
does nothing for us and we can just callObject.getPrototypeOf
directly and shed all the extra stuff.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: