Projekt

Obecné

Profil

Stáhnout (789 Bajtů) Statistiky
| Větev: | Revize:
1
var baseToPairs = require('./_baseToPairs'),
2
    getTag = require('./_getTag'),
3
    mapToArray = require('./_mapToArray'),
4
    setToPairs = require('./_setToPairs');
5

    
6
/** `Object#toString` result references. */
7
var mapTag = '[object Map]',
8
    setTag = '[object Set]';
9

    
10
/**
11
 * Creates a `_.toPairs` or `_.toPairsIn` function.
12
 *
13
 * @private
14
 * @param {Function} keysFunc The function to get the keys of a given object.
15
 * @returns {Function} Returns the new pairs function.
16
 */
17
function createToPairs(keysFunc) {
18
  return function(object) {
19
    var tag = getTag(object);
20
    if (tag == mapTag) {
21
      return mapToArray(object);
22
    }
23
    if (tag == setTag) {
24
      return setToPairs(object);
25
    }
26
    return baseToPairs(object, keysFunc(object));
27
  };
28
}
29

    
30
module.exports = createToPairs;
(187-187/634)