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

⛳ Goal: Almost feature parity with lodash #91

Open
raon0211 opened this issue Jun 28, 2024 · 11 comments
Open

⛳ Goal: Almost feature parity with lodash #91

raon0211 opened this issue Jun 28, 2024 · 11 comments

Comments

@raon0211
Copy link
Collaborator

raon0211 commented Jun 28, 2024

For easy migration from lodash to es-toolkit, our goal is to achieve almost complete feature parity with lodash.

For details, please refer to our compatibility documentation.

We intend to migrate most of the functions that lodash offers, with the following exceptions:

  • Functions that have specialized implementations for specific types of arrays, like sortedUniq.
    • Such functions fall outside the scope of es-toolkit.

If you encounter any lodash features that could complicate migration to es-toolkit, please inform us via comments on the issue.

@raon0211 raon0211 pinned this issue Jun 28, 2024
@raon0211 raon0211 changed the title Goal: Almost feature parity with lodash ⛳ Goal: Almost feature parity with lodash Jun 28, 2024
This was referenced Jul 9, 2024
@dcastil
Copy link

dcastil commented Jul 11, 2024

Was just checking whether we can replace lodash with es-toolkit and noticed that we're using the lodash pick function with deep keys, like

const pickedObject = pick(object, [
    'firstLevel.secondLevel.thirdLevel',
    'firstLevel.anotherKey.thirdLevel',
    'firstLevel.anotherKey.anotherKey',
])

Would it make sense for es-toolkit to provide a similar function? Maybe an API like this could work with type safety on the keys?

const pickedObject = pickDeep(object, [
    ['firstLevel', 'secondLevel', 'thirdLevel'],
    ['firstLevel', 'anotherKey', 'thirdLevel'],
    ['firstLevel', 'anotherKey', 'anotherKey'],
])

@arty-name
Copy link

arty-name commented Jul 12, 2024

I’ve noticed another major lodash feature seemingly not being supported. I very much enjoy how concise lodash makes the following code:

const email = 'test@example.com'
// ...
const user = find(users, { email })
// as opposed to
const user2 = find(users, user => user.email === email)

@KeKs0r
Copy link

KeKs0r commented Jul 12, 2024

Also did a short scan of my codebase and would love to replace lodash, mainly for the bad types of it.
The following seem to be not yet covered:

  • mapValues & mapKeys
  • find with object as query (as described by @arty-name
  • map - which I use to map over an object and return an array. I dont think doing these 2 things in 2 steps would be too bad though
  • max and min - could easily be done by maxBy and minBy. Maybe worth considering having the identity function as default iteree
  • set and has to check deal with deeply nested properties

Would love to hear your opinions. I don't think those necessarily need to be implemented, but I think extending and making the "not gonna implement" list as well, will be beneficial.

@damianobarbati
Copy link

It would be nice to have this pkg be a drop-in replacement for lodash and lodash-es. For now, I can't migrate because isEqual cloneDeep and isEmpty are missing.

@tom2drum
Copy link

Just wondering if you could add support for defaultsDeep as well?

@raon0211
Copy link
Collaborator Author

raon0211 commented Jul 18, 2024

Hello!

We're striving for perfect compatibility with lodash through es-toolkit/compat. We're actively adding missing functions to our library and importing unit test cases from lodash to ensure 100% accuracy.

If you add comments to this issue, we will prioritize adding support for your case.

For more details, please visit our compatibility page.

@krasnovmv
Copy link

Hello

I have attempted to migrate a large project to es-toolkit, but I got tired of manually checking whether a function has been migrated or not.
Do you have any plans to create a codemod for incremental migration from lodash/lodash-es to es-toolkit? I just want to run the command after the next update and replace all the imports of the implemented functions

@raon0211
Copy link
Collaborator Author

raon0211 commented Aug 20, 2024

It should be fine to just replace lodash or lodash-es to es-toolkit/compat when we achieve full compatibility with lodash. While we're on the way, and many frequently used functions are migrated, we expect the migration to be complete by the end of this year.

@danieldelcore
Copy link

danieldelcore commented Aug 21, 2024

I'm iterating on a pretty naive codemod here in case it helps:

https://www.hypermod.io/sandbox/cm036l7jf0001l20cf89mvmev

I'm going to go in and add proper coverage as per the support table here later today :)

@stychu
Copy link

stychu commented Sep 3, 2024

Was just checking whether we can replace lodash with es-toolkit and noticed that we're using the lodash pick function with deep keys, like

const pickedObject = pick(object, [
    'firstLevel.secondLevel.thirdLevel',
    'firstLevel.anotherKey.thirdLevel',
    'firstLevel.anotherKey.anotherKey',
])

Would it make sense for es-toolkit to provide a similar function? Maybe an API like this could work with type safety on the keys?

const pickedObject = pickDeep(object, [
    ['firstLevel', 'secondLevel', 'thirdLevel'],
    ['firstLevel', 'anotherKey', 'thirdLevel'],
    ['firstLevel', 'anotherKey', 'anotherKey'],
])

Ahh I was looking around for good utlity libs and found es-toolkit. This seems promising but the functionality over lodash seems not on par. I was very sad to find out the most used object util pick doesn't suport nested keys as opposed to loadsh. This simple one prevents me from using es-toolkit for now.

@raon0211
Copy link
Collaborator Author

The usecase for pick will be available from es-toolkit/compat v1.19.0 (which will be released next week). Please refer to our updated docs!

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

9 participants