Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
363 bytes
|
Line | |
---|
1 | var baseRandom = require('./_baseRandom');
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * A specialized version of `_.sample` for arrays.
|
---|
5 | *
|
---|
6 | * @private
|
---|
7 | * @param {Array} array The array to sample.
|
---|
8 | * @returns {*} Returns the random element.
|
---|
9 | */
|
---|
10 | function arraySample(array) {
|
---|
11 | var length = array.length;
|
---|
12 | return length ? array[baseRandom(0, length - 1)] : undefined;
|
---|
13 | }
|
---|
14 |
|
---|
15 | module.exports = arraySample;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.