Closed rosston closed 8 years ago
Other underscore/lodash functions used in index.js
but left unchanged:
_.extend
: aliased to _.assignIn
in lodash, seems to match underscore version, specifically that it extends from inherited properties as well_.union
: seems to match underscore version_.difference
: seems to match underscore version, although this one is a little harder to inspect due to the complexity of the lodash version_.isFunction
: seems to match underscore versionAll comparisons made by checking the docs and source for lodash 4.6.1 and underscore 1.5.2.
I don't really have any cycles to review this right now, but I wanted to say:
:+1: :+1: :+1: :+1: :+1: :+1: :+1:
No worries! I got caught up in other things, so haven't done the last bit of testing before merging. I plan to do another check to make sure lodash is API-compatible with underscore for the functions we're using.
Alright, I finally did the last bit of testing I wanted to do. I cloned the underscore repo, checked out the 1.5.2 tag, and threw lodash in the test suite. Here's the git diff:
And here are the results for each of the underscore functions we previously used in index.js and test/test.js:
_.keys
(ignored, since I replaced it with Object.keys
in our code) _.contains
✅ _.difference
✅ _.extend
✅ _.isFunction
✅ _.template
✅ _.union
❌ The only failed test for _.union
is this:
result = _.union(null, [1, 2, 3]);
deepEqual(result, [null, 1, 2, 3]);
...which seems like a pretty worthless piece of functionality. I also manually tested undefined
, and as (sort of) expected: underscore 1.5.2 keeps undefined
in the resulting array, lodash 4.11.1 drops the undefined
entirely. With where we use _.union
(see https://github.com/bithavoc/express-winston/blob/99b3e2d/index.js#L252-253), this difference will have no practical effect, since options.bodyWhitelist
and options.bodyBlacklist
fall back to the base exported versions.
So! In summary, everything is fine, and I'm merging this. 😄
Fixes #88.
Changes:
_.template
: minor API change_.contains
: calledincludes
in lodash 4_.keys
: underscore simply usedObject.keys
if available, so cut out the middlemanWhy lodash instead of underscore?
_.get
which could come in handy for #62 and #66)