-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Object Type-Detection and Replacing object.assign #3757
Conversation
* @return {Boolean} | ||
*/ | ||
export function isObject(value) { | ||
return !!value && typeof value === 'object'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this directly contradicts the jsdoc comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it doesn't but the line 63 is a bit unclear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will clarify! 👍
* @return {Boolean} | ||
*/ | ||
export function isPlain(value) { | ||
return isObject(value) && value.constructor === Object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove the toString
check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a copy-paste mistake.
Should |
@brandonocasey Yeah, I do think we ought to not have the partial lodash dependency there, but that function is a bit more complex in that it's recursive and has the "customizer" thing; so, it's a bit more prone to unforeseen breaking changes. That said, I do plan to take a stab at it. |
SPACE SAVING AHOY! 🚀 |
* | ||
* @return {Function} | ||
*/ | ||
export const throttle = function(fn, wait) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be done in a separate PR?
* @param {Object} value | ||
* @return {Boolean} | ||
*/ | ||
export function isPlain(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be better to use https://lodash.com/docs/4.16.6#isPlainObject?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My next PR is eliminating lodash as a dependency. It's not worth the extra weight of including lodash just for this.
* @param {Object} value | ||
* @return {Boolean} | ||
*/ | ||
export function isObject(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be better to just use https://lodash.com/docs/4.16.6#isObject?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My next PR is eliminating lodash as a dependency. It's not worth the extra weight of including lodash just for this.
70c5f46
to
0448fe8
Compare
0448fe8
to
68bd25b
Compare
68bd25b
to
c2a9610
Compare
c2a9610
to
c073674
Compare
Description
This pulls in a few updates I made to
utils/obj
from #3690 so they can be more isolated and make it into 5.x.Perhaps more impactful, this removes
object.assign
as a dependency and re-implements the functionality we were depending on. This change reduces the minified size of Video.js by over 2KB off the gzipped size.Specific Changes proposed
isObject
method: essentially,typeof x === 'object'
with a null check.isPlain
method: taken frommergeOptions
, this does a reasonable job at identifying plain objects.object.assign
.Requirements Checklist