es-toolkit
es-toolkit copied to clipboard
Support for findKey, findLastKey
Hi, @raon0211 ! Can I work findKey of https://github.com/toss/es-toolkit/issues/91 ??
https://github.com/toss/es-toolkit/issues/441 In the above issue, someone said they were implementing it, but it seems like it hasn't been implemented because it's been about 2 months.
And I have a question about the findKey interface.
https://lodash.com/docs/4.17.15#findKey
_.findKey(users, function(o) { return o.age < 40; });
// => 'barney' (iteration order is not guaranteed)
// The `_.matches` iteratee shorthand.
_.findKey(users, { 'age': 1, 'active': true });
// => 'pebbles'
// The `_.matchesProperty` iteratee shorthand.
_.findKey(users, ['active', false]);
// => 'fred'
// The `_.property` iteratee shorthand.
_.findKey(users, 'active');
// => 'barney'
Looking at the example in the lodash document, you can get the key by entering ['active', false] or 'active' as the second argument to findKey, but this makes the complexity of implementation very difficult.
https://github.com/toss/es-toolkit/blob/main/.github/CONTRIBUTING.md
However, if you look at es-toolkit's design priniciples, it emphasizes simplicity.
So I think that implementing only the first and second interfaces in the above example fits es-toolkit's priniciples.
However, if that happens, the interface will be different from lodash, so I think there might be a problem during the switching process in lodash.
Of these two conflicting issues principles vs compatibility with lodash, which issue has higher priority?