{"id":15465,"library":"lodash.pairs","title":"Lodash.pairs Module","description":"This package provides the `_.pairs` function from the Lodash utility library, specifically from the Lodash v3 era, as a standalone Node.js module. The `_.pairs` function converts an object into an array of `[key, value]` pairs. While originally part of a strategy for modularizing Lodash functions, this `lodash.pairs` package is at version 3.0.1 and was last published over a decade ago. It is considered deprecated in favor of direct imports from the main `lodash` package (which is currently at v4.18.1 and actively maintained) or, preferably, `lodash-es` for modern, tree-shakable ES Module environments. Relying on this older, single-function module can lead to outdated behavior, missed bug fixes, and potential security vulnerabilities present in the main Lodash library that have since been addressed in v4.x. Modern applications should use `lodash-es` or specific imports from `lodash` itself for optimized bundle sizes and access to the latest features and patches.","status":"deprecated","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/lodash/lodash","tags":["javascript","lodash","lodash-modularized","stdlib","util"],"install":[{"cmd":"npm install lodash.pairs","lang":"bash","label":"npm"},{"cmd":"yarn add lodash.pairs","lang":"bash","label":"yarn"},{"cmd":"pnpm add lodash.pairs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"For modern ES Module environments and tree-shaking, import directly from 'lodash-es'. This is the recommended approach for Lodash v4+.","wrong":"var pairs = require('lodash.pairs');","symbol":"pairs","correct":"import { pairs } from 'lodash-es';"},{"note":"For smaller CommonJS bundles without full Lodash, import the specific function directly from 'lodash/pairs'. Note that 'lodash' itself is primarily CommonJS but can be imported this way for cherry-picking.","wrong":"import { pairs } from 'lodash';","symbol":"pairs","correct":"import pairs from 'lodash/pairs';"},{"note":"This specific package (`lodash.pairs@3.0.1`) is a CommonJS module and must be imported using `require()`.","wrong":"import { pairs } from 'lodash.pairs';","symbol":"pairs","correct":"var pairs = require('lodash.pairs');"}],"quickstart":{"code":"import { pairs } from 'lodash-es';\n\nconst myObject = {\n  firstName: 'Alice',\n  lastName: 'Smith',\n  age: 30,\n  city: 'New York'\n};\n\nconst keyValuePairs = pairs(myObject);\n\nconsole.log(keyValuePairs);\n// Expected output: [['firstName', 'Alice'], ['lastName', 'Smith'], ['age', 30], ['city', 'New York']]\n\n// For older Node.js environments or if explicitly using the deprecated lodash.pairs package:\n// var oldPairs = require('lodash.pairs');\n// const oldKeyValuePairs = oldPairs(myObject);\n// console.log(oldKeyValuePairs);","lang":"typescript","description":"Demonstrates how to convert an object into an array of key-value pairs using `_.pairs` from `lodash-es`."},"warnings":[{"fix":"Migrate to `lodash` v4+ and import `pairs` directly from `lodash-es` (for ESM) or `lodash/pairs` (for CJS) to benefit from active maintenance, bug fixes, and security updates.","message":"This `lodash.pairs` package is stuck at version 3.0.1 (published 11 years ago) and does not receive updates, bug fixes, or security patches from the main Lodash library, which is currently at v4.x. Its behavior might differ from `_.pairs` in Lodash v4.x due to breaking changes between Lodash v3 and v4.","severity":"breaking","affected_versions":">=3.0.1"},{"fix":"Replace `require('lodash.pairs')` with `import { pairs } from 'lodash-es';` in ESM projects or `import pairs from 'lodash/pairs';` in CJS projects to leverage modern tooling and Lodash v4+ features.","message":"The pattern of using individual `lodash.<function>` modular packages like `lodash.pairs` is generally deprecated. Modern Lodash (v4+) favors `lodash-es` for tree-shakable ES module imports or direct cherry-picking from `lodash/functionName` paths for optimized bundle sizes.","severity":"deprecated","affected_versions":">=3.0.1"},{"fix":"Immediately update your dependencies to use the actively maintained `lodash` or `lodash-es` package and ensure you are on the latest versions to receive all security updates.","message":"Using this outdated `lodash.pairs` package means your application will not benefit from critical security advisories and patches released for the main `lodash` library, such as prototype pollution fixes in v4.18.0 (GHSA-f23m-r3pf-42rh). Although `_.pairs` itself might not be directly vulnerable, relying on an unmaintained module introduces unnecessary risk.","severity":"gotcha","affected_versions":">=3.0.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure you are importing `pairs` correctly for your module system. For ES Modules: `import { pairs } from 'lodash-es';`. For CommonJS using the main `lodash` package: `const { pairs } = require('lodash');` (if using Lodash v4+ with a bundler that can cherry-pick) or `const pairs = require('lodash/pairs');`. For this specific `lodash.pairs` module (deprecated): `const pairs = require('lodash.pairs');`.","cause":"Attempting to use `_.pairs` from a partial or incorrect `lodash` import, or trying to use the CommonJS `lodash.pairs` module with an ES module import syntax.","error":"TypeError: pairs is not a function"},{"fix":"If your project uses ESM, you must use `import` statements. Replace `require('lodash.pairs')` with `import { pairs } from 'lodash-es';` or `import pairs from 'lodash/pairs';` (after installing `lodash` or `lodash-es`). Alternatively, if you must use the old `lodash.pairs` package, convert your file to CommonJS or use an interop solution.","cause":"Attempting to use `require('lodash.pairs')` within an ES Module (ESM) file context in Node.js, where `require` is not globally available.","error":"ReferenceError: require is not defined"}],"ecosystem":"npm"}