Remove lodash.omit#478
Conversation
| */ | ||
| export function omit(obj, omitKeys) { | ||
| const result = {}; | ||
| Object.keys(obj).forEach(key => { |
There was a problem hiding this comment.
Is it worth having a null/undefined check before this line?
There was a problem hiding this comment.
Right now we have the following 2 ways that omit is used:
omit(this.props, ['some', 'keys', 'to', 'omit'])
omit(this.props, Object.keys(propTypes))That means that both the object and the keys to omit are always passed in.
Right now if you pass in null for either parameter, it will blow up because it will execute Object.keys(null) or null.indexOf(key).
Would you expect obj or omitKeys to be able to be null ?
There was a problem hiding this comment.
I was thinking of potential of obj to be null, but after a second I agree that it is unnecessary.
|
I'd imagine most people already use a ton of lodash so this would be a minor increase in filesize. But for those not using all of it, this will be a big save. 👍 |
When I was analyzing the source map for #474 I noticed that the package
lodash.omittakes up 9.29kB!Looking at the source, we can see that it pulls in a lot of dependent lodash functions.
I've added our own omit function to
utils.js, which minifies to 105 bytes, and works with the use cases that we provide to it:This saves the user ~9kB.