Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_createToPairs.js 789B

123456789101112131415161718192021222324252627282930
  1. var baseToPairs = require('./_baseToPairs'),
  2. getTag = require('./_getTag'),
  3. mapToArray = require('./_mapToArray'),
  4. setToPairs = require('./_setToPairs');
  5. /** `Object#toString` result references. */
  6. var mapTag = '[object Map]',
  7. setTag = '[object Set]';
  8. /**
  9. * Creates a `_.toPairs` or `_.toPairsIn` function.
  10. *
  11. * @private
  12. * @param {Function} keysFunc The function to get the keys of a given object.
  13. * @returns {Function} Returns the new pairs function.
  14. */
  15. function createToPairs(keysFunc) {
  16. return function(object) {
  17. var tag = getTag(object);
  18. if (tag == mapTag) {
  19. return mapToArray(object);
  20. }
  21. if (tag == setTag) {
  22. return setToPairs(object);
  23. }
  24. return baseToPairs(object, keysFunc(object));
  25. };
  26. }
  27. module.exports = createToPairs;