{"id":14682,"library":"lodash._basematches","title":"Lodash Internal baseMatches Module","description":"This package, `lodash._basematches`, exposes an internal utility function from Lodash v3, specifically `baseMatches`. It's part of Lodash's legacy modularization strategy (pre-v4) where core internal functions were published as individual npm packages. The `baseMatches` function itself is used internally by Lodash to create a predicate function for deep object comparison, similar to how `_.matches` works in the public API. This module is stable at version 3.2.0, which corresponds to the Lodash v3 release line. It is not actively maintained as a standalone module and is considered superseded by the main `lodash` package (v4.x and later) or `lodash-es` for modern usage. Its primary differentiation was being a single-purpose, highly optimized internal primitive available separately, though this approach is now largely deprecated in favor of comprehensive bundles and tree-shakable ES modules.","status":"abandoned","version":"3.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/lodash/lodash","tags":["javascript"],"install":[{"cmd":"npm install lodash._basematches","lang":"bash","label":"npm"},{"cmd":"yarn add lodash._basematches","lang":"bash","label":"yarn"},{"cmd":"pnpm add lodash._basematches","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not provide an ES module export. Direct CommonJS `require` is the only supported import method.","wrong":"import { baseMatches } from 'lodash._basematches';","symbol":"baseMatches","correct":"const baseMatches = require('lodash._basematches');"},{"note":"Even if this package were ESM-compatible, it exports a named function, not a default export. Attempting a default import would result in an undefined value.","wrong":"import baseMatches from 'lodash._basematches';","symbol":"baseMatches (using default import syntax mistakenly)","correct":"const baseMatches = require('lodash._basematches');"}],"quickstart":{"code":"const baseMatches = require('lodash._basematches');\n\n// baseMatches takes a source object and returns a predicate function.\n// The predicate function checks if an object has properties matching the source.\n\nconst source = { a: 1, b: 'test' };\nconst predicate = baseMatches(source);\n\nconsole.log('Predicate function created:', typeof predicate === 'function');\n\nconst object1 = { a: 1, b: 'test', c: 3 };\nconst object2 = { a: 1, b: 'wrong' };\nconst object3 = { a: 1 };\n\nconsole.log('Matching object1:', predicate(object1)); // Expected: true\nconsole.log('Matching object2:', predicate(object2)); // Expected: false\nconsole.log('Matching object3:', predicate(object3)); // Expected: false\n\nconst nestedSource = { user: { id: 123, name: 'Alice' } };\nconst nestedPredicate = baseMatches(nestedSource);\n\nconst data1 = { id: 1, user: { id: 123, name: 'Alice', email: 'a@example.com' } };\nconst data2 = { id: 2, user: { id: 456, name: 'Bob' } };\n\nconsole.log('Matching data1 (nested):', nestedPredicate(data1)); // Expected: true\nconsole.log('Matching data2 (nested):', nestedPredicate(data2)); // Expected: false\n","lang":"javascript","description":"Demonstrates how to import and use the `baseMatches` function to create a predicate for object property matching."},"warnings":[{"fix":"Migrate to using the main `lodash` package or `lodash-es` (for ES Modules) and import the equivalent `_.matches` function directly. For example, `import { matches } from 'lodash-es';` or `const _ = require('lodash'); const matches = _.matches;`","message":"This package is effectively abandoned. Its latest version is 3.2.0, corresponding to Lodash v3. Major changes in Lodash v4 mean this module is not compatible with or recommended for use alongside modern Lodash versions (v4.x and above).","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Always use `const baseMatches = require('lodash._basematches');` for this specific package. For new projects, prefer `lodash` or `lodash-es` which offer better ESM support.","message":"This module is strictly CommonJS. Attempting to import it using ES module syntax (`import ... from '...'`) in a modern JavaScript environment will result in errors.","severity":"gotcha","affected_versions":">=3.2.0"},{"fix":"Upgrade to a modern version of the main `lodash` package (currently v4.18.x) which actively receives security patches and mitigations for issues like prototype pollution. Do not rely on these granular internal v3 packages in new or security-sensitive projects.","message":"As an internal, legacy module, `lodash._basematches` does not receive security updates. While the function itself might be simple, its use in older, unmaintained applications could expose them to broader security issues if other Lodash v3 internals are present.","severity":"deprecated","affected_versions":">=3.2.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure your environment supports CommonJS `require()` (e.g., Node.js without `\"type\": \"module\"` in package.json) or transpile your code if targeting a browser. For new projects, use `lodash` or `lodash-es` with native ESM imports.","cause":"Attempting to use `require()` in an ES module context without proper transpilation or configuration, or directly using `import` with a CommonJS-only package.","error":"ReferenceError: require is not defined"},{"fix":"This package only provides a named export accessible via CommonJS `require`. Change your import to `const baseMatches = require('lodash._basematches');`.","cause":"Incorrectly trying to import a CommonJS module with `import baseMatches from 'lodash._basematches';` syntax, assuming a default export that doesn't exist.","error":"TypeError: (0 , _lodash_basematches.default) is not a function"}],"ecosystem":"npm"}