UNPKG

918 BJavaScriptView Raw
1var _curry1 =
2/*#__PURE__*/
3require("./internal/_curry1");
4
5var _has =
6/*#__PURE__*/
7require("./internal/_has");
8/**
9 * Converts an object into an array of key, value arrays. Only the object's
10 * own properties are used.
11 * Note that the order of the output array is not guaranteed to be consistent
12 * across different JS platforms.
13 *
14 * @func
15 * @memberOf R
16 * @since v0.4.0
17 * @category Object
18 * @sig {String: *} -> [[String,*]]
19 * @param {Object} obj The object to extract from
20 * @return {Array} An array of key, value arrays from the object's own properties.
21 * @see R.fromPairs
22 * @example
23 *
24 * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]]
25 */
26
27
28var toPairs =
29/*#__PURE__*/
30_curry1(function toPairs(obj) {
31 var pairs = [];
32
33 for (var prop in obj) {
34 if (_has(prop, obj)) {
35 pairs[pairs.length] = [prop, obj[prop]];
36 }
37 }
38
39 return pairs;
40});
41
42module.exports = toPairs;
\No newline at end of file