mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Ensure _.sample handles falsey collection arguments.
This commit is contained in:
@@ -3895,7 +3895,7 @@
|
|||||||
collection = collection.split('');
|
collection = collection.split('');
|
||||||
}
|
}
|
||||||
if (n == null || guard) {
|
if (n == null || guard) {
|
||||||
return collection[random(length - 1)];
|
return collection ? collection[random(length - 1)] : undefined;
|
||||||
}
|
}
|
||||||
var result = shuffle(collection);
|
var result = shuffle(collection);
|
||||||
result.length = nativeMin(nativeMax(0, n), result.length);
|
result.length = nativeMin(nativeMax(0, n), result.length);
|
||||||
|
|||||||
Reference in New Issue
Block a user