All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.cjs.pairs.js Maven / Gradle / Ivy

The newest version!
var keys = require('./keys.js');

// Convert an object into a list of `[key, value]` pairs.
// The opposite of `_.object` with one argument.
function pairs(obj) {
  var _keys = keys(obj);
  var length = _keys.length;
  var pairs = Array(length);
  for (var i = 0; i < length; i++) {
    pairs[i] = [_keys[i], obj[_keys[i]]];
  }
  return pairs;
}

module.exports = pairs;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy