Skip to content

isMatch from es-toolkit/compat does not behave like lodash-es/isMatch #1399

Description

@ChrisRast

Hello,
While trying to migrate away from lodash to es-toolkit/compat (btw, thanks a lot for this amazing work!) we noticed a few React components not behaving as expected.
I managed to narrow the issue to the isMatch function (found while using find).

If you run this code below, you'll notice that the same predicate doesn't output the same value whether we use Lodash or Es-Toolkit findor isMatch.

import lodashEs from "https://esm.sh/lodash-es";
import esToolkit from "https://esm.sh/es-toolkit/compat";

const list = [
  {
    label: "Foo",
    value: "foo"
  },
  {
    label: "Bar",
    value: "bar"
  }
];

const condition = {
  anyKeyOrMissingKey: undefined // Comment me, it doesn't change a thing
};

const foundLodash = lodashEs.find(list, {
  value: condition
});
const foundEtk = esToolkit.find(list, {
  value: condition
});

const isAMatchLodash = lodashEs.isMatch({value: 'bar'}, {value: condition})
const isAMatchEtk = esToolkit.isMatch({value: 'bar'}, {value: condition})

console.clear()
// Lodash and ESToolkit/compat should output the same "undefined" value
console.log("found lodash", foundLodash);
console.log("found estoolkit", foundEtk);
// Root problem is isMatch fn
console.log('isAMatchLodash', isAMatchLodash)
console.log('isAMatchEtk', isAMatchEtk)

Codepen

It seems also related to this issue about null: #750 .

Thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions