toPairsIn.js 924 B

123456789101112131415161718192021222324252627282930313233343536
  1. import _curry1 from "./internal/_curry1.js";
  2. /**
  3. * Converts an object into an array of key, value arrays. The object's own
  4. * properties and prototype properties are used. Note that the order of the
  5. * output array is not guaranteed to be consistent across different JS
  6. * platforms.
  7. *
  8. * @func
  9. * @memberOf R
  10. * @since v0.4.0
  11. * @category Object
  12. * @sig {String: *} -> [[String,*]]
  13. * @param {Object} obj The object to extract from
  14. * @return {Array} An array of key, value arrays from the object's own
  15. * and prototype properties.
  16. * @example
  17. *
  18. * const F = function() { this.x = 'X'; };
  19. * F.prototype.y = 'Y';
  20. * const f = new F();
  21. * R.toPairsIn(f); //=> [['x','X'], ['y','Y']]
  22. */
  23. var toPairsIn =
  24. /*#__PURE__*/
  25. _curry1(function toPairsIn(obj) {
  26. var pairs = [];
  27. for (var prop in obj) {
  28. pairs[pairs.length] = [prop, obj[prop]];
  29. }
  30. return pairs;
  31. });
  32. export default toPairsIn;