Lodash.pairs Module

3.0.1 · deprecated · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to convert an object into an array of key-value pairs using `_.pairs` from `lodash-es`.

import { pairs } from 'lodash-es';

const myObject = {
  firstName: 'Alice',
  lastName: 'Smith',
  age: 30,
  city: 'New York'
};

const keyValuePairs = pairs(myObject);

console.log(keyValuePairs);
// Expected output: [['firstName', 'Alice'], ['lastName', 'Smith'], ['age', 30], ['city', 'New York']]

// For older Node.js environments or if explicitly using the deprecated lodash.pairs package:
// var oldPairs = require('lodash.pairs');
// const oldKeyValuePairs = oldPairs(myObject);
// console.log(oldKeyValuePairs);

view raw JSON →