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.

sample.js 551B

123456789101112131415161718192021222324
  1. var arraySample = require('./_arraySample'),
  2. baseSample = require('./_baseSample'),
  3. isArray = require('./isArray');
  4. /**
  5. * Gets a random element from `collection`.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @since 2.0.0
  10. * @category Collection
  11. * @param {Array|Object} collection The collection to sample.
  12. * @returns {*} Returns the random element.
  13. * @example
  14. *
  15. * _.sample([1, 2, 3, 4]);
  16. * // => 2
  17. */
  18. function sample(collection) {
  19. var func = isArray(collection) ? arraySample : baseSample;
  20. return func(collection);
  21. }
  22. module.exports = sample;