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

Support for pick in es-toolkit/compat #236

Closed
raon0211 opened this issue Jul 18, 2024 · 8 comments
Closed

Support for pick in es-toolkit/compat #236

raon0211 opened this issue Jul 18, 2024 · 8 comments

Comments

@raon0211
Copy link
Collaborator

Support for pick is desirable. Reference

  • pick with object paths like a.b.c should be in es-toolkit/compat.
    • It would be easy to implement if we use get.
  • pick with simple object keys should be in the original es-toolkit.
@seungrodotlee
Copy link
Member

Hello, @raon0211! Let me implement this! :)

@raon0211
Copy link
Collaborator Author

Thanks! :)

@bitttttten
Copy link

bitttttten commented Jul 20, 2024

Hey just a heads up that lodash pick supports const three = pick({ array: [1, 2, 3] }, "array[2]") and also const item = pick({ my: { deep: { item: true }}, "my.deep.item"). Not sure how compatible you want to be although just wanted to make you aware of the array syntax too. Thanks!

@seungrodotlee
Copy link
Member

@bitttttten Thank you for information! I guess it should be implemented since es-toolkit/compat is designed to provide an identical API to lodash

@bitttttten
Copy link

It probably is a larger api and larger file size, so I can imagine pick and pickDeep existing side by side but then indeed the api will diverge from lodash.

@akira28
Copy link

akira28 commented Sep 23, 2024

hey @bitttttten , I just found out a difference between pick from lodash and es-toolkit/compat.
es-toolkit/compat:

const obj1 = {
  a: 'hello',
  b: 'world'
};
console.log(pick(obj1, ['a', 'b', 'c']));
---
{ a: 'hello', b: 'world', c: undefined }

lodash:

const obj1 = {
  a: 'hello',
  b: 'world'
};
console.log(_.pick(obj1, ['a', 'b', 'c']));
---
{ a: 'hello', b: 'world' }

@raon0211
Copy link
Collaborator Author

raon0211 commented Oct 1, 2024

Hello, closing this issue since we have pick with 100% compatibility with lodash.

Also, pick adding undefined values was fixed in our latest version of the library!

@raon0211 raon0211 closed this as completed Oct 1, 2024
@Xiot
Copy link

Xiot commented Oct 9, 2024

I just grabbed 1.24.0 and pick from es-toolkit/compat still adds the undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants