main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
787 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import baseToPairs from './_baseToPairs.js';
|
---|
| 2 | import getTag from './_getTag.js';
|
---|
| 3 | import mapToArray from './_mapToArray.js';
|
---|
| 4 | import setToPairs from './_setToPairs.js';
|
---|
| 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 | export default createToPairs;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.