_mapToArray.js 363 B

12345678910111213141516171819
  1. /**
  2. * Converts `map` to its key-value pairs.
  3. *
  4. * @private
  5. * @param {Object} map The map to convert.
  6. * @returns {Array} Returns the key-value pairs.
  7. */
  8. function mapToArray(map) {
  9. var index = -1,
  10. result = Array(map.size);
  11. map.forEach(function(value, key) {
  12. result[++index] = [key, value];
  13. });
  14. return result;
  15. }
  16. module.exports = mapToArray;