How to use the pairs function from lodash

Find comprehensive JavaScript lodash.pairs code examples handpicked from public code repositorys.

3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
 * @category Objects
 * @param {Object} object The object to inspect.
 * @returns {Array} Returns new array of key-value pairs.
 * @example
 *
 * _.pairs({ 'barney': 36, 'fred': 40 });
 * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed across environments)
 */
function pairs(object) {
  var index = -1,
fork icon73
star icon711
watch icon29

163
164
165
166
167
168
169
170
171
172
173
  const params = new URLSearchParams(queryString);
  return Object.fromEntries(params);
}


function toQueryParamString(o) {
  var pairs = _.pairs(o);
  pairs = _.map(pairs, function(pair) {
    return pair[0] + '=' + encodeURIComponent(pair[1]);
  });
  return pairs.join("&");
fork icon125
star icon491
watch icon21

+ 4 other calls in file

100
101
102
103
104
105
106
107
108
109
// been lower than the depth of the package including it.
var depths = {};
if (SOURCEMAP_KEY in sources) {
  sources[SOURCEMAP_KEY] = JSON.parse(sources[SOURCEMAP_KEY]);

  for (let pair of _.pairs(sources[SOURCEMAP_KEY])) {
    let hashPath = pair[0];
    let paths = pair[1];

    depths[hashPath] = _.min(_.map(
fork icon65
star icon1
watch icon3

+ 5 other calls in file

Other functions in lodash

Sorted by popularity

function icon

lodash.get is the most popular function in lodash (7670 examples)