source: node_modules/ramda/es/toPairs.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 904 bytes
RevLine 
[d24f17c]1import _curry1 from "./internal/_curry1.js";
2import _has from "./internal/_has.js";
3/**
4 * Converts an object into an array of key, value arrays. Only the object's
5 * own properties are used.
6 * Note that the order of the output array is not guaranteed to be consistent
7 * across different JS platforms.
8 *
9 * @func
10 * @memberOf R
11 * @since v0.4.0
12 * @category Object
13 * @sig {String: *} -> [[String,*]]
14 * @param {Object} obj The object to extract from
15 * @return {Array} An array of key, value arrays from the object's own properties.
16 * @see R.fromPairs, R.keys, R.values
17 * @example
18 *
19 * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]]
20 */
21
22var toPairs =
23/*#__PURE__*/
24_curry1(function toPairs(obj) {
25 var pairs = [];
26
27 for (var prop in obj) {
28 if (_has(prop, obj)) {
29 pairs[pairs.length] = [prop, obj[prop]];
30 }
31 }
32
33 return pairs;
34});
35
36export default toPairs;
Note: See TracBrowser for help on using the repository browser.