es-toolkit icon indicating copy to clipboard operation
es-toolkit copied to clipboard

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

Open ChrisRast opened this issue 3 months ago • 0 comments

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!

ChrisRast avatar Sep 16 '25 14:09 ChrisRast