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:
942 bytes
|
Line | |
---|
1 | var _curry1 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry1.js");
|
---|
4 |
|
---|
5 | var _has =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./internal/_has.js");
|
---|
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, R.keys, R.values
|
---|
22 | * @example
|
---|
23 | *
|
---|
24 | * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]]
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | var 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 |
|
---|
42 | module.exports = toPairs; |
---|
Note:
See
TracBrowser
for help on using the repository browser.