main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
498 bytes
|
Line | |
---|
1 | import baseClamp from './_baseClamp.js';
|
---|
2 | import copyArray from './_copyArray.js';
|
---|
3 | import shuffleSelf from './_shuffleSelf.js';
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * A specialized version of `_.sampleSize` for arrays.
|
---|
7 | *
|
---|
8 | * @private
|
---|
9 | * @param {Array} array The array to sample.
|
---|
10 | * @param {number} n The number of elements to sample.
|
---|
11 | * @returns {Array} Returns the random elements.
|
---|
12 | */
|
---|
13 | function arraySampleSize(array, n) {
|
---|
14 | return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
|
---|
15 | }
|
---|
16 |
|
---|
17 | export default arraySampleSize;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.