Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
548 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var baseClamp = require('./_baseClamp'),
|
---|
| 2 | shuffleSelf = require('./_shuffleSelf'),
|
---|
| 3 | values = require('./values');
|
---|
| 4 |
|
---|
| 5 | /**
|
---|
| 6 | * The base implementation of `_.sampleSize` without param guards.
|
---|
| 7 | *
|
---|
| 8 | * @private
|
---|
| 9 | * @param {Array|Object} collection The collection to sample.
|
---|
| 10 | * @param {number} n The number of elements to sample.
|
---|
| 11 | * @returns {Array} Returns the random elements.
|
---|
| 12 | */
|
---|
| 13 | function baseSampleSize(collection, n) {
|
---|
| 14 | var array = values(collection);
|
---|
| 15 | return shuffleSelf(array, baseClamp(n, 0, array.length));
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | module.exports = baseSampleSize;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.