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

_.pick is incorrectly simplified, Lodash accepts a path #308

Open
alejandroiglesias opened this issue Apr 6, 2021 · 2 comments
Open

_.pick is incorrectly simplified, Lodash accepts a path #308

alejandroiglesias opened this issue Apr 6, 2021 · 2 comments
Labels
PR welcome Please send us a pull request

Comments

@alejandroiglesias
Copy link

alejandroiglesias commented Apr 6, 2021

The Lodash version of pick accepts a path, thus this is perfectly doable in Lodash:

var object = { 'a': 1, 'b': '2', 'c': { 'd' : 3 } };

// Underscore/Lodash
var result = _.pick(object, ['a', 'c.d']);
console.log(result)
// output: {a: 1, c: {d: 3}}

But there's no equivalent in ES6.

By the way, _.pickBy is displayed incorrectly since it's missing the second parameter which is a function to evaluate if prop will be picked.

@cht8687
Copy link
Member

cht8687 commented Jul 10, 2021

👍 thanks for pointing it out. As stated in the very beginning of the doc:

Please note that the examples used below are just showing you the native alternative of performing certain tasks. For some functions, Lodash provides you more options than native built-ins. This list is not a 1:1 comparison.

we can fix the example though.

@cht8687 cht8687 added the PR welcome Please send us a pull request label Jul 10, 2021
@dietergeerts
Copy link

👍 thanks for pointing it out. As stated in the very beginning of the doc:

Please note that the examples used below are just showing you the native alternative of performing certain tasks. For some functions, Lodash provides you more options than native built-ins. This list is not a 1:1 comparison.

we can fix the example though.

Please update the example and clearly state what Lodash does extra, so that devs see that using Lodash still is very valuable for these things. Devs don't seem to read these side notes these days, as I have enough explaining to do why using Lodash is still a good thing, just because they see things like this, and then start to think that Lodash should be deprecated because you can do everything natively! The native way isn't always readable, and readability > not using libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR welcome Please send us a pull request
Projects
None yet
Development

No branches or pull requests

3 participants